Compare commits

..

1 Commits

Author SHA1 Message Date
4a629b954a version 2019-09-30 16:58:04 +02:00
440 changed files with 36796 additions and 42792 deletions

View File

@ -16,8 +16,7 @@ Checks: '*,
-hicpp-braces-around-statements, -hicpp-braces-around-statements,
-google-runtime-references, -google-runtime-references,
-google-readability-todo, -google-readability-todo,
-google-readability-braces-around-statements, -google-readability-braces-around-statements'
-modernize-use-trailing-return-type'
HeaderFilterRegex: \.h HeaderFilterRegex: \.h
AnalyzeTemporaryDtors: false AnalyzeTemporaryDtors: false

4
.gitignore vendored
View File

@ -12,10 +12,6 @@ build
RELEASE.txt RELEASE.txt
Testing/ Testing/
ctbDict.cpp
ctbDict.h
*.pyc *.pyc
*/__pycache__/* */__pycache__/*

View File

@ -8,7 +8,6 @@ env:
matrix: matrix:
- CONDA_PY=3.6 - CONDA_PY=3.6
- CONDA_PY=3.7 - CONDA_PY=3.7
- CONDA_PY=3.8
dist: trusty dist: trusty
@ -47,5 +46,5 @@ deploy:
provider: script provider: script
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \; script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
on: on:
branch: developer branch: filip1

View File

@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.11) cmake_minimum_required(VERSION 3.9)
project(slsDetectorPackage) project(slsDetectorPackage)
set(PROJECT_VERSION 5.0.0) set(PROJECT_VERSION 5.0.0)
include(CheckIPOSupported) include(CheckIPOSupported)
@ -41,9 +42,6 @@ option (SLS_USE_TESTS "TESTS" OFF)
option (SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF) option (SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF)
option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF) option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF)
option(SLS_USE_PYTHON "Python bindings" OFF) option(SLS_USE_PYTHON "Python bindings" OFF)
option(SLS_USE_CTBGUI "ctb GUI" OFF)
option(SLS_BUILD_DOCS "docs" OFF)
option(SLS_BUILD_EXAMPLES "examples" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -68,7 +66,6 @@ target_compile_options(slsProjectWarnings INTERFACE
-Wredundant-decls -Wredundant-decls
# -Wconversion # -Wconversion
-Wdouble-promotion -Wdouble-promotion
-Werror=return-type
) )
@ -106,6 +103,7 @@ endif()
if(SLS_USE_SANITIZER) if(SLS_USE_SANITIZER)
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer) target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
#target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined)
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined) target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread) # target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) # target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
@ -155,6 +153,7 @@ if (SLS_USE_RECEIVER)
find_package(HDF5 1.10 COMPONENTS CXX REQUIRED) find_package(HDF5 1.10 COMPONENTS CXX REQUIRED)
endif (SLS_USE_HDF5) endif (SLS_USE_HDF5)
add_subdirectory(slsReceiverSoftware) add_subdirectory(slsReceiverSoftware)
add_subdirectory(manual/manual-api)
endif (SLS_USE_RECEIVER) endif (SLS_USE_RECEIVER)
if (SLS_USE_GUI) if (SLS_USE_GUI)
@ -178,21 +177,15 @@ if (SLS_USE_PYTHON)
add_subdirectory(python) add_subdirectory(python)
endif(SLS_USE_PYTHON) endif(SLS_USE_PYTHON)
if (SLS_USE_CTBGUI)
add_subdirectory(ctbGui)
endif(SLS_USE_CTBGUI)
configure_file( .clang-tidy configure_file( .clang-tidy
${CMAKE_BINARY_DIR}/.clang-tidy ${CMAKE_BINARY_DIR}/.clang-tidy
) )
if (SLS_BUILD_EXAMPLES)
add_subdirectory(sample)
endif(SLS_BUILD_EXAMPLES)
if(SLS_BUILD_DOCS) add_subdirectory(sample)
add_subdirectory(docs)
endif(SLS_BUILD_DOCS) add_subdirectory(docs)

21
cmk.sh
View File

@ -10,7 +10,6 @@ DEBUG=0
PYTHON=0 PYTHON=0
TESTS=0 TESTS=0
SIMULATOR=0 SIMULATOR=0
CTBGUI=0
CLEAN=0 CLEAN=0
@ -19,7 +18,7 @@ CMAKE_PRE=""
CMAKE_POST="" CMAKE_POST=""
usage() { echo -e " usage() { echo -e "
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads> Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
-[no option]: only make -[no option]: only make
-c: Clean -c: Clean
-b: Builds/Rebuilds CMake files normal mode -b: Builds/Rebuilds CMake files normal mode
@ -30,7 +29,6 @@ Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>]
-r: Build/Rebuilds only receiver -r: Build/Rebuilds only receiver
-g: Build/Rebuilds only gui -g: Build/Rebuilds only gui
-s: Simulator -s: Simulator
-u: Chip Test Gui
-j: Number of threads to compile through -j: Number of threads to compile through
-e: Debug mode -e: Debug mode
-i: Builds tests -i: Builds tests
@ -69,7 +67,7 @@ For rebuilding only certain sections
" ; exit 1; } " ; exit 1; }
while getopts ":bpchd:j:trgeisu" opt ; do while getopts ":bpchd:j:trgeis" opt ; do
case $opt in case $opt in
b) b)
echo "Building of CMake files Required" echo "Building of CMake files Required"
@ -124,10 +122,6 @@ while getopts ":bpchd:j:trgeisu" opt ; do
echo "Compiling Options: Simulator" echo "Compiling Options: Simulator"
SIMULATOR=1 SIMULATOR=1
;; ;;
u)
echo "Compiling Options: Chip Test Gui"
CTBGUI=1
;;
\?) \?)
echo "Invalid option: -$OPTARG" echo "Invalid option: -$OPTARG"
usage usage
@ -155,7 +149,7 @@ if [ $TEXTCLIENT -eq 0 ] && [ $RECEIVER -eq 0 ] && [ $GUI -eq 0 ]; then
echo "Enabling Compile Option: TextClient, Receiver and GUI" echo "Enabling Compile Option: TextClient, Receiver and GUI"
else else
if [ $TEXTCLIENT -eq 1 ]; then if [ $TEXTCLIENT -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON -DSLS_USE_RECEIVER=OFF " CMAKE_POST+=" -DSLS_USE_TEXTCLIENT=ON "
echo "Enabling Compile Option: TextClient" echo "Enabling Compile Option: TextClient"
fi fi
if [ $RECEIVER -eq 1 ]; then if [ $RECEIVER -eq 1 ]; then
@ -194,19 +188,14 @@ fi
#Simulator #Simulator
if [ $SIMULATOR -eq 1 ]; then if [ $SIMULATOR -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_SIMULATOR=ON " CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SIMULATOR=ON "
echo "Simulator Option enabled" echo "Simulator Option enabled"
fi fi
#Chip Test Gui
if [ $CTBGUI -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_CTBGUI=ON "
echo "CTB Gui Option enabled"
fi
#Tests #Tests
if [ $TESTS -eq 1 ]; then if [ $TESTS -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_TESTS=ON -DSLS_USE_INTEGRATION_TESTS=ON" CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_TESTS=ON -DSLS_USE_INTEGRATION_TESTS=ON"
echo "Tests Option enabled" echo "Tests Option enabled"
fi fi

View File

@ -1,7 +1,7 @@
package: package:
name: sls_detector_software name: sls_detector_software
version: "developer" version: "filip1"
source: source:
- path: .. - path: ..
@ -65,10 +65,10 @@ outputs:
- setuptools - setuptools
- sls_detector_lib - sls_detector_lib
- pyzmq - pyzmq
- pybind11 2.4 - pybind11 2.2
host: host:
- python - python
- pybind11 2.4 - pybind11 2.2
- pyzmq - pyzmq
- sls_detector_lib - sls_detector_lib
- libstdcxx-ng - libstdcxx-ng
@ -76,7 +76,7 @@ outputs:
run: run:
- python - python
- numpy - numpy
- sls_detector_lib=developer - sls_detector_lib=filip1
- pyzmq - pyzmq
- libstdcxx-ng - libstdcxx-ng
- libgcc-ng - libgcc-ng

View File

@ -1,83 +0,0 @@
find_package(ROOT CONFIG REQUIRED COMPONENTS Core Gui)
find_package(TIFF REQUIRED)
target_include_directories(ROOT::Core INTERFACE "${ROOT_INCLUDE_DIRS}")
add_library(ROOT::Flags_CXX IMPORTED INTERFACE)
separate_arguments(ROOT_CXX_FLAGS)
target_compile_options(ROOT::Flags_CXX INTERFACE ${ROOT_CXX_FLAGS})
separate_arguments(ROOT_DEFINITIONS)
target_compile_definitions(ROOT::Flags_CXX INTERFACE ${ROOT_DEFINITIONS})
# This fixes a bug in the linker flags
string(REPLACE "-L " "-L" ROOT_EXE_LINKER_FLAGS "${ROOT_EXE_LINKER_FLAGS}")
separate_arguments(ROOT_EXE_LINKER_FLAGS)
# Stuck into using old property method due to separate -L and -l arguments
# (A full path to -l is better!)
set_property(TARGET ROOT::Flags_CXX PROPERTY
INTERFACE_LINK_LIBRARIES ${ROOT_EXE_LINKER_FLAGS})
set_property(TARGET ROOT::Core PROPERTY
INTERFACE_INCLUDE_DIRECTORIES "${ROOT_INCLUDE_DIRS}")
add_executable(ctbGui
ctbGui.cpp
ctbMain.cpp
ctbDacs.cpp
ctbPowers.cpp
ctbSlowAdcs.cpp
ctbSignals.cpp
ctbAdcs.cpp
ctbPattern.cpp
ctbAcquisition.cpp
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/tiffIO.cpp
)
#TODO! Replace with target
target_include_directories(ctbGui PRIVATE
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/dataStructures
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/interpolations
${CMAKE_SOURCE_DIR}/slsDetectorCalibration/
)
# Headders needed for ROOT dictionary generation
set( HEADERS
ctbDefs.h
ctbMain.h
ctbDacs.h
ctbPattern.h
ctbSignals.h
ctbAdcs.h
ctbAcquisition.h
ctbPowers.h
ctbSlowAdcs.h
)
#set(ROOT_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# ROOT dictionary generation
include("${ROOT_DIR}/modules/RootNewMacros.cmake")
root_generate_dictionary(ctbDict ${HEADERS} LINKDEF ctbLinkDef.h)
add_library(ctbRootLib SHARED ctbDict.cxx)
target_include_directories(ctbRootLib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(ctbRootLib PUBLIC
ROOT::Core
slsDetectorShared
slsSupportLib
${ROOT_LIBRARIES}
${ROOT_EXE_LINKER_FLAGS}
)
target_link_libraries(ctbGui PUBLIC
slsDetectorShared
slsSupportLib
ctbRootLib
${TIFF_LIBRARIES}
)
set_target_properties(ctbGui PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)

View File

@ -1,17 +1,17 @@
INCS=ctbMain.h ctbDacs.h ctbPattern.h ctbSignals.h ctbAdcs.h ctbAcquisition.h ctbPowers.h ctbSlowAdcs.h INCS=ctbMain.h ctbDacs.h ctbPattern.h ctbSignals.h ctbAdcs.h ctbAcquisition.h ctbPowers.h ctbSlowAdcs.h
SRC= $(INCS:.h=.cpp) ctbDict.cpp SRC= $(SRC:.h=.cpp) ctbDict.cpp
LINKDEF=ctbLinkDef.h LINKDEF=ctbLinkDef.h
ZMQLIB=../slsReceiverSoftware/include ZMQLIB=../slsReceiverSoftware/include
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-I../slsReceiverSoftware/include/ -I../slsDetectorSoftware/include/ -I../slsSupportLib/include/ -I../slsDetectorCalibration -I../slsDetectorCalibration/dataStructures -I$(CBFLIBDIR)/include -I../slsDetectorCalibration/interpolations INCDIR=-I../slsReceiverSoftware/include/ -I../slsDetectorSoftware/include/ -I../slsSupportLib/include/ -I../slsDetectorCalibration -I../slsDetectorCalibration/dataStructures -I$(CBFLIBDIR)/include -I../slsDetectorCalibration/interpolations
LDFLAG=-L../build/bin -lSlsDetector -lSlsSupport -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -std=c++11 LDFLAG=-L../bin -lSlsDetector -lSlsSupport -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -std=c++11
# #
MAIN=ctbGui.cpp MAIN=ctbGui.cpp
DESTDIR?=../build/bin DESTDIR?=../bin
OBJS = $(SRC:.cpp=.o) $(MAIN:.cpp=.o) OBJS = $(SRC:.cpp=.o) $(MAIN:.cpp=.o)
@ -30,13 +30,13 @@ ctbDict.cpp: $(INCS) $(LINKDEF)
%.o : %.cpp %.o : %.cpp
echo $@ echo $@
g++ -DMYROOT `root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o $@ -c $< $(INCDIR) g++ -DMYROOT `source root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o $@ -c $< $(INCDIR)
#$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS) #$(CXX) -o $@ -c $< $(INCLUDES) $(DFLAGS) -fPIC $(EPICSFLAGS) -lpthread #$(FLAGS)
$(DESTDIR)/ctbGui: $(OBJS) $(LINKDEF) $(DESTDIR)/ctbGui: $(OBJS) $(LINKDEF)
g++ -DMYROOT `root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o ctbGui $(INCDIR) $(OBJS) ../slsDetectorCalibration/tiffIO.cpp g++ -DMYROOT `source root-config --cflags --glibs` -lMinuit -DCTB $(LDFLAG) -o ctbGui $(INCDIR) $(OBJS) ../slsDetectorCalibration/tiffIO.cpp
mv ctbGui $(DESTDIR) mv ctbGui $(DESTDIR)
clean: clean:

View File

@ -24,8 +24,7 @@
#include <fstream> #include <fstream>
#include "ctbAcquisition.h" #include "ctbAcquisition.h"
#include "ctbDefs.h" #include "multiSlsDetector.h"
#include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "ctbMain.h" #include "ctbMain.h"
#include "moench03CtbData.h" #include "moench03CtbData.h"
@ -40,7 +39,6 @@
#include "Mythen3_02_jctbData.h" #include "Mythen3_02_jctbData.h"
#include "adcSar2_jctbData.h" #include "adcSar2_jctbData.h"
#include "moench04CtbZmqData.h" #include "moench04CtbZmqData.h"
#include "moench04CtbZmq10GbData.h"
#include "deserializer.h" #include "deserializer.h"
#include "detectorData.h" #include "detectorData.h"
@ -49,7 +47,7 @@ using namespace std;
ctbAcquisition::ctbAcquisition(TGVerticalFrame *page, sls::Detector *det) : TGGroupFrame(page,"Acquisition",kVerticalFrame), myDet(det), myCanvas(NULL), globalPlot(0), tenG(0), nAnalogSamples(1), nDigitalSamples(1), dataStructure(NULL), photonFinder(NULL), cmSub(0), dBitMask(0xffffffffffffffff), deserializer(0) { ctbAcquisition::ctbAcquisition(TGVerticalFrame *page, multiSlsDetector *det) : TGGroupFrame(page,"Acquisition",kVerticalFrame), myDet(det), myCanvas(NULL), globalPlot(0), nAnalogSamples(1), nDigitalSamples(1), dataStructure(NULL), photonFinder(NULL), cmSub(0), dBitMask(0xffffffffffffffff), deserializer(0) {
adcFit=NULL; adcFit=NULL;
bitPlot=NULL; bitPlot=NULL;
@ -72,11 +70,8 @@ ctbAcquisition::ctbAcquisition(TGVerticalFrame *page, sls::Detector *det) : TGGr
cFileSave->SetTextJustify(kTextRight); cFileSave->SetTextJustify(kTextRight);
cFileSave->Connect("Toggled(Bool_t)","ctbAcquisition",this,"setFsave(Bool_t)"); cFileSave->Connect("Toggled(Bool_t)","ctbAcquisition",this,"setFsave(Bool_t)");
std::string temp = "run";
try { eFname = new TGTextEntry(hframe, (myDet->getFileName()).c_str());
temp = myDet->getFileNamePrefix().tsquash("Different values");
} CATCH_DISPLAY ("Could not get file name prefix.", "ctbAcquisition::ctbAcquisition")
eFname = new TGTextEntry(hframe, temp.c_str());
hframe->AddFrame(eFname,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5)); hframe->AddFrame(eFname,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
eFname->MapWindow(); eFname->MapWindow();
@ -117,11 +112,7 @@ ctbAcquisition::ctbAcquisition(TGVerticalFrame *page, sls::Detector *det) : TGGr
temp = "/tmp/"; eOutdir = new TGTextEntry(hframe, (myDet->getFilePath()).c_str());
try {
temp = myDet->getFilePath().tsquash("Different values");
} CATCH_DISPLAY ("Could not get file path.", "ctbAcquisition::ctbAcquisition")
eOutdir = new TGTextEntry(hframe, temp.c_str());
hframe->AddFrame(eOutdir,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5)); hframe->AddFrame(eOutdir,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
eOutdir->MapWindow(); eOutdir->MapWindow();
@ -605,11 +596,20 @@ hframe=new TGHorizontalFrame(this, 800,50);
acqThread = new TThread("acqThread", acqThread = new TThread("acqThread",
ctbAcquisition::ThreadHandle,(void*)this); ctbAcquisition::ThreadHandle,(void*)this);
// acqThread->Run();
cout <<"Registering progress callback" << endl;
try {
myDet->registerProgressCallback(&progressCallback,(void*)this);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
cout <<"Registering data callback" << endl; cout <<"Registering data callback" << endl;
try { try{
myDet->registerDataCallback(&dataCallback, (void*)this); myDet->registerDataCallback(&dataCallback, (void*)this);
} CATCH_DISPLAY ("Could not get register call back.", "ctbAcquisition::ctbAcquisition") } catch (...) {
cout << "Do nothing for this error" << endl;
}
cout <<"Done" << endl; cout <<"Done" << endl;
@ -663,6 +663,10 @@ hframe=new TGHorizontalFrame(this, 800,50);
countsHisto[i]=h1; countsHisto[i]=h1;
} }
int nx,ny;
int csize=3;
int nsigma=5;
dataStructure=NULL; dataStructure=NULL;
commonMode=NULL; commonMode=NULL;
photonFinder=NULL; photonFinder=NULL;
@ -766,7 +770,7 @@ void ctbAcquisition::canvasClicked() {
void ctbAcquisition::setCanvas(TCanvas* c) { void ctbAcquisition::setCanvas(TCanvas* c) {
myCanvas=c; myCanvas=c;
myCanvas->cd(); myCanvas->cd();
myCanvas->AddExec("dynamic",Form("((ctbAcquisition*)%p)->canvasClicked()",this)); myCanvas->AddExec("dynamic",Form("((ctbAcquisition*)0x%x)->canvasClicked()",this));
// myCanvas->AddExec("ex","canvasClicked()"); // myCanvas->AddExec("ex","canvasClicked()");
} }
void ctbAcquisition::dataCallback(detectorData *data, long unsigned int index, unsigned int dum, void* pArgs) { void ctbAcquisition::dataCallback(detectorData *data, long unsigned int index, unsigned int dum, void* pArgs) {
@ -801,6 +805,8 @@ digital:
sample0 (dbit0 + dbit1 +...) sample0 (dbit0 + dbit1 +...)
sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") { sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) { if (action == PUT_ACTION) {
std::vector <int> dbitlist; std::vector <int> dbitlist;
@ -838,18 +844,19 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
// cout <<"------"<< index << " " << ip << " " << data->npoints << endl; // cout <<"------"<< index << " " << ip << " " << data->npoints << endl;
//#endif //#endif
int ig=0; int ig=0;
int i, ii, ib; int i, ii, ich=0, ib, vv;
// TList *l= adcStack->GetHists(); // TList *l= adcStack->GetHists();
// TList *l1= countsStack->GetHists(); // TList *l1= countsStack->GetHists();
TH1F *h; TH1F *h;
TH1F *h1; TH1F *h1;
TH1F *hb; TH1F *hb;
int x; int nb, x,y;
double ped=0; double ped=0;
int vv1,vv2;
int dsize=-1; int dsize=-1;
int *val=NULL; int *val=NULL;
int nx=1, ny=1; int nx=1, ny=1, jj;
short unsigned int *va;
if (dataStructure) { if (dataStructure) {
dataStructure->getDetectorSize(nx,ny); dataStructure->getDetectorSize(nx,ny);
cout << "Data structure: " << dataStructure << " size " << nx << " " << ny << endl; cout << "Data structure: " << dataStructure << " size " << nx << " " << ny << endl;
@ -865,7 +872,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
int nadc; int nadc;
int ndbit; int ndbit;
tenG = 0;
@ -886,18 +893,8 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
} }
} else } else
ndbit=dbitlist.size(); ndbit=dbitlist.size();
if (tenG){
if (nDigitalSamples && nAnalogSamples){ dsize=nadc*2*nAnalogSamples+ndbit*(nDigitalSamples-dBitOffset/8)/8;
if (nDigitalSamples>nAnalogSamples)
dsize=nDigitalSamples*(32*2+8);
else
dsize=nAnalogSamples*(32*2+8);
} else
dsize=32*2*nAnalogSamples+8*nDigitalSamples;
} else
dsize=nadc*2*nAnalogSamples+ndbit*(nDigitalSamples-dBitOffset/8)/8;
cout << "dataBytes is " << data->databytes << " expected " << dsize << endl; cout << "dataBytes is " << data->databytes << " expected " << dsize << endl;
@ -908,11 +905,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
i=0; i=0;
char *d_data; char *d_data= data->data+2*nadc*nAnalogSamples;
if (tenG)
d_data= data->data;
else
d_data = data->data+2*nadc*nAnalogSamples;
char dval; char dval;
@ -974,11 +967,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
ig=ii; ig=ii;
else else
ig=adclist.at(ii); ig=adclist.at(ii);
aval=data->getChannel(i);//*((uint16_t*)(data->cvalues+i*2));//
// if (tenG)
// aval=data->getChannel(i);
// else
aval=data->getChannel(i);//*((uint16_t*)(data->cvalues+i*2));//
if (plotFlag[ig]) { if (plotFlag[ig]) {
@ -990,11 +979,10 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
// cout << data->getChannel(i) << endl; // cout << data->getChannel(i) << endl;
h->SetBinContent(ip+1,aval); h->SetBinContent(ip+1,aval);
h1->Fill(aval); h1->Fill(aval);
} }
i++; i++;
} }
if (tenG) i+=4;
} }
@ -1004,10 +992,8 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
if (dbitlist.empty()) { if (dbitlist.empty()) {
for (ip=0; ip<nDigitalSamples; ip++) { for (ip=0; ip<nDigitalSamples; ip++) {
for (ig=0; ig<8; ig++) { for (ig=0; ig<8; ig++) {
if (tenG)
dval=*(d_data+ip*(8+32*2)+32*2+ig); dval=*(d_data+ip*8+ig);
else
dval=*(d_data+ip*8+ig);
for (ib=(ig)*8; ib<(ig+1)*8; ib++) { for (ib=(ig)*8; ib<(ig+1)*8; ib++) {
if (bitPlotFlag[ib]) { if (bitPlotFlag[ib]) {
@ -1024,6 +1010,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
} else { } else {
ii=0; ii=0;
int iii=0; int iii=0;
int nb=dbitlist.size();
for (const auto &value : dbitlist) { for (const auto &value : dbitlist) {
ib=value; ib=value;
hb=bitHisto[ib]; hb=bitHisto[ib];
@ -1189,10 +1176,10 @@ void ctbAcquisition::changeDetector(){
photonFinder=NULL; photonFinder=NULL;
dataStructure=NULL; dataStructure=NULL;
commonMode=NULL; commonMode=NULL;
TH2F *h2DMapOld=h2DMapAn;
// TH2F *h2ScanOld=h2Scan; // TH2F *h2ScanOld=h2Scan;
TH1F *h1DMapOld=h1DMap;
int dim=2;
int nx,ny; int nx,ny;
int csize=3; int csize=3;
int nsigma=5; int nsigma=5;
@ -1210,16 +1197,7 @@ void ctbAcquisition::changeDetector(){
// commonMode=new moench03CommonMode(); // commonMode=new moench03CommonMode();
break; break;
case MOENCH04: case MOENCH04:
dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
try {
auto retval = myDet->getTenGiga().tsquash("Different values");
if (retval) {
dataStructure=new moench04CtbZmq10GbData(nAnalogSamples, nDigitalSamples);
} else {
dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
}
} CATCH_DISPLAY ("Could not get ten giga enable.", "ctbAcquisition::changeDetector")
cout << "MOENCH 0.4!" << endl; cout << "MOENCH 0.4!" << endl;
commonMode=new moench03CommonMode(); commonMode=new moench03CommonMode();
break; break;
@ -1433,7 +1411,7 @@ void ctbAcquisition::setBitGraph(int i ,int en, Pixel_t col) {
float off=0; float off=0;
for (int ii=0; ii<NSIGNALS; ii++) { for (int ii=0; ii<NSIGNALS; ii++) {
if (bitPlotFlag[ii]) {bitOffset[ii]=off; if (bitPlotFlag[ii]) {bitOffset[ii]=off;
off+=static_cast<float>(1.5); off+=1.5;
cout << "bit " << ii << " offset " << bitOffset[ii] << endl; cout << "bit " << ii << " offset " << bitOffset[ii] << endl;
} }
} }
@ -1448,65 +1426,74 @@ void ctbAcquisition::setBitGraph(int i ,int en, Pixel_t col) {
void ctbAcquisition::setOutdir() { void ctbAcquisition::setOutdir() {
try { try {
myDet->setFilePath(eOutdir->GetText()); myDet->setFilePath(eOutdir->GetText());
} CATCH_DISPLAY ("Could not set file path", "ctbAcquisition::setOutdir") } catch (...) {
cout << "Do nothing for this error" << endl;
}
// // cout << "setting dac! "<< id << endl;
// myDet->setDAC(dacsEntry->GetIntNumber(), (slsDetectorDefs::dacIndex)id, dacsUnit->IsOn());
// getValue();
} }
void ctbAcquisition::setFname() { void ctbAcquisition::setFname() {
try { try {
myDet->setFileNamePrefix(eFname->GetText()); myDet->setFileName(eFname->GetText());
} CATCH_DISPLAY ("Could not set file name prefix", "ctbAcquisition::setFname") } catch (...) {
cout << "Do nothing for this error" << endl;
}
// int val=myDet->setDAC(-1, (slsDetectorDefs::dacIndex)id, dacsUnit->IsOn());
// char s[100];
// sprintf(s,"%d",val);
// dacsValue->SetText(s);
// return val;
} }
void ctbAcquisition::setFindex() { void ctbAcquisition::setFindex() {
try { try {
myDet->setAcquisitionIndex(eFindex->GetNumber()); myDet->setFileIndex(eFindex->GetNumber());
} CATCH_DISPLAY ("Could not set acquisition index", "ctbAcquisition::setFindex") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbAcquisition::setFsave(Bool_t b) { void ctbAcquisition::setFsave(Bool_t b) {
try { try {
myDet->setFileWrite(b); myDet->setFileWrite(b);
eFname->SetState(b); } catch (...) {
eOutdir->SetState(b); cout << "Do nothing for this error" << endl;
} CATCH_DISPLAY ("Could not set file write", "ctbAcquisition::setFsave") }
eFname->SetState(b);
eOutdir->SetState(b);
} }
void ctbAcquisition::update() { void ctbAcquisition::update() {
try {
auto retval = myDet->getFileNamePrefix().tsquash("Different values");
eFname->SetText(retval.c_str());
} CATCH_DISPLAY ("Could not get file name prefix", "ctbAcquisition::update")
try {
auto retval = myDet->getAcquisitionIndex().tsquash("Different values");
eFindex->SetNumber(retval);
} CATCH_DISPLAY ("Could not get acquisition index", "ctbAcquisition::update")
try {
auto retval = myDet->getFileWrite().tsquash("Different values");
cFileSave->SetOn(retval);
} CATCH_DISPLAY ("Could not get file write", "ctbAcquisition::update")
eFname->SetText((myDet->getFileName()).c_str());
eOutdir->SetText((myDet->getFilePath()).c_str());
eFindex->SetNumber(myDet->getFileIndex());
cFileSave->SetOn(myDet->getFileWrite());
eFname->SetState(cFileSave->IsOn()); eFname->SetState(cFileSave->IsOn());
eOutdir->SetState(cFileSave->IsOn()); eOutdir->SetState(cFileSave->IsOn());
eFindex->SetState(cFileSave->IsOn()); eFindex->SetState(cFileSave->IsOn());
// eMeasurements->SetNumber(myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1));
try { setAnalogSamples(myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES,-1));
auto retval = myDet->getNumberOfAnalogSamples().tsquash("Different values"); setDigitalSamples(myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES,-1));
setAnalogSamples(retval); roMode=myDet->setReadOutFlags();
} CATCH_DISPLAY ("Could not get number of analog samples", "ctbAcquisition::update") setReadoutMode(roMode);
//nChannels=myDet->getTotalNumberOfChannels();
try {
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values");
setDigitalSamples(retval);
} CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::update")
try {
roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values"));
setReadoutMode(roMode);
} CATCH_DISPLAY ("Could not get readout mode", "ctbAcquisition::update")
updateChans(); updateChans();
if (dataStructure) { if (dataStructure) {
@ -1520,14 +1507,7 @@ void ctbAcquisition::update() {
} }
} }
dBitOffset=myDet->getReceiverDbitOffset();
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
try {
tenG = myDet->getTenGiga().tsquash("Different values");
} CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update")
// char aargs[10][100]; // char aargs[10][100];
// char *args[10]; // char *args[10];
@ -1588,8 +1568,10 @@ void ctbAcquisition::loadPattern() {
cout << "Load: " << fname << endl; cout << "Load: " << fname << endl;
try { try {
myDet->loadParameters(fname); myDet->retrieveDetectorSetup(fname);
} CATCH_DISPLAY ("Could not load parameters", "ctbAcquisition::loadPattern") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
} }
@ -1600,26 +1582,16 @@ void ctbAcquisition::toggleAcquisition() {
if (acqThread->GetState()==1 || acqThread->GetState()==6) { if (acqThread->GetState()==1 || acqThread->GetState()==6) {
/** update all infos useful for the acquisition! */ /** update all infos useful for the acquisition! */
try { setAnalogSamples(myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES,-1));
auto retval = myDet->getNumberOfAnalogSamples().tsquash("Different values"); setDigitalSamples(myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES,-1));
setAnalogSamples(retval); dBitOffset=myDet->getReceiverDbitOffset();
} CATCH_DISPLAY ("Could not get number of analog samples", "ctbAcquisition::toggleAcquisition") roMode=myDet->setReadOutFlags();
try {
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values");
setDigitalSamples(retval);
} CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition")
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
try {
roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values"));
setReadoutMode(roMode); setReadoutMode(roMode);
} CATCH_DISPLAY ("Could not get readout mode", "ctbAcquisition::toggleAcquisition")
// iScanStep=0;
cout << "Run" << endl; cout << "Run" << endl;
bStatus->SetText("Stop"); bStatus->SetText("Stop");
ip=0; ip=0;
@ -1669,9 +1641,11 @@ void ctbAcquisition::toggleAcquisition() {
} else { } else {
StopFlag=1; StopFlag=1;
try{ try {
myDet->stopDetector(); myDet->stopAcquisition();
} CATCH_DISPLAY ("Could not stop acquisition", "ctbAcquisition::toggleAcquisition") } catch (...) {
cout << "Do nothing for this error" << endl;
}
stop=1; stop=1;
bStatus->SetText("Start"); bStatus->SetText("Start");
// acqThread->Kill(); // acqThread->Kill();
@ -1688,30 +1662,27 @@ void ctbAcquisition::acquisitionFinished() {
void ctbAcquisition::startAcquisition(){ void ctbAcquisition::startAcquisition(){
cout << "Detector started " <<eMeasurements->GetNumber()<< endl; cout << "Detector started " <<eMeasurements->GetNumber()<< endl;
stop=0; stop=0;
try {
tenG = myDet->getTenGiga().tsquash("Different values");
} CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::startAcquisition")
for (int im=0; im<eMeasurements->GetNumber(); im++) { for (int im=0; im<eMeasurements->GetNumber(); im++) {
try { try {
myDet->acquire(); myDet->acquire();
} CATCH_DISPLAY ("Could not acquire", "ctbAcquisition::startAcquisition") } catch (...) {
cout << "Do nothing for this error" << endl;
}
cout << im << endl; cout << im << endl;
if (stop) if (stop) break;
break;
} }
} }
void* ctbAcquisition::ThreadHandle(void *arg) void* ctbAcquisition::ThreadHandle(void *arg)
{ {
ctbAcquisition *acq = static_cast<ctbAcquisition*>(arg); ctbAcquisition *acq = static_cast<ctbAcquisition*>(arg);
int i=0;
acq->startAcquisition(); acq->startAcquisition();
acq->acquisitionFinished(); acq->acquisitionFinished();
return nullptr;
} }
void ctbAcquisition::progressCallback(double f,void* arg) { void ctbAcquisition::progressCallback(double f,void* arg) {
@ -1744,6 +1715,12 @@ void ctbAcquisition::setPatternCompiler(const char* t) {
} }
void ctbAcquisition::setMeasurements() { void ctbAcquisition::setMeasurements() {
// myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,eMeasurements->GetNumber());
} }
void ctbAcquisition::setAnalogSamples(int n) { void ctbAcquisition::setAnalogSamples(int n) {
@ -1798,11 +1775,11 @@ void ctbAcquisition::setDigitalSamples(int n) {
void ctbAcquisition::setReadoutMode(int f) { void ctbAcquisition::setReadoutMode(int f) {
roMode=f; roMode=f;
slsDetectorDefs::readoutMode flag=(slsDetectorDefs::readoutMode)f; slsDetectorDefs::readOutFlags flags=(slsDetectorDefs::readOutFlags)f;
if (flag == slsDetectorDefs::DIGITAL_ONLY) { if (flags&slsDetectorDefs::DIGITAL_ONLY) {
nAnalogSamples=0; nAnalogSamples=0;
adclist.clear(); adclist.clear();
} else if (flag ==slsDetectorDefs::ANALOG_AND_DIGITAL) { } else if (flags&slsDetectorDefs::ANALOG_AND_DIGITAL) {
; ;
} }
else { else {
@ -1848,32 +1825,46 @@ void ctbAcquisition::setDbitEnable(Int_t reg){
void ctbAcquisition::updateChans() { void ctbAcquisition::updateChans() {
// dbit list /** dbitlist updated */
std::vector <int> dbl;
try { try {
auto retval = myDet->getRxDbitList().tsquash("Different values"); dbl = myDet->getReceiverDbitList();
dbitlist.clear(); } catch (...) {
if (!retval.empty()) { cout << "Do nothing for this error" << endl;
for (const auto &value : retval) }
dbitlist.push_back(value); dbitlist.clear();
if (dbl.empty())
;
else {
for (const auto &value : dbl)
dbitlist.push_back(value);
}
uint32_t reg;
try {
reg=myDet->getADCEnableMask();
} catch (...) {
cout << "Do nothing for this error" << endl;
}
/* adc updated */
adclist.clear();
// // updateChans();
if (reg!=0xffffffff) {
for (int i=0; i<NADCS; i++) {
if (reg&(1<<i))
adclist.push_back(i);
// // else enableFlag[i]=1;
} }
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans") }
// adc mask
try {
auto retval = myDet->getADCEnableMask().tsquash("Different values");
adclist.clear();
if (retval!=0xffffffff) {
for (int i=0; i<NADCS; i++) {
if (retval&(1<<i)) {
adclist.push_back(i);
}
}
}
} CATCH_DISPLAY ("Could not get adc enable mask.", "ctbAcquisition::updateChans")
} }
void ctbAcquisition::resetPedestal() { void ctbAcquisition::resetPedestal() {
if (photonFinder) { if (photonFinder) {
photonFinder->newDataSet(); photonFinder->newDataSet();

View File

@ -23,10 +23,7 @@ class TH1F;
class TGLabel; class TGLabel;
class TGTextButton; class TGTextButton;
namespace sls class multiSlsDetector;
{
class Detector;
};
class detectorData; class detectorData;
template <class dataType> class slsDetectorData; template <class dataType> class slsDetectorData;
@ -115,7 +112,7 @@ class ctbAcquisition : public TGGroupFrame {
// TH1I *plotAdc[NADCS]; // TH1I *plotAdc[NADCS];
sls::Detector* myDet; multiSlsDetector* myDet;
int plotFlag[NADCS]; int plotFlag[NADCS];
int bitPlotFlag[NSIGNALS]; int bitPlotFlag[NSIGNALS];
@ -154,7 +151,6 @@ class ctbAcquisition : public TGGroupFrame {
int globalPlot; int globalPlot;
int adcPlot; int adcPlot;
int dbitPlot; int dbitPlot;
int tenG;
int nAnalogSamples, nDigitalSamples; int nAnalogSamples, nDigitalSamples;
// int iScanStep; // int iScanStep;
@ -172,7 +168,7 @@ class ctbAcquisition : public TGGroupFrame {
int deserializer; int deserializer;
public: public:
ctbAcquisition(TGVerticalFrame*, sls::Detector*); ctbAcquisition(TGVerticalFrame*, multiSlsDetector*);
void setOutdir(); void setOutdir();
void setFname(); void setFname();
void setMeasurements(); void setMeasurements();

View File

@ -24,14 +24,14 @@
#include <fstream> #include <fstream>
#include "ctbAdcs.h" #include "ctbAdcs.h"
#include "ctbDefs.h" #include "multiSlsDetector.h"
#include "Detector.h" #include "slsDetectorCommand.h"
using namespace std; using namespace std;
ctbAdc::ctbAdc(TGVerticalFrame *page, int i, sls::Detector *det) ctbAdc::ctbAdc(TGVerticalFrame *page, int i, multiSlsDetector *det)
: TGHorizontalFrame(page, 800,800), id(i), myDet(det) { : TGHorizontalFrame(page, 800,800), id(i), myDet(det) {
TGHorizontalFrame *hframe=this; TGHorizontalFrame *hframe=this;
@ -155,7 +155,7 @@ void ctbAdc::setAdcAlias(char *tit, int plot, int color) {
string ctbAdc::getAdcAlias() { string ctbAdc::getAdcAlias() {
char line[1000]; char line[1000];
sprintf(line,"ADC%d %s %d %lx\n",id,sAdcLabel->GetText()->Data(),sAdcPlot->IsOn(),fColorSel->GetColor()); sprintf(line,"ADC%d %s %d %x\n",id,sAdcLabel->GetText()->Data(),sAdcPlot->IsOn(),fColorSel->GetColor());
return string(line); return string(line);
} }
@ -264,7 +264,7 @@ void ctbAdc::setPlot(Bool_t b){
ctbAdcs::ctbAdcs(TGVerticalFrame *page, sls::Detector *det) ctbAdcs::ctbAdcs(TGVerticalFrame *page, multiSlsDetector *det)
: TGGroupFrame(page,"Adcs",kVerticalFrame), myDet(det) { : TGGroupFrame(page,"Adcs",kVerticalFrame), myDet(det) {
@ -272,6 +272,7 @@ ctbAdcs::ctbAdcs(TGVerticalFrame *page, sls::Detector *det)
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10)); page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
MapWindow(); MapWindow();
char tit[100];
TGHorizontalFrame* hframe=new TGHorizontalFrame(this, 800,800); TGHorizontalFrame* hframe=new TGHorizontalFrame(this, 800,800);
@ -414,41 +415,108 @@ ctbAdcs::ctbAdcs(TGVerticalFrame *page, sls::Detector *det)
int ctbAdcs::setEnable(int reg) { int ctbAdcs::setEnable(int reg) {
try { // char aargs[10][100];
if (reg > -1) { // char *args[10];
myDet->setADCEnableMask(reg); string retval;
} int retreg;
auto retval = myDet->getADCEnableMask().tsquash("Different values");
eEnableMask->SetHexNumber(retval);
return retval;
} CATCH_DISPLAY ("Could not set/get adc enablemask.", "ctbAdcs::setEnable")
return -1; // for (int i=0; i<10; i++) args[i]=aargs[i];
// sprintf(args[0],"adcenable");
// sprintf(args[1],"%x",reg);
// slsDetectorCommand *cmd=new slsDetectorCommand(myDet);
// if (reg>-1) {
// retval=cmd->executeLine(1,args,slsDetectorDefs::PUT_ACTION);
// }
if (reg>-1) {
try {
myDet->setADCEnableMask(reg);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
}
// retval=cmd->executeLine(1,args,slsDetectorDefs::GET_ACTION);
// cout <<"enable: " << retval << endl;;
// delete cmd;
// sscanf(retval.c_str(),"%x",&retreg);
try {
retreg=myDet->getADCEnableMask();
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eEnableMask->SetHexNumber(retreg);
return retreg;
} }
int ctbAdcs::setInvert(int reg) { int ctbAdcs::setInvert(int reg) {
try { // char aargs[10][100];
if (reg > -1) { // char *args[10];
myDet->setADCInvert(reg); string retval;
} int retreg;
auto retval = myDet->getADCInvert().tsquash("Different values");
eInversionMask->SetHexNumber(retval);
return retval;
} CATCH_DISPLAY ("Could not set/get adc enablemask.", "ctbAdcs::setEnable")
return -1; // for (int i=0; i<10; i++) args[i]=aargs[i];
//sprint// f(args[0],"adcinvert");
// sprintf(args[1],"%x",reg);
// slsDetectorCommand *cmd=new slsDetectorCommand(myDet);
if (reg>-1) {
try {
myDet->setADCInvert(reg);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
//retval=cmd->executeLine(1,args,slsDetectorDefs::PUT_ACTION);
}
try {
retreg=myDet->getADCInvert();
} catch (...) {
cout << "Do nothing for this error" << endl;
}
// retval=cmd->executeLine(1,args,slsDetectorDefs::GET_ACTION);
// cout <<"invert: " << retval << endl;;
// delete cmd;
// sscanf(retval.c_str(),"%x",&retreg);
eInversionMask->SetHexNumber(retreg);
return retreg;
} }
void ctbAdcs::update() { void ctbAdcs::update() {
Int_t invreg; Int_t invreg;//=myDet->readRegister(67);//(120);
Int_t disreg; Int_t disreg;//=myDet->readRegister(120);//(94);
// for (int i=0; i<10; i++)
// args[i]=aargs[i];
// string retval;
// sprintf(args[0],"adcenable");
// slsDetectorCommand *cmd=new slsDetectorCommand(myDet);
// retval=cmd->executeLine(1,args,slsDetectorDefs::GET_ACTION);
// delete cmd;
// // cout << retval << endl;
// sscanf(retval.c_str(),"adcenable %x",&disreg);
// eInversionMask->SetHexNumber(invreg);
// eEnableMask->SetHexNumber(disreg);
disreg=setEnable(); disreg=setEnable();
invreg=setInvert(); invreg=setInvert();
for (int is=0; is<NADCS; is++) { for (int is=0; is<NADCS; is++) {
sAdc[is]->setAdcAlias(NULL,-1,-1); sAdc[is]->setAdcAlias(NULL,-1,-1);
if (invreg & (1<<is) ) if (invreg & (1<<is) )
@ -460,29 +528,42 @@ void ctbAdcs::update() {
sAdc[is]->setEnable(kTRUE); sAdc[is]->setEnable(kTRUE);
else else
sAdc[is]->setEnable(kFALSE); sAdc[is]->setEnable(kFALSE);
} }
Emit("AdcEnable(Int_t)", disreg); Emit("AdcEnable(Int_t)", disreg);
} }
string ctbAdcs::getAdcParameters() { string ctbAdcs::getAdcParameters() {
ostringstream line;
ostringstream line;
line << "reg "<< hex << setInvert() << "# ADC invert reg" << dec << endl; line << "reg "<< hex << setInvert() << "# ADC invert reg" << dec << endl;
line << "reg "<< hex << setEnable() << " # ADC enable reg"<< dec << endl; line << "reg "<< hex << setEnable() << " # ADC enable reg"<< dec << endl;
// line << "reg "<< hex << 67 << " " << myDet->readRegister(67) << "# ADC invert reg" << dec << endl;
// line << "reg "<< hex << 120 << " " << myDet->readRegister(120) << " # ADC enable reg"<< dec << endl;
// // line << "reg "<< hex << 94 << " " << myDet->readRegister(94) << " # ADC enable reg"<< dec << endl;
return line.str(); return line.str();
} }
void ctbAdcs::CheckAll() { void ctbAdcs::CheckAll() {
for (int is=0; is<NADCS; is++){ for (int is=0; is<NADCS; is++){
sAdc[is]->setPlot(kTRUE); sAdc[is]->setPlot(kTRUE);
// sAdc[is]->setEnabled(kTRUE);
} }
} }
void ctbAdcs::RemoveAll() { void ctbAdcs::RemoveAll() {
for (int is=0; is<NADCS; is++) { for (int is=0; is<NADCS; is++) {
// sAdc[is]->setEnabled(kFALSE);
sAdc[is]->setPlot(kFALSE); sAdc[is]->setPlot(kFALSE);
} }
} }
@ -490,32 +571,51 @@ void ctbAdcs::RemoveAll() {
void ctbAdcs::CheckHalf0() { void ctbAdcs::CheckHalf0() {
for (int is=0; is<NADCS/2; is++) { for (int is=0; is<NADCS/2; is++) {
sAdc[is]->setPlot(kTRUE); sAdc[is]->setPlot(kTRUE);
// sAdc[is]->setEnabled(kTRUE)
} }
} }
void ctbAdcs::RemoveHalf0() { void ctbAdcs::RemoveHalf0() {
for (int is=0; is<NADCS/2; is++){ for (int is=0; is<NADCS/2; is++){
// sAdc[is]->setEnabled(kFALSE);
sAdc[is]->setPlot(kFALSE); sAdc[is]->setPlot(kFALSE);
} }
} }
void ctbAdcs::CheckHalf1() { void ctbAdcs::CheckHalf1() {
for (int is=NADCS/2; is<NADCS; is++){ for (int is=NADCS/2; is<NADCS; is++){
sAdc[is]->setPlot(kTRUE); sAdc[is]->setPlot(kTRUE);
// sAdc[is]->setEnabled(kTRUE)
} }
} }
void ctbAdcs::RemoveHalf1() { void ctbAdcs::RemoveHalf1() {
for (int is=NADCS/2; is<NADCS; is++){ for (int is=NADCS/2; is<NADCS; is++){
// sAdc[is]->setEnabled(kFALSE);
sAdc[is]->setPlot(kFALSE); sAdc[is]->setPlot(kFALSE);
} }
} }
// TGraph* ctbAdcs::getGraph(int i) {
// if (i>=0 && i<NADCS)
// return sAdc[i]->getGraph();
// return NULL;
// }
int ctbAdcs::setAdcAlias(string line) { int ctbAdcs::setAdcAlias(string line) {
int is=-1, plot=0, color=-1; int is=-1, plot=0, color=-1;
@ -557,23 +657,33 @@ void ctbAdcs::AdcEnable(Int_t b){
void ctbAdcs::ToggledAdcEnable(Int_t b){ void ctbAdcs::ToggledAdcEnable(Int_t b){
Int_t oreg=setEnable();
Int_t oreg=setEnable();//myDet->readRegister(67);
Int_t m=1<<b; Int_t m=1<<b;
if (sAdc[b]->getEnable()) if (sAdc[b]->getEnable())
oreg|=m; oreg|=m;
else else
oreg&=~m; oreg&=~m;
setEnable(oreg); // cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
setEnable(oreg);//)writeRegister(67, oreg);
//oreg=setEnable();//myDet->readRegister(67);
Emit("AdcEnable(Int_t)", oreg); Emit("AdcEnable(Int_t)", oreg);
//cout << "enable!" << endl;
// Emit("ToggledAdcPlot(Int_t)", b);
} }
void ctbAdcs::ToggledAdcInvert(Int_t b){ void ctbAdcs::ToggledAdcInvert(Int_t b){
Int_t oreg=setInvert(); // char val[1000];
Int_t oreg=setInvert();//myDet->readRegister(67);
Int_t m=1<<b; Int_t m=1<<b;
@ -582,7 +692,15 @@ void ctbAdcs::ToggledAdcInvert(Int_t b){
else else
oreg&=~m; oreg&=~m;
setInvert(oreg); // cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
setInvert(oreg);//)writeRegister(67, oreg);
// oreg=setInvert();//myDet->readRegister(67);
// cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
//sprintf(val,"%X",oreg);
//eInversionMask->SetHexNumber(oreg);
} }
@ -592,23 +710,22 @@ void ctbAdcs::ToggledAdcInvert(Int_t b){
Pixel_t ctbAdcs::getColor(int i){ Pixel_t ctbAdcs::getColor(int i){
if (i>=0 && i<NADCS) if (i>=0 && i<NADCS)
return sAdc[i]->getColor(); return sAdc[i]->getColor();
return static_cast<Pixel_t>(-1);
} }
Bool_t ctbAdcs::getEnabled(int i){ Bool_t ctbAdcs::getEnabled(int i){
if (i>=0 && i<NADCS) if (i>=0 && i<NADCS)
return sAdc[i]->getEnabled(); return sAdc[i]->getEnabled();
return static_cast<Bool_t>(-1);
} }
Bool_t ctbAdcs::getEnable(int i){ Bool_t ctbAdcs::getEnable(int i){
if (i>=0 && i<NADCS) if (i>=0 && i<NADCS)
return sAdc[i]->getEnable(); return sAdc[i]->getEnable();
return static_cast<Bool_t>(-1);
} }
Bool_t ctbAdcs::getPlot(int i){ Bool_t ctbAdcs::getPlot(int i){
if (i>=0 && i<NADCS) if (i>=0 && i<NADCS)
return sAdc[i]->getPlot(); return sAdc[i]->getPlot();
return static_cast<Bool_t>(-1);
} }

View File

@ -28,10 +28,7 @@ class TGTab;
class TGraph; class TGraph;
namespace sls class multiSlsDetector;
{
class Detector;
};
#include <string> #include <string>
using namespace std; using namespace std;
@ -52,10 +49,10 @@ class ctbAdc : public TGHorizontalFrame {
// TGraph *gADC; // TGraph *gADC;
int id; int id;
sls::Detector *myDet; multiSlsDetector *myDet;
public: public:
ctbAdc(TGVerticalFrame *page, int i, sls::Detector *det); ctbAdc(TGVerticalFrame *page, int i, multiSlsDetector *det);
void setAdcAlias(char *tit, int plot, int color); void setAdcAlias(char *tit, int plot, int color);
@ -92,7 +89,7 @@ class ctbAdcs : public TGGroupFrame {
private: private:
ctbAdc *sAdc[NADCS]; ctbAdc *sAdc[NADCS];
sls::Detector *myDet; multiSlsDetector *myDet;
TGTextButton *bCheckAll; TGTextButton *bCheckAll;
@ -118,7 +115,7 @@ private:
public: public:
ctbAdcs(TGVerticalFrame *page, sls::Detector *det); ctbAdcs(TGVerticalFrame *page, multiSlsDetector *det);
int setAdcAlias(string line); int setAdcAlias(string line);
string getAdcAlias(); string getAdcAlias();
string getAdcParameters(); string getAdcParameters();

View File

@ -9,14 +9,17 @@
#include <TGButton.h> #include <TGButton.h>
#include "ctbDacs.h" #include "ctbDacs.h"
#include "ctbDefs.h" #include "multiSlsDetector.h"
#include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
using namespace std; using namespace std;
ctbDac::ctbDac(TGGroupFrame *page, int idac, sls::Detector *det) : TGHorizontalFrame(page, 800,50) , id(idac), myDet(det) {
ctbDac::ctbDac(TGGroupFrame *page, int idac, multiSlsDetector *det) : TGHorizontalFrame(page, 800,50) , id(idac), myDet(det) {
TGHorizontalFrame *hframe=this; TGHorizontalFrame *hframe=this;
@ -101,9 +104,12 @@ int ctbDac::setLabel(char *tit, int mv) {
} }
string ctbDac::getLabel() { string ctbDac::getLabel() {
ostringstream line; ostringstream line;
line << dacsLabel->GetText() << " " << dacsUnit->IsOn() << endl; line << dacsLabel->GetText() << " " << dacsUnit->IsOn() << endl;
// line << "DAC" << dec << id << " " << dacsUnit->IsOn() << endl; // line << "DAC" << dec << id << " " << dacsUnit->IsOn() << endl;
return line.str(); return line.str();
} }
@ -113,45 +119,65 @@ void ctbDac::setValue(Long_t a) {setValue();}
void ctbDac::setValue() { void ctbDac::setValue() {
cout << "setting dac! "<< id << " value " << dacsEntry->GetIntNumber() << " units " << dacsUnit->IsOn() << endl;
cout << "setting dac! "<< id << " value " << dacsEntry->GetIntNumber() << " units " << dacsUnit->IsOn() << endl;
try { try {
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(id), dacsEntry->GetIntNumber(), dacsUnit->IsOn()); myDet->setDAC(dacsEntry->GetIntNumber(), (slsDetectorDefs::dacIndex)id, dacsUnit->IsOn()); } catch (...) {
} CATCH_DISPLAY ("Could not set dac " + to_string(id) + ".", "ctbDac::setValue") cout << "Do nothing for this error" << endl;
}
getValue(); getValue();
} }
void ctbDac::setOn(Bool_t b) { void ctbDac::setOn(Bool_t b) {
// cout << "setting dac! "<< id << endl; // cout << "setting dac! "<< id << endl;
if ( dacsLabel->IsOn()) { if ( dacsLabel->IsOn()) {
setValue(); setValue();
} else { } else {
try { try {
myDet->setDAC(static_cast<slsDetectorDefs::dacIndex>(id), -100, false); myDet->setDAC(-100, (slsDetectorDefs::dacIndex)id, 0);
} CATCH_DISPLAY ("Could not power off dac " + to_string(id) + ".", "ctbDac::setOn") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
getValue(); getValue();
} }
int ctbDac::getValue() { int ctbDac::getValue() {
int val;
try { try {
int val = myDet->getDAC(static_cast<slsDetectorDefs::dacIndex>(id), dacsUnit->IsOn()).tsquash("Different values"); val=myDet->setDAC(-1,(slsDetectorDefs::dacIndex)id, dacsUnit->IsOn());
cout << "dac " << id << " " << val << endl; } catch (...) {
dacsValue->SetText(to_string(val).c_str()); cout << "Do nothing for this error" << endl;
if (val >= 0) { }
dacsLabel->SetOn(kTRUE); char s[100];
} else { cout << "dac " << id << " " << val << endl;
dacsLabel->SetOn(kFALSE); sprintf(s,"%d",val);
} dacsValue->SetText(s);
return val; if (val>=0) {
} CATCH_DISPLAY ("Could not get dac " + to_string(id) + ".", "ctbDac::getValue") dacsLabel->SetOn(kTRUE);
} else {
dacsLabel->SetOn(kFALSE);
}
return val;
return -1;
} }
ctbDacs::ctbDacs(TGVerticalFrame *page, sls::Detector *det) : TGGroupFrame(page,"DACs",kVerticalFrame) , myDet(det){
ctbDacs::ctbDacs(TGVerticalFrame *page, multiSlsDetector *det) : TGGroupFrame(page,"DACs",kVerticalFrame) , myDet(det){
SetTitlePos(TGGroupFrame::kLeft); SetTitlePos(TGGroupFrame::kLeft);
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10)); page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
@ -166,12 +192,14 @@ ctbDacs::ctbDacs(TGVerticalFrame *page, sls::Detector *det) : TGGroupFrame(pag
} }
dacs[NDACS]=new ctbDac(this, slsDetectorDefs::ADC_VPP, myDet); dacs[NDACS]=new ctbDac(this, slsDetectorDefs::ADC_VPP, myDet);
dacs[NDACS+1]=new ctbDac(this, slsDetectorDefs::HIGH_VOLTAGE, myDet); dacs[NDACS+1]=new ctbDac(this, slsDetectorDefs::HIGH_VOLTAGE, myDet);
dacs[NDACS]->setLabel((char*)"ADC Vpp",2); dacs[NDACS]->setLabel("ADC Vpp",2);
dacs[NDACS+1]->setLabel((char*)"High Voltage",3); dacs[NDACS+1]->setLabel("High Voltage",3);
} }
int ctbDacs::setDacAlias(string line) { int ctbDacs::setDacAlias(string line) {
int is=-1, mv=0; int is=-1, mv=0;
char tit[100]; char tit[100];
int narg=sscanf(line.c_str(),"DAC%d %s %d",&is,tit,&mv); int narg=sscanf(line.c_str(),"DAC%d %s %d",&is,tit,&mv);
@ -189,6 +217,7 @@ string ctbDacs::getDacAlias() {
for (int i=0; i<NDACS; i++) for (int i=0; i<NDACS; i++)
line << dacs[i]->getLabel() << endl; line << dacs[i]->getLabel() << endl;
return line.str(); return line.str();
} }
@ -196,6 +225,8 @@ string ctbDacs::getDacAlias() {
string ctbDacs::getDacParameters() { string ctbDacs::getDacParameters() {
ostringstream line; ostringstream line;
for (int i=0; i<NDACS; i++) { for (int i=0; i<NDACS; i++) {
@ -203,12 +234,18 @@ string ctbDacs::getDacParameters() {
line << "dac:" << i << " " << dacs[i]->getValue() << endl; line << "dac:" << i << " " << dacs[i]->getValue() << endl;
} }
return line.str(); return line.str();
} }
void ctbDacs::update() { void ctbDacs::update() {
for (int idac=0; idac<NDACS+1; idac++) { for (int idac=0; idac<NDACS+1; idac++) {
dacs[idac]->getValue(); dacs[idac]->getValue();
} }
} }

View File

@ -15,10 +15,7 @@ class TGNumberEntry;
class TGCheckButton; class TGCheckButton;
namespace sls class multiSlsDetector;
{
class Detector;
};
#include <string> #include <string>
using namespace std; using namespace std;
@ -35,9 +32,9 @@ class ctbDac : public TGHorizontalFrame {
TGLabel *dacsValue; TGLabel *dacsValue;
int id; int id;
sls::Detector* myDet; multiSlsDetector* myDet;
public: public:
ctbDac(TGGroupFrame*, int , sls::Detector*); ctbDac(TGGroupFrame*, int , multiSlsDetector*);
void setValue(); void setValue();
void setValue(Long_t); void setValue(Long_t);
int getValue(); int getValue();
@ -58,10 +55,10 @@ private:
ctbDac *dacs[NDACS+2]; ctbDac *dacs[NDACS+2];
sls::Detector* myDet; multiSlsDetector* myDet;
public: public:
ctbDacs(TGVerticalFrame *page, sls::Detector*); ctbDacs(TGVerticalFrame *page, multiSlsDetector*);
int setDacAlias(string line); int setDacAlias(string line);
// int setDacAlias(string line); // int setDacAlias(string line);

View File

@ -1,84 +0,0 @@
#pragma once
#include <string>
#include <stdexcept>
#include <chrono>
//#include "sls_detector_exceptions.h"
//#include "ansi.h"
#define RED "\x1b[31m"
#define RESET "\x1b[0m"
#define BOLD "\x1b[1m"
#define cprintf(code, format, ...) printf(code format RESET, ##__VA_ARGS__)
#define CATCH_DISPLAY(m, s) catch(...) { ctbDefs::DisplayExceptions(m, s); }
#define CATCH_HANDLE(...) catch(...) { ctbDefs::HandleExceptions(__VA_ARGS__); }
class ctbDefs {
public:
/**
* Empty Constructor
*/
ctbDefs(){};
// convert double seconds to chrono ns
static std::chrono::nanoseconds ConvertDoubleStoChronoNS(double timeS) {
using std::chrono::duration;
using std::chrono::duration_cast;
using std::chrono::nanoseconds;
return duration_cast<nanoseconds>(duration<double>(timeS));
}
// convert chrono ns to doubel s
static double ConvertChronoNStoDoubleS(std::chrono::nanoseconds timeNs) {
using std::chrono::duration;
using std::chrono::duration_cast;
return duration_cast<duration<double>>(timeNs).count();
}
static void DisplayExceptions(std::string emsg, std::string src) {
try {
throw;
} /* catch (const sls::SocketError &e) {
throw;
} catch (const sls::SharedMemoryError &e) {
throw;
} */catch (const std::exception &e) {
ExceptionMessage(emsg, e.what(), src);
}
};
template <class CT> struct NonDeduced { using type = CT; };
template <class S, typename RT, typename... CT>
static void HandleExceptions(const std::string emsg, const std::string src, S* s,
RT (S::*somefunc)(CT...),
typename NonDeduced<CT>::type... Args) {
try {
throw;
} /*catch (const sls::SocketError &e) {
throw;
} catch (const sls::SharedMemoryError &e) {
throw;
} */catch (const std::exception &e) {
ExceptionMessage(emsg, e.what(), src);
(s->*somefunc)(Args...);
}
};
static void ExceptionMessage(std::string message,
std::string exceptionMessage,
std::string source) {
// because sls_detector_exceptions cannot be included
if (exceptionMessage.find("hared memory")) {
throw;
}
if (exceptionMessage.find("annot connect")) {
throw;
}
cprintf(RED, "Warning (%s): %s [Caught Exception: %s]\n", source.c_str(), message.c_str(), exceptionMessage.c_str());
//return Message(qDefs::WARNING, message + std::string("\nCaught exception:\n") + exceptionMessage, source);
};
};

View File

@ -9,11 +9,11 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
#include "Detector.h"
#include "multiSlsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
//#include "sls_receiver_defs.h" //#include "sls_receiver_defs.h"
#include "ctbMain.h" #include "ctbMain.h"
#include "ctbDefs.h"
using namespace std; using namespace std;
@ -45,9 +45,9 @@ int main(int argc, char **argv) {
} else if (strcmp(argv[ia],"-par")==0) { } else if (strcmp(argv[ia],"-par")==0) {
if (ia+1<argc) { if (ia+1<argc) {
pfname=argv[ia+1]; pfname=argv[ia+1];
ia++; ia++;
pf=1; pf=1;
} }
@ -61,27 +61,31 @@ int main(int argc, char **argv) {
cout << " *** " << endl; cout << " *** " << endl;
sls::Detector *myDet = nullptr;
try {
/****** Create detector ****************/
myDet=new sls::Detector(id);
cout << "Created multi detector id " << id << endl;
if (cf) { /****** Create detector ****************/
myDet->loadConfig(cfname); multiSlsDetector *myDet=new multiSlsDetector(id);
cout << "Config file loaded successfully" << endl; // myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
} else {
cout << "No config file specified" << endl; //cout << id << " " << myDet << " " << myDet->setOnline() << endl;
} if (cf) {
cout << "hostname " << myDet->getHostname() << endl; myDet->readConfigurationFile(cfname);
} else
cout << "No config file specified" << endl;
cout << "aa" << endl;
cout << "Created multi detector id " << id << " hostname " << myDet->getHostname() << endl;
cout << "bb" << endl;
if (pf) {
myDet->retrieveDetectorSetup(pfname);
} else
cout << "No parameter file specified" << endl;
if (pf) {
myDet->loadParameters(pfname);
cout << "Loaded parameter file successfully" << endl;
} else{
cout << "No parameter file specified" << endl;
}
} CATCH_DISPLAY ("Could not create detector/ load config/parameters.", "ctbGui::main")
/***********Create GUI stuff *******************/ /***********Create GUI stuff *******************/
TApplication theApp("App",&argc,argv); TApplication theApp("App",&argc,argv);
@ -137,7 +141,7 @@ int main(int argc, char **argv) {
gROOT->ForceStyle(); gROOT->ForceStyle();
ctbMain *mf=new ctbMain(gClient->GetRoot(), myDet); ctbMain *mf=new ctbMain(gClient->GetRoot(),myDet);
cout << " *** " << argc << endl; cout << " *** " << argc << endl;
for (int ia=0; ia<argc; ia++) for (int ia=0; ia<argc; ia++)

View File

@ -29,13 +29,15 @@
#include <stdio.h> #include <stdio.h>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string> #include <string>
#include "Detector.h" #include "multiSlsDetector.h"
#include "ctbDefs.h"
#include "ctbMain.h" #include "ctbMain.h"
#include "ctbDacs.h" #include "ctbDacs.h"
#include "ctbSlowAdcs.h" #include "ctbSlowAdcs.h"
@ -50,7 +52,7 @@ using namespace std;
ctbMain::ctbMain(const TGWindow *p, sls::Detector *det) ctbMain::ctbMain(const TGWindow *p, multiSlsDetector *det)
: TGMainFrame(p,800,800), pwrs(NULL), senses(NULL) { : TGMainFrame(p,800,800), pwrs(NULL), senses(NULL) {
myDet=det; myDet=det;
@ -145,7 +147,7 @@ ctbMain::ctbMain(const TGWindow *p, sls::Detector *det)
tf = mtab->AddTab("Power Supplies"); tf = mtab->AddTab("Power Supplies");
page=new TGVerticalFrame(tf, 1500,1200); page=new TGVerticalFrame(tf, 1500,1200);
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1)); tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
pwrs=new ctbPowers(page, myDet); pwrs=new ctbPowers(page, myDet);
i_pwrs=i_page++; i_pwrs=i_page++;
@ -153,7 +155,7 @@ ctbMain::ctbMain(const TGWindow *p, sls::Detector *det)
tf = mtab->AddTab("Sense"); tf = mtab->AddTab("Sense");
page=new TGVerticalFrame(tf, 1500,1200); page=new TGVerticalFrame(tf, 1500,1200);
tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1)); tf->AddFrame(page, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
senses=new ctbSlowAdcs(page, myDet); senses=new ctbSlowAdcs(page, myDet);
i_senses=i_page++; i_senses=i_page++;
@ -302,7 +304,7 @@ void ctbMain::HandleMenu(Int_t id)
fi.fIniDir = StrDup(dir); fi.fIniDir = StrDup(dir);
printf("fIniDir = %s\n", fi.fIniDir); printf("fIniDir = %s\n", fi.fIniDir);
new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi); new TGFileDialog(gClient->GetRoot(), this, kFDOpen, &fi);
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); printf("Open file: %s (dir: %s)\n", fi.fFilename);
// dir = fi.fIniDir; // dir = fi.fIniDir;
if (fi.fFilename) if (fi.fFilename)
loadAlias(fi.fFilename); loadAlias(fi.fFilename);
@ -318,12 +320,13 @@ void ctbMain::HandleMenu(Int_t id)
fi.fIniDir = StrDup(dir); fi.fIniDir = StrDup(dir);
printf("fIniDir = %s\n", fi.fIniDir); printf("fIniDir = %s\n", fi.fIniDir);
new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi); new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
printf("Save file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); printf("Save file: %s (dir: %s)\n", fi.fFilename);
// dir = fi.fIniDir; // dir = fi.fIniDir;
if (fi.fFilename) if (fi.fFilename)
saveAlias(fi.fFilename); saveAlias(fi.fFilename);
} }
break; break;
case 2: //fMenuFile->AddEntry("Open Parameters", im++); case 2: //fMenuFile->AddEntry("Open Parameters", im++);
cout << "Open Parameters" << endl; cout << "Open Parameters" << endl;
{ {
@ -340,7 +343,23 @@ void ctbMain::HandleMenu(Int_t id)
} }
break; break;
case 3: // fMenuFile->AddEntry("Open Configuration", im++); case 3: //fMenuFile->AddEntry("Save Parameters", im++);
cout << "Save Parameters" << endl;
{
static TString dir(".");
TGFileInfo fi;
//fi.fFileTypes = filetypes;
fi.fIniDir = StrDup(dir);
printf("fIniDir = %s\n", fi.fIniDir);
new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
// dir = fi.fIniDir;
if (fi.fFilename)
saveParameters(fi.fFilename);
}
break;
case 4: // fMenuFile->AddEntry("Open Configuration", im++);
cout << "Open configuration" << endl; cout << "Open configuration" << endl;
{ {
static TString dir("."); static TString dir(".");
@ -356,7 +375,23 @@ void ctbMain::HandleMenu(Int_t id)
} }
break; break;
case 4: //fMenuFile->AddEntry("Open Pattern", im++); case 5: // fMenuFile->AddEntry("Save Configuration", im++);
cout << "Save configuration" << endl;
{
static TString dir(".");
TGFileInfo fi;
//fi.fFileTypes = filetypes;
fi.fIniDir = StrDup(dir);
printf("fIniDir = %s\n", fi.fIniDir);
new TGFileDialog(gClient->GetRoot(), this, kFDSave, &fi);
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
// dir = fi.fIniDir;
if (fi.fFilename)
saveConfiguration(fi.fFilename);
}
break;
case 6: //fMenuFile->AddEntry("Open Pattern", im++);
cout << "Open pattern" << endl; cout << "Open pattern" << endl;
{ {
static TString dir("."); static TString dir(".");
@ -372,7 +407,7 @@ void ctbMain::HandleMenu(Int_t id)
} }
break; break;
case 5: //fMenuFile->AddEntry("Save Pattern", im++); case 7: //fMenuFile->AddEntry("Save Pattern", im++);
cout << "Save pattern" << endl; cout << "Save pattern" << endl;
{ {
static TString dir("."); static TString dir(".");
@ -384,11 +419,11 @@ void ctbMain::HandleMenu(Int_t id)
printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
// dir = fi.fIniDir; // dir = fi.fIniDir;
if (fi.fFilename) if (fi.fFilename)
savePattern(fi.fFilename); saveParameters(fi.fFilename);
} }
break; break;
case 6: // fMenuFile->AddEntry("Exit", im++); case 8: // fMenuFile->AddEntry("Exit", im++);
CloseWindow(); CloseWindow();
default: default:
@ -404,7 +439,7 @@ int ctbMain::setADCPlot(Int_t i) {
// cout << "ADC " << i << " plot or color toggled" << endl; // cout << "ADC " << i << " plot or color toggled" << endl;
// acq->setGraph(i,adcs->getGraph(i)); // acq->setGraph(i,adcs->getGraph(i));
acq->setGraph(i,adcs->getEnabled(i),adcs->getColor(i)); acq->setGraph(i,adcs->getEnabled(i),adcs->getColor(i));
return -1;
} }
@ -413,31 +448,120 @@ int ctbMain::setSignalPlot(Int_t i) {
// cout << "ADC " << i << " plot or color toggled" << endl; // cout << "ADC " << i << " plot or color toggled" << endl;
// acq->setGraph(i,adcs->getGraph(i)); // acq->setGraph(i,adcs->getGraph(i));
acq->setBitGraph(i,sig->getPlot(i),sig->getColor(i)); acq->setBitGraph(i,sig->getPlot(i),sig->getColor(i));
return -1;
} }
void ctbMain::loadConfiguration(string fname) { int ctbMain::loadConfiguration(string fname) {
try{
myDet->loadConfig(fname); myDet->readConfigurationFile(fname);
} CATCH_DISPLAY ("Could not load config.", "ctbMain::loadConfiguration")
// string line;
// int i;
// ifstream myfile (fname.c_str());
// if (myfile.is_open())
// {
// while ( getline (myfile,line) )
// {
// }
// myfile.close();
// }
// else cout << "Unable to open file";
return 0;
} }
void ctbMain::loadParameters(string fname) {
try{
myDet->loadParameters(fname);
} CATCH_DISPLAY ("Could not load parameters.", "ctbMain::loadParameters")
int ctbMain::saveConfiguration(string fname) {
myDet->writeConfigurationFile(fname);
// string line;
// int i;
// ofstream myfile (fname.c_str());
// if (myfile.is_open())
// {
// myfile.close();
// }
// else cout << "Unable to open file";
return 0;
} }
void ctbMain::savePattern(string fname) {
try{
myDet->savePattern(fname);
} CATCH_DISPLAY ("Could not save pattern.", "ctbMain::savePattern")
int ctbMain::loadParameters(string fname) {
myDet->retrieveDetectorSetup(fname);
// string line;
// int i;
// ifstream myfile (fname.c_str());
// if (myfile.is_open())
// {
// while ( getline (myfile,line) )
// {
// }
// myfile.close();
// }
// else cout << "Unable to open file";
return 0;
} }
int ctbMain::saveParameters(string fname) {
string line;
int i;
myDet->dumpDetectorSetup(fname);
// ofstream myfile (fname.c_str());
// if (myfile.is_open())
// {
// myfile << dacs->getDacParameters();
// myfile << sig->getSignalParameters();
// myfile << adcs->getAdcParameters();
// myfile.close();
// }
// else cout << "Unable to open file";
return 0;
}
int ctbMain::loadAlias(string fname) { int ctbMain::loadAlias(string fname) {
@ -465,7 +589,7 @@ int ctbMain::loadAlias(string fname) {
else if (sscanf(line.c_str(),"PAT%s",aaaa)>0) { else if (sscanf(line.c_str(),"PAT%s",aaaa)>0) {
pat->setPatternAlias(line); pat->setPatternAlias(line);
// cout << "---------" << line<< endl; // cout << "---------" << line<< endl;
} else if (sscanf(line.c_str(),"V%s",aaaa)>0) { } else if (sscanf(line.c_str(),"V%s",&i)>0) {
if (pwrs) pwrs->setPwrAlias(line); if (pwrs) pwrs->setPwrAlias(line);
// cout << "+++++++++" << line<< endl; // cout << "+++++++++" << line<< endl;
} else if (sscanf(line.c_str(),"SENSE%d",&i)>0) { } else if (sscanf(line.c_str(),"SENSE%d",&i)>0) {
@ -491,6 +615,7 @@ int ctbMain::saveAlias(string fname) {
string line; string line;
int i;
ofstream myfile (fname.c_str()); ofstream myfile (fname.c_str());
if (myfile.is_open()) if (myfile.is_open())
{ {

View File

@ -33,10 +33,7 @@ class ctbPowers;
class ctbSignals; class ctbSignals;
namespace sls class multiSlsDetector;
{
class Detector;
};
class ctbPattern; class ctbPattern;
class ctbAdcs; class ctbAdcs;
@ -50,7 +47,7 @@ class ctbMain : public TGMainFrame {
private: private:
sls::Detector *myDet; multiSlsDetector *myDet;
@ -99,14 +96,15 @@ private:
public: public:
ctbMain(const TGWindow *p, sls::Detector *det); ctbMain(const TGWindow *p, multiSlsDetector *det);
int loadAlias(string fname); int loadAlias(string fname);
int saveAlias(string fname); int saveAlias(string fname);
void loadParameters(string fname); int loadParameters(string fname);
void savePattern(string fname); int saveParameters(string fname);
void loadConfiguration(string fname); int loadConfiguration(string fname);
int saveConfiguration(string fname);
void tabSelected(Int_t); void tabSelected(Int_t);
int setADCPlot(Int_t); int setADCPlot(Int_t);
int setSignalPlot(Int_t); int setSignalPlot(Int_t);

View File

@ -24,16 +24,15 @@
#include <fstream> #include <fstream>
#include "ctbPattern.h" #include "ctbPattern.h"
#include "ctbDefs.h" #include "multiSlsDetector.h"
#include "Detector.h"
#include <chrono>
using namespace std; using namespace std;
ctbLoop::ctbLoop(TGGroupFrame *page, int i, sls::Detector *det) : TGHorizontalFrame(page, 800,800), id(i), myDet(det) { ctbLoop::ctbLoop(TGGroupFrame *page, int i, multiSlsDetector *det) : TGHorizontalFrame(page, 800,800), id(i), myDet(det) {
TGHorizontalFrame *hframe=this; TGHorizontalFrame *hframe=this;
@ -117,29 +116,47 @@ ctbLoop::ctbLoop(TGGroupFrame *page, int i, sls::Detector *det) : TGHorizontalFr
} }
void ctbLoop::setNLoops() { void ctbLoop::setNLoops() {
try{
myDet->setPatternLoopCycles(id, eLoopNumber->GetNumber()); int start, stop, n;
} CATCH_DISPLAY ("Could not set number of pattern loops for level " + to_string(id) + ".", "ctbLoop::setNLoops")
start=-1;
stop=-1;
n=eLoopNumber->GetNumber();
try{
myDet->setPatternLoops(id,start, stop,n);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbLoop::update() { void ctbLoop::update() {
try{
auto loop = myDet->getPatternLoopCycles(id).tsquash("Different values"); int start, stop, n;
eLoopNumber->SetNumber(loop);
auto loopaddr = myDet->getPatternLoopAddresses(id).tsquash("Different values"); std::array<int, 3> loop;
eLoopStartAddr->SetHexNumber(loopaddr[0]);
eLoopStopAddr->SetHexNumber(loopaddr[1]); try {
loop=myDet->getPatternLoops(id);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
} CATCH_DISPLAY ("Could not get pattern loops for level " + to_string(id) + ".", "ctbLoop::update") eLoopStartAddr->SetHexNumber(loop[0]);
eLoopStopAddr->SetHexNumber(loop[1]);
eLoopNumber->SetNumber(loop[2]);
} }
ctbWait::ctbWait(TGGroupFrame *page, int i, sls::Detector *det) : TGHorizontalFrame(page, 800,800), id(i), myDet(det) { ctbWait::ctbWait(TGGroupFrame *page, int i, multiSlsDetector *det) : TGHorizontalFrame(page, 800,800), id(i), myDet(det) {
char tit[100]; char tit[100];
TGHorizontalFrame *hframe=this; TGHorizontalFrame *hframe=this;
@ -194,25 +211,41 @@ ctbWait::ctbWait(TGGroupFrame *page, int i, sls::Detector *det) : TGHorizontalFr
void ctbWait::setWaitTime() { void ctbWait::setWaitTime() {
Long64_t t=eWaitTime->GetNumber();
try{ try{
t=myDet->setPatternWaitTime(id,t);
} catch (...) {
myDet->setPatternWaitTime(id, eWaitTime->GetNumber()); cout << "Do nothing for this error" << endl;
}
} CATCH_DISPLAY ("Could not set pattern wait time for level " + to_string(id) + ".", "ctbWait::setWaitTime")
} }
void ctbWait::update() { void ctbWait::update() {
int start, stop, n, addr;
Long64_t t=-1;
try{ try{
auto time = myDet->getPatternWaitTime(id).tsquash("Different values"); t=myDet->setPatternWaitTime(id,t);
auto addr = myDet->getPatternWaitAddr(id).tsquash("Different values"); } catch (...) {
cout << "Do nothing for this error" << endl;
}
try{
addr=myDet->setPatternWaitAddr(id,-1);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eWaitAddr->SetHexNumber(addr); eWaitAddr->SetHexNumber(addr);
eWaitTime->SetNumber(time); eWaitTime->SetNumber(t);
} CATCH_DISPLAY ("Could not get pattern loops for level " + to_string(id) + ".", "ctbWait::update")
} }
@ -223,7 +256,7 @@ void ctbWait::update() {
ctbPattern::ctbPattern(TGVerticalFrame *page, sls::Detector *det) ctbPattern::ctbPattern(TGVerticalFrame *page, multiSlsDetector *det)
: TGGroupFrame(page,"Pattern",kVerticalFrame), myDet(det) { : TGGroupFrame(page,"Pattern",kVerticalFrame), myDet(det) {
@ -457,7 +490,7 @@ ctbPattern::ctbPattern(TGVerticalFrame *page, sls::Detector *det)
hframe->MapWindow(); hframe->MapWindow();
sprintf(tit, "Number of triggers: "); sprintf(tit, "Number of cycles: ");
label= new TGLabel(hframe, tit); label= new TGLabel(hframe, tit);
hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1)); hframe->AddFrame(label,new TGLayoutHints(kLHintsTop | kLHintsLeft| kLHintsExpandX, 1, 1, 1, 1));
@ -467,14 +500,14 @@ ctbPattern::ctbPattern(TGVerticalFrame *page, sls::Detector *det)
eTriggers = new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger, eCycles = new TGNumberEntry(hframe, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative, TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELNoLimits); TGNumberFormat::kNELNoLimits);
hframe->AddFrame( eTriggers,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1)); hframe->AddFrame( eCycles,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
eTriggers->MapWindow(); eCycles->MapWindow();
eTriggers->Resize(150,30); eCycles->Resize(150,30);
e= eTriggers->TGNumberEntry::GetNumberEntry(); e= eCycles->TGNumberEntry::GetNumberEntry();
e->Connect("ReturnPressed()","ctbPattern",this,"setTriggers()"); e->Connect("ReturnPressed()","ctbPattern",this,"setCycles()");
// sprintf(tit, "Number of measurements: "); // sprintf(tit, "Number of measurements: ");
@ -776,64 +809,134 @@ ctbPattern::ctbPattern(TGVerticalFrame *page, sls::Detector *det)
} }
void ctbPattern::update() { void ctbPattern::update() {
try{
auto retval = myDet->getRUNClock().tsquash("Different values");
eRunClkFreq->SetNumber(retval);
} CATCH_DISPLAY ("Could not get run clock.", "ctbPattern::update")
try{ int start, stop, n, addr;
auto retval = myDet->getADCClock().tsquash("Different values");
eAdcClkFreq->SetNumber(retval);
} CATCH_DISPLAY ("Could not get adc clock.", "ctbPattern::update")
try{ Long_t t;
auto retval = myDet->getADCPhase().tsquash("Different values");
eAdcClkPhase->SetNumber(retval);
} CATCH_DISPLAY ("Could not get adc phase shift.", "ctbPattern::update")
try{
auto retval = myDet->getADCPipeline().tsquash("Different values");
eAdcPipeline->SetNumber(retval);
} CATCH_DISPLAY ("Could not get adc pipeline.", "ctbPattern::update")
try{ try {
auto retval = myDet->getDBITClock().tsquash("Different values"); n=myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER,-1,0);
eDBitClkFreq->SetNumber(retval); } catch (...) {
} CATCH_DISPLAY ("Could not get dbit clock.", "ctbPattern::update")
try{ cout << "Do nothing for this error" << endl;
auto retval = myDet->getDBITPhase().tsquash("Different values"); }
eDBitClkPhase->SetNumber(retval);
} CATCH_DISPLAY ("Could not get dbit phase shift.", "ctbPattern::update")
try{ eRunClkFreq->SetNumber(n);
auto retval = myDet->getDBITPipeline().tsquash("Different values");
eDBitPipeline->SetNumber(retval);
} CATCH_DISPLAY ("Could not get dbit pipeline.", "ctbPattern::update")
try{ try {
auto retval = myDet->getNumberOfFrames().tsquash("Different values"); n=myDet->setSpeed(slsDetectorDefs::ADC_CLOCK,-1,0);
eFrames->SetNumber(retval); } catch (...) {
} CATCH_DISPLAY ("Could not get number of frames.", "ctbPattern::update")
try{ cout << "Do nothing for this error" << endl;
auto timeNs = myDet->getPeriod().tsquash("Different values"); }
ePeriod->SetNumber(ctbDefs::ConvertChronoNStoDoubleS(timeNs));
} CATCH_DISPLAY ("Could not get period.", "ctbPattern::update")
try{ eAdcClkFreq->SetNumber(n);
auto retval = myDet->getNumberOfTriggers().tsquash("Different values");
eTriggers->SetNumber(retval);
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
try{ try {
auto retval = myDet->getPatternLoopAddresses(-1).tsquash("Different values"); n=myDet->setSpeed(slsDetectorDefs::ADC_PHASE,-1,0);
eStartAddr->SetHexNumber(retval[0]); } catch (...) {
eStopAddr->SetHexNumber(retval[1]);
} CATCH_DISPLAY ("Could not get dbit phase shift.", "ctbPattern::update") cout << "Do nothing for this error" << endl;
}
eAdcClkPhase->SetNumber(n);
try {
n=myDet->setSpeed(slsDetectorDefs::ADC_PIPELINE,-1,0);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eAdcPipeline->SetNumber(n);
try {
n=myDet->setSpeed(slsDetectorDefs::DBIT_CLOCK,-1,0);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eDBitClkFreq->SetNumber(n);
try {
n=myDet->setSpeed(slsDetectorDefs::DBIT_PHASE,-1,0);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eDBitClkPhase->SetNumber(n);
try {
myDet->setSpeed(slsDetectorDefs::DBIT_PIPELINE,0,-1);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eDBitPipeline->SetNumber(n);
try {
n=myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,-1);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eFrames->SetNumber(n);
try {
n=myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,-1);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
ePeriod->SetNumber(((Double_t)n)*1E-9);
try {
n=myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,-1);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eCycles->SetNumber(n);
// try {
// myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,-1);
// } catch (...) {
// cout << "Do nothing for this error" << endl;
// }
// eMeasurements->SetNumber(n);
start=-1;
stop=-1;
n=-1;
std::array<int, 3> loop;
try {
loop=myDet->getPatternLoops(-1);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eStartAddr->SetHexNumber(loop[0]);
eStopAddr->SetHexNumber(loop[1]);
for (int iloop=0; iloop<NLOOPS; iloop++) { for (int iloop=0; iloop<NLOOPS; iloop++) {
eLoop[iloop]->update(); eLoop[iloop]->update();
} }
for (int iwait=0; iwait<NWAITS; iwait++) { for (int iwait=0; iwait<NWAITS; iwait++) {
@ -843,9 +946,8 @@ void ctbPattern::update() {
getAnalogSamples(); getAnalogSamples();
getDigitalSamples(); getDigitalSamples();
getReadoutMode(); getReadoutMode();
} }
void ctbPattern::setFile() { void ctbPattern::setFile() {
patternFileChanged(patternFile->GetText()); patternFileChanged(patternFile->GetText());
@ -882,8 +984,7 @@ void ctbPattern::setPatternAlias(string line){
string ctbPattern::getPatternAlias() { string ctbPattern::getPatternAlias() {
char line[100000]; char line[100000];
sprintf(line, "PATCOMPILER %s\nPATFILE %s\n",patternCompiler->GetText(),patternFile->GetText()); sprintf("PATCOMPILER %s\nPATFILE %s\n",patternCompiler->GetText(),patternFile->GetText());
return line;
} }
@ -931,103 +1032,154 @@ string ctbPattern::getPatternFile() {
} }
void ctbPattern::setFrames() { void ctbPattern::setFrames() {
try{ try {
myDet->setNumberOfFrames(eFrames->GetNumber()); myDet->setTimer(slsDetectorDefs::FRAME_NUMBER,eFrames->GetNumber());
} CATCH_DISPLAY ("Could not set number of frames", "ctbPattern::setFrames") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbPattern::setTriggers() { void ctbPattern::setCycles() {
try{ try {
myDet->setNumberOfTriggers(eTriggers->GetNumber()); myDet->setTimer(slsDetectorDefs::CYCLES_NUMBER,eFrames->GetNumber());
} CATCH_DISPLAY ("Could not set number of triggers", "ctbPattern::setTriggers") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
// void ctbPattern::setMeasurements() {
// try {
// myDet->setTimer(slsDetectorDefs::MEASUREMENTS_NUMBER,eFrames->GetNumber());
// } catch (...) {
// cout << "Do nothing for this error" << endl;
// }
// }
void ctbPattern::setPeriod() { void ctbPattern::setPeriod() {
using std::chrono::duration; try {
using std::chrono::duration_cast; myDet->setTimer(slsDetectorDefs::FRAME_PERIOD,ePeriod->GetNumber()*1E9);
using std::chrono::nanoseconds; } catch (...) {
try{
auto timeNs = ctbDefs::ConvertDoubleStoChronoNS(ePeriod->GetNumber()); cout << "Do nothing for this error" << endl;
myDet->setPeriod(timeNs); }
} CATCH_DISPLAY ("Could not set period", "ctbPattern::setPeriod")
} }
void ctbPattern::setAdcFreq() { void ctbPattern::setAdcFreq() {
try{ try {
myDet->setADCClock(eAdcClkFreq->GetNumber()); myDet->setSpeed(slsDetectorDefs::ADC_CLOCK,eAdcClkFreq->GetNumber(),0);
} CATCH_DISPLAY ("Could not set adc clock", "ctbPattern::setAdcFreq") } catch (...) {
}
cout << "Do nothing for this error" << endl;
}
}
void ctbPattern::setRunFreq() { void ctbPattern::setRunFreq() {
try{ try{
myDet->setRUNClock(eRunClkFreq->GetNumber()); myDet->setSpeed(slsDetectorDefs::CLOCK_DIVIDER,eRunClkFreq->GetNumber(),0);
} CATCH_DISPLAY ("Could not set run clock", "ctbPattern::setRunFreq") } catch (...) {
}
cout << "Do nothing for this error" << endl;
}
}
void ctbPattern::setDBitFreq() { void ctbPattern::setDBitFreq() {
try{ // cout <<"Not setting dbit frequency to " << eDBitClkFreq->GetNumber()<< endl;
myDet->setDBITClock(eDBitClkFreq->GetNumber()); try {
} CATCH_DISPLAY ("Could not set dbit clock", "ctbPattern::setDBitFreq") myDet->setSpeed(slsDetectorDefs::DBIT_CLOCK,eDBitClkFreq->GetNumber(),0);
} } catch (...) {
cout << "Do nothing for this error" << endl;
}
}
void ctbPattern::setAdcPhase() { void ctbPattern::setAdcPhase() {
try{ try {
myDet->setADCPhase(eAdcClkPhase->GetNumber()); myDet->setSpeed(slsDetectorDefs::ADC_PHASE,eAdcClkPhase->GetNumber(),0);
} CATCH_DISPLAY ("Could not set adc phase shift", "ctbPattern::setAdcPhase") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbPattern::setDBitPhase() { void ctbPattern::setDBitPhase() {
try{ // cout <<"Not setting dbit phase to " << eDBitClkPhase->GetNumber()<< endl;
myDet->setDBITPhase(eDBitClkPhase->GetNumber()); try {
} CATCH_DISPLAY ("Could not set dbit phase shift", "ctbPattern::setDBitPhase") myDet->setSpeed(slsDetectorDefs::DBIT_PHASE,eDBitClkPhase->GetNumber(),0);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbPattern::setAdcPipeline() { void ctbPattern::setAdcPipeline() {
try{ try {
myDet->setADCPipeline(eAdcPipeline->GetNumber()); myDet->setSpeed(slsDetectorDefs::ADC_PIPELINE,eAdcPipeline->GetNumber(),0);
} CATCH_DISPLAY ("Could not set adc pipeline", "ctbPattern::setAdcPipeline") } catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbPattern::setDBitPipeline() { void ctbPattern::setDBitPipeline() {
try{ // cout <<"Not setting dbit pipeline to " << eDBitPipeline->GetNumber() << endl;
myDet->setDBITPipeline(eDBitPipeline->GetNumber()); try {
} CATCH_DISPLAY ("Could not set dbit pipeline", "ctbPattern::setDBitPipeline") myDet->setSpeed(slsDetectorDefs::DBIT_PIPELINE,eDBitPipeline->GetNumber(),0);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
} }
void ctbPattern::setAnalogSamples() { void ctbPattern::setAnalogSamples() {
try{ try {
myDet->setNumberOfAnalogSamples(eAnalogSamples->GetNumber()); myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES,eAnalogSamples->GetNumber());
} CATCH_DISPLAY ("Could not set number of analog sampels", "ctbPattern::setAnalogSamples") } catch (...) {
cout << "Do nothing for this error" << endl;
}
analogSamplesChanged(eAnalogSamples->GetNumber()); analogSamplesChanged(eAnalogSamples->GetNumber());
} }
void ctbPattern::setDigitalSamples() { void ctbPattern::setDigitalSamples() {
try{ try {
myDet->setNumberOfDigitalSamples(eDigitalSamples->GetNumber()); myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES,eDigitalSamples->GetNumber());
} CATCH_DISPLAY ("Could not set number of digital samples", "ctbPattern::setDigitalSamples") } catch (...) {
cout << "Do nothing for this error" << endl;
}
digitalSamplesChanged(eDigitalSamples->GetNumber()); digitalSamplesChanged(eDigitalSamples->GetNumber());
} }
void ctbPattern::setReadoutMode(Bool_t) { void ctbPattern::setReadoutMode(Bool_t) {
// cout << "Set readout mode to be implemented" << endl;
slsDetectorDefs::readOutFlags flags;
if (cbAnalog->IsOn() && cbDigital->IsOn()) flags=slsDetectorDefs::ANALOG_AND_DIGITAL;
else if (~cbAnalog->IsOn() && cbDigital->IsOn()) flags=slsDetectorDefs::DIGITAL_ONLY;
else if (cbAnalog->IsOn() && ~cbDigital->IsOn()) flags=slsDetectorDefs::NORMAL_READOUT;
else flags=slsDetectorDefs::GET_READOUT_FLAGS;
try { try {
slsDetectorDefs::readoutMode flag = slsDetectorDefs::ANALOG_ONLY; myDet->setReadOutFlags(flags);
if (cbAnalog->IsOn() && cbDigital->IsOn()) } catch (...) {
flag=slsDetectorDefs::ANALOG_AND_DIGITAL;
else if (~cbAnalog->IsOn() && cbDigital->IsOn())
flag=slsDetectorDefs::DIGITAL_ONLY;
else if (cbAnalog->IsOn() && ~cbDigital->IsOn())
flag=slsDetectorDefs::ANALOG_ONLY;
else {
throw runtime_error("unkown readout flag");
}
myDet->setReadoutMode(flag);
cout << "Set readout flag: " << flag << endl;
} CATCH_DISPLAY ("Could not set readout flag", "ctbPattern::setReadoutMode")
cout << "Do nothing for this error" << endl;
}
cout << "Set readout flags " << hex << flags << dec << endl;
getReadoutMode(); getReadoutMode();
// myDet->setTimer(slsDetectorDefs::SAMPLES_CTB,eSamples->GetNumber());
//samplesChanged(eSamples->GetNumber());
} }
void ctbPattern::readoutModeChanged(int flags) { void ctbPattern::readoutModeChanged(int flags) {
@ -1036,57 +1188,72 @@ void ctbPattern::readoutModeChanged(int flags) {
} }
int ctbPattern::getReadoutMode() { int ctbPattern::getReadoutMode() {
try{ // cout << "Get readout mode to be implemented" << endl;
auto retval = myDet->getReadoutMode().tsquash("Different values"); slsDetectorDefs::readOutFlags flags;
switch(retval) { try {
case slsDetectorDefs::ANALOG_AND_DIGITAL: flags=(slsDetectorDefs::readOutFlags) myDet->setReadOutFlags();
cout << "analog and digital" << endl; } catch (...) {
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kTRUE);
break;
case slsDetectorDefs::DIGITAL_ONLY:
cout << "digital only" << endl;
cbAnalog->SetOn(kFALSE);
cbDigital->SetOn(kTRUE);
break;
case slsDetectorDefs::ANALOG_ONLY:
cout << "analog only" << endl;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE);
break;
default:
throw("unknown readout flag");
}
Emit("readoutModeChanged(int)",static_cast<int>(retval));
return retval;
} CATCH_DISPLAY ("Could not get readout flags", "ctbPattern::getReadoutMode")
return -1; cout << "Do nothing for this error" << endl;
}
cout << "++++++++++++++++++++"<< hex << flags << dec << endl;
if (flags&slsDetectorDefs::ANALOG_AND_DIGITAL) {
cout << "analog and digital" << hex << slsDetectorDefs::ANALOG_AND_DIGITAL << dec<< endl;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kTRUE);
} else if (flags&slsDetectorDefs::DIGITAL_ONLY) {
cout << "digital only" << hex << slsDetectorDefs::DIGITAL_ONLY << dec << endl;
cbAnalog->SetOn(kFALSE);
cbDigital->SetOn(kTRUE);
}// else if (flags==slsDetectorDefs::NORMAL_READOUT) {
// cbAnalog->SetOn(kTRUE);
// cbDigital->SetOn(kFALSE);
// }
else {
cout << "analog only" << endl;
flags=slsDetectorDefs::NORMAL_READOUT;
cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE);
}
Emit("readoutModeChanged(int)",(int)flags);
return (int)flags;
// myDet->setTimer(slsDetectorDefs::SAMPLES_CTB,eSamples->GetNumber());
//samplesChanged(eSamples->GetNumber());
} }
int ctbPattern::getAnalogSamples() { int ctbPattern::getAnalogSamples() {
try{ int n;
auto retval = myDet->getNumberOfAnalogSamples().tsquash("Different values"); try {
eAnalogSamples->SetNumber((Double_t)retval); n=(myDet->setTimer(slsDetectorDefs::ANALOG_SAMPLES,-1));
Emit("analogSamplesChanged(const int)", eAnalogSamples->GetNumber()); } catch (...) {
return eAnalogSamples->GetNumber();
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
return -1; cout << "Do nothing for this error" << endl;
}
eAnalogSamples->SetNumber((Double_t)n);
Emit("analogSamplesChanged(const int)", eAnalogSamples->GetNumber());
return eAnalogSamples->GetNumber();
} }
int ctbPattern::getDigitalSamples() { int ctbPattern::getDigitalSamples() {
try{ int n;
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values"); try {
eDigitalSamples->SetNumber((Double_t)retval);
Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber());
return eDigitalSamples->GetNumber();
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
return -1; n=(myDet->setTimer(slsDetectorDefs::DIGITAL_SAMPLES,-1));
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eDigitalSamples->SetNumber(((Double_t)n));
Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber());
return eDigitalSamples->GetNumber();
} }
void ctbPattern::analogSamplesChanged(const int t){ void ctbPattern::analogSamplesChanged(const int t){
Emit("analogSamplesChanged(const int)", t); Emit("analogSamplesChanged(const int)", t);
} }

View File

@ -27,10 +27,7 @@ class energyCalibration;
class TGTextButton; class TGTextButton;
class TGTab; class TGTab;
namespace sls class multiSlsDetector;
{
class Detector;
};
#include <string> #include <string>
@ -49,10 +46,10 @@ class ctbLoop : public TGHorizontalFrame {
int id; int id;
sls::Detector *myDet; multiSlsDetector *myDet;
public: public:
ctbLoop(TGGroupFrame *page, int i,sls::Detector *det); ctbLoop(TGGroupFrame *page, int i,multiSlsDetector *det);
void setNLoops(); void setNLoops();
void update(); void update();
@ -70,10 +67,10 @@ class ctbWait : public TGHorizontalFrame {
int id; int id;
sls::Detector *myDet; multiSlsDetector *myDet;
public: public:
ctbWait(TGGroupFrame *page, int i,sls::Detector *det); ctbWait(TGGroupFrame *page, int i,multiSlsDetector *det);
void setWaitTime(); void setWaitTime();
void update(); void update();
@ -102,7 +99,7 @@ private:
TGNumberEntry *eStopAddr; TGNumberEntry *eStopAddr;
TGNumberEntry *eFrames; TGNumberEntry *eFrames;
TGNumberEntry *ePeriod; TGNumberEntry *ePeriod;
TGNumberEntry *eTriggers; TGNumberEntry *eCycles;
// TGNumberEntry *eMeasurements; // TGNumberEntry *eMeasurements;
TGNumberEntry *eAdcPipeline; TGNumberEntry *eAdcPipeline;
TGNumberEntry *eDBitPipeline; TGNumberEntry *eDBitPipeline;
@ -125,11 +122,11 @@ private:
char pat[PATLEN*8]; char pat[PATLEN*8];
sls::Detector *myDet; multiSlsDetector *myDet;
public: public:
ctbPattern(TGVerticalFrame *page, sls::Detector *det); ctbPattern(TGVerticalFrame *page, multiSlsDetector *det);
void update(); void update();
void setAdcFreq(); void setAdcFreq();
@ -141,7 +138,7 @@ public:
void setAdcPipeline(); void setAdcPipeline();
void setDBitPipeline(); void setDBitPipeline();
void setFrames(); void setFrames();
void setTriggers(); void setCycles();
// void setMeasurements(); // void setMeasurements();
void setPeriod(); void setPeriod();

View File

@ -10,48 +10,61 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include "ctbDefs.h"
#include "ctbDacs.h" #include "ctbDacs.h"
#include "ctbPowers.h" #include "ctbPowers.h"
#include "Detector.h" #include "multiSlsDetector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
using namespace std; using namespace std;
ctbPower::ctbPower(TGGroupFrame* f, int i, sls::Detector* d) ctbPower::ctbPower(TGGroupFrame* f, int i, multiSlsDetector* d)
: ctbDac(f, i, d) : ctbDac(f, i, d)
{ {
cout << "****************************************************************power " << i << endl; cout << "****************************************************************power " << i << endl;
dacsUnit->SetOn(kTRUE); dacsUnit->SetOn(kTRUE);
dacsUnit->SetEnabled(kFALSE); dacsUnit->SetEnabled(kFALSE);
int ii=0;
switch(i) { switch(i) {
case slsDetectorDefs::V_POWER_IO: case slsDetectorDefs::V_POWER_IO:
dacsLabel->SetText("VIO"); dacsLabel->SetText("VIO");
ii=slsDetectorDefs::I_POWER_IO;
break; break;
case slsDetectorDefs::V_POWER_A: case slsDetectorDefs::V_POWER_A:
dacsLabel->SetText("VA"); dacsLabel->SetText("VA");
ii=slsDetectorDefs::I_POWER_A;
break; break;
case slsDetectorDefs::V_POWER_B: case slsDetectorDefs::V_POWER_B:
dacsLabel->SetText("VB"); dacsLabel->SetText("VB");
ii=slsDetectorDefs::I_POWER_B;
break; break;
case slsDetectorDefs::V_POWER_C: case slsDetectorDefs::V_POWER_C:
dacsLabel->SetText("VC"); dacsLabel->SetText("VC");
ii=slsDetectorDefs::I_POWER_C;
break; break;
case slsDetectorDefs::V_POWER_D: case slsDetectorDefs::V_POWER_D:
dacsLabel->SetText("VD"); dacsLabel->SetText("VD");
ii=slsDetectorDefs::I_POWER_D;
break; break;
case slsDetectorDefs::V_POWER_CHIP: case slsDetectorDefs::V_POWER_CHIP:
dacsLabel->SetText("VCHIP"); dacsLabel->SetText("VCHIP");
dacsLabel->SetEnabled(kFALSE); dacsLabel->SetEnabled(kFALSE);
ii=-1;
break; break;
default: default:
dacsLabel->SetText("Bad index"); dacsLabel->SetText("Bad index");
ii=-1;
break; break;
}; };
// ctbSlowAdc *vm=new ctbSlowAdc(f,i,d);
// vm->setLabel("V: ");
// if (ii>=0) {
// ctbSlowAdc *im=new ctbSlowAdc(f,ii,d);
// im->setLabel("I: ");
// }
TGTextEntry *e=dacsEntry->TGNumberEntry::GetNumberEntry(); TGTextEntry *e=dacsEntry->TGNumberEntry::GetNumberEntry();
e->Disconnect ("ReturnPressed()"); e->Disconnect ("ReturnPressed()");
@ -91,45 +104,44 @@ string ctbPower::getLabel() {
} }
line << " " << dacsLabel->GetText() << endl; line << " " << dacsLabel->GetText() << endl;
return line.str(); return line.str();
} }
void ctbPower::setValue(Long_t a) {ctbPower::setValue();}
void ctbPower::setValue(Long_t a) {cout << "ssssssssss" << endl; ctbPower::setValue();}
void ctbPower::setValue() { void ctbPower::setValue() {
cout << "***************************Setting power " << dacsEntry->GetIntNumber() << " " << id << " " << 1 << endl;
try {
myDet->setVoltage(static_cast<slsDetectorDefs::dacIndex>(id), dacsEntry->GetIntNumber()); cout << "***************************Setting power " << dacsEntry->GetIntNumber() << " " << (slsDetectorDefs::dacIndex)id <<" " << 1 << endl;
} CATCH_DISPLAY ("Could not set power " + to_string(id) + ".", "ctbPower::setValue") myDet->setDAC(dacsEntry->GetIntNumber(), (slsDetectorDefs::dacIndex)id, 1);
getValue(); getValue();
} }
int ctbPower::getValue() { int ctbPower::getValue() {
try {
int val = myDet->getVoltage(static_cast<slsDetectorDefs::dacIndex>(id)).tsquash("Different values"); int val=myDet->setDAC(-1, (slsDetectorDefs::dacIndex)id, 1);
cout << "****************************Getting power " << val << " " << id << " " << 1 << endl; char s[100];
cout << "****************************Getting power " << val << " " << (slsDetectorDefs::dacIndex)id <<" " << 1 << endl;
dacsValue->SetText(to_string(val).c_str()); sprintf(s,"%d",val);
if (val > 0) { dacsValue->SetText(s);
if (id != static_cast<int>(slsDetectorDefs::V_POWER_CHIP)) if (val>0) {
if (id!=slsDetectorDefs::V_POWER_CHIP)
dacsLabel->SetOn(kTRUE); dacsLabel->SetOn(kTRUE);
} else { } else {
dacsLabel->SetOn(kFALSE); dacsLabel->SetOn(kFALSE);
} }
return val; return val;
} CATCH_DISPLAY ("Could not get power " + to_string(id) + ".", "ctbPower::getValue")
return -1;
} }
ctbPowers::ctbPowers(TGVerticalFrame* page, sls::Detector* det) : TGGroupFrame(page,"Power Supplies",kVerticalFrame) , myDet(det){ ctbPowers::ctbPowers(TGVerticalFrame* page, multiSlsDetector* det) : TGGroupFrame(page,"Power Supplies",kVerticalFrame) , myDet(det){
SetTitlePos(TGGroupFrame::kLeft); SetTitlePos(TGGroupFrame::kLeft);
@ -147,8 +159,9 @@ ctbPowers::ctbPowers(TGVerticalFrame* page, sls::Detector* det) : TGGroupFrame
int ctbPowers::setPwrAlias(string line) { int ctbPowers::setPwrAlias(string line) {
int is=-1; int is=-1, mv=0;
char tit[100]; char tit[100];
int narg;
if (sscanf(line.c_str(),"VA %s",tit)) { if (sscanf(line.c_str(),"VA %s",tit)) {
dacs[0]->setLabel(tit,1); dacs[0]->setLabel(tit,1);
@ -199,6 +212,7 @@ string ctbPowers::getPwrAlias() {
string ctbPowers::getPwrParameters() { string ctbPowers::getPwrParameters() {
ostringstream line; ostringstream line;
line << "v_a" << " " << dacs[0]->getValue() << " mv" << endl; line << "v_a" << " " << dacs[0]->getValue() << " mv" << endl;
line << "v_b" << " " << dacs[1]->getValue() << " mv" << endl; line << "v_b" << " " << dacs[1]->getValue() << " mv" << endl;
@ -211,13 +225,19 @@ string ctbPowers::getPwrParameters() {
// line << "dac:" << i << " " << dacs[i]->getValue() << endl; // line << "dac:" << i << " " << dacs[i]->getValue() << endl;
// } // }
return line.str(); return line.str();
} }
void ctbPowers::update() { void ctbPowers::update() {
for (int idac=0; idac<NPOWERS; idac++) { for (int idac=0; idac<NPOWERS; idac++) {
dacs[idac]->getValue(); dacs[idac]->getValue();
} }
} }

View File

@ -3,7 +3,14 @@
#include <TGFrame.h> #include <TGFrame.h>
#ifndef CTB
#define NPOWERS 0
#else
#define NPOWERS 6 #define NPOWERS 6
#endif
@ -15,10 +22,8 @@ class TGCheckButton;
namespace sls class multiSlsDetector;
{
class Detector;
};
#include <string> #include <string>
using namespace std; using namespace std;
@ -31,7 +36,7 @@ class ctbPower : public ctbDac {
public: public:
ctbPower(TGGroupFrame* f, int i, sls::Detector* d); ctbPower(TGGroupFrame* f, int i, multiSlsDetector* d);
string getLabel(); string getLabel();
@ -49,11 +54,11 @@ class ctbPowers : public TGGroupFrame
ctbPower *dacs[NPOWERS]; ctbPower *dacs[NPOWERS];
sls::Detector* myDet; multiSlsDetector* myDet;
public: public:
//ctbPowers(); //ctbPowers();
ctbPowers(TGVerticalFrame*, sls::Detector*); ctbPowers(TGVerticalFrame*, multiSlsDetector*);
int setPwrAlias(string); int setPwrAlias(string);
string getPwrAlias(); string getPwrAlias();

View File

@ -34,8 +34,7 @@
#include "ctbSignals.h" #include "ctbSignals.h"
#include "ctbDefs.h" #include "multiSlsDetector.h"
#include "Detector.h"
using namespace std; using namespace std;
@ -44,7 +43,7 @@ using namespace std;
//#define DEFAULTFN "run_0.encal" //#define DEFAULTFN "run_0.encal"
ctbSignal::ctbSignal(TGFrame *page, int i, sls::Detector *det) ctbSignal::ctbSignal(TGFrame *page, int i, multiSlsDetector *det)
: TGHorizontalFrame(page, 800,50), myDet(det), id(i), hsig(NULL) { : TGHorizontalFrame(page, 800,50), myDet(det), id(i), hsig(NULL) {
@ -179,6 +178,10 @@ int ctbSignal::fixOutput(int i) {
int ctbSignal::setDbitList(Long64_t r) { int ctbSignal::setDbitList(Long64_t r) {
Long64_t mask=((Long64_t)1<<id);
// cout << hex << r << dec <<endl;
if (r) if (r)
sDbitList->SetOn(kTRUE,kFALSE); sDbitList->SetOn(kTRUE,kFALSE);
else else
@ -194,6 +197,7 @@ int ctbSignal::isPlot() { return sPlot->IsOn();}
Pixel_t ctbSignal::getColor(){return fColorSel->GetColor();} Pixel_t ctbSignal::getColor(){return fColorSel->GetColor();}
void ctbSignal::ToggledOutput(Bool_t b) { void ctbSignal::ToggledOutput(Bool_t b) {
Long_t mask=b<<id;
ToggledSignalOutput(id); ToggledSignalOutput(id);
if (b) { if (b) {
// sClock->SetEnabled(kTRUE); // sClock->SetEnabled(kTRUE);
@ -245,7 +249,7 @@ void ctbSignal::ToggledSignalPlot(Int_t b){
} }
ctbSignals::ctbSignals(TGVerticalFrame *page, sls::Detector *det) ctbSignals::ctbSignals(TGVerticalFrame *page, multiSlsDetector *det)
: TGGroupFrame(page,"IO Signals",kVerticalFrame), myDet(det) { : TGGroupFrame(page,"IO Signals",kVerticalFrame), myDet(det) {
@ -255,6 +259,7 @@ ctbSignals::ctbSignals(TGVerticalFrame *page, sls::Detector *det)
TGHorizontalFrame *hframe; TGHorizontalFrame *hframe;
char tit[100];
TGHorizontalFrame* hhframe=new TGHorizontalFrame(this, 800,800); TGHorizontalFrame* hhframe=new TGHorizontalFrame(this, 800,800);
AddFrame(hhframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1)); AddFrame(hhframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
@ -285,6 +290,36 @@ ctbSignals::ctbSignals(TGVerticalFrame *page, sls::Detector *det)
} }
// #ifdef CTB
// idac=62;
// signals[idac]=new ctbSignal(vframe,idac,myDet);
// vframe->AddFrame(signals[idac],new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
// signals[idac]->MapWindow();
// sprintf(tit,"DBIT Latch");
// signals[idac]->setSignalAlias(tit,-1,-1);
// signals[idac]->Connect("ToggledSignalOutput(Int_t)","ctbSignals",this,"ToggledOutReg(Int_t)");
// signals[idac]->Connect("ToggledSignalDbitList(Int_t)","ctbSignals",this,"ToggledDbitList(Int_t)");
// signals[idac]->Connect("ToggledSignalPlot(Int_t)","ctbSignals",this,"ToggledPlot(Int_t)");
// #endif
// idac=63;
// signals[idac]=new ctbSignal(vframe,idac,myDet);
// vframe->AddFrame(signals[idac],new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
// signals[idac]->MapWindow();
// sprintf(tit,"ADC Latch");
// signals[idac]->setSignalAlias(tit,-1,-1);
// signals[idac]->Connect("ToggledSignalOutput(Int_t)","ctbSignals",this,"ToggledOutReg(Int_t)");
// signals[idac]->Connect("ToggledSignalDbitList(Int_t)","ctbSignals",this,"ToggledDbitList(Int_t)");
// signals[idac]->Connect("ToggledSignalPlot(Int_t)","ctbSignals",this,"ToggledPlot(Int_t)");
hframe=new TGHorizontalFrame(vframe, 800,50); hframe=new TGHorizontalFrame(vframe, 800,50);
vframe->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1)); vframe->AddFrame(hframe,new TGLayoutHints(kLHintsTop | kLHintsExpandX , 1,1,1,1));
hframe->MapWindow(); hframe->MapWindow();
@ -363,132 +398,121 @@ string ctbSignals::getSignalAlias() {
void ctbSignals::update() { void ctbSignals::update() {
try { Long64_t oreg=myDet->setPatternIOControl();//setCTBWord(-1,-1);
// Long64_t creg=myDet->setPatternClockControl();//setCTBWord(-2,-1);
Long64_t oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values"));
cout << hex << oreg << dec << endl;
for (int idac=0; idac<NIOSIGNALS; idac++) { char val[1000];
signals[idac]->setOutput(oreg); cout << hex << oreg << dec << endl;
// cout << hex << creg << dec << endl;
sprintf(val,"%llX",oreg);
// eIOCntrlRegister->SetHexNumber(oreg);
for (int idac=0; idac<NIOSIGNALS; idac++) {
signals[idac]->setOutput(oreg);
}
Long64_t mask;
std::vector <int> dbitlist=myDet->getReceiverDbitList();
if (dbitlist.empty())
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
} }
else {
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update") for (int is=0; is<64; is++) signals[is]->setDbitList(0);
for (const auto &value : dbitlist) {
try { signals[value]->setDbitList(1);
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all
if (dbitlist.empty()) {
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
}
}
else {
// disable all
for (int is=0; is<64; is++) {
signals[is]->setDbitList(0);
}
// enable selected
for (const auto &value : dbitlist) {
signals[value]->setDbitList(1);
}
} }
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
try { eDbitOffset->SetNumber(myDet->getReceiverDbitOffset());
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
} }
string ctbSignals::getSignalParameters() { string ctbSignals::getSignalParameters() {
try {
auto val = myDet->getPatternIOControl().tsquash("Different values"); ostringstream line;
ostringstream line; line << "patioctrl " << hex << myDet->setPatternIOControl() << dec << endl;//setCTBWord(-1,-1)
line << "patioctrl " << hex << val << dec << endl; return line.str();
return line.str();
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::getSignalParameters")
return ("");
} }
void ctbSignals::ToggledOutReg(Int_t mask) { void ctbSignals::ToggledOutReg(Int_t mask) {
try {
Long64_t oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values")); char val[1000];
Long64_t m=((Long64_t)1)<<mask; Long64_t oreg=myDet->setPatternIOControl();//setCTBWord(-1,-1);
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg; Long64_t m=((Long64_t)1)<<mask;
if (signals[mask]->isOutput()) {
cout << " or " << m ;
oreg|=m;
} else {
cout << " not " << ~m ;
oreg&=~m;
}
cout << " after " << oreg << endl;
myDet->setPatternIOControl(static_cast<uint64_t>(oreg)); cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg;
oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values"));
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
eIOCntrlRegister->SetText(to_string(oreg).c_str());
} CATCH_DISPLAY ("Could not get/set patternIOcontrol.", "ctbSignals::ToggledOutReg")
if (signals[mask]->isOutput()) {
cout << " or " << m ;
oreg|=m;
} else {
cout << " not " << ~m ;
oreg&=~m;
}
cout << " after " << oreg << endl;
myDet->setPatternIOControl(oreg);//setCTBWord(-1,oreg);
oreg=myDet->setPatternIOControl();//myDet->setCTBWord(-1,-1);
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
sprintf(val,"%llX",oreg);
// eIOCntrlRegister->SetHexNumber(oreg);
eIOCntrlRegister->SetText(val);
// eIOCntrlRegister->SetNumber(oreg);
} }
void ctbSignals::ToggledDbitList(Int_t mask){ void ctbSignals::ToggledDbitList(Int_t mask){
try {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// anyway all enabled
if ((dbitlist.empty()) && (signals[mask]->isDbitList())) {
;
}
// set the dbitlist
else {
std::vector <int> new_dbitlist;
for (int is=0; is<64; is++) {
if (signals[is]->isDbitList()){
new_dbitlist.push_back(is);
cout << is << " " << new_dbitlist.size() - 1 << endl;
}
}
if (new_dbitlist.size() > 64)
new_dbitlist.clear();
myDet->setRxDbitList(new_dbitlist);
// get list again
dbitlist = myDet->getRxDbitList().tsquash("Different values");
}
// enable all cout << "************* Here" << endl;
if (dbitlist.empty()) {
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
} std::vector <int> new_dbitlist;
} std::vector <int> old_dbitlist=myDet->getReceiverDbitList();
else {
// disable all char val[1000];
for (int is=0; is<64; is++) { Long64_t m=((Long64_t)1)<<mask;
signals[is]->setDbitList(0);
} if (old_dbitlist.empty() && signals[mask]->isDbitList())
// enable selected ;
for (const auto &value : dbitlist) { else {
signals[value]->setDbitList(1); int ns=0;
for (int is=0; is<64; is++) {
if (signals[is]->isDbitList()){
new_dbitlist.push_back(is);
ns++;
cout << is << " " << ns << endl;
} }
} }
if (ns>63) new_dbitlist.clear();
myDet->setReceiverDbitList(new_dbitlist);
}
std::vector <int> dbitlist=myDet->getReceiverDbitList();
if (dbitlist.empty())
for (int is=0; is<64; is++) signals[is]->setDbitList(1);
else
for (int is=0; is<64; is++) signals[is]->setDbitList(0);
for (const auto &value : dbitlist) signals[value]->setDbitList(1);
} CATCH_DISPLAY ("Could not get/set receiver dbit list.", "ctbSignals::ToggledDbitList")
} }
@ -509,23 +533,16 @@ void ctbSignals::ToggledSignalPlot(Int_t b) {
Pixel_t ctbSignals::getColor(int i){ Pixel_t ctbSignals::getColor(int i){
if (i>=0 && i<NSIGNALS) if (i>=0 && i<NSIGNALS) return signals[i]->getColor();
return signals[i]->getColor();
return static_cast<Pixel_t>(-1);
} }
int ctbSignals::getPlot(int i){ int ctbSignals::getPlot(int i){
if (i>=0 && i<NSIGNALS) if (i>=0 && i<NSIGNALS) return signals[i]->isPlot();
return signals[i]->isPlot();
return -1;
}; };
void ctbSignals::setDbitOffset(Long_t) { void ctbSignals::setDbitOffset(Long_t) {
setDbitOffset(); setDbitOffset();
} }
void ctbSignals::setDbitOffset(){ void ctbSignals::setDbitOffset(){
try { myDet->setReceiverDbitOffset(eDbitOffset->GetNumber());
myDet->setRxDbitOffset(eDbitOffset->GetNumber());
} CATCH_DISPLAY ("Could not set receiver dbit offset.", "ctbSignals::setDbitOffset")
} }

View File

@ -25,10 +25,7 @@ class TGColorSelect;
class TGNumberEntry; class TGNumberEntry;
namespace sls class multiSlsDetector;
{
class Detector;
};
class ctbSignal; class ctbSignal;
#include <string> #include <string>
@ -48,14 +45,14 @@ private:
TGNumberEntry *sEntry; TGNumberEntry *sEntry;
TGColorSelect *fColorSel; TGColorSelect *fColorSel;
sls::Detector *myDet; multiSlsDetector *myDet;
Int_t id; Int_t id;
TH1I *hsig; TH1I *hsig;
public: public:
ctbSignal(TGFrame *page, int i, sls::Detector *det); ctbSignal(TGFrame *page, int i, multiSlsDetector *det);
int setSignalAlias(char *tit, int plot, int col); int setSignalAlias(char *tit, int plot, int col);
string getSignalAlias(); string getSignalAlias();
@ -92,10 +89,10 @@ private:
TGNumberEntry *eIOCntrlRegister; TGNumberEntry *eIOCntrlRegister;
TGNumberEntry *eDbitOffset; TGNumberEntry *eDbitOffset;
sls::Detector *myDet; multiSlsDetector *myDet;
public: public:
ctbSignals(TGVerticalFrame *page, sls::Detector *det); ctbSignals(TGVerticalFrame *page, multiSlsDetector *det);
int setSignalAlias(string line); int setSignalAlias(string line);
string getSignalAlias(); string getSignalAlias();

View File

@ -9,8 +9,7 @@
#include <TGButton.h> #include <TGButton.h>
#include "ctbSlowAdcs.h" #include "ctbSlowAdcs.h"
#include "ctbDefs.h" #include "multiSlsDetector.h"
#include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
using namespace std; using namespace std;
@ -18,7 +17,7 @@ using namespace std;
ctbSlowAdc::ctbSlowAdc(TGGroupFrame *page, int idac, sls::Detector *det) : TGHorizontalFrame(page, 800,50) , id(idac), myDet(det) { ctbSlowAdc::ctbSlowAdc(TGGroupFrame *page, int idac, multiSlsDetector *det) : TGHorizontalFrame(page, 800,50) , id(idac), myDet(det) {
TGHorizontalFrame *hframe=this; TGHorizontalFrame *hframe=this;
@ -56,6 +55,9 @@ ctbSlowAdc::ctbSlowAdc(TGGroupFrame *page, int idac, sls::Detector *det) : TGHor
b->SetTextJustify(kTextLeft); b->SetTextJustify(kTextLeft);
b->Connect("Clicked()","ctbSlowAdc",this,"getValue()"); b->Connect("Clicked()","ctbSlowAdc",this,"getValue()");
} }
@ -64,50 +66,38 @@ int ctbSlowAdc::setLabel(char *tit) {
if(tit) if(tit)
dacsLabel->SetText(tit); dacsLabel->SetText(tit);
return id; return id;
} }
string ctbSlowAdc::getLabel() { string ctbSlowAdc::getLabel() {
ostringstream line; ostringstream line;
line << dacsLabel->GetText() << endl; line << dacsLabel->GetText() << endl;
// line << "DAC" << dec << id << " " << dacsUnit->IsOn() << endl; // line << "DAC" << dec << id << " " << dacsUnit->IsOn() << endl;
return line.str(); return line.str();
} }
int ctbSlowAdc::getValue() { int ctbSlowAdc::getValue() {
try {
std::string s;
// temp int val=myDet->getADC((slsDetectorDefs::dacIndex)id);
if (id == static_cast<int>(slsDetectorDefs::SLOW_ADC_TEMP)) { char s[100];
cout << "adc " << id << " " << val << endl;
sprintf(s,"%d mV",val);
if (id==999)
sprintf(s,"%d <20>C",val);
dacsValue->SetText(s);
int val = myDet->getTemperature(static_cast<slsDetectorDefs::dacIndex>(id)).tsquash("Different values");
cout << "slow adc temp" << " " << val << endl;
s = to_string(val) + " " + to_string(0x00b0) + "C";//<2F>C
dacsValue->SetText(s.c_str());
return val;
}
// mv return val;
else {
int val = myDet->getSlowADC(static_cast<slsDetectorDefs::dacIndex>(id)).tsquash("Different values");
cout << "slow adc " << id << " " << val << endl;
s = to_string(val) + " mV";
dacsValue->SetText(s.c_str());
return val;
}
} CATCH_DISPLAY ("Could not get slow dac " + to_string(id) + ".", "ctbSlowAdc::getValue")
return -1;
} }
@ -116,7 +106,8 @@ int ctbSlowAdc::getValue() {
ctbSlowAdcs::ctbSlowAdcs(TGVerticalFrame *page, sls::Detector *det) : TGGroupFrame(page,"Sense",kVerticalFrame) , myDet(det){ ctbSlowAdcs::ctbSlowAdcs(TGVerticalFrame *page, multiSlsDetector *det) : TGGroupFrame(page,"Sense",kVerticalFrame) , myDet(det){
SetTitlePos(TGGroupFrame::kLeft); SetTitlePos(TGGroupFrame::kLeft);
page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10)); page->AddFrame(this,new TGLayoutHints( kLHintsTop | kLHintsExpandX , 10,10,10,10));
@ -125,12 +116,14 @@ ctbSlowAdcs::ctbSlowAdcs(TGVerticalFrame *page, sls::Detector *det) : TGGroupF
// cout << "window mapped " << endl; // cout << "window mapped " << endl;
for (int idac=0; idac<NSLOWADCS + 1; idac++) { for (int idac=0; idac<NSLOWADCS; idac++) {
adcs[idac]=new ctbSlowAdc(this, idac+1000, myDet); adcs[idac]=new ctbSlowAdc(this, idac+1000, myDet);
} }
adcs[NSLOWADCS]->setLabel((char*)"Temperature"); adcs[NSLOWADCS]=new ctbSlowAdc(this, 999, myDet);
adcs[NSLOWADCS]->setLabel("Temperature");
} }
@ -140,7 +133,7 @@ int ctbSlowAdcs::setSlowAdcAlias(string line) {
int is=-1, mv=0; int is=-1, mv=0;
char tit[100]; char tit[100];
int narg=sscanf(line.c_str(),"SENSE%d %s %d",&is,tit,&mv); int narg=sscanf(line.c_str(),"SENSE%d %s",&is,tit,&mv);
if (narg<2) if (narg<2)
return -1; return -1;
if (is>=0 && is<NSLOWADCS) if (is>=0 && is<NSLOWADCS)
@ -156,6 +149,7 @@ string ctbSlowAdcs::getSlowAdcAlias() {
for (int i=0; i<NSLOWADCS; i++) for (int i=0; i<NSLOWADCS; i++)
line << adcs[i]->getLabel() << endl; line << adcs[i]->getLabel() << endl;
return line.str(); return line.str();
} }
@ -163,6 +157,7 @@ string ctbSlowAdcs::getSlowAdcAlias() {
string ctbSlowAdcs::getAdcParameters() { string ctbSlowAdcs::getAdcParameters() {
ostringstream line; ostringstream line;
for (int i=0; i<NSLOWADCS; i++) { for (int i=0; i<NSLOWADCS; i++) {
@ -171,12 +166,20 @@ string ctbSlowAdcs::getAdcParameters() {
} }
line << "adc:-1" << adcs[NSLOWADCS]->getValue() << endl; line << "adc:-1" << adcs[NSLOWADCS]->getValue() << endl;
return line.str(); return line.str();
} }
void ctbSlowAdcs::update() { void ctbSlowAdcs::update() {
for (int idac=0; idac<NSLOWADCS+1; idac++) { for (int idac=0; idac<NSLOWADCS+1; idac++) {
adcs[idac]->getValue(); adcs[idac]->getValue();
} }
} }

View File

@ -19,10 +19,7 @@ class TGTextButton;
namespace sls class multiSlsDetector;
{
class Detector;
};
#include <string> #include <string>
using namespace std; using namespace std;
@ -38,9 +35,9 @@ class ctbSlowAdc : public TGHorizontalFrame {
TGLabel *dacsValue; TGLabel *dacsValue;
int id; int id;
sls::Detector* myDet; multiSlsDetector* myDet;
public: public:
ctbSlowAdc(TGGroupFrame*, int , sls::Detector*); ctbSlowAdc(TGGroupFrame*, int , multiSlsDetector*);
int getValue(); int getValue();
int setLabel(char *tit); int setLabel(char *tit);
@ -59,10 +56,10 @@ private:
ctbSlowAdc *adcs[NSLOWADCS+1]; ctbSlowAdc *adcs[NSLOWADCS+1];
sls::Detector* myDet; multiSlsDetector* myDet;
public: public:
ctbSlowAdcs(TGVerticalFrame *page, sls::Detector*); ctbSlowAdcs(TGVerticalFrame *page, multiSlsDetector*);
int setSlowAdcAlias(string line); int setSlowAdcAlias(string line);
// int setDacAlias(string line); // int setDacAlias(string line);

View File

@ -3,11 +3,9 @@ find_package(Sphinx)
if (DOXYGEN_FOUND AND SPHINX_FOUND) if (DOXYGEN_FOUND AND SPHINX_FOUND)
message(${CMAKE_PROJECT_SORURCE_DIR}/slsDetectorSoftware/src)
# Utility to generate command line documentation # #Utility to generate command line documentation
add_executable(gendoc src/gendoc.cpp) add_executable(gendoc src/gendoc.cpp)
# This is a bit hacky, but better than exposing stuff?
target_include_directories(gendoc PRIVATE ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/src)
target_link_libraries(gendoc PRIVATE target_link_libraries(gendoc PRIVATE
slsDetectorShared slsDetectorShared
) )

View File

@ -36,7 +36,7 @@ int main() {
std::cout << "Generating command line documentation!\n"; std::cout << "Generating command line documentation!\n";
sls::CmdProxy proxy(nullptr); sls::CmdProxy<sls::Detector> proxy(nullptr);
auto commands = proxy.GetProxyCommands(); auto commands = proxy.GetProxyCommands();
std::ofstream fs("commands.rst"); std::ofstream fs("commands.rst");

View File

@ -1,132 +0,0 @@
#G1 Energy #G2 Energy
300 7000
#G0 pedestal G1 pedestal G2 pedestal G0 gain G1 gain G2 gain (for every channel) ADU
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1
100 100 100 10 1 0.1

View File

@ -8,7 +8,7 @@ period 0.000024984
delay 0.999999968 delay 0.999999968
gates 1 gates 1
frames 300000.000000000 frames 300000.000000000
triggers 1.000000000 cycles 1.000000000
timing auto timing auto
fineoff 0.000000 fineoff 0.000000
startscript none startscript none

View File

@ -22,56 +22,56 @@ TEST_CASE_METHOD(MultiDetectorFixture, "Set and get dacs",
auto th = 1000; auto th = 1000;
// set and read back each individual dac of EIGER // set and read back each individual dac of EIGER
d.setDAC(0, di::SVP, 0); d.setDAC(0, di::E_SvP, 0);
CHECK(d.setDAC(-1, di::SVP, 0) == 0); CHECK(d.setDAC(-1, di::E_SvP, 0) == 0);
d.setDAC(4000, di::SVN, 0); d.setDAC(4000, di::E_SvN, 0);
CHECK(d.setDAC(-1, di::SVN, 0) == 4000); CHECK(d.setDAC(-1, di::E_SvN, 0) == 4000);
d.setDAC(2000, di::VTR, 0); d.setDAC(2000, di::E_Vtr, 0);
CHECK(d.setDAC(-1, di::VTR, 0) == 2000); CHECK(d.setDAC(-1, di::E_Vtr, 0) == 2000);
d.setDAC(3500, di::VRF, 0); d.setDAC(3500, di::E_Vrf, 0);
CHECK(d.setDAC(-1, di::VRF, 0) == 3500); CHECK(d.setDAC(-1, di::E_Vrf, 0) == 3500);
d.setDAC(1400, di::VRS, 0); d.setDAC(1400, di::E_Vrs, 0);
CHECK(d.setDAC(-1, di::VRS, 0) == 1400); CHECK(d.setDAC(-1, di::E_Vrs, 0) == 1400);
d.setDAC(2556, di::VTGSTV, 0); d.setDAC(2556, di::E_Vtgstv, 0);
CHECK(d.setDAC(-1, di::VTGSTV, 0) == 2556); CHECK(d.setDAC(-1, di::E_Vtgstv, 0) == 2556);
d.setDAC(1500, di::VCMP_LL, 0); d.setDAC(1500, di::E_Vcmp_ll, 0);
CHECK(d.setDAC(-1, di::VCMP_LL, 0) == 1500); CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == 1500);
d.setDAC(1400, di::VCMP_LR, 0); d.setDAC(1400, di::E_Vcmp_lr, 0);
CHECK(d.setDAC(-1, di::VCMP_LR, 0) == 1400); CHECK(d.setDAC(-1, di::E_Vcmp_lr, 0) == 1400);
d.setDAC(4000, di::CAL, 0); d.setDAC(4000, di::E_cal, 0);
CHECK(d.setDAC(-1, di::CAL, 0) == 4000); CHECK(d.setDAC(-1, di::E_cal, 0) == 4000);
d.setDAC(1300, di::VCMP_RL, 0); d.setDAC(1300, di::E_Vcmp_rl, 0);
CHECK(d.setDAC(-1, di::VCMP_RL, 0) == 1300); CHECK(d.setDAC(-1, di::E_Vcmp_rl, 0) == 1300);
d.setDAC(1200, di::VCMP_RR, 0); d.setDAC(1200, di::E_Vcmp_rr, 0);
CHECK(d.setDAC(-1, di::VCMP_RR, 0) == 1200); CHECK(d.setDAC(-1, di::E_Vcmp_rr, 0) == 1200);
d.setDAC(1100, di::RXB_RB, 0); d.setDAC(1100, di::E_rxb_rb, 0);
CHECK(d.setDAC(-1, di::RXB_RB, 0) == 1100); CHECK(d.setDAC(-1, di::E_rxb_rb, 0) == 1100);
d.setDAC(1100, di::RXB_LB, 0); d.setDAC(1100, di::E_rxb_lb, 0);
CHECK(d.setDAC(-1, di::RXB_LB, 0) == 1100); CHECK(d.setDAC(-1, di::E_rxb_lb, 0) == 1100);
d.setDAC(1500, di::VCP, 0); d.setDAC(1500, di::E_Vcp, 0);
CHECK(d.setDAC(-1, di::VCP, 0) == 1500); CHECK(d.setDAC(-1, di::E_Vcp, 0) == 1500);
d.setDAC(2000, di::VCN, 0); d.setDAC(2000, di::E_Vcn, 0);
CHECK(d.setDAC(-1, di::VCN, 0) == 2000); CHECK(d.setDAC(-1, di::E_Vcn, 0) == 2000);
d.setDAC(1550, di::VIS, 0); d.setDAC(1550, di::E_Vis, 0);
CHECK(d.setDAC(-1, di::VIS, 0) == 1550); CHECK(d.setDAC(-1, di::E_Vis, 0) == 1550);
d.setDAC(660, di::IO_DELAY, 0); d.setDAC(660, di::IO_DELAY, 0);
CHECK(d.setDAC(-1, di::IO_DELAY, 0) == 660); CHECK(d.setDAC(-1, di::IO_DELAY, 0) == 660);
// setting threshold sets all individual vcmp // setting threshold sets all individual vcmp
d.setDAC(th, di::THRESHOLD, 0); d.setDAC(th, di::THRESHOLD, 0);
CHECK(d.setDAC(-1, di::THRESHOLD, 0) == th); CHECK(d.setDAC(-1, di::THRESHOLD, 0) == th);
CHECK(d.setDAC(-1, di::VCMP_LL, 0) == th); CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == th);
CHECK(d.setDAC(-1, di::VCMP_LR, 0) == th); CHECK(d.setDAC(-1, di::E_Vcmp_lr, 0) == th);
CHECK(d.setDAC(-1, di::VCMP_RL, 0) == th); CHECK(d.setDAC(-1, di::E_Vcmp_rl, 0) == th);
CHECK(d.setDAC(-1, di::VCMP_RR, 0) == th); CHECK(d.setDAC(-1, di::E_Vcmp_rr, 0) == th);
// different values gives -1 // different values gives -1
if (d.getNumberOfDetectors() > 1) { if (d.getNumberOfDetectors() > 1) {
d.setDAC(1600, di::VCMP_LL, 0, 0); d.setDAC(1600, di::E_Vcmp_ll, 0, 0);
d.setDAC(1700, di::VCMP_LL, 0, 1); d.setDAC(1700, di::E_Vcmp_ll, 0, 1);
CHECK(d.setDAC(-1, di::VCMP_LL, 0, 0) == 1600); CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0, 0) == 1600);
CHECK(d.setDAC(-1, di::VCMP_LL, 0, 1) == 1700); CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0, 1) == 1700);
CHECK(d.setDAC(-1, di::VCMP_LL, 0) == -1); CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == -1);
CHECK(d.setDAC(-1, di::THRESHOLD, 0) == -1); CHECK(d.setDAC(-1, di::THRESHOLD, 0) == -1);
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 0) == -1); CHECK(d.setDAC(-1, di::THRESHOLD, 0, 0) == -1);
CHECK(d.setDAC(-1, di::THRESHOLD, 0, 1) == -1); CHECK(d.setDAC(-1, di::THRESHOLD, 0, 1) == -1);

View File

@ -102,8 +102,8 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
// Setting and reading exposure time // Setting and reading exposure time
auto t = 1000000000; auto t = 1000000000;
d.setExptime(t); d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t);
CHECK(d.getExptime() == t); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t);
// size of an eiger half module with and without gap pixels // size of an eiger half module with and without gap pixels
CHECK(d.getTotalNumberOfChannels() == 256 * 256 * 4); CHECK(d.getTotalNumberOfChannels() == 256 * 256 * 4);
@ -143,8 +143,8 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
// Can we still access the detector while it's locked // Can we still access the detector while it's locked
auto t = 1300000000; auto t = 1300000000;
d.setExptime(t); d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t);
CHECK(d.getExptime() == t); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t);
// unlock again and free // unlock again and free
d.lockServer(0); d.lockServer(0);
@ -163,12 +163,12 @@ TEST_CASE("Set settings", "[.integration][.single]"){
TEST_CASE("Timer functions", "[.integration][cli]") { TEST_CASE("Timer functions", "[.integration][cli]") {
// FRAME_NUMBER, /**< number of real time frames: total number of // FRAME_NUMBER, /**< number of real time frames: total number of
// acquisitions is number or frames*number of triggers */ ACQUISITION_TIME, // acquisitions is number or frames*number of cycles */ ACQUISITION_TIME,
// /**< exposure time */ FRAME_PERIOD, /**< period between exposures */ // /**< exposure time */ FRAME_PERIOD, /**< period between exposures */
// DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or // DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or
// readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per // readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per
// frame (in gated mode) */ TRIGGER_NUMBER, /**< number of triggers: total // frame (in gated mode) */ CYCLES_NUMBER, /**< number of cycles: total
// number of acquisitions is number or frames*number of triggers */ // number of acquisitions is number or frames*number of cycles */
// ACTUAL_TIME, /**< Actual time of the detector's internal timer */ // ACTUAL_TIME, /**< Actual time of the detector's internal timer */
// MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) // MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo)
// */ // */
@ -190,38 +190,49 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
// Number of frames // Number of frames
auto frames = 5; auto frames = 5;
d.setNumberOfFrames(frames); d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, frames);
CHECK(d.getNumberOfFrames() == frames); CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER) == frames);
auto exptime = 2000000000; auto exptime = 2000000000;
d.setExptime(exptime); d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, exptime);
CHECK(d.getExptime() == exptime); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == exptime);
auto period = 2000000000; auto period = 2000000000;
d.setPeriod(period); d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
CHECK(d.getPeriod() == period); CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD) == period);
if (test::type != dt::EIGER) { if (test::type != dt::EIGER) {
auto delay = 10000; auto delay = 10000;
d.setDelayAfterTrigger(delay); d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay);
CHECK(d.getDelayAfterTrigger() == CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) ==
delay); delay);
} }
auto triggers = 2; if (test::type != dt::EIGER) {
d.setNumberOfTriggers(triggers); auto gates = 1;
CHECK(d.getNumberOfTriggers() == triggers); d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates);
}
auto cycles = 2;
d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER, cycles);
CHECK(d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER) == cycles);
if (test::type == dt::EIGER) { if (test::type == dt::EIGER) {
auto subtime = 200; auto subtime = 200;
d.setSubExptime(subtime); d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME,
CHECK(d.getSubExptime() == subtime); subtime);
CHECK(d.setTimer(
slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) ==
subtime);
} }
// for (int i =0; i!=frames; ++i) // for (int i =0; i!=frames; ++i)
d.startAndReadAll(); d.startAndReadAll();
d.freeSharedMemory(); d.freeSharedMemory();
// If we add a timer we should add tests for the timer
CHECK(slsDetectorDefs::MAX_TIMERS == 19);
} }
// TEST_CASE("Aquire", "[.integration][eiger]"){ // TEST_CASE("Aquire", "[.integration][eiger]"){
@ -232,13 +243,13 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
// auto period = 1000000000; // auto period = 1000000000;
// auto exptime = 100000000; // auto exptime = 100000000;
// d.setNumberOfFrames(5); // d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, 5);
// d.setExptime(exptime); // d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, exptime);
// d.setPeriod(period); // d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
// d.startAndReadAll(); // d.startAndReadAll();
// auto rperiod = // auto rperiod =
// d.getMeasuredPeriod(); // d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD);
// CHECK(rperiod == 0.1); // CHECK(rperiod == 0.1);
// d.freeSharedMemory(); // d.freeSharedMemory();
@ -463,7 +474,7 @@ TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegr
REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU))); REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU)));
REQUIRE(m.getHostname() == c.hostname); REQUIRE(m.getHostname() == c.hostname);
CHECK(m.setNumberOfFrames(1) == 1); CHECK(m.setTimer(slsDetectorDefs::FRAME_NUMBER, 1) == 1);
// starting fnum // starting fnum
uint64_t val = 8; uint64_t val = 8;

View File

@ -50,7 +50,7 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
// DELAY_AFTER_TRIGGER, // DELAY_AFTER_TRIGGER,
// GATES_NUMBER, // GATES_NUMBER,
// TRIGGER_NUMBER, // CYCLES_NUMBER,
// ACTUAL_TIME // ACTUAL_TIME
// MEASUREMENT_TIME // MEASUREMENT_TIME

View File

@ -17,13 +17,13 @@
/*! \file document.h */ /*! \file document.h */
#include "encodedstream.h" #include "reader.h"
#include "internal/meta.h" #include "internal/meta.h"
#include "internal/strfunc.h" #include "internal/strfunc.h"
#include "memorystream.h" #include "memorystream.h"
#include "reader.h" #include "encodedstream.h"
#include <limits>
#include <new> // placement new #include <new> // placement new
#include <limits>
RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PUSH
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -15,8 +15,8 @@
#ifndef RAPIDJSON_ENCODEDSTREAM_H_ #ifndef RAPIDJSON_ENCODEDSTREAM_H_
#define RAPIDJSON_ENCODEDSTREAM_H_ #define RAPIDJSON_ENCODEDSTREAM_H_
#include "memorystream.h"
#include "stream.h" #include "stream.h"
#include "memorystream.h"
#ifdef __GNUC__ #ifdef __GNUC__
RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PUSH

View File

@ -15,9 +15,9 @@
#ifndef RAPIDJSON_STRTOD_ #ifndef RAPIDJSON_STRTOD_
#define RAPIDJSON_STRTOD_ #define RAPIDJSON_STRTOD_
#include "ieee754.h"
#include "biginteger.h" #include "biginteger.h"
#include "diyfp.h" #include "diyfp.h"
#include "ieee754.h"
#include "pow10.h" #include "pow10.h"
RAPIDJSON_NAMESPACE_BEGIN RAPIDJSON_NAMESPACE_BEGIN

View File

@ -164,8 +164,8 @@
#include "msinttypes/inttypes.h" #include "msinttypes/inttypes.h"
#else #else
// Other compilers should have this. // Other compilers should have this.
#include <inttypes.h>
#include <stdint.h> #include <stdint.h>
#include <inttypes.h>
#endif #endif
//!@endcond //!@endcond
#ifdef RAPIDJSON_DOXYGEN_RUNNING #ifdef RAPIDJSON_DOXYGEN_RUNNING

View File

@ -18,11 +18,11 @@
/*! \file reader.h */ /*! \file reader.h */
#include "allocators.h" #include "allocators.h"
#include "stream.h"
#include "encodedstream.h" #include "encodedstream.h"
#include "internal/meta.h" #include "internal/meta.h"
#include "internal/stack.h" #include "internal/stack.h"
#include "internal/strtod.h" #include "internal/strtod.h"
#include "stream.h"
#include <limits> #include <limits>
#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER) #if defined(RAPIDJSON_SIMD) && defined(_MSC_VER)

View File

@ -353,19 +353,19 @@ In the case of REAL CONTINUOUS readout, i.e. continuous acquire and readout from
\begin{table} \begin{table}
\begin{tabular}{|c|c|c|c|c|} \begin{tabular}{|c|c|c|c|c|}
\hline \hline
\tiny{GbE} & \tiny{dynamic range} & \tiny{continuos maximum frame rate(Hz)} & \tiny{minimum period ($\mu$s)}& \tiny{calculated/measered time to send out data ($\mu$s)}\\ \tiny{GbE} & \tiny{dynamic range} & \tiny{continuos maximum frame rate(Hz)} & \tiny{minimum period ($\mu$s)}& \tiny{time to send out data ($\mu$s)}\\
\hline \hline
1 & 16 & \textbf{256} & 3901 & \\ 1 & 16 & \textbf{256} & 3901 & \\
\hline \hline
1 & 32 & \textbf{128} & 7820 & \\ 1 & 32 & \textbf{128} & 7820 & \\
\hline \hline
10 & 4 & \textbf{10240} & 98 & 105/128\\ 10 & 4 & \textbf{10240} & 98 & 100\\
\hline \hline
10 & 8 & \textbf{5120} & 196 & 210/250\\ 10 & 8 & \textbf{5120} & 196 & 200\\
\hline \hline
10 & 16 & \textbf{2560} & 391 & 420/490\\ 10 & 16 & \textbf{2560} & 391 & 400\\
\hline \hline
10 & 32 & \textbf{1280} & 782 & 840/977\\ 10 & 32 & \textbf{1280} & 782 & 800\\
\hline \hline
\end{tabular} \end{tabular}
\caption{Frame rate limits for the CONTINUOS streaming out of images, i.e. the data rate out is just below 1Gb/s or 10Gb/s. 1280~Hz for 32-bit, 10GbE is obtained from the 10GbE limitation. The maximum achievable frame rate is 977~Hz.} \caption{Frame rate limits for the CONTINUOS streaming out of images, i.e. the data rate out is just below 1Gb/s or 10Gb/s. 1280~Hz for 32-bit, 10GbE is obtained from the 10GbE limitation. The maximum achievable frame rate is 977~Hz.}
@ -609,17 +609,17 @@ The detector can be setup such to receive external triggers. Connect a LEMO sign
\begin{verbatim} \begin{verbatim}
sls_detector_put 0-timing [auto/trigger/burst_trigger/gating] sls_detector_put 0-timing [auto/trigger/burst_trigger/gating]
sls_detector_put 0-frames x sls_detector_put 0-frames x
sls_detector_put 0-triggers y sls_detector_put 0-cycles y
sls_detector_acquire 0- sls_detector_acquire 0-
\end{verbatim} \end{verbatim}
No timeout is expected between the start of the acquisition and the arrival of the first trigger. No timeout is expected between the start of the acquisition and the arrival of the first trigger.
Here are the implemented options so far: Here are the implemented options so far:
\begin{itemize} \begin{itemize}
\item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of triggers (i.e. triggers) to 1 using {\tt{triggers}}. Set number of frames using {\tt{frames}}. \item {\tt{auto}} is the software controlled acquisition (does not use triggers), where {\tt{exptime}} and {\tt{period}} have to be set. Set number of cycles (i.e. triggers) to 1 using {\tt{cycles}}. Set number of frames using {\tt{frames}}.
\item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{triggers}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series. \item {\tt{trigger}} 1 frame taken for 1 trigger. Your {\tt{frames}} needs to be 1 always, {\tt{cycles}} can be changed and defines how many triggers are considered. {\tt{exptime}} needs to be set. In the GUI this is called trigger exposure series.
\item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{triggers}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout. \item {\tt{burst\_trigger}} gets only 1 trigger, but allows to take many frames. With {\tt{frames}} one can change the number of frames. {\tt{cycles}} needs to be 1. {\tt{exptime}} and {\tt{period}} have to be set. In the gui it is called trigger readout.
\item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{triggers}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. IMPORTANT: Up to firmware 23, the last subframe is oblige to finish being taken, despite the gate signal going down. This will be configurable from later fw and software version. Also, in gating mode, due to timimg of the state machine, you need to leave 500~$\mu$s deadtime between the end on an acquisition and the next. This is as the state machine is unable to check for changes in the status in the first 500~$\mu$s. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime. \item{\tt{gating}} allows to get a frame only when the trigger pulse is gating. Note that in this case the exp time and period only depend on the gating signal. {\tt{cycles}} allows to select how many gates to consider. Set number of frames to 1 using {\tt{frames}}. IMPORTANT: Up to firmware 23, the last subframe is oblige to finish being taken, despite the gate signal going down. This will be configurable from later fw and software version. Also, in gating mode, due to timimg of the state machine, you need to leave 500~$\mu$s deadtime between the end on an acquisition and the next. This is as the state machine is unable to check for changes in the status in the first 500~$\mu$s. ATTENTION: if you are in 16 bit mode and you are applying online rate corrections, as now the exptime is generated by the trigger, you might not have correct rate corrections. If you know what the exposure time is in the gating signal, then you can set the {\tt{exptime}} once and the rate corrections will be correct. In 32 bit mode, it does not matter as the rate corrections depends on the {\tt{subexptime}} which is software set independently from the gate exptime.
When using 32-bit mode, by default the acquisition ends the last complete subframe that was started when still the acquisition time was valid. This has been chosen as many people wants to know the exact acquisition time for when the detector was taking data and also, if {\tt{ratecorr}} are active, the last subframe will be correctly corrected, while otherwise it will be corrected with a wrong subdeadtime. When using 32-bit mode, by default the acquisition ends the last complete subframe that was started when still the acquisition time was valid. This has been chosen as many people wants to know the exact acquisition time for when the detector was taking data and also, if {\tt{ratecorr}} are active, the last subframe will be correctly corrected, while otherwise it will be corrected with a wrong subdeadtime.
However, from 4.1.0, in gating mode, an option to immediately terminate the subframe when the gate signal goes down it is implemented to stop the acquisition at the same time. This option is {\tt{./sls\_detector\_put interruptsubframe 1}} while the default option is {\tt{./sls\_detector\_put interruptsubframe 0}}. However, from 4.1.0, in gating mode, an option to immediately terminate the subframe when the gate signal goes down it is implemented to stop the acquisition at the same time. This option is {\tt{./sls\_detector\_put interruptsubframe 1}} while the default option is {\tt{./sls\_detector\_put interruptsubframe 0}}.
@ -628,13 +628,13 @@ However, from 4.1.0, in gating mode, an option to immediately terminate the subf
Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be output in 32 bit mode. The TRIGGER OUT outputs the sum-up-signal at the moment (which is useless). This will be changed in the future to output the envelop of the enable signal. Hardware-wise, the ENABLE OUT signal outputs when the chips are really acquiring. This means that the single subframes will be output in 32 bit mode. The TRIGGER OUT outputs the sum-up-signal at the moment (which is useless). This will be changed in the future to output the envelop of the enable signal.
We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst\_trigger}} trigger modes and make both {\tt{frames}} and {\tt{triggers}} configurable at the same time. We are planning to change some functionality, i.e. unify the {\tt{trigger}} and {\tt{burst\_trigger}} trigger modes and make both {\tt{frames}} and {\tt{cycles}} configurable at the same time.
There is the possibility to use {\tt{timing trigger/burst\_trigger}} and send software single commands to fake the trigger. This is done with: There is the possibility to use {\tt{timing trigger/burst\_trigger}} and send software single commands to fake the trigger. This is done with:
\begin{verbatim} \begin{verbatim}
sls_detector_put 0-timing [trigger/burst_trigger] sls_detector_put 0-timing [trigger/burst_trigger]
sls_detector_put 0-frames x sls_detector_put 0-frames x
sls_detector_put 0-triggers y sls_detector_put 0-cycles y
sls_detector_status trigger sls_detector_status trigger
\end{verbatim} \end{verbatim}
Note that this functionality is very (!) useful if you need to do something between and acquisition and the next. This can be used to do a fast threshold scan for example. See section~\ref{sec:fastthresholdscan}. Note that this functionality is very (!) useful if you need to do something between and acquisition and the next. This can be used to do a fast threshold scan for example. See section~\ref{sec:fastthresholdscan}.
@ -715,7 +715,7 @@ If \textbf{dr} is 32 and \textbf{clkdivider} is not 2, whatever the detector get
Here is a list of parameters that should be reset: Here is a list of parameters that should be reset:
\begin{enumerate} \begin{enumerate}
\item \textbf{resetframescaught} should be reset to zero after every acquisition taken with {\tt{receiver start}},{\tt{status start}},{\tt{receiver stop}}. If the acquisition is taken with {\tt{sls\_detector\_acquire}}, there is no need to reset this. \item \textbf{resetframescaught} should be reset to zero after every acquisition taken with {\tt{receiver start}},{\tt{status start}},{\tt{receiver stop}}. If the acquisition is taken with {\tt{sls\_detector\_acquire}}, there is no need to reset this.
\item After changing the {\tt{timing}} mode of the detector, one should reset to '1' the unused value, in that specific timing mode, between \textbf{frames} and \textbf{triggers}. See section~\ref{triggering} for how to use the timing. At the present moment the detector will acquire more frames than planned if the variable not used between \textbf{frames} and \textbf{triggers} is not reset. In future releases, the unused variable will be ignored. Still resetting is a good practice. \item After changing the {\tt{timing}} mode of the detector, one should reset to '1' the unused value, in that specific timing mode, between \textbf{frames} and \textbf{cycles}. See section~\ref{triggering} for how to use the timing. At the present moment the detector will acquire more frames than planned if the variable not used between \textbf{frames} and \textbf{cycles} is not reset. In future releases, the unused variable will be ignored. Still resetting is a good practice.
\end{enumerate} \end{enumerate}
@ -794,23 +794,9 @@ Transmission delays should be chosen only to accomodate the writing speed of the
Table~\ref{tcont} gives the times that are needed to transfer 1 images out of the 10~Gb Ethernet connection. This reflects the CONTINUOS frame rate achieavable. The disk speed can be monitored with {\tt{dstat}}. One you have worked out this, you can calculated the {\tt{txndelay\_frame}} delay as: Table~\ref{tcont} gives the times that are needed to transfer 1 images out of the 10~Gb Ethernet connection. This reflects the CONTINUOS frame rate achieavable. The disk speed can be monitored with {\tt{dstat}}. One you have worked out this, you can calculated the {\tt{txndelay\_frame}} delay as:
\begin{equation} \begin{equation}
{\tt{txndelay\_frame}}=-t_sending+dr \cdot \frac{4*256*256*N\_half\_modules}{1024 \cdot 1000 \cdot disk\_speed [MB/s] \cdot 8} {\tt{txndelay\_frame}}=-tsending+dr \cdot \frac{4*256*256*N\_half\_modules}{1024 \cdot 1000 \cdot disk\_speed [MB/s]}
\end{equation} \end{equation}
In 4-bit mode, for a disk seed of 320MB/s, the {\tt{txndelay\_frame}} is 300~$\mu$s (30000 to be set up to the detector). The sending time is 100~$\mu$s, such that an total ackievable writing speed of 1/400~$\mu$s (2.5~kHz) in achieved. In 4-bit mode, for a disk seed of 320MB/s, the {\tt{txndelay\_frame}} is 300~$\mu$s (30000 to be set up to the detector). The sending time is 100~$\mu$s, such that an total ackievable writing sped of 1/400~$\mu$s (2.5~kHz) in achieved.
Note that:
\begin{enumerate}
\item The continuos frame rate goes down when transmission delays are introduced:
\begin{equation}
continuos\_frame\_rate= \frac{1}{\tt{txndelay\_frame}+t\_sending}
\end{equation}
\item If your transmission delays reduce the continuos frame rate, you will saturate the memory on board at some point and you will corrupt images. Conservatively, we say that the number of maximum images in buffered mode is the one listed in table~\ref{timgs}, call N\_images. However, one can approximately say that (and here we need to test more, so do not believe to these numbers yet),
\begin{equation}
N\_tot\_images= N\_images+\frac{ N\_images}{frame\_rate \cdot (t\_delay\_frame + t\_sending) }
\end{equation}
\end{enumerate}
\section{Setting up the PC settings for 10Gb}\label{10g} \section{Setting up the PC settings for 10Gb}\label{10g}
@ -832,8 +818,12 @@ ethtool -G xth1 rx 4096 #or wheterver is the max number for your pc
ethtool -C xth1 rx-usecs 100 ethtool -C xth1 rx-usecs 100
ethtool -A xth1 rx on ethtool -A xth1 rx on
\end{verbatim} \end{verbatim}
where {\tt{xth1}} can be replaced with the correct 10Gb device. where {\tt{xth1}} can be replaced with the correct 10Gb device. To minimise loosing packets, priorities are set better as root user, so have the receiver as root.
NOTE THAT THIS SETTINGS WILL BE LOST IF YOU REBOOT THE COMPUTER. To try to bypass being root, we trued something like this:
\begin{verbatim}
/etc/security/limits.conf username rtprio 99
\end{verbatim}
but somehow it did not fully worked so we kept the trick of being root.
Very important is to activate the flow control in 10Gb (in 1Gb it is on by default and not configurable) Very important is to activate the flow control in 10Gb (in 1Gb it is on by default and not configurable)
\begin{verbatim} \begin{verbatim}
@ -867,18 +857,10 @@ to make the settings permanent, edit /etc/sysctl.conf:
\begin{verbatim} \begin{verbatim}
# 100MiB # 100MiB
net.core.rmem_max = 104857600 net.core.rmem_max = 104857600
net.core.rmem_default= 104857600
net.core.netdev_max_backlog = 250000 net.core.netdev_max_backlog = 250000
\end{verbatim} \end{verbatim}
and run \textbf{sysctl -p}. and run \textbf{sysctl -p}.
To minimise loosing packets, priorities are set better as root user, so have the receiver as root.
To try to bypass being root, we trued something like this:
\begin{verbatim}
/etc/security/limits.conf username rtprio 99
\end{verbatim}
but somehow it did not fully worked so we kept the trick of being root.
Last, you can disable power saving in the CPU frequency (chose the appropriate command for your system): Last, you can disable power saving in the CPU frequency (chose the appropriate command for your system):
\begin{verbatim} \begin{verbatim}
cpupower frequency-info cpupower frequency-info
@ -913,6 +895,9 @@ mount -t tmpfs none /mnt/ramdisk -o size=10G
\end{verbatim} \end{verbatim}
check how many GB memory you can allocate, to avoid swapping otherwise check how many GB memory you can allocate, to avoid swapping otherwise
\section{Offline processing and monitoring} \section{Offline processing and monitoring}
\subsection{Data out of the detector: UDP packets}\label{UDP} \subsection{Data out of the detector: UDP packets}\label{UDP}
@ -950,22 +935,19 @@ If you use the option of writing raw files, you will have a raw file for each UD
The master file is named: {\tt{filename\_master\_0.raw}} and for version ``4.0.0'' of the slsDetectorSoftware looks like: The master file is named: {\tt{filename\_master\_0.raw}} and for version ``4.0.0'' of the slsDetectorSoftware looks like:
\begin{verbatim} \begin{verbatim}
Version : 4.0 Version : 2.0
Detector Type : 3
Dynamic Range : 32 Dynamic Range : 32
Ten Giga : 1 Ten Giga : 1
Image Size : 524288 bytes Image Size : 524288 bytes
nPixelsX : 512 pixels x : 512 pixels
nPixelsY : 256 pixels y : 256 pixels
Max Frames Per File : 10000 Max. Frames Per File : 10000
Total Frames : 3 Total Frames : 1
Exptime (ns) : 10000000 Exptime (ns) : 1000000000
SubExptime (ns) : 2621440 SubExptime (ns) : 2621440
SubPeriod(ns) : 2621440 SubPeriod(ns) : 2621440
Period (ns) : 0 Period (ns) : 1000000000
Gap Pixels Enable : 0 Timestamp : Mon Sep 3 09:07:05 2018
Quad Enable : 0
Timestamp : Wed Aug 21 16:30:20 2019
#Frame Header #Frame Header
@ -975,9 +957,9 @@ Packet Number : 4 bytes
Bunch ID : 8 bytes Bunch ID : 8 bytes
Timestamp : 8 bytes Timestamp : 8 bytes
Module Id : 2 bytes Module Id : 2 bytes
Row : 2 bytes X Coordinate : 2 bytes
Column : 2 bytes Y Coordinate : 2 bytes
Reserved : 2 bytes Z Coordinate : 2 bytes
Debug : 4 bytes Debug : 4 bytes
Round Robin Number : 2 bytes Round Robin Number : 2 bytes
Detector Type : 1 byte Detector Type : 1 byte
@ -990,15 +972,15 @@ Note that if one wants to reconstruct the real time the detector was acquiring
\subsection{Offline image reconstruction} \subsection{Offline image reconstruction}
The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. The code is still available doing \\ The offline image reconstruction{\tt{slsImageReconstruction}} is not part of the package anymore. The code is still available doing \\
{\tt{git clone git@git.psi.ch:sls\_detectors\_software/sls\_image\_reconstruction.git slsImageReconstruction}}. {\tt{git clone git@git.psi.ch:sls\_detectors\_software/sls\_image\_reconstruction.git slsImageReconstruction}}.
Checkout the {\tt{developer}} branch if in a 3.1.X release, the {\tt{v4.0.0}} branch if in 4.0.X release, or the {\tt{v4.1}} branch if in 4.1.X release of the {\tt{slsDetector}} code. Checkout the {\tt{developer}} branch if in a 3.1.X release or the {\tt{v4.0.0}} branch if in 4.0.X release of the {\tt{slsDetector}} code.
Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5} and \textbf{root} format. The detector writes 4 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted. Three possible conversions are possible: into \textbf{cbf}, \textbf{hdf5} and \textbf{root} format. The detector writes 4 raw files per receiver. An offline image reconstruction executable has been written to collate the possible files together and produce output files. By default an interpolation between the values of the large pixels is performed. Gap pixels between modules are also inserted.
Note that the number of images per file in the 3.1.X release is hardcoded and needs to match whatever you are using in {\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}: Note that the number of images per file is hardcoded and needs to match whatever you are using in {\tt{slsDetectorsPackage/slsReceiverSoftware/include/sls\_receiver\_defs.h}}:
\begin{verbatim} \begin{verbatim}
#define EIGER_MAX_FRAMES_PER_FILE 2000 #define EIGER_MAX_FRAMES_PER_FILE 2000
\end{verbatim} \end{verbatim}
The default is 2000 in the 3.1.X release. The default has been changed to 10000 frm realease 4.0.X and now this is picked up automatically without doing anything. The default is 2000.
\subsubsection{cbf} \subsubsection{cbf}
The cbf executable executable uses the CBFlib-0.9.5 library (downloaded from the web as it downloads architecture dependent packages at installation).Edit the Makefile to correclty point at it.\\ The cbf executable executable uses the CBFlib-0.9.5 library (downloaded from the web as it downloads architecture dependent packages at installation).Edit the Makefile to correclty point at it.\\
@ -1257,7 +1239,7 @@ We have also been requested if we could speed up the threshold scan. At the mome
./sls_detector_put enablefwrite 0 ./sls_detector_put enablefwrite 0
./sls_detector_put resetframescaught 0 ./sls_detector_put resetframescaught 0
./sls_detector_put index 0 ./sls_detector_put index 0
./sls_detector_put triggers 21 ./sls_detector_put cycles 21
./sls_detector_put receiver start ./sls_detector_put receiver start
./sls_detector_put status start ./sls_detector_put status start
for i in $(seq 0 20); for i in $(seq 0 20);
@ -1515,8 +1497,8 @@ frames number
where {\tt{number}} is a string to be interpreted as an integer. where {\tt{number}} is a string to be interpreted as an integer.
\item \begin{verbatim} \item \begin{verbatim}
sls_detector_get triggers sls_detector_get cycles
triggers number cycles number
\end{verbatim} \end{verbatim}
where {\tt{number}} is a string to be interpreted as an integer. where {\tt{number}} is a string to be interpreted as an integer.

View File

@ -111,7 +111,7 @@
"delay"; // sets/gets delay after trigger in s "delay"; // sets/gets delay after trigger in s
"gates"; // sets/gets number of gates per frame in gated mode "gates"; // sets/gets number of gates per frame in gated mode
"frames"; // sets/gets number of frames "frames"; // sets/gets number of frames
"triggers"; // sets/gets number of triggers (use in trigger mode) "cycles"; // sets/gets number of cycles (use in trigger mode)
"probes"; // sets/gets number of probes (advanced!) "probes"; // sets/gets number of probes (advanced!)
"measurements"; // sets/gets number of non-real time measurements "measurements"; // sets/gets number of non-real time measurements
/* read only timers */ /* read only timers */
@ -120,7 +120,7 @@
"delayl"; // gets delay left "delayl"; // gets delay left
"gatesl"; // gets number of gates left "gatesl"; // gets number of gates left
"framesl"; // gets number of frames left "framesl"; // gets number of frames left
"triggersl"; // gets number of triggers left "cyclesl"; // gets number of cycles left
"now"; // gets time stamp from the dteector "now"; // gets time stamp from the dteector
"timestamp"; // gets time stamp for the frames (fifo-style) "timestamp"; // gets time stamp for the frames (fifo-style)
"framescaught";// gets the entire frames caught by receiver "framescaught";// gets the entire frames caught by receiver

View File

@ -94,7 +94,7 @@ where: \\
\textit{v0} is the scan0 variable with the desired precision, if scan0 is enabled;\\ \textit{v0} is the scan0 variable with the desired precision, if scan0 is enabled;\\
\textit{v1} is the scan1 variable with the desired precision, if scan1 is enabled;\\ \textit{v1} is the scan1 variable with the desired precision, if scan1 is enabled;\\
\textit{p} is the position index, if different positions are configured;\\ \textit{p} is the position index, if different positions are configured;\\
\textit{f} is the frame index of the first frame stored in the file, if many frames and triggers are configured;\\ \textit{f} is the frame index of the first frame stored in the file, if many frames and cycles are configured;\\
\textit{i} is the file index;\\ \textit{i} is the file index;\\
\textit{ext} is the file extension e.g. \textit{.raw} for MYTHEN and \E raw data, \textit{.dat} for MYTHEN processed data. \textit{ext} is the file extension e.g. \textit{.raw} for MYTHEN and \E raw data, \textit{.dat} for MYTHEN processed data.
\item[index i] Sets the starting index of the file i at the beginning of the acquisition (automatically incremented for each measurement). \item[index i] Sets the starting index of the file i at the beginning of the acquisition (automatically incremented for each measurement).
@ -115,10 +115,10 @@ Sets the number of gates per frame in gated (stroboscopic) mode.\\
Refer to the detailed documentation to understand how the different timing modes work. Refer to the detailed documentation to understand how the different timing modes work.
\item[frames n] \item[frames n]
Sets the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). The frame index in the output file name will automatically be incremented.\\ Sets the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). The frame index in the output file name will automatically be incremented.\\
Note that the total number of images will be frames times triggers. Refer to detailed documentation to understand how the different timing modes work. Note that the total number of images will be frames times cycles. Refer to detailed documentation to understand how the different timing modes work.
\item[triggers n] \item[cycles n]
Sets the number of triggers (e.g. number of triggers). The frame index in the output file name will automatically be incremented. \\ Sets the number of cycles (e.g. number of triggers). The frame index in the output file name will automatically be incremented. \\
Note that the total number of images will be by frames times triggers. Refer to the detailed documentation to understand how the different timing modes work. Note that the total number of images will be by frames times cycles. Refer to the detailed documentation to understand how the different timing modes work.
\item[probes] Sets the number of probes to accumulate for stroboscopic measurements. \\ \item[probes] Sets the number of probes to accumulate for stroboscopic measurements. \\
Refer to detailed documentation to understand how the different timing modes work. Refer to detailed documentation to understand how the different timing modes work.
\item[measurements] Sets the number of repetitions of the acquisitions (non real time!). The file index in the file name will be automatically incremented.\\ \item[measurements] Sets the number of repetitions of the acquisitions (non real time!). The file index in the file name will be automatically incremented.\\
@ -231,7 +231,7 @@ It is normally recommended to use \verb=sls\_detector\_acquire [j-]=, which take
%\item[delayl] %\item[delayl]
%\item[gatesl] %\item[gatesl]
%\item[framesl] %\item[framesl]
%\item[triggersl] %\item[cyclesl]
%\item[frameindex] %\item[frameindex]
%\item[now] %\item[now]
\end{description} \end{description}
@ -430,11 +430,11 @@ Returns the number of gates per frame in gated (stroboscopic) mode.
Refer to detailed documentation to understand how the different timing modes work. Refer to detailed documentation to understand how the different timing modes work.
\item[frames] \item[frames]
Returns the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). Returned as a string to be interpreted as an integer ``frames integer'' Returns the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). Returned as a string to be interpreted as an integer ``frames integer''
Note that the total number of images is frames times triggers. Note that the total number of images is frames times cycles.
Refer to detailed documentation to understand how the different timing modes work. Refer to detailed documentation to understand how the different timing modes work.
\item[triggers n] \item[cycles n]
Returns the number of triggers (e.g. number of triggers). Returned as atring to be interpreted as an integer ``triggers integer'' Returns the number of cycles (e.g. number of triggers). Returned as atring to be interpreted as an integer ``cycles integer''
Note that the total number of images is frames times triggers. Note that the total number of images is frames times cycles.
Refer to detailed documentation to understand how the different timing modes work. Refer to detailed documentation to understand how the different timing modes work.
\item[probes] Returns the number of probes to accumulate for stroboscopic measurements. \item[probes] Returns the number of probes to accumulate for stroboscopic measurements.
Refer to detailed documentation to understand how the different timing modes work. Refer to detailed documentation to understand how the different timing modes work.
@ -556,7 +556,7 @@ It is normally recommended to use \verb=sls\_detector\_acquire [j-]=, which take
\item[delayl] Returns the delay after trigger left for the current frame. \item[delayl] Returns the delay after trigger left for the current frame.
\item[gatesl] Returns the number of gates left for the current frame. \item[gatesl] Returns the number of gates left for the current frame.
\item[framesl] Returns the number of frames left for the current cycle. \item[framesl] Returns the number of frames left for the current cycle.
\item[triggersl] Returns the number of triggers left for the current acquisition. \item[cyclesl] Returns the number of cycles left for the current acquisition.
\item[now] Returns the current timestamp of the detector clock. \item[now] Returns the current timestamp of the detector clock.
\item[timestamp] Returns the timestamp of the acquisitions in a First-In/First-Out mode i.e. every time it is called it returns the timestamp of the first acquisition start of readout. The FIFO is reset everytime the acquisition is started. \item[timestamp] Returns the timestamp of the acquisitions in a First-In/First-Out mode i.e. every time it is called it returns the timestamp of the first acquisition start of readout. The FIFO is reset everytime the acquisition is started.
\end{description} \end{description}

View File

@ -217,7 +217,7 @@ is used to configure the detector parameter var
\item[delay t] Sets the delay after trigger (in s) \item[delay t] Sets the delay after trigger (in s)
\item[gates n] Sets the number of gates per frame \item[gates n] Sets the number of gates per frame
\item[frames n] Sets the number of frames per cycle (e.g. after each trigger) \item[frames n] Sets the number of frames per cycle (e.g. after each trigger)
\item[triggers n] Sets the number of triggers (e.g. number of triggers) \item[cycles n] Sets the number of cycles (e.g. number of triggers)
\item[probes n] Sets the number of probes to accumulate (max 3) \item[probes n] Sets the number of probes to accumulate (max 3)
\item[dr n] Sets the dynamic range - can be (1,) 4, 8,16 or 24 bits \item[dr n] Sets the dynamic range - can be (1,) 4, 8,16 or 24 bits
\item[flags mode] Sets the readout flags - can be none or storeinram \item[flags mode] Sets the readout flags - can be none or storeinram
@ -298,7 +298,7 @@ is used to retrieve the detector parameter var
\item[delay] Gets the delay after trigger (in s) \item[delay] Gets the delay after trigger (in s)
\item[gates] Gets the number of gates per frame \item[gates] Gets the number of gates per frame
\item[frames] Gets the number of frames per cycle (e.g. after each trigger) \item[frames] Gets the number of frames per cycle (e.g. after each trigger)
\item[triggers] Gets the number of triggers (e.g. number of triggers) \item[cycles] Gets the number of cycles (e.g. number of triggers)
\item[probes] Gets the number of probes to accumulate (max 3) \item[probes] Gets the number of probes to accumulate (max 3)
\item[timestamp] Gets the internal time stamp of the nex frame acquired (i.e. during an acquisition, all timestamps of the frames are stored in a FIFO which can be read after the acquisition - returns -1 if the FIFO is empty) \item[timestamp] Gets the internal time stamp of the nex frame acquired (i.e. during an acquisition, all timestamps of the frames are stored in a FIFO which can be read after the acquisition - returns -1 if the FIFO is empty)
\item[dr] Gets the dynamic range \item[dr] Gets the dynamic range

View File

@ -372,7 +372,7 @@ gs 1 -1 sc (Number of frames) col0 sh gr
gs 1 -1 sc (Number of frames) col0 sh gr gs 1 -1 sc (Number of frames) col0 sh gr
/Times-Roman ff 450.00 scf sf /Times-Roman ff 450.00 scf sf
11325 9150 m 11325 9150 m
gs 1 -1 sc (Number of triggers) col0 sh gr gs 1 -1 sc (Number of cycles) col0 sh gr
/Times-Roman ff 240.00 scf sf /Times-Roman ff 240.00 scf sf
5325 4950 m 5325 4950 m
gs 1 -1 sc (Readout) col0 sh gr gs 1 -1 sc (Readout) col0 sh gr

View File

@ -118,7 +118,7 @@ Single
21900 2700 22050 2700 21900 2700 22050 2700
4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of triggers\001 4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of cycles\001
4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001 4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001
4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001 4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001
4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001 4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001

View File

@ -95,7 +95,7 @@ Single
4 0 0 50 0 0 30 0.0000 4 405 2580 9450 6600 Exposure time\001 4 0 0 50 0 0 30 0.0000 4 405 2580 9450 6600 Exposure time\001
4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of triggers\001 4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of cycles\001
4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001 4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001
4 0 0 50 0 0 30 0.0000 4 300 2565 1050 4125 Detection time\001 4 0 0 50 0 0 30 0.0000 4 300 2565 1050 4125 Detection time\001
4 0 0 50 0 0 30 0.0000 4 300 1785 1050 5550 Dead time\001 4 0 0 50 0 0 30 0.0000 4 300 1785 1050 5550 Dead time\001

View File

@ -341,7 +341,7 @@ gs 1 -1 sc (Number of frames) col0 sh gr
gs 1 -1 sc (Number of frames) col0 sh gr gs 1 -1 sc (Number of frames) col0 sh gr
/Times-Roman ff 450.00 scf sf /Times-Roman ff 450.00 scf sf
11325 9150 m 11325 9150 m
gs 1 -1 sc (Number of triggers) col0 sh gr gs 1 -1 sc (Number of cycles) col0 sh gr
/Times-Roman ff 240.00 scf sf /Times-Roman ff 240.00 scf sf
5325 4950 m 5325 4950 m
gs 1 -1 sc (Readout) col0 sh gr gs 1 -1 sc (Readout) col0 sh gr

View File

@ -79,7 +79,7 @@ Single
4200 5850 4650 5850 4200 5850 4650 5850
4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of triggers\001 4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of cycles\001
4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001 4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001
4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001 4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001
4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001 4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001

View File

@ -118,7 +118,7 @@ Single
21900 2700 22050 2700 21900 2700 22050 2700
4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of triggers\001 4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of cycles\001
4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001 4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001
4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001 4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001
4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001 4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001

View File

@ -401,7 +401,7 @@ gs 1 -1 sc (External trigger) col0 sh gr
gs 1 -1 sc (Number of frames) col0 sh gr gs 1 -1 sc (Number of frames) col0 sh gr
/Times-Roman ff 450.00 scf sf /Times-Roman ff 450.00 scf sf
12600 9150 m 12600 9150 m
gs 1 -1 sc (Number of triggers) col0 sh gr gs 1 -1 sc (Number of cycles) col0 sh gr
/Times-Roman ff 240.00 scf sf /Times-Roman ff 240.00 scf sf
6600 4950 m 6600 4950 m
gs 1 -1 sc (Readout) col0 sh gr gs 1 -1 sc (Readout) col0 sh gr

View File

@ -111,7 +111,7 @@ Single
4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001 4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001
4 0 0 50 0 0 30 0.0000 4 405 2760 825 2700 External trigger\001 4 0 0 50 0 0 30 0.0000 4 405 2760 825 2700 External trigger\001
4 0 0 50 0 0 30 0.0000 4 300 3225 8250 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 8250 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 405 3090 12600 9150 Number of triggers\001 4 0 0 50 0 0 30 0.0000 4 405 3090 12600 9150 Number of cycles\001
4 0 0 50 0 0 16 0.0000 4 165 810 6600 4950 Readout\001 4 0 0 50 0 0 16 0.0000 4 165 810 6600 4950 Readout\001
4 0 0 50 0 0 30 0.0000 4 405 2580 4575 6225 Exposure time\001 4 0 0 50 0 0 30 0.0000 4 405 2580 4575 6225 Exposure time\001
4 0 0 50 0 0 30 0.0000 4 300 1140 9525 6225 Period\001 4 0 0 50 0 0 30 0.0000 4 300 1140 9525 6225 Period\001

View File

@ -79,7 +79,7 @@ Single
4200 5850 4650 5850 4200 5850 4650 5850
4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 6975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001 4 0 0 50 0 0 30 0.0000 4 300 3225 15975 7800 Number of frames\001
4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of triggers\001 4 0 0 50 0 0 30 0.0000 4 405 3090 11325 9150 Number of cycles\001
4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001 4 0 0 50 0 0 16 0.0000 4 165 810 5325 4950 Readout\001
4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001 4 0 0 50 0 0 30 0.0000 4 300 2565 825 4125 Detection time\001
4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001 4 0 0 50 0 0 30 0.0000 4 300 1785 825 5550 Dead time\001

View File

@ -217,7 +217,7 @@ is used to configure the detector parameter var
\item[delay t] Sets the delay after trigger (in s) \item[delay t] Sets the delay after trigger (in s)
\item[gates n] Sets the number of gates per frame \item[gates n] Sets the number of gates per frame
\item[frames n] Sets the number of frames per cycle (e.g. after each trigger) \item[frames n] Sets the number of frames per cycle (e.g. after each trigger)
\item[triggers n] Sets the number of triggers (e.g. number of triggers) \item[cycles n] Sets the number of cycles (e.g. number of triggers)
\item[probes n] Sets the number of probes to accumulate (max 3) \item[probes n] Sets the number of probes to accumulate (max 3)
\item[dr n] Sets the dynamic range - can be (1,) 4, 8,16 or 24 bits \item[dr n] Sets the dynamic range - can be (1,) 4, 8,16 or 24 bits
\item[flags mode] Sets the readout flags - can be none or storeinram \item[flags mode] Sets the readout flags - can be none or storeinram
@ -298,7 +298,7 @@ is used to retrieve the detector parameter var
\item[delay] Gets the delay after trigger (in s) \item[delay] Gets the delay after trigger (in s)
\item[gates] Gets the number of gates per frame \item[gates] Gets the number of gates per frame
\item[frames] Gets the number of frames per cycle (e.g. after each trigger) \item[frames] Gets the number of frames per cycle (e.g. after each trigger)
\item[triggers] Gets the number of triggers (e.g. number of triggers) \item[cycles] Gets the number of cycles (e.g. number of triggers)
\item[probes] Gets the number of probes to accumulate (max 3) \item[probes] Gets the number of probes to accumulate (max 3)
\item[timestamp] Gets the internal time stamp of the nex frame acquired (i.e. during an acquisition, all timestamps of the frames are stored in a FIFO which can be read after the acquisition - returns -1 if the FIFO is empty) \item[timestamp] Gets the internal time stamp of the nex frame acquired (i.e. during an acquisition, all timestamps of the frames are stored in a FIFO which can be read after the acquisition - returns -1 if the FIFO is empty)
\item[dr] Gets the dynamic range \item[dr] Gets the dynamic range

View File

@ -127,7 +127,7 @@ where: \\
\textit{v0} is the scan0 variable with the desired precision, if scan0 is enabled;\\ \textit{v0} is the scan0 variable with the desired precision, if scan0 is enabled;\\
\textit{v1} is the scan1 variable with the desired precision, if scan1 is enabled;\\ \textit{v1} is the scan1 variable with the desired precision, if scan1 is enabled;\\
\textit{p} is the position index, if different positions are configured;\\ \textit{p} is the position index, if different positions are configured;\\
\textit{f} is the frame index of the first frame stored in the file, if many frames and triggers are configured;\\ \textit{f} is the frame index of the first frame stored in the file, if many frames and cycles are configured;\\
\textit{i} is the file index;\\ \textit{i} is the file index;\\
\textit{ext} is the file extension e.g. \textit{.raw} for MYTHEN raw data, \textit{.dat} for MYTHEN processed data. \textit{ext} is the file extension e.g. \textit{.raw} for MYTHEN raw data, \textit{.dat} for MYTHEN processed data.
@ -241,7 +241,7 @@ Figure~\ref{eq:acqflow} shows in which sequence the various scripts and loops ar
If you prefere to handle the acquisition from your acquisition enviroment, simply leave al scripts and scans disabled and call the acquition from your acquisition enviroment. \\ If you prefere to handle the acquisition from your acquisition enviroment, simply leave al scripts and scans disabled and call the acquition from your acquisition enviroment. \\
Only the frames and triggers loops are defined in firmware and guarantee a precise timing of the acquisition which cannot replaced by any other method (you can synchronize to your beamline by hardware connection of the IO signals as described in~\ref{sec:timing}). Only the frames and cycles loops are defined in firmware and guarantee a precise timing of the acquisition which cannot replaced by any other method (you can synchronize to your beamline by hardware connection of the IO signals as described in~\ref{sec:timing}).
Hereafter a description of the meaning of the various loops: Hereafter a description of the meaning of the various loops:
\begin{description} \begin{description}
@ -259,11 +259,11 @@ Hereafter a description of the meaning of the various loops:
The detector is moved in the angular positions specified by the positions command.\\ The detector is moved in the angular positions specified by the positions command.\\
The command for moving the detector should be defined as described in~\ref{sec:usersFunc}.\\ The command for moving the detector should be defined as described in~\ref{sec:usersFunc}.\\
All data acquired during a position loop will be merged together, unless the number of positions is set to 0. In this case single frames will be converted to angle without merging.\\ All data acquired during a position loop will be merged together, unless the number of positions is set to 0. In this case single frames will be converted to angle without merging.\\
Avoid using the position loop together with many frames/triggers. Avoid using the position loop together with many frames/cycles.
\item[Triggers loop] is executed in real time and defines e.g. the number of triggers that will be accepted. The total number of images will be given by frames times triggers. \item[Cycles loop] is executed in real time and defines e.g. the number of triggers that will be accepted. The total number of images will be given by frames times cycles.
\item[Frames loop] is executed in real time and defines e.g. the images acquired per trigger. The total number of images will be given by frames times triggers. \item[Frames loop] is executed in real time and defines e.g. the images acquired per trigger. The total number of images will be given by frames times cycles.
\end{description} \end{description}
Executing a script simply consists in a system call with the arguments specified below. The various scripts are executed only if they are enabled and different than \textit{none}. \\ Executing a script simply consists in a system call with the arguments specified below. The various scripts are executed only if they are enabled and different than \textit{none}. \\
@ -332,11 +332,11 @@ In the following is a list of the main parameters involved in the acquisition ti
\item[Period] is the period of the images acquired. If it is shorter than the exposure time plus readout time, it will be ignored. \item[Period] is the period of the images acquired. If it is shorter than the exposure time plus readout time, it will be ignored.
\item[Delay after trigger] can be set as a delay between the trigger signal and the start of the detection time. \item[Delay after trigger] can be set as a delay between the trigger signal and the start of the detection time.
\item[Number of gates] is used only in \textit{gating} mode and is the number of times that the gate is toggled before the detector is read out. Useful for stroboscopic measurements with gate period shorter than the minim acquisition period of the detector, otherwise can be left to 1. \item[Number of gates] is used only in \textit{gating} mode and is the number of times that the gate is toggled before the detector is read out. Useful for stroboscopic measurements with gate period shorter than the minim acquisition period of the detector, otherwise can be left to 1.
\item[Number of frames] is the number of images to be acquired per cycle. Frames and triggers have the same meaning except in trigger mode, when frames means the number of images per trigger. The total number of images is frames time triggers. \item[Number of frames] is the number of images to be acquired per cycle. Frames and cycles have the same meaning except in trigger mode, when frames means the number of images per trigger. The total number of images is frames time cycles.
\item[Number of triggers] is the number of times that the frames are acquired. Frames and triggers have the same meaning except in trigger mode, when triggers means the number of triggers that will be accepted. The total number of images is frames time triggers. \item[Number of cycles] is the number of times that the frames are acquired. Frames and cycles have the same meaning except in trigger mode, when cycles means the number of triggers that will be accepted. The total number of images is frames time cycles.
\item[Number of probes] is used in stoboscopic measurements when the period is longer than the minimum acquisition period, but shorter than the frame rate.\\ \item[Number of probes] is used in stoboscopic measurements when the period is longer than the minimum acquisition period, but shorter than the frame rate.\\
In this case the data can be summed in firmware. \\ In this case the data can be summed in firmware. \\
Currently it is implemented for Mythen only. If probes is set to 0, works normallyreturning an image for each readout, otherwise set number of triggers to 1. The maximum number of probes that can be set is 3. The detector will return a number of image equal to the number of probes, where all frames are going to be accumulated. The total number of readouts is number of frames time probes and for probes=1 the detector will return one image where all frames have been summed, for probes=2 two images where every second frame has been summed (each image accumulates the number of frames), for probes=3 three images where every third image has been summed (each image accumulates the number of frames).\\ Currently it is implemented for Mythen only. If probes is set to 0, works normallyreturning an image for each readout, otherwise set number of cycles to 1. The maximum number of probes that can be set is 3. The detector will return a number of image equal to the number of probes, where all frames are going to be accumulated. The total number of readouts is number of frames time probes and for probes=1 the detector will return one image where all frames have been summed, for probes=2 two images where every second frame has been summed (each image accumulates the number of frames), for probes=3 three images where every third image has been summed (each image accumulates the number of frames).\\
The returned images will always have 32~bit dynamic range, while the dynamic range if the detector defines the bit depth of the counters in rder to limit the readout time, if necessary.\\ The returned images will always have 32~bit dynamic range, while the dynamic range if the detector defines the bit depth of the counters in rder to limit the readout time, if necessary.\\
The probes counter waorks also in trigger and gating modes. The probes counter waorks also in trigger and gating modes.
\end{description} \end{description}
@ -349,14 +349,14 @@ The probes counter waorks also in trigger and gating modes.
\begin{center} \begin{center}
\includegraphics[width=\textwidth]{images/normal_acquisition.eps} \includegraphics[width=\textwidth]{images/normal_acquisition.eps}
\end{center} \end{center}
\caption{Auto timing: the detection time is defined by the exposure time and the period by period (if longer than exposure time plus readout time). The total number of images is frames (in the example 3) times triggers (in the example 2), and in this case there is no difference between the acquisition of the two.}\label{fig:autotiming} \caption{Auto timing: the detection time is defined by the exposure time and the period by period (if longer than exposure time plus readout time). The total number of images is frames (in the example 3) times cycles (in the example 2), and in this case there is no difference between the acquisition of the two.}\label{fig:autotiming}
\end{figure} \end{figure}
\begin{figure} \begin{figure}
\begin{center} \begin{center}
\includegraphics[width=\textwidth]{images/gated_acquisition.eps} \includegraphics[width=\textwidth]{images/gated_acquisition.eps}
\end{center} \end{center}
\caption{Gating mode: the detector acquires for a number of gates define by the user (in this case 4) before being read out, independently on the timing of the gates. The detector remains insensitive during the readout time and then starts being active again. External gates given during the readout time are ignored. The total number of images is frames (in the example 3) times triggers (in the example 2), and in this case there is no difference between the acquisition of the two. The polarity of the external gate signal can be defined by the user through the \textit{external signal flag} (in the example active high).}\label{fig:gating} \caption{Gating mode: the detector acquires for a number of gates define by the user (in this case 4) before being read out, independently on the timing of the gates. The detector remains insensitive during the readout time and then starts being active again. External gates given during the readout time are ignored. The total number of images is frames (in the example 3) times cycles (in the example 2), and in this case there is no difference between the acquisition of the two. The polarity of the external gate signal can be defined by the user through the \textit{external signal flag} (in the example active high).}\label{fig:gating}
\end{figure} \end{figure}
@ -365,7 +365,7 @@ The probes counter waorks also in trigger and gating modes.
\begin{center} \begin{center}
\includegraphics[width=\textwidth]{images/trigger_acquisition.eps} \includegraphics[width=\textwidth]{images/trigger_acquisition.eps}
\end{center} \end{center}
\caption{Trigger mode: the external trigger signal defines the start of the beginning of the acquisition, which starts after the delay set by the user. For each trigger, the number of frames is acquired (in the example 3) and all trigger signals ignored. The number of trigger accepted is given by the number of triggers (in the example 2). The polarity of the external trigger signal can be defined by the user through the \textit{external signal flag} (in the example rising edge).}\label{fig:trig} \caption{Trigger mode: the external trigger signal defines the start of the beginning of the acquisition, which starts after the delay set by the user. For each trigger, the number of frames is acquired (in the example 3) and all trigger signals ignored. The number of trigger accepted is given by the number of cycles (in the example 2). The polarity of the external trigger signal can be defined by the user through the \textit{external signal flag} (in the example rising edge).}\label{fig:trig}
\end{figure} \end{figure}
@ -373,7 +373,7 @@ The probes counter waorks also in trigger and gating modes.
\begin{center} \begin{center}
\includegraphics[width=\textwidth]{images/ro_trigger_acquisition.eps} \includegraphics[width=\textwidth]{images/ro_trigger_acquisition.eps}
\end{center} \end{center}
\caption{Read Out Trigger mode: the external trigger signal defines the beginning of the readout. The exposure time works as a time out for the waiting time for the trigger signal. The number of trigger accepted is given by the number of triggers (in the example 3) and it does not make sense to program more than one frame. The polarity of the external trigger signal can be defined by the user through the \textit{external signal flag} (in the example rising edge).}\label{fig:trig} \caption{Read Out Trigger mode: the external trigger signal defines the beginning of the readout. The exposure time works as a time out for the waiting time for the trigger signal. The number of trigger accepted is given by the number of cycles (in the example 3) and it does not make sense to program more than one frame. The polarity of the external trigger signal can be defined by the user through the \textit{external signal flag} (in the example rising edge).}\label{fig:trig}
\end{figure} \end{figure}

View File

@ -91,7 +91,7 @@ where: \\
\textit{v0} is the scan0 variable with the desired precision, if scan0 is enabled;\\ \textit{v0} is the scan0 variable with the desired precision, if scan0 is enabled;\\
\textit{v1} is the scan1 variable with the desired precision, if scan1 is enabled;\\ \textit{v1} is the scan1 variable with the desired precision, if scan1 is enabled;\\
\textit{p} is the position index, if different positions are configured;\\ \textit{p} is the position index, if different positions are configured;\\
\textit{f} is the frame index of the first frame stored in the file, if many frames and triggers are configured;\\ \textit{f} is the frame index of the first frame stored in the file, if many frames and cycles are configured;\\
\textit{i} is the file index;\\ \textit{i} is the file index;\\
\textit{ext} is the file extension e.g. \textit{.raw} for MYTHEN raw data, \textit{.dat} for MYTHEN processed data. \textit{ext} is the file extension e.g. \textit{.raw} for MYTHEN raw data, \textit{.dat} for MYTHEN processed data.
\item[index i] Sets the starting index of the file i at the beginning of the acquisition (automatically incremented for each measurement). \item[index i] Sets the starting index of the file i at the beginning of the acquisition (automatically incremented for each measurement).
@ -110,10 +110,10 @@ Sets the number of gates per frame in gated (stroboscopic) mode.\\
Refere to the detailed documentation to understand how the different timing modes work. Refere to the detailed documentation to understand how the different timing modes work.
\item[frames n] \item[frames n]
Sets the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). The frame index in the output file name will automatically be incremented.\\ Sets the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). The frame index in the output file name will automatically be incremented.\\
Note that the total number of images will be frames times triggers. Refere to detailed documentation to understand how the different timing modes work. Note that the total number of images will be frames times cycles. Refere to detailed documentation to understand how the different timing modes work.
\item[triggers n] \item[cycles n]
Sets the number of triggers (e.g. number of triggers). The frame index in the output file name will automatically be incremented. \\ Sets the number of cycles (e.g. number of triggers). The frame index in the output file name will automatically be incremented. \\
Note that the total number of images will be by frames times triggers. Refere to the detailed documentation to understand how the different timing modes work. Note that the total number of images will be by frames times cycles. Refere to the detailed documentation to understand how the different timing modes work.
\item[probes] Sets the number of probes to accumulate for stroboscopic measurements. \\ \item[probes] Sets the number of probes to accumulate for stroboscopic measurements. \\
Refere to detailed documentation to understand how the different timing modes work. Refere to detailed documentation to understand how the different timing modes work.
\item[measurements] Sets the number of repetitions of the acquisitions (non real time!). The file index in the file name will be automotically incremented.\\ \item[measurements] Sets the number of repetitions of the acquisitions (non real time!). The file index in the file name will be automotically incremented.\\
@ -234,7 +234,7 @@ It is normally reccomended to use \verb=sls\_detector\_acquire [j-]=, which take
%\item[delayl] %\item[delayl]
%\item[gatesl] %\item[gatesl]
%\item[framesl] %\item[framesl]
%\item[triggersl] %\item[cyclesl]
%\item[frameindex] %\item[frameindex]
%\item[now] %\item[now]
\end{description} \end{description}
@ -393,11 +393,11 @@ Returns the number of gates per frame in gated (stroboscopic) mode.
Refere to detailed documentation to understand how the different timing modes work. Refere to detailed documentation to understand how the different timing modes work.
\item[frames] \item[frames]
Returns the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode). Returns the number of frames acquired sequentially per cycle (e.g. after each trigger), with the exposure time defined by exptime and the period defined by period (unless in gated mode).
Note that the total number of images is frames times triggers. Note that the total number of images is frames times cycles.
Refere to detailed documentation to understand how the different timing modes work. Refere to detailed documentation to understand how the different timing modes work.
\item[triggers n] \item[cycles n]
Returns the number of triggers (e.g. number of triggers). Returns the number of cycles (e.g. number of triggers).
Note that the total number of images is frames times triggers. Note that the total number of images is frames times cycles.
Refere to detailed documentation to understand how the different timing modes work. Refere to detailed documentation to understand how the different timing modes work.
\item[probes] Returns the number of probes to accumulate for stroboscopic measurements. \item[probes] Returns the number of probes to accumulate for stroboscopic measurements.
Refere to detailed documentation to understand how the different timing modes work. Refere to detailed documentation to understand how the different timing modes work.
@ -518,7 +518,7 @@ It is normally reccomended to use \verb=sls\_detector\_acquire [j-]=, which take
\item[delayl] Returns the delay after trigger left for the current frame. \item[delayl] Returns the delay after trigger left for the current frame.
\item[gatesl] Returns the number of gates left for the current frame. \item[gatesl] Returns the number of gates left for the current frame.
\item[framesl] Returns the number of frames left for the current cycle. \item[framesl] Returns the number of frames left for the current cycle.
\item[triggersl] Returns the number of triggers left for the current acquisition. \item[cyclesl] Returns the number of cycles left for the current acquisition.
\item[now] Returns the current timestamp of the detector clock. \item[now] Returns the current timestamp of the detector clock.
\item[timestamp] Returns the timestamp of the acquisitions in a First-In/First-Out mode i.e. every time it is called it returns the timestamp of the first acquisition start of readout. The FIFO is reset everytime the acquisition is started. \item[timestamp] Returns the timestamp of the acquisitions in a First-In/First-Out mode i.e. every time it is called it returns the timestamp of the first acquisition start of readout. The FIFO is reset everytime the acquisition is started.
\end{description} \end{description}

View File

@ -217,7 +217,7 @@ is used to configure the detector parameter var
\item[delay t] Sets the delay after trigger (in s) \item[delay t] Sets the delay after trigger (in s)
\item[gates n] Sets the number of gates per frame \item[gates n] Sets the number of gates per frame
\item[frames n] Sets the number of frames per cycle (e.g. after each trigger) \item[frames n] Sets the number of frames per cycle (e.g. after each trigger)
\item[triggers n] Sets the number of triggers (e.g. number of triggers) \item[cycles n] Sets the number of cycles (e.g. number of triggers)
\item[probes n] Sets the number of probes to accumulate (max 3) \item[probes n] Sets the number of probes to accumulate (max 3)
\item[dr n] Sets the dynamic range - can be (1,) 4, 8,16 or 24 bits \item[dr n] Sets the dynamic range - can be (1,) 4, 8,16 or 24 bits
\item[flags mode] Sets the readout flags - can be none or storeinram \item[flags mode] Sets the readout flags - can be none or storeinram
@ -298,7 +298,7 @@ is used to retrieve the detector parameter var
\item[delay] Gets the delay after trigger (in s) \item[delay] Gets the delay after trigger (in s)
\item[gates] Gets the number of gates per frame \item[gates] Gets the number of gates per frame
\item[frames] Gets the number of frames per cycle (e.g. after each trigger) \item[frames] Gets the number of frames per cycle (e.g. after each trigger)
\item[triggers] Gets the number of triggers (e.g. number of triggers) \item[cycles] Gets the number of cycles (e.g. number of triggers)
\item[probes] Gets the number of probes to accumulate (max 3) \item[probes] Gets the number of probes to accumulate (max 3)
\item[timestamp] Gets the internal time stamp of the nex frame acquired (i.e. during an acquisition, all timestamps of the frames are stored in a FIFO which can be read after the acquisition - returns -1 if the FIFO is empty) \item[timestamp] Gets the internal time stamp of the nex frame acquired (i.e. during an acquisition, all timestamps of the frames are stored in a FIFO which can be read after the acquisition - returns -1 if the FIFO is empty)
\item[dr] Gets the dynamic range \item[dr] Gets the dynamic range

View File

@ -2,10 +2,11 @@
pybind11_add_module(_sls_detector pybind11_add_module(_sls_detector
src/main.cpp src/main.cpp
src/enums.cpp src/enums.cpp
src/detector.cpp src/experimental.cpp
src/network.cpp
) )
target_link_libraries(_sls_detector PUBLIC target_link_libraries(_sls_detector PUBLIC
slsDetectorShared slsDetectorShared
slsReceiverShared slsReceiverShared
@ -28,9 +29,9 @@ set( PYTHON_FILES
detector.py detector.py
eiger.py eiger.py
errors.py errors.py
ctb.py experimental.py
jungfrau_ctb.py
jungfrau.py jungfrau.py
mythen3.py
registers.py registers.py
utils.py utils.py
@ -46,6 +47,3 @@ endforeach(FILE ${PYTHON_FILES})
configure_file( scripts/basic.py configure_file( scripts/basic.py
${CMAKE_BINARY_DIR}/basic.py ${CMAKE_BINARY_DIR}/basic.py
) )
configure_file( scripts/test_virtual.py
${CMAKE_BINARY_DIR}/test_virtual.py
)

View File

@ -2,14 +2,11 @@ import os
import sys import sys
import numpy as np import numpy as np
sys.path.append(os.path.join(os.getcwd(), 'bin')) sys.path.append(os.path.join(os.getcwd(), 'bin'))
from sls_detector import Eiger, Detector
from sls_detector import ExperimentalDetector
from sls_detector import Detector, Mythen3, Eiger, Jungfrau, DetectorDacs, Dac, Ctb from _sls_detector.io import read_my302_file
from sls_detector import dacIndex
d = Detector() d = Detector()
# e = Eiger() e = ExperimentalDetector()
# c = Ctb()
# j = Jungfrau()
m = Mythen3()

View File

@ -1,25 +0,0 @@
import subprocess
import locale
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
cmd = out.stdout.splitlines()
cmd.pop(0)
from sls_detector import Detector, Eiger, Ctb
pycmd = dir(Detector)+dir(Eiger)+dir(Ctb)
pycmd += ['vrf', 'vtr', 'vrs', 'vtgstv', 'vsvn', 'vtrim',
'vsvp', 'vth1', 'vth2', 'vth3', 'vshaper', 'vshaperneg', 'rxb_rb',
'rxb_lb', 'vref_prech', 'vref_restore', 'vref_cds',
'vpreamp', 'vref_comp', 'vref_comp_fe vref_ds', 'vref_h_adc',
'vref_l_adc', 'iodelay', 'list', 'vref_ds', 'vis', 'vpl',
'vref_comp_fe', 'vph', 'vout_cm', 'vcp', 'vcn', 'vcmp_ll', 'vcmp_lr'
, 'vcmp_rl', 'vcmp_rr']
missing = []
for c in cmd:
if c not in pycmd:
print(c)
missing.append(c)
print(f'Missing: {len(missing)} commands')

View File

@ -1,77 +0,0 @@
"""
Code generator for enum bindings in the Python extension.
Reads the sls_detector_defs.h and enums_in.cpp then outputs
enums.cpp
"""
import re
import subprocess
# def remove_comments(text):
# def replacer(match):
# s = match.group(0)
# if s.startswith('/'):
# return " " # note: a space and not an empty string
# else:
# return s
# pattern = re.compile(
# r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
# re.DOTALL | re.MULTILINE
# )
# return re.sub(pattern, replacer, text)
def extract_enums(lines):
line_iter = iter(lines)
enums = {}
for line in line_iter:
m = re.search("(?<=enum )\w+(?= {)", line)
if m:
enum_name = m.group()
# print(enum_name)
fields = []
while True:
l = next(line_iter)
if '};' in l:
break
m = re.search("\w+", l)
try:
# print('\t', m.group())
fields.append(m.group())
except:
pass
enums[enum_name] = fields
return enums
def generate_enum_string(enums):
data = []
for key, value in enums.items():
data.append(f'py::enum_<slsDetectorDefs::{key}>(Defs, "{key}")\n')
for v in value:
data.append(f'\t.value("{v}", slsDetectorDefs::{key}::{v})\n')
data.append('.export_values();\n\n')
return ''.join(data)
with open('../../slsSupportLib/include/sls_detector_defs.h') as f:
data = f.read()
data = remove_comments(data)
data = data.splitlines()
enums = extract_enums(data)
s = generate_enum_string(enums)
with open('../src/enums_in.cpp') as f:
data = f.read()
text = data.replace('[[ENUMS]]', s)
warning = '/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n'
with open('../src/enums.cpp', 'w') as f:
f.write(warning)
f.write(text)
# run clang format on the output
subprocess.run(['clang-format', '../src/enums.cpp', '-i'])

View File

@ -1,84 +0,0 @@
"""
This file is used to auto generate Python bindings for the
sls::Detector class. The tool needs the libclang bindings
to be installed.
When the Detector API is updated this file should be run
manually
"""
from clang import cindex
import subprocess
import argparse
from parse import system_include_paths
default_build_path = "/home/l_frojdh/sls/build/"
fpath = "../../slsDetectorSoftware/src/Detector.cpp"
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--build_path", help="Path to the build database", type = str, default=default_build_path)
cargs = parser.parse_args()
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
index = cindex.Index.create()
args = db.getCompileCommands(fpath)
args = list(iter(args).__next__().arguments)[0:-1]
args = args + "-x c++ --std=c++11".split()
syspath = system_include_paths('clang++')
incargs = ["-I" + inc for inc in syspath]
args = args + incargs
tu = index.parse(fpath, args=args)
m = []
ag = []
lines = []
def get_arguments(node):
args = [a.type.spelling for a in node.get_arguments()]
args = [
"py::arg() = Positions{}" if item == "sls::Positions" else "py::arg()"
for item in args
]
args = ', '.join(args)
if args:
args = f', {args}'
return args
def visit(node):
if node.kind == cindex.CursorKind.CLASS_DECL:
if node.displayname == "Detector":
for child in node.get_children():
if (
child.kind == cindex.CursorKind.CXX_METHOD
and child.access_specifier == cindex.AccessSpecifier.PUBLIC
):
m.append(child)
args = get_arguments(child)
lines.append(f'.def(\"{child.spelling}\", &Detector::{child.spelling}{args})')
for child in node.get_children():
visit(child)
visit(tu.cursor)
with open('../src/detector_in.cpp') as f:
data = f.read()
s = ''.join(lines)
s += ';'
text = data.replace('[[FUNCTIONS]]', s)
warning = '/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n'
with open('../src/detector.cpp', 'w') as f:
f.write(warning)
f.write(text)
# run clang format on the output
subprocess.run(['clang-format', '../src/detector.cpp', '-i'])

View File

@ -1,56 +0,0 @@
import parse
from pathlib import Path
import os
import locale
import argparse
path = Path('../../slsDetectorSoftware/tests/')
import subprocess
parser = argparse.ArgumentParser()
parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None)
args = parser.parse_args()
files = [f for f in os.listdir(path) if 'CmdProxy' in f]
tested = []
for fname in files:
with open(path/fname) as f:
data = f.read()
data = parse.remove_comments(data)
data = data.splitlines()
for line in data:
if 'TEST_CASE' in line or 'SECTION' in line:
cmd = line.split("\"")[1]
tested.append(cmd)
out = subprocess.run(['g', 'list'], stdout = subprocess.PIPE, encoding=locale.getpreferredencoding())
all_cmd = out.stdout.splitlines()
all_cmd.pop(0)
if args.startswith is not None:
all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)]
tested = [cmd for cmd in tested if cmd.startswith(args.startswith)]
not_tested = [cmd for cmd in all_cmd if cmd not in tested]
misnamed = [cmd for cmd in tested if cmd not in all_cmd]
tested = [cmd for cmd in tested if cmd in all_cmd]
print("\nThe following commands are tested:")
for cmd in tested:
print(cmd)
print("\nThe following commands are NOT tested:")
for cmd in not_tested:
print(cmd)
print(f"\nThe following {len(misnamed)} tests does not match commands and might be misnamed:")
for cmd in misnamed:
print(cmd)
print(f'\nTests cover {len(tested)} of {len(all_cmd)} commands')

View File

@ -1,56 +0,0 @@
import re
import subprocess
from subprocess import PIPE
import os
def remove_comments(text):
def replacer(match):
s = match.group(0)
if s.startswith('/'):
return " " # note: a space and not an empty string
else:
return s
pattern = re.compile(
r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"',
re.DOTALL | re.MULTILINE
)
return re.sub(pattern, replacer, text)
#based on ccsyspath: https://github.com/AndrewWalker/ccsyspath
def compiler_preprocessor_verbose(compiler, extraflags):
"""Capture the compiler preprocessor stage in verbose mode
"""
lines = []
with open(os.devnull, 'r', encoding='utf-8') as devnull:
cmd = [compiler, '-E']
cmd += extraflags
cmd += ['-', '-v']
p = subprocess.Popen(cmd, stdin=devnull, stdout=PIPE, stderr=PIPE)
p.wait()
lines = p.stderr.read()
lines = lines.splitlines()
return lines
def system_include_paths(compiler, cpp=True):
extraflags = []
if cpp:
extraflags = b'-x c++'.split()
lines = compiler_preprocessor_verbose(compiler, extraflags)
lines = [ line.strip() for line in lines ]
start = lines.index(b'#include <...> search starts here:')
end = lines.index(b'End of search list.')
lines = lines[start+1:end]
paths = []
for line in lines:
line = line.replace(b'(framework directory)', b'')
line = line.strip()
paths.append(line)
paths = [p.decode('utf-8') for p in paths]
return paths

View File

@ -1,164 +0,0 @@
import pytest
import subprocess
import os
import sys
import time
import datetime as dt
sys.path.append(os.path.join(os.getcwd(), "bin"))
from sls_detector import ExperimentalDetector, detectorSettings
n_detectors = 3
start_port = 1952
port_step = 3
@pytest.fixture(scope="module")
def virtual_jf_detectors(request):
"""
Fixture that is run once for the module
will launch virtual servers and clean up
after
"""
print("Setting up virtual detectors")
# Ensure that no detector servers are running
subprocess.run(["killall", "jungfrauDetectorServer_virtual"])
# Ensure no shared memory exists before tests start
d = ExperimentalDetector()
d.free()
# Start servers
virtual_jf_detectors = [
subprocess.Popen(
[
"bin/jungfrauDetectorServer_virtual",
"--port",
f"{start_port+port_step*i}",
]
)
for i in range(n_detectors)
]
# Allow server startup to complete
time.sleep(3)
def fin():
print("Cleaning up virtual detectors")
d = ExperimentalDetector()
d.free()
subprocess.run(["killall", "jungfrauDetectorServer_virtual"])
request.addfinalizer(fin)
return virtual_jf_detectors # provide the fixture value
def test_shmid(virtual_jf_detectors):
d = ExperimentalDetector()
assert d.getShmId() == 0
d.free()
d = ExperimentalDetector(73)
assert d.getShmId() == 73
d.free()
def test_hostname(virtual_jf_detectors):
d = ExperimentalDetector()
d.hostname = "localhost"
assert d.hostname == ["localhost"]
d.hostname = [f"localhost:{start_port+i*port_step}" for i in range(n_detectors)]
assert d.hostname == ["localhost"] * n_detectors
def test_fwversion(virtual_jf_detectors):
d = ExperimentalDetector()
assert d.detectorversion == 0 # Firmware of virtual detector
assert d.getFirmwareVersion() == [0] * n_detectors
def test_len(virtual_jf_detectors):
d = ExperimentalDetector()
assert len(d) == n_detectors
assert d.size() == n_detectors
def test_module_geometry(virtual_jf_detectors):
d = ExperimentalDetector()
geo = d.module_geometry
assert geo.x == 1
assert geo.y == 3
def test_module_size(virtual_jf_detectors):
d = ExperimentalDetector()
geo = d.module_size
assert geo.x == 1024
assert geo.y == 512
def test_settings(virtual_jf_detectors):
d = ExperimentalDetector()
assert d.settings == detectorSettings.DYNAMICGAIN
gain_list = [
detectorSettings.FIXGAIN1,
detectorSettings.FIXGAIN2,
detectorSettings.FORCESWITCHG1,
detectorSettings.FORCESWITCHG2,
detectorSettings.DYNAMICHG0,
detectorSettings.DYNAMICGAIN,
]
# Set all viable gain for Jungfrau to make sure nothing is crashing
for gain in gain_list:
d.settings = gain
assert d.settings == gain
d.setSettings(detectorSettings.FORCESWITCHG1, [1])
assert d.settings == [
detectorSettings.DYNAMICGAIN,
detectorSettings.FORCESWITCHG1,
detectorSettings.DYNAMICGAIN,
]
d.settings = detectorSettings.DYNAMICGAIN
assert d.settings == detectorSettings.DYNAMICGAIN
def test_frames(virtual_jf_detectors):
d = ExperimentalDetector()
d.frames = 10
assert d.frames == 10
# def test_triggers(virtual_jf_detectors):
def test_exptime(virtual_jf_detectors):
d = ExperimentalDetector()
#default value
assert d.exptime == 1e-5
d.exptime = 1.5
assert d.exptime == 1.5
t = dt.timedelta(microseconds=10)
d.exptime = t
assert d.exptime == 10e-6
def test_period(virtual_jf_detectors):
d = ExperimentalDetector()
#default value
d.period = 0
assert d.period == 0
d.period = 1.5
assert d.period == 1.5
t = dt.timedelta(microseconds=10)
d.period = t
assert d.period == 10e-6

View File

@ -38,8 +38,7 @@ ext_modules = [
'_sls_detector', '_sls_detector',
['src/main.cpp', ['src/main.cpp',
'src/enums.cpp', 'src/enums.cpp',
'src/detector.cpp', 'src/experimental.cpp'],
'src/network.cpp'],
include_dirs=[ include_dirs=[
# Path to pybind11 headers # Path to pybind11 headers
get_pybind_include(), get_pybind_include(),

View File

@ -1,22 +1,9 @@
# from .detector import Detector, DetectorError, free_shared_memory from .detector import Detector, DetectorError, free_shared_memory
from .eiger import Eiger from .eiger import Eiger
from .ctb import Ctb from .experimental import ExperimentalDetector
from .dacs import DetectorDacs, Dac
from .detector import Detector
from .jungfrau import Jungfrau from .jungfrau import Jungfrau
from .mythen3 import Mythen3 from .jungfrau_ctb import JungfrauCTB
# from .jungfrau_ctb import JungfrauCTB from _sls_detector import DetectorApi
# from _sls_detector import DetectorApi
import _sls_detector import _sls_detector
defs = _sls_detector.slsDetectorDefs
runStatus = _sls_detector.slsDetectorDefs.runStatus runStatus = _sls_detector.slsDetectorDefs.runStatus
speedLevel = _sls_detector.slsDetectorDefs.speedLevel
timingMode = _sls_detector.slsDetectorDefs.timingMode
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
detectorType = _sls_detector.slsDetectorDefs.detectorType
detectorSettings = _sls_detector.slsDetectorDefs.detectorSettings
IpAddr = _sls_detector.IpAddr
MacAddr = _sls_detector.MacAddr

View File

@ -1,121 +0,0 @@
from .detector import Detector
from .utils import element_if_equal
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
class CtbDacs(DetectorDacs):
"""
Ctb dacs
"""
_dacs = [('dac0', dacIndex(0), 0, 4000, 1400),
('dac1', dacIndex(1), 0, 4000, 1200),
('dac2', dacIndex(2), 0, 4000, 900),
('dac3', dacIndex(3), 0, 4000, 1050),
('dac4', dacIndex(4), 0, 4000, 1400),
('dac5', dacIndex(5), 0, 4000, 655),
('dac6', dacIndex(6), 0, 4000, 2000),
('dac7', dacIndex(7), 0, 4000, 1400),
('dac8', dacIndex(8), 0, 4000, 850),
('dac9', dacIndex(9), 0, 4000, 2000),
('dac10', dacIndex(10), 0, 4000, 2294),
('dac11', dacIndex(11), 0, 4000, 983),
('dac12', dacIndex(12), 0, 4000, 1475),
('dac13', dacIndex(13), 0, 4000, 1200),
('dac14', dacIndex(14), 0, 4000, 1600),
('dac15', dacIndex(15), 0, 4000, 1455),
('dac16', dacIndex(16), 0, 4000, 0),
('dac17', dacIndex(17), 0, 4000, 1000),
]
_dacnames = [_d[0] for _d in _dacs]
from .utils import element
class Ctb(Detector):
def __init__(self, id = 0):
super().__init__(id)
self._frozen = False
self._dacs = CtbDacs(self)
@property
def dacs(self):
return self._dacs
@property
@element
def v_a(self):
return self.getDAC(dacIndex.V_POWER_A, True)
@v_a.setter
def v_a(self, value):
self.setDAC(dacIndex.V_POWER_A, value, True)
@property
@element
def v_b(self):
return self.getDAC(dacIndex.V_POWER_B, True)
@v_b.setter
def v_b(self, value):
self.setDAC(dacIndex.V_POWER_B, value, True)
@property
@element
def v_c(self):
return self.getDAC(dacIndex.V_POWER_C, True)
@v_c.setter
def v_c(self, value):
self.setDAC(dacIndex.V_POWER_C, value, True)
@property
@element
def v_d(self):
return self.getDAC(dacIndex.V_POWER_D, True)
@v_d.setter
def v_d(self, value):
self.setDAC(dacIndex.V_POWER_D, value, True)
@property
@element
def v_io(self):
return self.getDAC(dacIndex.V_POWER_IO, True)
@v_io.setter
def v_io(self, value):
self.setDAC(dacIndex.V_POWER_IO, value, True)
@property
@element
def v_limit(self):
return self.getDAC(dacIndex.V_LIMIT, True)
@v_limit.setter
def v_limit(self, value):
self.setDAC(dacIndex.V_LIMIT, value, True)
@property
@element
def im_a(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_A)
@property
@element
def im_b(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_B)
@property
@element
def im_c(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_C)
@property
@element
def im_d(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_D)
@property
@element
def im_io(self):
return self.getMeasuredCurrent(dacIndex.I_POWER_IO)

View File

@ -1,9 +1,7 @@
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
from functools import partial from functools import partial
import numpy as np import numpy as np
import _sls_detector
from .detector import freeze
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
class Dac(DetectorProperty): class Dac(DetectorProperty):
""" """
This class represents a dac on the detector. One instance handles all This class represents a dac on the detector. One instance handles all
@ -16,11 +14,11 @@ class Dac(DetectorProperty):
""" """
def __init__(self, name, enum, low, high, default, detector): def __init__(self, name, low, high, default, detector):
super().__init__(partial(detector.getDAC, enum, False), super().__init__(partial(detector._api.getDac, name),
lambda x, y : detector.setDAC(enum, x, False, y), partial(detector._api.setDac, name),
detector.size, detector._api.getNumberOfDetectors,
name) name)
self.min_value = low self.min_value = low
@ -31,16 +29,30 @@ class Dac(DetectorProperty):
def __repr__(self): def __repr__(self):
"""String representation for a single dac in all modules""" """String representation for a single dac in all modules"""
dacstr = ''.join([f'{item:5d}' for item in self.get()]) r_str = ['{:10s}: '.format(self.__name__)]
return f'{self.__name__:10s}:{dacstr}' r_str += ['{:5d}, '.format(self.get(i)) for i in range(self.get_nmod())]
return ''.join(r_str).strip(', ')
# a = Dac('vrf', dacIndex.VRF, 0, 4000, 2500, d )
# @freeze
class DetectorDacs: class DetectorDacs:
_dacs = [] _dacs = [('vsvp', 0, 4000, 0),
('vtr', 0, 4000, 2500),
('vrf', 0, 4000, 3300),
('vrs', 0, 4000, 1400),
('vsvn', 0, 4000, 4000),
('vtgstv', 0, 4000, 2556),
('vcmp_ll', 0, 4000, 1500),
('vcmp_lr', 0, 4000, 1500),
('vcall', 0, 4000, 4000),
('vcmp_rl', 0, 4000, 1500),
('rxb_rb', 0, 4000, 1100),
('rxb_lb', 0, 4000, 1100),
('vcmp_rr', 0, 4000, 1500),
('vcp', 0, 4000, 200),
('vcn', 0, 4000, 2000),
('vis', 0, 4000, 1550),
('iodelay', 0, 4000, 660)]
_dacnames = [_d[0] for _d in _dacs] _dacnames = [_d[0] for _d in _dacs]
_allowed_attr = ['_detector', '_current']
_frozen = False
def __init__(self, detector): def __init__(self, detector):
# We need to at least initially know which detector we are connected to # We need to at least initially know which detector we are connected to
@ -53,8 +65,6 @@ class DetectorDacs:
for _d in self._dacs: for _d in self._dacs:
setattr(self, '_'+_d[0], Dac(*_d, detector)) setattr(self, '_'+_d[0], Dac(*_d, detector))
self._frozen = True
def __getattr__(self, name): def __getattr__(self, name):
return self.__getattribute__('_' + name) return self.__getattribute__('_' + name)
@ -63,11 +73,8 @@ class DetectorDacs:
if name in self._dacnames: if name in self._dacnames:
return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value) return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
else: else:
if self._frozen == True and name not in self._allowed_attr:
raise AttributeError(f'Dac not found: {name}')
super().__setattr__(name, value) super().__setattr__(name, value)
def __next__(self): def __next__(self):
if self._current >= len(self._dacs): if self._current >= len(self._dacs):
self._current = 0 self._current = 0
@ -88,7 +95,7 @@ class DetectorDacs:
""" """
Read the dacs into a numpy array with dimensions [ndacs, nmodules] Read the dacs into a numpy array with dimensions [ndacs, nmodules]
""" """
dac_array = np.zeros((len(self._dacs), len(self._detector))) dac_array = np.zeros((len(self._dacs), self._detector.n_modules))
for i, _d in enumerate(self): for i, _d in enumerate(self):
dac_array[i,:] = _d[:] dac_array[i,:] = _d[:]
return dac_array return dac_array
@ -108,3 +115,11 @@ class DetectorDacs:
for _d in self: for _d in self:
_d[:] = _d.default _d[:] = _d.default
def update_nmod(self):
"""
Update the cached value of nmod, needs to be run after adding or
removing detectors
"""
for _d in self:
_d._n_modules = self._detector.n_modules

File diff suppressed because it is too large Load Diff

View File

@ -14,20 +14,21 @@ class DetectorProperty:
def __getitem__(self, key): def __getitem__(self, key):
if key == slice(None, None, None): if key == slice(None, None, None):
return self.get() return [self.get(i) for i in range(self.get_nmod())]
elif isinstance(key, Iterable): elif isinstance(key, Iterable):
return self.get(list(key)) return [self.get(k) for k in key]
else: else:
return self.get([key])[0] #No list for single value return self.get(key)
def __setitem__(self, key, value): def __setitem__(self, key, value):
#operate on all values #operate on all values
if key == slice(None, None, None): if key == slice(None, None, None):
if isinstance(value, (np.integer, int)): if isinstance(value, (np.integer, int)):
self.set(value, []) for i in range(self.get_nmod()):
self.set(i, value)
elif isinstance(value, Iterable): elif isinstance(value, Iterable):
for i in range(self.get_nmod()): for i in range(self.get_nmod()):
self.set(value[i], [i]) self.set(i, value[i])
else: else:
raise ValueError('Value should be int or np.integer not', type(value)) raise ValueError('Value should be int or np.integer not', type(value))
@ -35,14 +36,15 @@ class DetectorProperty:
elif isinstance(key, Iterable): elif isinstance(key, Iterable):
if isinstance(value, Iterable): if isinstance(value, Iterable):
for k,v in zip(key, value): for k,v in zip(key, value):
self.set(v, [k]) self.set(k,v)
elif isinstance(value, int): elif isinstance(value, int):
self.set(value, list(key)) for k in key:
self.set(k, value)
#Set single value #Set single value
elif isinstance(key, int): elif isinstance(key, int):
self.set(value, [key]) self.set(key, value)
def __repr__(self): def __repr__(self):
s = ', '.join(str(v) for v in self[:]) s = ', '.join(str(v) for v in self[:])

View File

@ -6,16 +6,17 @@ Created on Wed Dec 6 11:51:18 2017
@author: l_frojdh @author: l_frojdh
""" """
import socket
from collections.abc import Iterable
from collections import namedtuple
from functools import partial
from .detector import Detector from .adcs import Adc, DetectorAdcs
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs from .dacs import DetectorDacs
import _sls_detector from .detector import Detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty from .detector_property import DetectorProperty
# from .utils import element_if_equal from .utils import element_if_equal
# from sls_detector.errors import DetectorValueError, DetectorError from sls_detector.errors import DetectorValueError, DetectorError
class EigerVcmp: class EigerVcmp:
""" """
@ -29,20 +30,20 @@ class EigerVcmp:
""" """
def __init__(self, detector): def __init__(self, detector):
_dacs = [ dacIndex.VCMP_LL, _names = ['vcmp_ll',
dacIndex.VCMP_LR, 'vcmp_lr',
dacIndex.VCMP_RL, 'vcmp_rl',
dacIndex.VCMP_RR] 'vcmp_rr']
self.set = [] self.set = []
self.get = [] self.get = []
for i in range(detector.size()): for i in range(detector.n_modules):
if i % 2 == 0: if i % 2 == 0:
dacs = _dacs name = _names
else: else:
dacs = _dacs[::-1] name = _names[::-1]
for d in dacs: for n in name:
self.set.append(lambda x, d=d, i=i : detector.setDAC(d, x, False, [i])) self.set.append(partial(detector._api.setDac, n, i))
self.get.append(lambda d=d, i=i : detector.getDAC(d, False, [i])[0]) self.get.append(partial(detector._api.getDac, n, i))
def __getitem__(self, key): def __getitem__(self, key):
if key == slice(None, None, None): if key == slice(None, None, None):
@ -57,84 +58,80 @@ class EigerVcmp:
class EigerDacs(DetectorDacs): class EigerDacs(DetectorDacs):
""" _dacs = [('vsvp', 0, 4000, 0),
Eiger specific dacs ('vtr', 0, 4000, 2500),
""" ('vrf', 0, 4000, 3300),
_dacs = [('vsvp', dacIndex.SVP,0, 4000, 0), ('vrs', 0, 4000, 1400),
('vtr', dacIndex.VTR,0, 4000, 2500), ('vsvn', 0, 4000, 4000),
('vrf', dacIndex.VRF,0, 4000, 3300), ('vtgstv', 0, 4000, 2556),
('vrs', dacIndex.VRS,0, 4000, 1400), ('vcmp_ll', 0, 4000, 1500),
('vsvn', dacIndex.SVN,0, 4000, 4000), ('vcmp_lr', 0, 4000, 1500),
('vtgstv', dacIndex.VTGSTV,0, 4000, 2556), ('vcall', 0, 4000, 4000),
('vcmp_ll', dacIndex.VCMP_LL,0, 4000, 1500), ('vcmp_rl', 0, 4000, 1500),
('vcmp_lr', dacIndex.VCMP_LR,0, 4000, 1500), ('rxb_rb', 0, 4000, 1100),
('vcall', dacIndex.CAL,0, 4000, 4000), ('rxb_lb', 0, 4000, 1100),
('vcmp_rl', dacIndex.VCMP_RL,0, 4000, 1500), ('vcmp_rr', 0, 4000, 1500),
('rxb_rb', dacIndex.RXB_RB,0, 4000, 1100), ('vcp', 0, 4000, 200),
('rxb_lb', dacIndex.RXB_LB,0, 4000, 1100), ('vcn', 0, 4000, 2000),
('vcmp_rr', dacIndex.VCMP_RR,0, 4000, 1500), ('vis', 0, 4000, 1550),
('vcp', dacIndex.VCP,0, 4000, 200), ('iodelay', 0, 4000, 660)]
('vcn', dacIndex.VCN,0, 4000, 2000),
('vis', dacIndex.VIS,0, 4000, 1550),
('iodelay', dacIndex.IO_DELAY,0, 4000, 660)]
_dacnames = [_d[0] for _d in _dacs] _dacnames = [_d[0] for _d in _dacs]
# # noinspection PyProtectedMember
# class DetectorDelays:
# _delaynames = ['frame', 'left', 'right']
# def __init__(self, detector): # noinspection PyProtectedMember
# # We need to at least initially know which detector we are connected to class DetectorDelays:
# self._detector = detector _delaynames = ['frame', 'left', 'right']
# setattr(self, '_frame', DetectorProperty(detector._api.getDelayFrame, def __init__(self, detector):
# detector._api.setDelayFrame, # We need to at least initially know which detector we are connected to
# detector._api.getNumberOfDetectors, self._detector = detector
# 'frame'))
# setattr(self, '_left', DetectorProperty(detector._api.getDelayLeft, setattr(self, '_frame', DetectorProperty(detector._api.getDelayFrame,
# detector._api.setDelayLeft, detector._api.setDelayFrame,
# detector._api.getNumberOfDetectors, detector._api.getNumberOfDetectors,
# 'left')) 'frame'))
# setattr(self, '_right', DetectorProperty(detector._api.getDelayRight, setattr(self, '_left', DetectorProperty(detector._api.getDelayLeft,
# detector._api.setDelayRight, detector._api.setDelayLeft,
# detector._api.getNumberOfDetectors, detector._api.getNumberOfDetectors,
# 'right')) 'left'))
# # Index to support iteration
# self._current = 0
# def __getattr__(self, name): setattr(self, '_right', DetectorProperty(detector._api.getDelayRight,
# return self.__getattribute__('_' + name) detector._api.setDelayRight,
detector._api.getNumberOfDetectors,
'right'))
# Index to support iteration
self._current = 0
# def __setattr__(self, name, value): def __getattr__(self, name):
# if name in self._delaynames: return self.__getattribute__('_' + name)
# return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
# else:
# super().__setattr__(name, value)
# def __next__(self): def __setattr__(self, name, value):
# if self._current >= len(self._delaynames): if name in self._delaynames:
# self._current = 0 return self.__getattribute__('_' + name).__setitem__(slice(None, None, None), value)
# raise StopIteration else:
# else: super().__setattr__(name, value)
# self._current += 1
# return self.__getattr__(self._delaynames[self._current-1])
# def __iter__(self): def __next__(self):
# return self if self._current >= len(self._delaynames):
self._current = 0
raise StopIteration
else:
self._current += 1
return self.__getattr__(self._delaynames[self._current-1])
# def __repr__(self): def __iter__(self):
# hn = self._detector.hostname return self
# r_str = ['Transmission delay [ns]\n'
# '{:11s}{:>8s}{:>8s}{:>8s}'.format('', 'left', 'right', 'frame')] def __repr__(self):
# for i in range(self._detector.n_modules): hn = self._detector.hostname
# r_str.append('{:2d}:{:8s}{:>8d}{:>8d}{:>8d}'.format(i, hn[i], self.left[i], self.right[i], self.frame[i])) r_str = ['Transmission delay [ns]\n'
# return '\n'.join(r_str) '{:11s}{:>8s}{:>8s}{:>8s}'.format('', 'left', 'right', 'frame')]
for i in range(self._detector.n_modules):
r_str.append('{:2d}:{:8s}{:>8d}{:>8d}{:>8d}'.format(i, hn[i], self.left[i], self.right[i], self.frame[i]))
return '\n'.join(r_str)
from .detector import freeze
@freeze
class Eiger(Detector): class Eiger(Detector):
""" """
Subclassing Detector to set up correct dacs and detector specific Subclassing Detector to set up correct dacs and detector specific
@ -148,80 +145,79 @@ class Eiger(Detector):
def __init__(self, id=0): def __init__(self, id=0):
super().__init__(id) super().__init__(id)
self._frozen = False
self._dacs = EigerDacs(self) self._active = DetectorProperty(self._api.getActive,
self._api.setActive,
self._api.getNumberOfDetectors,
'active')
self._vcmp = EigerVcmp(self) self._vcmp = EigerVcmp(self)
self._dacs = EigerDacs(self)
self._trimbit_limits = namedtuple('trimbit_limits', ['min', 'max'])(0, 63)
self._delay = DetectorDelays(self)
# self._active = DetectorProperty(self.getActive, # Eiger specific adcs
# self.setActive, self._temp = DetectorAdcs()
# self.size, self._temp.fpga = Adc('temp_fpga', self)
# 'active') self._temp.fpgaext = Adc('temp_fpgaext', self)
self._temp.t10ge = Adc('temp_10ge', self)
self._temp.dcdc = Adc('temp_dcdc', self)
self._temp.sodl = Adc('temp_sodl', self)
self._temp.sodr = Adc('temp_sodr', self)
self._temp.fpgafl = Adc('temp_fpgafl', self)
self._temp.fpgafr = Adc('temp_fpgafr', self)
# self._trimbit_limits = namedtuple('trimbit_limits', ['min', 'max'])(0, 63) @property
# self._delay = DetectorDelays(self) def active(self):
"""
Is the detector active? Can be used to enable or disable a detector
module
# # Eiger specific adcs Examples
# self._temp = DetectorAdcs() ----------
# self._temp.fpga = Adc('temp_fpga', self)
# self._temp.fpgaext = Adc('temp_fpgaext', self)
# self._temp.t10ge = Adc('temp_10ge', self)
# self._temp.dcdc = Adc('temp_dcdc', self)
# self._temp.sodl = Adc('temp_sodl', self)
# self._temp.sodr = Adc('temp_sodr', self)
# self._temp.fpgafl = Adc('temp_fpgafl', self)
# self._temp.fpgafr = Adc('temp_fpgafr', self)
# @property ::
# def active(self):
# """
# Is the detector active? Can be used to enable or disable a detector
# module
# Examples d.active
# ---------- >> active: [True, True]
# :: d.active[1] = False
>> active: [True, False]
"""
return self._active
# d.active @active.setter
# >> active: [True, True] def active(self, value):
self._active[:] = value
# d.active[1] = False @property
# >> active: [True, False] def measured_period(self):
# """ return self._api.getMeasuredPeriod()
# return self._active
# @active.setter @property
# def active(self, value): def measured_subperiod(self):
# self._active[:] = value return self._api.getMeasuredSubPeriod()
# @property @property
# def measured_period(self): def add_gappixels(self):
# return self._api.getMeasuredPeriod() """Enable or disable the (virual) pixels between ASICs
# @property Examples
# def measured_subperiod(self): ----------
# return self._api.getMeasuredSubPeriod()
# @property ::
# def add_gappixels(self):
# """Enable or disable the (virual) pixels between ASICs
# Examples d.add_gappixels = True
# ----------
# :: d.add_gappixels
>> True
# d.add_gappixels = True """
return self._api.getGapPixels()
# d.add_gappixels @add_gappixels.setter
# >> True def add_gappixels(self, value):
self._api.setGapPixels(value)
# """
# return self._api.getGapPixels()
# @add_gappixels.setter
# def add_gappixels(self, value):
# self._api.setGapPixels(value)
@property @property
def dacs(self): def dacs(self):
@ -284,68 +280,114 @@ class Eiger(Detector):
""" """
return self._dacs return self._dacs
# @property @property
# def tx_delay(self): def tx_delay(self):
# """ """
# Transmission delay of the modules to allow running the detector Transmission delay of the modules to allow running the detector
# in a network not supporting the full speed of the detector. in a network not supporting the full speed of the detector.
# :: ::
# d.tx_delay d.tx_delay
# >> >>
# Transmission delay [ns] Transmission delay [ns]
# left right frame left right frame
# 0:beb048 0 15000 0 0:beb048 0 15000 0
# 1:beb049 100 190000 100 1:beb049 100 190000 100
# d.tx_delay.left = [2000,5000] d.tx_delay.left = [2000,5000]
# """ """
# return self._delay return self._delay
# def pulse_all_pixels(self, n): def default_settings(self):
# """ """
# Pulse each pixel of the chip **n** times using the analog test pulses. reset the detector to some type of standard settings
# The pulse height is set using d.dacs.vcall with 4000 being 0 and 0 being mostly used when testing
# the highest pulse. """
self.n_frames = 1
self.exposure_time = 1
self.period = 0
self.n_cycles = 1
self.n_measurements = 1
self.dynamic_range = 16
# :: @property
def eiger_matrix_reset(self):
"""
Matrix reset bit for Eiger.
# #Pulse all pixels ten times :py:obj:`True` : Normal operation, the matrix is reset before each acq.
# d.pulse_all_pixels(10) :py:obj:`False` : Matrix reset disabled. Used to not reset before
reading out analog test pulses.
"""
return self._api.getCounterBit()
# #Avoid resetting before acq @eiger_matrix_reset.setter
# d.eiger_matrix_reset = False def eiger_matrix_reset(self, value):
self._api.setCounterBit(value)
# d.acq() #take frame @property
def flowcontrol_10g(self):
"""
:py:obj:`True` - Flow control enabled :py:obj:`False` flow control disabled.
Sets for all moduels, if for some reason access to a single module is needed
this can be done trough the C++ API.
# #Restore normal behaviour """
# d.eiger_matrix_reset = True fc = self._api.getNetworkParameter('flow_control_10g')
return element_if_equal([bool(int(e)) for e in fc])
@flowcontrol_10g.setter
def flowcontrol_10g(self, value):
if value is True:
v = '1'
else:
v = '0'
self._api.setNetworkParameter('flow_control_10g', v, -1)
def pulse_all_pixels(self, n):
"""
Pulse each pixel of the chip **n** times using the analog test pulses.
The pulse height is set using d.dacs.vcall with 4000 being 0 and 0 being
the highest pulse.
::
#Pulse all pixels ten times
d.pulse_all_pixels(10)
#Avoid resetting before acq
d.eiger_matrix_reset = False
d.acq() #take frame
#Restore normal behaviour
d.eiger_matrix_reset = True
# """ """
# self._api.pulseAllPixels(n) self._api.pulseAllPixels(n)
# def pulse_diagonal(self, n): def pulse_diagonal(self, n):
# """ """
# Pulse pixels in super colums in a diagonal fashion. Used for calibration Pulse pixels in super colums in a diagonal fashion. Used for calibration
# of vcall. Saves time compared to pulsing all pixels. of vcall. Saves time compared to pulsing all pixels.
# """ """
# self._api.pulseDiagonal(n) self._api.pulseDiagonal(n)
# def pulse_chip(self, n): def pulse_chip(self, n):
# """ """
# Advance the counter by toggling enable. Gives 2*n+2 int the counter Advance the counter by toggling enable. Gives 2*n+2 int the counter
# """ """
# n = int(n) n = int(n)
# if n >= -1: if n >= -1:
# self._api.pulseChip(n) self._api.pulseChip(n)
# else: else:
# raise ValueError('n must be equal or larger than -1') raise ValueError('n must be equal or larger than -1')
@property @property
def vcmp(self): def vcmp(self):
@ -378,99 +420,177 @@ class Eiger(Detector):
else: else:
raise ValueError('vcmp only compatible with setting all') raise ValueError('vcmp only compatible with setting all')
# @property @property
# def rx_udpport(self): def rx_udpport(self):
# """ """
# UDP port for the receiver. Each module has two ports referred to UDP port for the receiver. Each module has two ports referred to
# as rx_udpport and rx_udpport2 in the command line interface as rx_udpport and rx_udpport2 in the command line interface
# here they are grouped for each detector here they are grouped for each detector
# :: ::
# [0:rx_udpport, 0:rx_udpport2, 1:rx_udpport ...] [0:rx_udpport, 0:rx_udpport2, 1:rx_udpport ...]
# Examples Examples
# ----------- -----------
# :: ::
# d.rx_udpport d.rx_udpport
# >> [50010, 50011, 50004, 50005] >> [50010, 50011, 50004, 50005]
# d.rx_udpport = [50010, 50011, 50012, 50013] d.rx_udpport = [50010, 50011, 50012, 50013]
# """ """
# p0 = self._api.getReceiverUDPPort() p0 = self._api.getReceiverUDPPort()
# p1 = self._api.getReceiverUDPPort2() p1 = self._api.getReceiverUDPPort2()
# return [int(val) for pair in zip(p0, p1) for val in pair] return [int(val) for pair in zip(p0, p1) for val in pair]
# @rx_udpport.setter @rx_udpport.setter
# def rx_udpport(self, ports): def rx_udpport(self, ports):
# """Requires iterating over elements two and two for setting ports""" """Requires iterating over elements two and two for setting ports"""
# a = iter(ports) a = iter(ports)
# for i, p in enumerate(zip(a, a)): for i, p in enumerate(zip(a, a)):
# self._api.setReceiverUDPPort(p[0], i) self._api.setReceiverUDPPort(p[0], i)
# self._api.setReceiverUDPPort2(p[1], i) self._api.setReceiverUDPPort2(p[1], i)
@property @property
def rx_zmqport(self): def rx_zmqport(self):
""" """
Return the receiver zmq ports. Note that Eiger has two ports per receiver! Return the receiver zmq ports. Note that Eiger has two ports per receiver!
This functions therefore differ from the base class.
:: ::
e.rx_zmqport detector.rx_zmqport
>> [30001, 30002, 30003, 30004] >> [30001, 30002, 30003, 30004]
""" """
ports = self.getRxZmqPort() _s = self._api.getReceiverStreamingPort()
return [p + i for p in ports for i in range(2)] if _s == '':
return []
else:
return [int(_p) + i for _p in _s for i in range(2)]
@rx_zmqport.setter
def rx_zmqport(self, port):
if isinstance(port, Iterable):
for i, p in enumerate(port):
self._api.setReceiverStreamingPort(p, i)
else:
self._api.setReceiverStreamingPort(port, -1)
# @rx_zmqport.setter @property
# def rx_zmqport(self, port): def sub_exposure_time(self):
# if isinstance(port, Iterable): """
# for i, p in enumerate(port): Sub frame exposure time in *seconds* for Eiger in 32bit autosumming mode
# self._api.setReceiverStreamingPort(p, i)
# else:
# self._api.setReceiverStreamingPort(port, -1)
# @property ::
# def temp(self):
# """
# An instance of DetectorAdcs used to read the temperature
# of different components
# Examples d.sub_exposure_time
# ----------- >> 0.0023
# :: d.sub_exposure_time = 0.002
# detector.temp """
# >> return self._api.getSubExposureTime() / 1e9
# temp_fpga : 36.90°C, 45.60°C
# temp_fpgaext : 31.50°C, 32.50°C
# temp_10ge : 0.00°C, 0.00°C
# temp_dcdc : 36.00°C, 36.00°C
# temp_sodl : 33.00°C, 34.50°C
# temp_sodr : 33.50°C, 34.00°C
# temp_fpgafl : 33.81°C, 30.93°C
# temp_fpgafr : 27.88°C, 29.15°C
# a = detector.temp.fpga[:]
# a
# >> [36.568, 45.542]
# """ @sub_exposure_time.setter
# return self._temp def sub_exposure_time(self, t):
#TODO! checking here or in the detector?
ns_time = int(t * 1e9)
if ns_time > 0:
self._api.setSubExposureTime(ns_time)
else:
raise DetectorValueError('Sub exposure time must be larger than 0')
@property
def sub_deadtime(self):
"""
Deadtime between subexposures. Used to mimize noise by delaying the start of the next
subexposure.
"""
return self._api.getSubExposureDeadTime() / 1e9
@sub_deadtime.setter
def sub_deadtime(self, t):
ns_time = int(t * 1e9)
if ns_time >= 0:
self._api.setSubExposureDeadTime(ns_time)
else:
raise ValueError('Sub deadtime time must be larger or equal to 0')
# def set_delays(self, delta): @property
# self.tx_delay.left = [delta*(i*2) for i in range(self.n_modules)] def temp(self):
# self.tx_delay.right = [delta*(i*2+1) for i in range(self.n_modules)] """
An instance of DetectorAdcs used to read the temperature
of different components
Examples
-----------
::
detector.temp
>>
temp_fpga : 36.90°C, 45.60°C
temp_fpgaext : 31.50°C, 32.50°C
temp_10ge : 0.00°C, 0.00°C
temp_dcdc : 36.00°C, 36.00°C
temp_sodl : 33.00°C, 34.50°C
temp_sodr : 33.50°C, 34.00°C
temp_fpgafl : 33.81°C, 30.93°C
temp_fpgafr : 27.88°C, 29.15°C
a = detector.temp.fpga[:]
a
>> [36.568, 45.542]
"""
return self._temp
@property
def tengiga(self):
"""Enable 10Gbit/s data output
Examples
----------
::
d.tengiga
>> False
d.tengiga = True
"""
return self._api.getTenGigabitEthernet()
@tengiga.setter
def tengiga(self, value):
self._api.setTenGigabitEthernet(value)
def set_delays(self, delta):
self.tx_delay.left = [delta*(i*2) for i in range(self.n_modules)]
self.tx_delay.right = [delta*(i*2+1) for i in range(self.n_modules)]
def setup500k(self, hostnames):
"""
Setup the Eiger detector to run on the local machine
"""
self.hostname = hostnames
self.file_write = False
self.image_size = (512, 1024)
self.rx_tcpport = [1954, 1955]
self.rx_udpport = [50010, 50011, 50004, 50005]
self.rx_hostname = socket.gethostname().split('.')[0]
self.rx_datastream = False
self.file_write = False
self.online = True
self.receiver_online = True

View File

@ -0,0 +1,180 @@
from _sls_detector import multiDetectorApi
from _sls_detector import slsDetectorDefs
runStatus = slsDetectorDefs.runStatus
from .utils import element_if_equal, all_equal
import datetime as dt
from functools import wraps
def freeze(cls):
cls.__frozen = False
def frozensetattr(self, key, value):
if self.__frozen and not hasattr(self, key):
raise AttributeError(
"Class {} is frozen. Cannot set {} = {}".format(
cls.__name__, key, value
)
)
else:
object.__setattr__(self, key, value)
def init_decorator(func):
@wraps(func)
def wrapper(self, *args, **kwargs):
func(self, *args, **kwargs)
self.__frozen = True
return wrapper
cls.__setattr__ = frozensetattr
cls.__init__ = init_decorator(cls.__init__)
return cls
@freeze
class ExperimentalDetector(multiDetectorApi):
"""
This class is the base for detector specific
interfaces. Most functions exists in two versions
like the getExptime() function that uses the
C++ API directly and the simplified exptime property.
"""
def __init__(self, multi_id = 0):
"""
multi_id refers to the shared memory id of the
slsDetectorPackage. Default value is 0.
"""
super().__init__(multi_id)
# Acq
@property
def rx_status(self):
"""
Read the status of the receiver
"""
return element_if_equal(self.getReceiverStatus())
@rx_status.setter
def rx_status(self, status_str):
if status_str == "start":
self.startReceiver()
elif status_str == "stop":
self.stopReceiver()
else:
raise NotImplementedError("Unknown argument to rx_status")
@property
def busy(self):
"""
Checks if the detector is acquiring. Can also be set but should only be used if the acquire fails and
leaves the detector with busy == True
.. note ::
Only works when the measurement is launched using acquire, not with status start!
Returns
--------
bool
:py:obj:`True` if the detector is acquiring otherwise :py:obj:`False`
Examples
----------
::
d.busy
>> True
#If the detector is stuck reset by:
d.busy = False
"""
return self.getAcquiringFlag()
@busy.setter
def busy(self, value):
self.setAcquiringFlag(value)
# Configuration
@property
def startingfnum(self):
return element_if_equal(self.getStartingFrameNumber())
@startingfnum.setter
def startingfnum(self, value):
self.setStartingFrameNumber(value)
@property
def config(self):
return NotImplementedError("config is set only")
@config.setter
def config(self, fname):
self.setConfig(fname)
# File
@property
def fname(self):
return element_if_equal(self.getFileName())
@fname.setter
def fname(self, file_name):
self.setFileName(file_name)
@property
def fpath(self):
return element_if_equal(self.getFilePath())
@fpath.setter
def fpath(self, path):
self.setFilePath(path)
@property
def fwrite(self):
return element_if_equal(self.getFileWrite())
@fwrite.setter
def fwrite(self, value):
self.setFileWrite(value)
@property
def foverwrite(self):
return element_if_equal(self.getFileOverWrite())
@foverwrite.setter
def foverwrite(self, value):
self.setFileOverWrite(value)
# Time
@property
def exptime(self):
res = self.getExptime()
return element_if_equal([it.total_seconds() for it in res])
@exptime.setter
def exptime(self, t):
self.setExptime(dt.timedelta(seconds=t))
@property
def subexptime(self):
res = self.getSubExptime()
return element_if_equal([it.total_seconds() for it in res])
@subexptime.setter
def subexptime(self, t):
self.setSubExptime(dt.timedelta(seconds=t))
@property
def period(self):
res = self.getPeriod()
return element_if_equal([it.total_seconds() for it in res])
@period.setter
def period(self, t):
self.setPeriod(dt.timedelta(seconds=t))

271
python/sls_detector/jungfrau.py Normal file → Executable file
View File

@ -1,54 +1,259 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
This file contains the specialization for the Jungfrau detector Jungfrau detector class and support functions.
Inherits from Detector.
""" """
from .adcs import Adc, DetectorAdcs
from .detector import Detector
from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs from .dacs import DetectorDacs
import _sls_detector from .utils import element_if_equal
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# @freeze
class JungfrauDacs(DetectorDacs): class JungfrauDacs(DetectorDacs):
""" _dacs = [('vb_comp', 0, 4000, 1220),
Jungfrau specific DACs ('vdd_prot', 0, 4000, 3000),
""" ('vin_com', 0, 4000, 1053),
_dacs = [('vb_comp', dacIndex.VB_COMP, 0, 4000, 1220), ('vref_prech', 0, 4000, 1450),
('vdd_prot', dacIndex.VDD_PROT, 0, 4000, 3000), ('vb_pixbuff', 0, 4000, 750),
('vin_com', dacIndex.VIN_COM, 0, 4000, 1053), ('vb_ds', 0, 4000, 1000),
('vref_prech', dacIndex.VREF_PRECH, 0, 4000, 1450), ('vref_ds', 0, 4000, 480),
('vb_pixbuff', dacIndex.VB_PIXBUF, 0, 4000, 750), ('vref_comp', 0, 4000, 420),
('vb_ds', dacIndex.VB_DS, 0, 4000, 1000),
('vref_ds', dacIndex.VREF_DS, 0, 4000, 480),
('vref_comp', dacIndex.VREF_COMP, 0, 4000, 420),
] ]
_dacnames = [_d[0] for _d in _dacs] _dacnames = [_d[0] for _d in _dacs]
@freeze
class Jungfrau(Detector): class Jungfrau(Detector):
""" """
Subclassing Detector to set up correct dacs and detector specific Class used to control a Jungfrau detector. Inherits from the Detector class but a specialized
functions. class is needed to provide the correct dacs and unique functions.
""" """
_detector_dynamic_range = [4, 8, 16, 32] _detector_dynamic_range = [4, 8, 16, 32]
_settings = ['dynamichg0',
'dynamicgain',
'fixgain1',
'fixgain2',
'forceswitchg1',
'forceswitchg2']
"""Available settings for Jungfrau"""
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain'] def __init__(self, multi_id=0):
"""available settings for Eiger, note almost always standard""" #Init on base calss
super().__init__(multi_id)
def __init__(self, id=0):
super().__init__(id)
self._frozen = False
self._dacs = JungfrauDacs(self) self._dacs = JungfrauDacs(self)
#Jungfrau specific temps, this can be reduced to a single value?
self._temp = DetectorAdcs()
self._temp.fpga = Adc('temp_fpga', self)
# self._register = Register(self)
@property @property
def dacs(self): def dacs(self):
"""
An instance of DetectorDacs used for accessing the dacs of a single
or multi detector.
Examples
---------
::
#Jungfrau
"""
return self._dacs return self._dacs
@property
def power_chip(self):
"""Power on or off the ASICs, True for on False for off"""
return self._api.isChipPowered()
@power_chip.setter
def power_chip(self, value):
self._api.powerChip(value)
@property
def delay(self):
"""Delay after trigger [s]"""
return self._api.getDelay()/1e9
@delay.setter
def delay(self, t):
ns_time = int(t * 1e9)
self._api.setDelay(ns_time)
@property
def n_gates(self):
return self._api.getNumberOfGates()
@n_gates.setter
def n_gates(self, n):
self._api.setNumberOfGates(n)
@property
def n_probes(self):
return self._api.getNumberOfProbes()
@n_probes.setter
def n_probes(self, n):
self._api.setNumberOfProbes(n)
@property
def storagecell_start(self):
"""
First storage cell
"""
return self._api.getStoragecellStart()
@storagecell_start.setter
def storagecell_start(self, value):
self._api.setStoragecellStart(value)
@property
def n_storagecells(self):
"""
number of storage cells used for the measurements
"""
return self._api.getNumberOfStorageCells()
@n_storagecells.setter
def n_storagecells(self, value):
self._api.setNumberOfStorageCells(value)
@property
def temp(self):
"""
An instance of DetectorAdcs used to read the temperature
of different components
Examples
-----------
::
detector.temp
>>
temp_fpga : 36.90°C, 45.60°C
a = detector.temp.fpga[:]
a
>> [36.568, 45.542]
"""
return self._temp
@property
def temperature_threshold(self):
"""Threshold for switching of chips"""
return self._api.getThresholdTemperature()
@temperature_threshold.setter
def temperature_threshold(self, t):
self._api.setThresholdTemperature(t)
@property
def temperature_control(self):
"""
Monitor the temperature of the detector and switch off chips if temperature_threshold is
crossed
Examples
---------
::
#activate
detector.temperature_control = True
#deactivate
detector.temperature_control = False
"""
return self._api.getTemperatureControl()
@temperature_control.setter
def temperature_control(self, v):
self._api.setTemperatureControl(v)
@property
def temperature_event(self):
"""Have the temperature threshold been crossed?
Returns
---------
:py:obj:`True` if the threshold have been crossed and temperature_control is active
otherwise :py:obj:`False`
"""
return self._api.getTemperatureEvent()
def reset_temperature_event(self):
"""Reset the temperature_event. After reset temperature_event is False"""
self._api.resetTemperatureEvent()
@property
def rx_udpport(self):
"""
UDP port for the receiver. Each module have one port.
Note! Eiger has two ports
::
[0:rx_udpport]
Examples
-----------
::
d.rx_udpport
>> [50010]
d.rx_udpport = [50010]
"""
return self._api.getNetworkParameter('rx_udpport')
@rx_udpport.setter
def rx_udpport(self, ports):
"""Requires iterating over elements two and two for setting ports"""
for i, p in enumerate(ports):
self._api.setNetworkParameter('rx_udpport', str(p), i)
@property
def detector_mac(self):
s = self._api.getNetworkParameter('detectormac')
return element_if_equal(s)
@detector_mac.setter
def detector_mac(self, mac):
if isinstance(mac, list):
for i, m in enumerate(mac):
self._api.setNetworkParameter('detectormac', m, i)
else:
self._api.setNetworkParameter('detectormac', mac, -1)
@property
def detector_ip(self):
s = self._api.getNetworkParameter('detectorip')
return element_if_equal(s)
@detector_ip.setter
def detector_ip(self, ip):
if isinstance(ip, list):
for i, addr in enumerate(ip):
self._api.setNetworkParameter('detectorip', addr, i)
else:
self._api.setNetworkParameter('detectorip', ip, -1)

View File

@ -0,0 +1,178 @@
from functools import partial
from collections.abc import Iterable
from collections import namedtuple
import socket
from .detector import Detector
from .utils import element_if_equal
from .adcs import DetectorAdcs, Adc
from .dacs import DetectorDacs
from .detector_property import DetectorProperty
from .registers import Register, Adc_register
class JungfrauCTBDacs(DetectorDacs):
_dacs = [('dac0', 0, 4000, 1400),
('dac1', 0, 4000, 1200),
('dac2', 0, 4000, 900),
('dac3', 0, 4000, 1050),
('dac4', 0, 4000, 1400),
('dac5', 0, 4000, 655),
('dac6', 0, 4000, 2000),
('dac7', 0, 4000, 1400),
('dac8', 0, 4000, 850),
('dac9', 0, 4000, 2000),
('dac10', 0, 4000, 2294),
('dac11', 0, 4000, 983),
('dac12', 0, 4000, 1475),
('dac13', 0, 4000, 1200),
('dac14', 0, 4000, 1600),
('dac15', 0, 4000, 1455),
('dac16', 0, 4000, 0),
('dac17', 0, 4000, 1000),
]
_dacnames = [_d[0] for _d in _dacs]
class JungfrauCTB(Detector):
def __init__(self, id = 0):
super().__init__(id)
self._dacs = JungfrauCTBDacs(self)
self._register = Register(self)
self._adc_register = Adc_register(self)
@property
def v_a(self):
return self._api.getDac_mV('v_a', -1)
@v_a.setter
def v_a(self, value):
self._api.setDac_mV('v_a', -1, value)
@property
def v_b(self):
return self._api.getDac_mV('v_b', -1)
@v_b.setter
def v_b(self, value):
self._api.setDac_mV('v_b', -1, value)
@property
def v_c(self):
return self._api.getDac_mV('v_c', -1)
@v_c.setter
def v_c(self, value):
self._api.setDac_mV('v_c', -1, value)
@property
def v_d(self):
return self._api.getDac_mV('v_d', -1)
@v_d.setter
def v_d(self, value):
self._api.setDac_mV('v_d', -1, value)
@property
def v_io(self):
return self._api.getDac_mV('v_io', -1)
@v_io.setter
def v_io(self, value):
self._api.setDac_mV('v_io', -1, value)
@property
def v_limit(self):
return self._api.getDac_mV('v_limit', -1)
@v_limit.setter
def v_limit(self, value):
self._api.setDac_mV('v_limit', -1, value)
@property
def adc_register(self):
return self._adc_register
# @property
# def register(self):
# return self._register
def adcOFF(self):
"""Switch off the ADC"""
self.adc_register[0x8] = 1
@property
def dacs(self):
"""
An instance of DetectorDacs used for accessing the dacs of a single
or multi detector.
Examples
---------
::
#JungfrauCTB
"""
return self._dacs
@property
def dbitpipeline(self):
return self._api.getDbitPipeline()
@dbitpipeline.setter
def dbitpipeline(self, value):
self._api.setDbitPipeline(value)
@property
def dbitphase(self):
return self._api.getDbitPhase()
@dbitphase.setter
def dbitphase(self, value):
self._api.setDbitPhase(value)
@property
def dbitclock(self):
return self._api.getDbitClock()
@dbitclock.setter
def dbitclock(self, value):
self._api.setDbitClock(value)
@property
def samples(self):
return self._api.getJCTBSamples()
@samples.setter
def samples(self, value):
self._api.setJCTBSamples(value)
@property
def readout_clock(self):
"""
Speed of the readout clock relative to the full speed
Examples
---------
::
"""
return self._api.getReadoutClockSpeed()
@readout_clock.setter
def readout_clock(self, value):
self._api.setReadoutClockSpeed(value)

View File

@ -1,80 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This file contains the specialization for the Jungfrau detector
"""
from .detector import Detector, freeze
# from .adcs import Adc, DetectorAdcs
from .dacs import DetectorDacs
import _sls_detector
dacIndex = _sls_detector.slsDetectorDefs.dacIndex
from .detector_property import DetectorProperty
# vcassh 1200,
# vth2 2800,
# vshaper 1280,
# vshaperneg 2800,
# vipre_out 1220,
# vth3 2800,
# vth1 2800,
# vicin 1708,
# vcas 1800,
# vpreamp 1100,
# vpl 1100,
# vipre 2624,
# viinsh 1708,
# vph 1712,
# vtrim 2800,
# vdcsh 800
# @freeze
class Mythen3Dacs(DetectorDacs):
"""
Jungfrau specific DACs
"""
_dacs = [('vcassh', dacIndex.CASSH, 0, 4000, 1220),
('vth2', dacIndex.VTH2, 0, 4000, 2800),
('vshaper', dacIndex.SHAPER1, 0, 4000, 1280),
('vshaperneg', dacIndex.SHAPER2, 0, 4000, 2800),
('vipre_out', dacIndex.VIPRE_OUT, 0, 4000, 1220),
('vth3', dacIndex.VTH3, 0, 4000, 2800),
('vth1', dacIndex.THRESHOLD, 0, 4000, 2800),
('vicin', dacIndex.VICIN, 0, 4000, 1708),
('vcas', dacIndex.CAS, 0, 4000, 1800),
('vpreamp', dacIndex.PREAMP, 0, 4000, 1100),
('vpl', dacIndex.VPL, 0, 4000, 1100),
('vipre', dacIndex.VIPRE, 0, 4000, 2624),
('viinsh', dacIndex.VIINSH, 0, 4000, 1708),
('vph', dacIndex.CALIBRATION_PULSE, 0, 4000, 1712),
('vtrim', dacIndex.TRIMBIT_SIZE, 0, 4000, 2800),
('vdcsh', dacIndex.VDCSH, 0, 4000, 800),
]
_dacnames = [_d[0] for _d in _dacs]
@freeze
class Mythen3(Detector):
"""
Subclassing Detector to set up correct dacs and detector specific
functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['standard', 'highgain', 'lowgain', 'veryhighgain', 'verylowgain']
"""available settings for Eiger, note almost always standard"""
def __init__(self, id=0):
super().__init__(id)
self._frozen = False
self._dacs = Mythen3Dacs(self)
@property
def dacs(self):
return self._dacs

View File

@ -3,17 +3,14 @@ class Register:
self._detector = detector self._detector = detector
def __getitem__(self, key): def __getitem__(self, key):
return self._detector.readRegister(key) return self._detector._api.readRegister(key)
def __setitem__(self, key, value): def __setitem__(self, key, value):
self._detector.writeRegister(key, value) self._detector._api.writeRegister(key, value)
class Adc_register: class Adc_register:
def __init__(self, detector): def __init__(self, detector):
self._detector = detector self._detector = detector
def __setitem__(self, key, value): def __setitem__(self, key, value):
self._detector.writeAdcRegister(key, value) self._detector._api.writeAdcRegister(key, value)
def __getitem__(self, key):
raise ValueError('Adc registers cannot be read back')

View File

@ -2,34 +2,7 @@
Utility functions that are useful for testing and troubleshooting Utility functions that are useful for testing and troubleshooting
but not directly used in controlling the detector but not directly used in controlling the detector
""" """
from collections import namedtuple
import _sls_detector #C++ lib
import functools
Geometry = namedtuple('Geometry', ['x', 'y'])
def get_set_bits(mask):
"""
Return a list of the set bits in a python integer
"""
return [i for i in range(mask.bit_length()) if (mask>>i)&1]
def list_to_bitmask(values):
"""
Convert a list of integers to a bitmask with set bits
where the list indicates
"""
mask = int(0)
values = list(set(values)) #Remove duplicates
for v in values:
mask += 1 << v
return mask
def to_geo(value):
if isinstance(value, _sls_detector.xy):
return Geometry(x = value.x, y = value.y)
else:
raise ValueError("Can only convert sls_detector.xy")
def all_equal(mylist): def all_equal(mylist):
"""If all elements are equal return true otherwise false""" """If all elements are equal return true otherwise false"""
@ -46,14 +19,6 @@ def element_if_equal(mylist):
else: else:
return mylist return mylist
def element(func):
"""
Wrapper to return either list or element
"""
@functools.wraps(func)
def wrapper(self, *args, **kwargs):
return element_if_equal(func(self, *args, **kwargs))
return wrapper
def eiger_register_to_time(register): def eiger_register_to_time(register):
""" """

File diff suppressed because it is too large Load Diff

View File

@ -1,636 +0,0 @@
/* WARINING This file is auto generated any edits might be overwritten without
* warning */
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "Detector.h"
#include "ToString.h"
#include "network_utils.h"
#include "sls_detector_defs.h"
#include "typecaster.h"
namespace py = pybind11;
void init_det(py::module &m) {
using sls::Detector;
using sls::Positions;
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi
.def(py::init<int>())
.def("freeSharedMemory", &Detector::freeSharedMemory)
.def("loadConfig", &Detector::loadConfig, py::arg())
.def("loadParameters", &Detector::loadParameters, py::arg())
.def("getHostname", &Detector::getHostname, py::arg() = Positions{})
.def("setHostname", &Detector::setHostname, py::arg())
.def("setVirtualDetectorServers", &Detector::setVirtualDetectorServers,
py::arg(), py::arg())
.def("getShmId", &Detector::getShmId)
.def("getPackageVersion", &Detector::getPackageVersion)
.def("getClientVersion", &Detector::getClientVersion)
.def("getFirmwareVersion", &Detector::getFirmwareVersion,
py::arg() = Positions{})
.def("getDetectorServerVersion", &Detector::getDetectorServerVersion,
py::arg() = Positions{})
.def("getSerialNumber", &Detector::getSerialNumber,
py::arg() = Positions{})
.def("getReceiverVersion", &Detector::getReceiverVersion,
py::arg() = Positions{})
.def("getDetectorType", &Detector::getDetectorType,
py::arg() = Positions{})
.def("size", &Detector::size)
.def("empty", &Detector::empty)
.def("getModuleGeometry", &Detector::getModuleGeometry)
.def("getModuleSize", &Detector::getModuleSize, py::arg() = Positions{})
.def("getDetectorSize", &Detector::getDetectorSize)
.def("setDetectorSize", &Detector::setDetectorSize, py::arg())
.def("getSettings", &Detector::getSettings, py::arg() = Positions{})
.def("setSettings", &Detector::setSettings, py::arg(),
py::arg() = Positions{})
.def("registerAcquisitionFinishedCallback",
&Detector::registerAcquisitionFinishedCallback, py::arg(),
py::arg())
.def("registerDataCallback", &Detector::registerDataCallback, py::arg(),
py::arg())
.def("getNumberOfFrames", &Detector::getNumberOfFrames,
py::arg() = Positions{})
.def("setNumberOfFrames", &Detector::setNumberOfFrames, py::arg())
.def("getNumberOfTriggers", &Detector::getNumberOfTriggers,
py::arg() = Positions{})
.def("setNumberOfTriggers", &Detector::setNumberOfTriggers, py::arg())
.def("getExptime", &Detector::getExptime, py::arg() = Positions{})
.def("setExptime", &Detector::setExptime, py::arg(),
py::arg() = Positions{})
.def("getPeriod", &Detector::getPeriod, py::arg() = Positions{})
.def("setPeriod", &Detector::setPeriod, py::arg(),
py::arg() = Positions{})
.def("getDelayAfterTrigger", &Detector::getDelayAfterTrigger,
py::arg() = Positions{})
.def("setDelayAfterTrigger", &Detector::setDelayAfterTrigger, py::arg(),
py::arg() = Positions{})
.def("getNumberOfFramesLeft", &Detector::getNumberOfFramesLeft,
py::arg() = Positions{})
.def("getNumberOfTriggersLeft", &Detector::getNumberOfTriggersLeft,
py::arg() = Positions{})
.def("getDelayAfterTriggerLeft", &Detector::getDelayAfterTriggerLeft,
py::arg() = Positions{})
.def("getPeriodLeft", &Detector::getPeriodLeft, py::arg() = Positions{})
.def("getSpeed", &Detector::getSpeed, py::arg() = Positions{})
.def("setSpeed", &Detector::setSpeed, py::arg(),
py::arg() = Positions{})
.def("getADCPhase", &Detector::getADCPhase, py::arg() = Positions{})
.def("setADCPhase", &Detector::setADCPhase, py::arg(),
py::arg() = Positions{})
.def("getMaxADCPhaseShift", &Detector::getMaxADCPhaseShift,
py::arg() = Positions{})
.def("getADCPhaseInDegrees", &Detector::getADCPhaseInDegrees,
py::arg() = Positions{})
.def("setADCPhaseInDegrees", &Detector::setADCPhaseInDegrees, py::arg(),
py::arg() = Positions{})
.def("getClockFrequency", &Detector::getClockFrequency, py::arg(),
py::arg() = Positions{})
.def("setClockFrequency", &Detector::setClockFrequency, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getClockPhase", &Detector::getClockPhase, py::arg(),
py::arg() = Positions{})
.def("setClockPhase", &Detector::setClockPhase, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getMaxClockPhaseShift", &Detector::getMaxClockPhaseShift,
py::arg(), py::arg() = Positions{})
.def("getClockPhaseinDegrees", &Detector::getClockPhaseinDegrees,
py::arg(), py::arg() = Positions{})
.def("setClockPhaseinDegrees", &Detector::setClockPhaseinDegrees,
py::arg(), py::arg(), py::arg() = Positions{})
.def("getClockDivider", &Detector::getClockDivider, py::arg(),
py::arg() = Positions{})
.def("setClockDivider", &Detector::setClockDivider, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getHighVoltage", &Detector::getHighVoltage,
py::arg() = Positions{})
.def("setHighVoltage", &Detector::setHighVoltage, py::arg(),
py::arg() = Positions{})
.def("getTemperature", &Detector::getTemperature, py::arg(),
py::arg() = Positions{})
.def("getDAC", &Detector::getDAC, py::arg(), py::arg(),
py::arg() = Positions{})
.def("setDAC", &Detector::setDAC, py::arg(), py::arg(), py::arg(),
py::arg() = Positions{})
.def("getOnChipDAC", &Detector::getOnChipDAC, py::arg(), py::arg(),
py::arg() = Positions{})
.def("setOnChipDAC", &Detector::setOnChipDAC, py::arg(), py::arg(),
py::arg(), py::arg() = Positions{})
.def("getTimingMode", &Detector::getTimingMode, py::arg() = Positions{})
.def("setTimingMode", &Detector::setTimingMode, py::arg(),
py::arg() = Positions{})
.def("acquire", &Detector::acquire)
.def("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("startReceiver", &Detector::startReceiver)
.def("stopReceiver", &Detector::stopReceiver)
.def("startDetector", &Detector::startDetector)
.def("stopDetector", &Detector::stopDetector)
.def("getDetectorStatus", &Detector::getDetectorStatus,
py::arg() = Positions{})
.def("getReceiverStatus", &Detector::getReceiverStatus,
py::arg() = Positions{})
.def("getFramesCaught", &Detector::getFramesCaught,
py::arg() = Positions{})
.def("getNumMissingPackets", &Detector::getNumMissingPackets,
py::arg() = Positions{})
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
py::arg() = Positions{})
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
py::arg(), py::arg() = Positions{})
.def("sendSoftwareTrigger", &Detector::sendSoftwareTrigger,
py::arg() = Positions{})
.def("getNumberofUDPInterfaces", &Detector::getNumberofUDPInterfaces,
py::arg() = Positions{})
.def("setNumberofUDPInterfaces", &Detector::setNumberofUDPInterfaces,
py::arg(), py::arg() = Positions{})
.def("getSelectedUDPInterface", &Detector::getSelectedUDPInterface,
py::arg() = Positions{})
.def("selectUDPInterface", &Detector::selectUDPInterface, py::arg(),
py::arg() = Positions{})
.def("getSourceUDPIP", &Detector::getSourceUDPIP,
py::arg() = Positions{})
.def("setSourceUDPIP", &Detector::setSourceUDPIP, py::arg(),
py::arg() = Positions{})
.def("getSourceUDPIP2", &Detector::getSourceUDPIP2,
py::arg() = Positions{})
.def("setSourceUDPIP2", &Detector::setSourceUDPIP2, py::arg(),
py::arg() = Positions{})
.def("getSourceUDPMAC", &Detector::getSourceUDPMAC,
py::arg() = Positions{})
.def("setSourceUDPMAC", &Detector::setSourceUDPMAC, py::arg(),
py::arg() = Positions{})
.def("getSourceUDPMAC2", &Detector::getSourceUDPMAC2,
py::arg() = Positions{})
.def("setSourceUDPMAC2", &Detector::setSourceUDPMAC2, py::arg(),
py::arg() = Positions{})
.def("getDestinationUDPIP", &Detector::getDestinationUDPIP,
py::arg() = Positions{})
.def("setDestinationUDPIP", &Detector::setDestinationUDPIP, py::arg(),
py::arg() = Positions{})
.def("getDestinationUDPIP2", &Detector::getDestinationUDPIP2,
py::arg() = Positions{})
.def("setDestinationUDPIP2", &Detector::setDestinationUDPIP2, py::arg(),
py::arg() = Positions{})
.def("getDestinationUDPMAC", &Detector::getDestinationUDPMAC,
py::arg() = Positions{})
.def("setDestinationUDPMAC", &Detector::setDestinationUDPMAC, py::arg(),
py::arg() = Positions{})
.def("getDestinationUDPMAC2", &Detector::getDestinationUDPMAC2,
py::arg() = Positions{})
.def("setDestinationUDPMAC2", &Detector::setDestinationUDPMAC2,
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPPort", &Detector::getDestinationUDPPort,
py::arg() = Positions{})
.def("setDestinationUDPPort", &Detector::setDestinationUDPPort,
py::arg(), py::arg())
.def("getDestinationUDPPort2", &Detector::getDestinationUDPPort2,
py::arg() = Positions{})
.def("setDestinationUDPPort2", &Detector::setDestinationUDPPort2,
py::arg(), py::arg())
.def("printRxConfiguration", &Detector::printRxConfiguration,
py::arg() = Positions{})
.def("getTenGiga", &Detector::getTenGiga, py::arg() = Positions{})
.def("setTenGiga", &Detector::setTenGiga, py::arg(),
py::arg() = Positions{})
.def("getTenGigaFlowControl", &Detector::getTenGigaFlowControl,
py::arg() = Positions{})
.def("setTenGigaFlowControl", &Detector::setTenGigaFlowControl,
py::arg(), py::arg() = Positions{})
.def("getTransmissionDelayFrame", &Detector::getTransmissionDelayFrame,
py::arg() = Positions{})
.def("setTransmissionDelayFrame", &Detector::setTransmissionDelayFrame,
py::arg(), py::arg() = Positions{})
.def("getTransmissionDelayLeft", &Detector::getTransmissionDelayLeft,
py::arg() = Positions{})
.def("setTransmissionDelayLeft", &Detector::setTransmissionDelayLeft,
py::arg(), py::arg() = Positions{})
.def("getTransmissionDelayRight", &Detector::getTransmissionDelayRight,
py::arg() = Positions{})
.def("setTransmissionDelayRight", &Detector::setTransmissionDelayRight,
py::arg(), py::arg() = Positions{})
.def("getUseReceiverFlag", &Detector::getUseReceiverFlag,
py::arg() = Positions{})
.def("getRxHostname", &Detector::getRxHostname, py::arg() = Positions{})
.def("setRxHostname", &Detector::setRxHostname, py::arg(),
py::arg() = Positions{})
.def("getRxPort", &Detector::getRxPort, py::arg() = Positions{})
.def("setRxPort", &Detector::setRxPort, py::arg(), py::arg())
.def("getRxFifoDepth", &Detector::getRxFifoDepth,
py::arg() = Positions{})
.def("setRxFifoDepth", &Detector::setRxFifoDepth, py::arg(),
py::arg() = Positions{})
.def("getRxSilentMode", &Detector::getRxSilentMode,
py::arg() = Positions{})
.def("setRxSilentMode", &Detector::setRxSilentMode, py::arg(),
py::arg() = Positions{})
.def("getRxFrameDiscardPolicy", &Detector::getRxFrameDiscardPolicy,
py::arg() = Positions{})
.def("setRxFrameDiscardPolicy", &Detector::setRxFrameDiscardPolicy,
py::arg(), py::arg() = Positions{})
.def("getPartialFramesPadding", &Detector::getPartialFramesPadding,
py::arg() = Positions{})
.def("setPartialFramesPadding", &Detector::setPartialFramesPadding,
py::arg(), py::arg() = Positions{})
.def("getRxUDPSocketBufferSize", &Detector::getRxUDPSocketBufferSize,
py::arg() = Positions{})
.def("setRxUDPSocketBufferSize", &Detector::setRxUDPSocketBufferSize,
py::arg(), py::arg() = Positions{})
.def("getRxRealUDPSocketBufferSize",
&Detector::getRxRealUDPSocketBufferSize, py::arg() = Positions{})
.def("getRxLock", &Detector::getRxLock, py::arg() = Positions{})
.def("setRxLock", &Detector::setRxLock, py::arg(),
py::arg() = Positions{})
.def("getRxLastClientIP", &Detector::getRxLastClientIP,
py::arg() = Positions{})
.def("getFileFormat", &Detector::getFileFormat, py::arg() = Positions{})
.def("setFileFormat", &Detector::setFileFormat, py::arg(),
py::arg() = Positions{})
.def("getFilePath", &Detector::getFilePath, py::arg() = Positions{})
.def("setFilePath", &Detector::setFilePath, py::arg(),
py::arg() = Positions{})
.def("getFileNamePrefix", &Detector::getFileNamePrefix,
py::arg() = Positions{})
.def("setFileNamePrefix", &Detector::setFileNamePrefix, py::arg(),
py::arg() = Positions{})
.def("getAcquisitionIndex", &Detector::getAcquisitionIndex,
py::arg() = Positions{})
.def("setAcquisitionIndex", &Detector::setAcquisitionIndex, py::arg(),
py::arg() = Positions{})
.def("getFileWrite", &Detector::getFileWrite, py::arg() = Positions{})
.def("setFileWrite", &Detector::setFileWrite, py::arg(),
py::arg() = Positions{})
.def("getMasterFileWrite", &Detector::getMasterFileWrite,
py::arg() = Positions{})
.def("setMasterFileWrite", &Detector::setMasterFileWrite, py::arg(),
py::arg() = Positions{})
.def("getFileOverWrite", &Detector::getFileOverWrite,
py::arg() = Positions{})
.def("setFileOverWrite", &Detector::setFileOverWrite, py::arg(),
py::arg() = Positions{})
.def("getFramesPerFile", &Detector::getFramesPerFile,
py::arg() = Positions{})
.def("setFramesPerFile", &Detector::setFramesPerFile, py::arg(),
py::arg() = Positions{})
.def("getRxZmqDataStream", &Detector::getRxZmqDataStream,
py::arg() = Positions{})
.def("setRxZmqDataStream", &Detector::setRxZmqDataStream, py::arg(),
py::arg() = Positions{})
.def("getRxZmqFrequency", &Detector::getRxZmqFrequency,
py::arg() = Positions{})
.def("setRxZmqFrequency", &Detector::setRxZmqFrequency, py::arg(),
py::arg() = Positions{})
.def("getRxZmqTimer", &Detector::getRxZmqTimer, py::arg() = Positions{})
.def("setRxZmqTimer", &Detector::setRxZmqTimer, py::arg(),
py::arg() = Positions{})
.def("getRxZmqPort", &Detector::getRxZmqPort, py::arg() = Positions{})
.def("setRxZmqPort", &Detector::setRxZmqPort, py::arg(), py::arg())
.def("getRxZmqIP", &Detector::getRxZmqIP, py::arg() = Positions{})
.def("setRxZmqIP", &Detector::setRxZmqIP, py::arg(),
py::arg() = Positions{})
.def("getClientZmqPort", &Detector::getClientZmqPort,
py::arg() = Positions{})
.def("setClientZmqPort", &Detector::setClientZmqPort, py::arg(),
py::arg())
.def("getClientZmqIp", &Detector::getClientZmqIp,
py::arg() = Positions{})
.def("setClientZmqIp", &Detector::setClientZmqIp, py::arg(),
py::arg() = Positions{})
.def("getDynamicRange", &Detector::getDynamicRange,
py::arg() = Positions{})
.def("setDynamicRange", &Detector::setDynamicRange, py::arg())
.def("getSubExptime", &Detector::getSubExptime, py::arg() = Positions{})
.def("setSubExptime", &Detector::setSubExptime, py::arg(),
py::arg() = Positions{})
.def("getSubDeadTime", &Detector::getSubDeadTime,
py::arg() = Positions{})
.def("setSubDeadTime", &Detector::setSubDeadTime, py::arg(),
py::arg() = Positions{})
.def("getThresholdEnergy", &Detector::getThresholdEnergy,
py::arg() = Positions{})
.def("setThresholdEnergy", &Detector::setThresholdEnergy, py::arg(),
py::arg(), py::arg(), py::arg() = Positions{})
.def("getSettingsPath", &Detector::getSettingsPath,
py::arg() = Positions{})
.def("setSettingsPath", &Detector::setSettingsPath, py::arg(),
py::arg() = Positions{})
.def("loadTrimbits", &Detector::loadTrimbits, py::arg(),
py::arg() = Positions{})
.def("getRxAddGapPixels", &Detector::getRxAddGapPixels,
py::arg() = Positions{})
.def("setRxAddGapPixels", &Detector::setRxAddGapPixels, py::arg())
.def("getParallelMode", &Detector::getParallelMode,
py::arg() = Positions{})
.def("setParallelMode", &Detector::setParallelMode, py::arg(),
py::arg() = Positions{})
.def("getOverFlowMode", &Detector::getOverFlowMode,
py::arg() = Positions{})
.def("setOverFlowMode", &Detector::setOverFlowMode, py::arg(),
py::arg() = Positions{})
.def("getStoreInRamMode", &Detector::getStoreInRamMode,
py::arg() = Positions{})
.def("setStoreInRamMode", &Detector::setStoreInRamMode, py::arg(),
py::arg() = Positions{})
.def("getBottom", &Detector::getBottom, py::arg() = Positions{})
.def("setBottom", &Detector::setBottom, py::arg(),
py::arg() = Positions{})
.def("getAllTrimbits", &Detector::getAllTrimbits,
py::arg() = Positions{})
.def("setAllTrimbits", &Detector::setAllTrimbits, py::arg(),
py::arg() = Positions{})
.def("getTrimEnergies", &Detector::getTrimEnergies,
py::arg() = Positions{})
.def("setTrimEnergies", &Detector::setTrimEnergies, py::arg(),
py::arg() = Positions{})
.def("getRateCorrection", &Detector::getRateCorrection,
py::arg() = Positions{})
.def("setDefaultRateCorrection", &Detector::setDefaultRateCorrection,
py::arg() = Positions{})
.def("setRateCorrection", &Detector::setRateCorrection, py::arg(),
py::arg() = Positions{})
.def("getPartialReadout", &Detector::getPartialReadout,
py::arg() = Positions{})
.def("setPartialReadout", &Detector::setPartialReadout, py::arg(),
py::arg() = Positions{})
.def("getInterruptSubframe", &Detector::getInterruptSubframe,
py::arg() = Positions{})
.def("setInterruptSubframe", &Detector::setInterruptSubframe, py::arg(),
py::arg() = Positions{})
.def("getMeasuredPeriod", &Detector::getMeasuredPeriod,
py::arg() = Positions{})
.def("getMeasuredSubFramePeriod", &Detector::getMeasuredSubFramePeriod,
py::arg() = Positions{})
.def("getActive", &Detector::getActive, py::arg() = Positions{})
.def("setActive", &Detector::setActive, py::arg(),
py::arg() = Positions{})
.def("getRxPadDeactivatedMode", &Detector::getRxPadDeactivatedMode,
py::arg() = Positions{})
.def("setRxPadDeactivatedMode", &Detector::setRxPadDeactivatedMode,
py::arg(), py::arg() = Positions{})
.def("getPartialReset", &Detector::getPartialReset,
py::arg() = Positions{})
.def("setPartialReset", &Detector::setPartialReset, py::arg(),
py::arg() = Positions{})
.def("pulsePixel", &Detector::pulsePixel, py::arg(), py::arg(),
py::arg() = Positions{})
.def("pulsePixelNMove", &Detector::pulsePixelNMove, py::arg(),
py::arg(), py::arg() = Positions{})
.def("pulseChip", &Detector::pulseChip, py::arg(),
py::arg() = Positions{})
.def("getQuad", &Detector::getQuad, py::arg() = Positions{})
.def("setQuad", &Detector::setQuad, py::arg())
.def("getThresholdTemperature", &Detector::getThresholdTemperature,
py::arg() = Positions{})
.def("setThresholdTemperature", &Detector::setThresholdTemperature,
py::arg(), py::arg() = Positions{})
.def("getTemperatureControl", &Detector::getTemperatureControl,
py::arg() = Positions{})
.def("setTemperatureControl", &Detector::setTemperatureControl,
py::arg(), py::arg() = Positions{})
.def("getTemperatureEvent", &Detector::getTemperatureEvent,
py::arg() = Positions{})
.def("resetTemperatureEvent", &Detector::resetTemperatureEvent,
py::arg() = Positions{})
.def("getPowerChip", &Detector::getPowerChip, py::arg() = Positions{})
.def("setPowerChip", &Detector::setPowerChip, py::arg(),
py::arg() = Positions{})
.def("getAutoCompDisable", &Detector::getAutoCompDisable,
py::arg() = Positions{})
.def("setAutoCompDisable", &Detector::setAutoCompDisable, py::arg(),
py::arg() = Positions{})
.def("getNumberOfAdditionalStorageCells",
&Detector::getNumberOfAdditionalStorageCells,
py::arg() = Positions{})
.def("setNumberOfAdditionalStorageCells",
&Detector::setNumberOfAdditionalStorageCells, py::arg())
.def("getStorageCellStart", &Detector::getStorageCellStart,
py::arg() = Positions{})
.def("setStoragecellStart", &Detector::setStoragecellStart, py::arg(),
py::arg() = Positions{})
.def("getStorageCellDelay", &Detector::getStorageCellDelay,
py::arg() = Positions{})
.def("setStorageCellDelay", &Detector::setStorageCellDelay, py::arg(),
py::arg() = Positions{})
.def("getROI", &Detector::getROI, py::arg() = Positions{})
.def("setROI", &Detector::setROI, py::arg(), py::arg())
.def("clearROI", &Detector::clearROI, py::arg() = Positions{})
.def("getExptimeLeft", &Detector::getExptimeLeft,
py::arg() = Positions{})
.def("getExternalSignalFlags", &Detector::getExternalSignalFlags,
py::arg() = Positions{})
.def("setExternalSignalFlags", &Detector::setExternalSignalFlags,
py::arg(), py::arg() = Positions{})
.def("getImageTestMode", &Detector::getImageTestMode,
py::arg() = Positions{})
.def("setImageTestMode", &Detector::setImageTestMode, py::arg(),
py::arg() = Positions{})
.def("getInjectChannel", &Detector::getInjectChannel,
py::arg() = Positions{})
.def("setInjectChannel", &Detector::setInjectChannel, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getVetoPhoton", &Detector::getVetoPhoton, py::arg(),
py::arg() = Positions{})
.def("setVetoPhoton", &Detector::setVetoPhoton, py::arg(), py::arg(),
py::arg(), py::arg(), py::arg() = Positions{})
.def("setVetoReference", &Detector::setVetoReference, py::arg(),
py::arg(), py::arg() = Positions{})
.def("setBurstMode", &Detector::setBurstMode, py::arg(),
py::arg() = Positions{})
.def("getBurstMode", &Detector::getBurstMode, py::arg() = Positions{})
.def("getCounterMask", &Detector::getCounterMask,
py::arg() = Positions{})
.def("setCounterMask", &Detector::setCounterMask, py::arg(),
py::arg() = Positions{})
.def("getNumberOfAnalogSamples", &Detector::getNumberOfAnalogSamples,
py::arg() = Positions{})
.def("setNumberOfAnalogSamples", &Detector::setNumberOfAnalogSamples,
py::arg(), py::arg() = Positions{})
.def("getNumberOfDigitalSamples", &Detector::getNumberOfDigitalSamples,
py::arg() = Positions{})
.def("setNumberOfDigitalSamples", &Detector::setNumberOfDigitalSamples,
py::arg(), py::arg() = Positions{})
.def("getReadoutMode", &Detector::getReadoutMode,
py::arg() = Positions{})
.def("setReadoutMode", &Detector::setReadoutMode, py::arg(),
py::arg() = Positions{})
.def("getDBITPhase", &Detector::getDBITPhase, py::arg() = Positions{})
.def("setDBITPhase", &Detector::setDBITPhase, py::arg(),
py::arg() = Positions{})
.def("getMaxDBITPhaseShift", &Detector::getMaxDBITPhaseShift,
py::arg() = Positions{})
.def("getDBITPhaseInDegrees", &Detector::getDBITPhaseInDegrees,
py::arg() = Positions{})
.def("setDBITPhaseInDegrees", &Detector::setDBITPhaseInDegrees,
py::arg(), py::arg() = Positions{})
.def("getADCClock", &Detector::getADCClock, py::arg() = Positions{})
.def("setADCClock", &Detector::setADCClock, py::arg(),
py::arg() = Positions{})
.def("getDBITClock", &Detector::getDBITClock, py::arg() = Positions{})
.def("setDBITClock", &Detector::setDBITClock, py::arg(),
py::arg() = Positions{})
.def("getRUNClock", &Detector::getRUNClock, py::arg() = Positions{})
.def("setRUNClock", &Detector::setRUNClock, py::arg(),
py::arg() = Positions{})
.def("getSYNCClock", &Detector::getSYNCClock, py::arg() = Positions{})
.def("getADCPipeline", &Detector::getADCPipeline,
py::arg() = Positions{})
.def("setADCPipeline", &Detector::setADCPipeline, py::arg(),
py::arg() = Positions{})
.def("getDBITPipeline", &Detector::getDBITPipeline,
py::arg() = Positions{})
.def("setDBITPipeline", &Detector::setDBITPipeline, py::arg(),
py::arg() = Positions{})
.def("getVoltage", &Detector::getVoltage, py::arg(),
py::arg() = Positions{})
.def("setVoltage", &Detector::setVoltage, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getMeasuredVoltage", &Detector::getMeasuredVoltage, py::arg(),
py::arg() = Positions{})
.def("getMeasuredCurrent", &Detector::getMeasuredCurrent, py::arg(),
py::arg() = Positions{})
.def("getSlowADC", &Detector::getSlowADC, py::arg(),
py::arg() = Positions{})
.def("getADCEnableMask", &Detector::getADCEnableMask,
py::arg() = Positions{})
.def("setADCEnableMask", &Detector::setADCEnableMask, py::arg(),
py::arg() = Positions{})
.def("getTenGigaADCEnableMask", &Detector::getTenGigaADCEnableMask,
py::arg() = Positions{})
.def("setTenGigaADCEnableMask", &Detector::setTenGigaADCEnableMask,
py::arg(), py::arg() = Positions{})
.def("getADCInvert", &Detector::getADCInvert, py::arg() = Positions{})
.def("setADCInvert", &Detector::setADCInvert, py::arg(),
py::arg() = Positions{})
.def("getExternalSamplingSource", &Detector::getExternalSamplingSource,
py::arg() = Positions{})
.def("setExternalSamplingSource", &Detector::setExternalSamplingSource,
py::arg(), py::arg() = Positions{})
.def("getExternalSampling", &Detector::getExternalSampling,
py::arg() = Positions{})
.def("setExternalSampling", &Detector::setExternalSampling, py::arg(),
py::arg() = Positions{})
.def("getRxDbitList", &Detector::getRxDbitList, py::arg() = Positions{})
.def("setRxDbitList", &Detector::setRxDbitList, py::arg(),
py::arg() = Positions{})
.def("getRxDbitOffset", &Detector::getRxDbitOffset,
py::arg() = Positions{})
.def("setRxDbitOffset", &Detector::setRxDbitOffset, py::arg(),
py::arg() = Positions{})
.def("setDigitalIODelay", &Detector::setDigitalIODelay, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getLEDEnable", &Detector::getLEDEnable, py::arg() = Positions{})
.def("setLEDEnable", &Detector::setLEDEnable, py::arg(),
py::arg() = Positions{})
.def("setPattern", &Detector::setPattern, py::arg(),
py::arg() = Positions{})
.def("savePattern", &Detector::savePattern, py::arg())
.def("getPatternIOControl", &Detector::getPatternIOControl,
py::arg() = Positions{})
.def("setPatternIOControl", &Detector::setPatternIOControl, py::arg(),
py::arg() = Positions{})
.def("getPatternClockControl", &Detector::getPatternClockControl,
py::arg() = Positions{})
.def("setPatternClockControl", &Detector::setPatternClockControl,
py::arg(), py::arg() = Positions{})
.def("getPatternWord", &Detector::getPatternWord, py::arg(),
py::arg() = Positions{})
.def("setPatternWord", &Detector::setPatternWord, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getPatternLoopAddresses", &Detector::getPatternLoopAddresses,
py::arg(), py::arg() = Positions{})
.def("setPatternLoopAddresses", &Detector::setPatternLoopAddresses,
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
.def("getPatternLoopCycles", &Detector::getPatternLoopCycles, py::arg(),
py::arg() = Positions{})
.def("setPatternLoopCycles", &Detector::setPatternLoopCycles, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getPatternWaitAddr", &Detector::getPatternWaitAddr, py::arg(),
py::arg() = Positions{})
.def("setPatternWaitAddr", &Detector::setPatternWaitAddr, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getPatternWaitTime", &Detector::getPatternWaitTime, py::arg(),
py::arg() = Positions{})
.def("setPatternWaitTime", &Detector::setPatternWaitTime, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getPatternMask", &Detector::getPatternMask,
py::arg() = Positions{})
.def("setPatternMask", &Detector::setPatternMask, py::arg(),
py::arg() = Positions{})
.def("getPatternBitMask", &Detector::getPatternBitMask,
py::arg() = Positions{})
.def("setPatternBitMask", &Detector::setPatternBitMask, py::arg(),
py::arg() = Positions{})
.def("getAdditionalJsonHeader", &Detector::getAdditionalJsonHeader,
py::arg() = Positions{})
.def("setAdditionalJsonHeader", &Detector::setAdditionalJsonHeader,
py::arg(), py::arg() = Positions{})
.def("getAdditionalJsonParameter",
&Detector::getAdditionalJsonParameter, py::arg(),
py::arg() = Positions{})
.def("setAdditionalJsonParameter",
&Detector::setAdditionalJsonParameter, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getDetectorMinMaxEnergyThreshold",
&Detector::getDetectorMinMaxEnergyThreshold, py::arg(),
py::arg() = Positions{})
.def("setDetectorMinMaxEnergyThreshold",
&Detector::setDetectorMinMaxEnergyThreshold, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getFrameMode", &Detector::getFrameMode, py::arg() = Positions{})
.def("setFrameMode", &Detector::setFrameMode, py::arg(),
py::arg() = Positions{})
.def("getDetectorMode", &Detector::getDetectorMode,
py::arg() = Positions{})
.def("setDetectorMode", &Detector::setDetectorMode, py::arg(),
py::arg() = Positions{})
.def("programFPGA", &Detector::programFPGA, py::arg(),
py::arg() = Positions{})
.def("resetFPGA", &Detector::resetFPGA, py::arg() = Positions{})
.def("copyDetectorServer", &Detector::copyDetectorServer, py::arg(),
py::arg(), py::arg() = Positions{})
.def("rebootController", &Detector::rebootController,
py::arg() = Positions{})
.def("updateFirmwareAndServer", &Detector::updateFirmwareAndServer,
py::arg(), py::arg(), py::arg(), py::arg() = Positions{})
.def("readRegister", &Detector::readRegister, py::arg(),
py::arg() = Positions{})
.def("writeRegister", &Detector::writeRegister, py::arg(), py::arg(),
py::arg() = Positions{})
.def("setBit", &Detector::setBit, py::arg(), py::arg(),
py::arg() = Positions{})
.def("clearBit", &Detector::clearBit, py::arg(), py::arg(),
py::arg() = Positions{})
.def("executeFirmwareTest", &Detector::executeFirmwareTest,
py::arg() = Positions{})
.def("executeBusTest", &Detector::executeBusTest,
py::arg() = Positions{})
.def("writeAdcRegister", &Detector::writeAdcRegister, py::arg(),
py::arg(), py::arg() = Positions{})
.def("getControlPort", &Detector::getControlPort,
py::arg() = Positions{})
.def("setControlPort", &Detector::setControlPort, py::arg(),
py::arg() = Positions{})
.def("getStopPort", &Detector::getStopPort, py::arg() = Positions{})
.def("setStopPort", &Detector::setStopPort, py::arg(),
py::arg() = Positions{})
.def("getDetectorLock", &Detector::getDetectorLock,
py::arg() = Positions{})
.def("setDetectorLock", &Detector::setDetectorLock, py::arg(),
py::arg() = Positions{})
.def("getLastClientIP", &Detector::getLastClientIP,
py::arg() = Positions{})
.def("executeCommand", &Detector::executeCommand, py::arg(),
py::arg() = Positions{})
.def("getNumberOfFramesFromStart",
&Detector::getNumberOfFramesFromStart, py::arg() = Positions{})
.def("getActualTime", &Detector::getActualTime, py::arg() = Positions{})
.def("getMeasurementTime", &Detector::getMeasurementTime,
py::arg() = Positions{})
.def("getUserDetails", &Detector::getUserDetails)
.def("getRxCurrentFrameIndex", &Detector::getRxCurrentFrameIndex,
py::arg() = Positions{});
}

View File

@ -1,21 +0,0 @@
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "Detector.h"
#include "ToString.h"
#include "network_utils.h"
#include "sls_detector_defs.h"
#include "typecaster.h"
namespace py = pybind11;
void init_det(py::module &m) {
using sls::Detector;
using sls::Positions;
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi
.def(py::init<int>())
[[FUNCTIONS]]
}

View File

@ -1,6 +1,3 @@
/* WARINING This file is auto generated any edits might be overwritten without
* warning */
#include <pybind11/chrono.h> #include <pybind11/chrono.h>
#include <pybind11/operators.h> #include <pybind11/operators.h>
#include <pybind11/pybind11.h> #include <pybind11/pybind11.h>
@ -10,25 +7,6 @@
namespace py = pybind11; namespace py = pybind11;
void init_enums(py::module &m) { void init_enums(py::module &m) {
py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs"); py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs");
py::class_<slsDetectorDefs::xy> xy(m, "xy");
xy.def(py::init());
xy.def(py::init<int, int>());
xy.def_readwrite("x", &slsDetectorDefs::xy::x);
xy.def_readwrite("y", &slsDetectorDefs::xy::y);
py::enum_<slsDetectorDefs::detectorType>(Defs, "detectorType")
.value("GET_DETECTOR_TYPE",
slsDetectorDefs::detectorType::GET_DETECTOR_TYPE)
.value("GENERIC", slsDetectorDefs::detectorType::GENERIC)
.value("EIGER", slsDetectorDefs::detectorType::EIGER)
.value("GOTTHARD", slsDetectorDefs::detectorType::GOTTHARD)
.value("JUNGFRAU", slsDetectorDefs::detectorType::JUNGFRAU)
.value("CHIPTESTBOARD", slsDetectorDefs::detectorType::CHIPTESTBOARD)
.value("MOENCH", slsDetectorDefs::detectorType::MOENCH)
.value("MYTHEN3", slsDetectorDefs::detectorType::MYTHEN3)
.value("GOTTHARD2", slsDetectorDefs::detectorType::GOTTHARD2)
.export_values();
py::enum_<slsDetectorDefs::runStatus>(Defs, "runStatus") py::enum_<slsDetectorDefs::runStatus>(Defs, "runStatus")
.value("IDLE", slsDetectorDefs::runStatus::IDLE) .value("IDLE", slsDetectorDefs::runStatus::IDLE)
.value("ERROR", slsDetectorDefs::runStatus::ERROR) .value("ERROR", slsDetectorDefs::runStatus::ERROR)
@ -38,244 +16,4 @@ void init_enums(py::module &m) {
.value("RUNNING", slsDetectorDefs::runStatus::RUNNING) .value("RUNNING", slsDetectorDefs::runStatus::RUNNING)
.value("STOPPED", slsDetectorDefs::runStatus::STOPPED) .value("STOPPED", slsDetectorDefs::runStatus::STOPPED)
.export_values(); .export_values();
py::enum_<slsDetectorDefs::frameDiscardPolicy>(Defs, "frameDiscardPolicy")
.value("GET_FRAME_DISCARD_POLICY",
slsDetectorDefs::frameDiscardPolicy::GET_FRAME_DISCARD_POLICY)
.value("NO_DISCARD", slsDetectorDefs::frameDiscardPolicy::NO_DISCARD)
.value("DISCARD_EMPTY_FRAMES",
slsDetectorDefs::frameDiscardPolicy::DISCARD_EMPTY_FRAMES)
.value("DISCARD_PARTIAL_FRAMES",
slsDetectorDefs::frameDiscardPolicy::DISCARD_PARTIAL_FRAMES)
.value("NUM_DISCARD_POLICIES",
slsDetectorDefs::frameDiscardPolicy::NUM_DISCARD_POLICIES)
.export_values();
py::enum_<slsDetectorDefs::fileFormat>(Defs, "fileFormat")
.value("GET_FILE_FORMAT", slsDetectorDefs::fileFormat::GET_FILE_FORMAT)
.value("BINARY", slsDetectorDefs::fileFormat::BINARY)
.value("HDF5", slsDetectorDefs::fileFormat::HDF5)
.value("NUM_FILE_FORMATS",
slsDetectorDefs::fileFormat::NUM_FILE_FORMATS)
.export_values();
py::enum_<slsDetectorDefs::dimension>(Defs, "dimension")
.value("X", slsDetectorDefs::dimension::X)
.value("Y", slsDetectorDefs::dimension::Y)
.export_values();
py::enum_<slsDetectorDefs::externalSignalFlag>(Defs, "externalSignalFlag")
.value("GET_EXTERNAL_SIGNAL_FLAG",
slsDetectorDefs::externalSignalFlag::GET_EXTERNAL_SIGNAL_FLAG)
.value("SIGNAL_OFF", slsDetectorDefs::externalSignalFlag::SIGNAL_OFF)
.value("GATE_IN_ACTIVE_HIGH",
slsDetectorDefs::externalSignalFlag::GATE_IN_ACTIVE_HIGH)
.value("GATE_IN_ACTIVE_LOW",
slsDetectorDefs::externalSignalFlag::GATE_IN_ACTIVE_LOW)
.value("TRIGGER_IN_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_RISING_EDGE)
.value("TRIGGER_IN_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_IN_FALLING_EDGE)
.value("RO_TRIGGER_IN_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_IN_RISING_EDGE)
.value("RO_TRIGGER_IN_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_IN_FALLING_EDGE)
.value("GATE_OUT_ACTIVE_HIGH",
slsDetectorDefs::externalSignalFlag::GATE_OUT_ACTIVE_HIGH)
.value("GATE_OUT_ACTIVE_LOW",
slsDetectorDefs::externalSignalFlag::GATE_OUT_ACTIVE_LOW)
.value("TRIGGER_OUT_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_OUT_RISING_EDGE)
.value("TRIGGER_OUT_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::TRIGGER_OUT_FALLING_EDGE)
.value("RO_TRIGGER_OUT_RISING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_OUT_RISING_EDGE)
.value("RO_TRIGGER_OUT_FALLING_EDGE",
slsDetectorDefs::externalSignalFlag::RO_TRIGGER_OUT_FALLING_EDGE)
.value("OUTPUT_LOW", slsDetectorDefs::externalSignalFlag::OUTPUT_LOW)
.value("OUTPUT_HIGH", slsDetectorDefs::externalSignalFlag::OUTPUT_HIGH)
.value(
"MASTER_SLAVE_SYNCHRONIZATION",
slsDetectorDefs::externalSignalFlag::MASTER_SLAVE_SYNCHRONIZATION)
.export_values();
py::enum_<slsDetectorDefs::timingMode>(Defs, "timingMode")
.value("GET_TIMING_MODE", slsDetectorDefs::timingMode::GET_TIMING_MODE)
.value("AUTO_TIMING", slsDetectorDefs::timingMode::AUTO_TIMING)
.value("TRIGGER_EXPOSURE",
slsDetectorDefs::timingMode::TRIGGER_EXPOSURE)
.value("GATED", slsDetectorDefs::timingMode::GATED)
.value("BURST_TRIGGER", slsDetectorDefs::timingMode::BURST_TRIGGER)
.export_values();
py::enum_<slsDetectorDefs::dacIndex>(Defs, "dacIndex")
.value("THRESHOLD", slsDetectorDefs::dacIndex::THRESHOLD)
.value("CALIBRATION_PULSE",
slsDetectorDefs::dacIndex::CALIBRATION_PULSE)
.value("TRIMBIT_SIZE", slsDetectorDefs::dacIndex::TRIMBIT_SIZE)
.value("PREAMP", slsDetectorDefs::dacIndex::PREAMP)
.value("SHAPER1", slsDetectorDefs::dacIndex::SHAPER1)
.value("SHAPER2", slsDetectorDefs::dacIndex::SHAPER2)
.value("TEMPERATURE_ADC", slsDetectorDefs::dacIndex::TEMPERATURE_ADC)
.value("TEMPERATURE_FPGA", slsDetectorDefs::dacIndex::TEMPERATURE_FPGA)
.value("VREF_DS", slsDetectorDefs::dacIndex::VREF_DS)
.value("VCASCN_PB", slsDetectorDefs::dacIndex::VCASCN_PB)
.value("VCASCP_PB", slsDetectorDefs::dacIndex::VCASCP_PB)
.value("VOUT_CM", slsDetectorDefs::dacIndex::VOUT_CM)
.value("VCASC_OUT", slsDetectorDefs::dacIndex::VCASC_OUT)
.value("VIN_CM", slsDetectorDefs::dacIndex::VIN_CM)
.value("VREF_COMP", slsDetectorDefs::dacIndex::VREF_COMP)
.value("IB_TESTC", slsDetectorDefs::dacIndex::IB_TESTC)
.value("SVP", slsDetectorDefs::dacIndex::SVP)
.value("SVN", slsDetectorDefs::dacIndex::SVN)
.value("VTR", slsDetectorDefs::dacIndex::VTR)
.value("VRF", slsDetectorDefs::dacIndex::VRF)
.value("VRS", slsDetectorDefs::dacIndex::VRS)
.value("VTGSTV", slsDetectorDefs::dacIndex::VTGSTV)
.value("VCMP_LL", slsDetectorDefs::dacIndex::VCMP_LL)
.value("VCMP_LR", slsDetectorDefs::dacIndex::VCMP_LR)
.value("CAL", slsDetectorDefs::dacIndex::CAL)
.value("VCMP_RL", slsDetectorDefs::dacIndex::VCMP_RL)
.value("VCMP_RR", slsDetectorDefs::dacIndex::VCMP_RR)
.value("RXB_RB", slsDetectorDefs::dacIndex::RXB_RB)
.value("RXB_LB", slsDetectorDefs::dacIndex::RXB_LB)
.value("VCP", slsDetectorDefs::dacIndex::VCP)
.value("VCN", slsDetectorDefs::dacIndex::VCN)
.value("VIS", slsDetectorDefs::dacIndex::VIS)
.value("IO_DELAY", slsDetectorDefs::dacIndex::IO_DELAY)
.value("ADC_VPP", slsDetectorDefs::dacIndex::ADC_VPP)
.value("HIGH_VOLTAGE", slsDetectorDefs::dacIndex::HIGH_VOLTAGE)
.value("TEMPERATURE_FPGAEXT",
slsDetectorDefs::dacIndex::TEMPERATURE_FPGAEXT)
.value("TEMPERATURE_10GE", slsDetectorDefs::dacIndex::TEMPERATURE_10GE)
.value("TEMPERATURE_DCDC", slsDetectorDefs::dacIndex::TEMPERATURE_DCDC)
.value("TEMPERATURE_SODL", slsDetectorDefs::dacIndex::TEMPERATURE_SODL)
.value("TEMPERATURE_SODR", slsDetectorDefs::dacIndex::TEMPERATURE_SODR)
.value("TEMPERATURE_FPGA2",
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA2)
.value("TEMPERATURE_FPGA3",
slsDetectorDefs::dacIndex::TEMPERATURE_FPGA3)
.value("VIPRE", slsDetectorDefs::dacIndex::VIPRE)
.value("VIINSH", slsDetectorDefs::dacIndex::VIINSH)
.value("VDCSH", slsDetectorDefs::dacIndex::VDCSH)
.value("VTH2", slsDetectorDefs::dacIndex::VTH2)
.value("VPL", slsDetectorDefs::dacIndex::VPL)
.value("VTH3", slsDetectorDefs::dacIndex::VTH3)
.value("CASSH", slsDetectorDefs::dacIndex::CASSH)
.value("CAS", slsDetectorDefs::dacIndex::CAS)
.value("VICIN", slsDetectorDefs::dacIndex::VICIN)
.value("VIPRE_OUT", slsDetectorDefs::dacIndex::VIPRE_OUT)
.value("VREF_H_ADC", slsDetectorDefs::dacIndex::VREF_H_ADC)
.value("VB_COMP_FE", slsDetectorDefs::dacIndex::VB_COMP_FE)
.value("VB_COMP_ADC", slsDetectorDefs::dacIndex::VB_COMP_ADC)
.value("VCOM_CDS", slsDetectorDefs::dacIndex::VCOM_CDS)
.value("VREF_RESTORE", slsDetectorDefs::dacIndex::VREF_RESTORE)
.value("VB_OPA_1ST", slsDetectorDefs::dacIndex::VB_OPA_1ST)
.value("VREF_COMP_FE", slsDetectorDefs::dacIndex::VREF_COMP_FE)
.value("VCOM_ADC1", slsDetectorDefs::dacIndex::VCOM_ADC1)
.value("VREF_PRECH", slsDetectorDefs::dacIndex::VREF_PRECH)
.value("VREF_L_ADC", slsDetectorDefs::dacIndex::VREF_L_ADC)
.value("VREF_CDS", slsDetectorDefs::dacIndex::VREF_CDS)
.value("VB_CS", slsDetectorDefs::dacIndex::VB_CS)
.value("VB_OPA_FD", slsDetectorDefs::dacIndex::VB_OPA_FD)
.value("VCOM_ADC2", slsDetectorDefs::dacIndex::VCOM_ADC2)
.value("VB_DS", slsDetectorDefs::dacIndex::VB_DS)
.value("VB_COMP", slsDetectorDefs::dacIndex::VB_COMP)
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
.value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C)
.value("V_POWER_D", slsDetectorDefs::dacIndex::V_POWER_D)
.value("V_POWER_IO", slsDetectorDefs::dacIndex::V_POWER_IO)
.value("V_POWER_CHIP", slsDetectorDefs::dacIndex::V_POWER_CHIP)
.value("I_POWER_A", slsDetectorDefs::dacIndex::I_POWER_A)
.value("I_POWER_B", slsDetectorDefs::dacIndex::I_POWER_B)
.value("I_POWER_C", slsDetectorDefs::dacIndex::I_POWER_C)
.value("I_POWER_D", slsDetectorDefs::dacIndex::I_POWER_D)
.value("I_POWER_IO", slsDetectorDefs::dacIndex::I_POWER_IO)
.value("V_LIMIT", slsDetectorDefs::dacIndex::V_LIMIT)
.value("SLOW_ADC0", slsDetectorDefs::dacIndex::SLOW_ADC0)
.value("SLOW_ADC1", slsDetectorDefs::dacIndex::SLOW_ADC1)
.value("SLOW_ADC2", slsDetectorDefs::dacIndex::SLOW_ADC2)
.value("SLOW_ADC3", slsDetectorDefs::dacIndex::SLOW_ADC3)
.value("SLOW_ADC4", slsDetectorDefs::dacIndex::SLOW_ADC4)
.value("SLOW_ADC5", slsDetectorDefs::dacIndex::SLOW_ADC5)
.value("SLOW_ADC6", slsDetectorDefs::dacIndex::SLOW_ADC6)
.value("SLOW_ADC7", slsDetectorDefs::dacIndex::SLOW_ADC7)
.value("SLOW_ADC_TEMP", slsDetectorDefs::dacIndex::SLOW_ADC_TEMP)
.export_values();
py::enum_<slsDetectorDefs::detectorSettings>(Defs, "detectorSettings")
.value("GET_SETTINGS", slsDetectorDefs::detectorSettings::GET_SETTINGS)
.value("STANDARD", slsDetectorDefs::detectorSettings::STANDARD)
.value("FAST", slsDetectorDefs::detectorSettings::FAST)
.value("HIGHGAIN", slsDetectorDefs::detectorSettings::HIGHGAIN)
.value("DYNAMICGAIN", slsDetectorDefs::detectorSettings::DYNAMICGAIN)
.value("LOWGAIN", slsDetectorDefs::detectorSettings::LOWGAIN)
.value("MEDIUMGAIN", slsDetectorDefs::detectorSettings::MEDIUMGAIN)
.value("VERYHIGHGAIN", slsDetectorDefs::detectorSettings::VERYHIGHGAIN)
.value("DYNAMICHG0", slsDetectorDefs::detectorSettings::DYNAMICHG0)
.value("FIXGAIN1", slsDetectorDefs::detectorSettings::FIXGAIN1)
.value("FIXGAIN2", slsDetectorDefs::detectorSettings::FIXGAIN2)
.value("FORCESWITCHG1",
slsDetectorDefs::detectorSettings::FORCESWITCHG1)
.value("FORCESWITCHG2",
slsDetectorDefs::detectorSettings::FORCESWITCHG2)
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
.value("UNINITIALIZED",
slsDetectorDefs::detectorSettings::UNINITIALIZED)
.export_values();
py::enum_<slsDetectorDefs::clockIndex>(Defs, "clockIndex")
.value("ADC_CLOCK", slsDetectorDefs::clockIndex::ADC_CLOCK)
.value("DBIT_CLOCK", slsDetectorDefs::clockIndex::DBIT_CLOCK)
.value("RUN_CLOCK", slsDetectorDefs::clockIndex::RUN_CLOCK)
.value("SYNC_CLOCK", slsDetectorDefs::clockIndex::SYNC_CLOCK)
.export_values();
py::enum_<slsDetectorDefs::readoutMode>(Defs, "readoutMode")
.value("ANALOG_ONLY", slsDetectorDefs::readoutMode::ANALOG_ONLY)
.value("DIGITAL_ONLY", slsDetectorDefs::readoutMode::DIGITAL_ONLY)
.value("ANALOG_AND_DIGITAL",
slsDetectorDefs::readoutMode::ANALOG_AND_DIGITAL)
.export_values();
py::enum_<slsDetectorDefs::speedLevel>(Defs, "speedLevel")
.value("FULL_SPEED", slsDetectorDefs::speedLevel::FULL_SPEED)
.value("HALF_SPEED", slsDetectorDefs::speedLevel::HALF_SPEED)
.value("QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
.export_values();
py::enum_<slsDetectorDefs::portType>(Defs, "portType")
.value("CONTROL_PORT", slsDetectorDefs::portType::CONTROL_PORT)
.value("STOP_PORT", slsDetectorDefs::portType::STOP_PORT)
.value("DATA_PORT", slsDetectorDefs::portType::DATA_PORT)
.export_values();
py::enum_<slsDetectorDefs::masterFlags>(Defs, "masterFlags")
.value("GET_MASTER", slsDetectorDefs::masterFlags::GET_MASTER)
.value("NO_MASTER", slsDetectorDefs::masterFlags::NO_MASTER)
.value("IS_MASTER", slsDetectorDefs::masterFlags::IS_MASTER)
.value("IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE)
.export_values();
py::enum_<slsDetectorDefs::frameModeType>(Defs, "frameModeType")
.value("GET_FRAME_MODE", slsDetectorDefs::frameModeType::GET_FRAME_MODE)
.value("PEDESTAL", slsDetectorDefs::frameModeType::PEDESTAL)
.value("NEW_PEDESTAL", slsDetectorDefs::frameModeType::NEW_PEDESTAL)
.value("FLATFIELD", slsDetectorDefs::frameModeType::FLATFIELD)
.value("NEW_FLATFIELD", slsDetectorDefs::frameModeType::NEW_FLATFIELD)
.export_values();
py::enum_<slsDetectorDefs::detectorModeType>(Defs, "detectorModeType")
.value("GET_DETECTOR_MODE",
slsDetectorDefs::detectorModeType::GET_DETECTOR_MODE)
.value("COUNTING", slsDetectorDefs::detectorModeType::COUNTING)
.value("INTERPOLATING",
slsDetectorDefs::detectorModeType::INTERPOLATING)
.value("ANALOG", slsDetectorDefs::detectorModeType::ANALOG)
.export_values();
} }

View File

@ -1,18 +0,0 @@
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "sls_detector_defs.h"
namespace py = pybind11;
void init_enums(py::module &m) {
py::class_<slsDetectorDefs> Defs(m, "slsDetectorDefs");
py::class_<slsDetectorDefs::xy> xy(m, "xy");
xy.def(py::init());
xy.def(py::init<int,int>());
xy.def_readwrite("x", &slsDetectorDefs::xy::x);
xy.def_readwrite("y", &slsDetectorDefs::xy::y);
[[ENUMS]]
}

View File

@ -0,0 +1,70 @@
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "Detector.h"
#include "sls_detector_defs.h"
#include "typecaster.h"
namespace py = pybind11;
void init_experimental(py::module &m) {
// Experimental API to use the multi directly and inherit from to reduce
// code duplication need to investigate how to handle documentation
using sls::Detector;
using sls::Positions;
py::class_<Detector> multiDetectorApi(m, "multiDetectorApi");
multiDetectorApi
.def(py::init<int>())
// Acq related
.def("acquire", &Detector::acquire)
.def("startReceiver", &Detector::startReceiver, py::arg() = Positions{})
.def("stopReceiver", &Detector::stopReceiver, py::arg() = Positions{})
.def("getAcquiringFlag", &Detector::getAcquiringFlag)
.def("setAcquiringFlag", &Detector::setAcquiringFlag)
.def("getReceiverStatus", &Detector::getReceiverStatus,
py::arg() = Positions{})
// Configuration
.def("free", &Detector::freeSharedMemory)
.def("setConfig", &Detector::setConfig)
.def("getHostname", &Detector::getHostname, py::arg() = Positions{})
// Bits and registers
.def("setBit", &Detector::setBit, py::arg(), py::arg(),
py::arg() = Positions{})
.def("clearBit", &Detector::clearBit, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getRegister", &Detector::getRegister, py::arg(),
py::arg() = Positions{})
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
py::arg() = Positions{})
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
py::arg(), py::arg() = Positions{})
// File
.def("getFileName", &Detector::getFileName)
.def("setFileName", &Detector::setFileName, py::arg())
.def("getFilePath", &Detector::getFilePath)
.def("setFilePath", &Detector::setFilePath, py::arg())
.def("setFileWrite", &Detector::setFileWrite, py::arg(),
py::arg() = Positions{})
.def("getFileWrite", &Detector::getFileWrite, py::arg() = Positions{})
.def("setFileOverWrite", &Detector::setFileOverWrite, py::arg(),
py::arg() = Positions{})
.def("getFileOverWrite", &Detector::getFileOverWrite,
py::arg() = Positions{})
// Time
.def("setExptime", &Detector::setExptime, py::arg(),
py::arg() = Positions{})
.def("getExptime", &Detector::getExptime, py::arg() = Positions{})
.def("setPeriod", &Detector::setPeriod, py::arg(),
py::arg() = Positions{})
.def("getPeriod", &Detector::getPeriod, py::arg() = Positions{})
.def("setSubExptime", &Detector::setSubExptime, py::arg(),
py::arg() = Positions{})
.def("getSubExptime", &Detector::getSubExptime,
py::arg() = Positions{});
}

View File

@ -4,6 +4,7 @@
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include "Detector.h" #include "Detector.h"
#include "DetectorPythonInterface.h"
#include "Result.h" #include "Result.h"
#include "mythenFileIO.h" #include "mythenFileIO.h"
#include <chrono> #include <chrono>
@ -11,14 +12,20 @@
#include "typecaster.h" #include "typecaster.h"
// // Add type_typecaster to pybind for our wrapper type
// namespace pybind11 {
// namespace detail {
// template <typename Type, typename Alloc>
// struct type_caster<sls::Result<Type, Alloc>>
// : list_caster<sls::Result<Type, Alloc>, Type> {};
// } // namespace detail
// } // namespace pybind11
using ds = std::chrono::duration<double>; using ds = std::chrono::duration<double>;
namespace py = pybind11; namespace py = pybind11;
void init_enums(py::module &); void init_enums(py::module &);
void init_experimental(py::module &); void init_experimental(py::module &);
void init_det(py::module &);
void init_network(py::module &);
PYBIND11_MODULE(_sls_detector, m) { PYBIND11_MODULE(_sls_detector, m) {
m.doc() = R"pbdoc( m.doc() = R"pbdoc(
C/C++ API C/C++ API
@ -31,9 +38,309 @@ PYBIND11_MODULE(_sls_detector, m) {
)pbdoc"; )pbdoc";
init_enums(m); init_enums(m);
init_det(m); init_experimental(m);
init_network(m);
// init_experimental(m); py::class_<DetectorPythonInterface> DetectorApi(m, "DetectorApi", R"pbdoc(
Interface to the multiSlsDetector class through Detector.h These functions
are used by the python classes Eiger and Jungfrau and normally it is better
to use them than to directly access functions here.
However it is possible to access these functions...
::
#Using the python class
from sls_detector import Eiger
d = Eiger()
d._api.getThresholdEnergy()
from _sls_detector import DetectorApi
api = DetectorApi(0)
api.getNumberOfFrames()
#But the Pythonic way is almost alway simpler
d = Eiger()
d.n_frames
>> 10
)pbdoc");
DetectorApi.def(py::init<int>())
.def("freeSharedMemory", &DetectorPythonInterface::freeSharedMemory)
.def("getMultiDetectorId", &DetectorPythonInterface::getMultiDetectorId)
.def("acq", &DetectorPythonInterface::acquire)
.def("getAcquiringFlag", &DetectorPythonInterface::getAcquiringFlag)
.def("setAcquiringFlag", &DetectorPythonInterface::setAcquiringFlag)
.def("setAllTrimbits", &DetectorPythonInterface::setAllTrimbits)
.def("getAllTrimbits", &DetectorPythonInterface::getAllTrimbits)
.def("setCounterBit", &DetectorPythonInterface::setCounterBit)
.def("getCounterBit", &DetectorPythonInterface::getCounterBit)
.def("getAdc", &DetectorPythonInterface::getAdc)
.def("getDac", &DetectorPythonInterface::getDac)
.def("getDac_mV", &DetectorPythonInterface::getDac_mV)
.def("setDac", &DetectorPythonInterface::setDac)
.def("setDac_mV", &DetectorPythonInterface::setDac_mV)
.def("getDacFromIndex", &DetectorPythonInterface::getDacFromIndex)
.def("setDacFromIndex", &DetectorPythonInterface::setDacFromIndex)
.def("getDbitPipeline", &DetectorPythonInterface::getDbitPipeline)
.def("setDbitPipeline", &DetectorPythonInterface::setDbitPipeline)
.def("getDbitPhase", &DetectorPythonInterface::getDbitPhase)
.def("setDbitPhase", &DetectorPythonInterface::setDbitPhase)
.def("getDbitClock", &DetectorPythonInterface::getDbitClock)
.def("setDbitClock", &DetectorPythonInterface::setDbitClock)
.def("setThresholdEnergy", &DetectorPythonInterface::setThresholdEnergy)
.def("getThresholdEnergy", &DetectorPythonInterface::getThresholdEnergy)
.def("getSettings", &DetectorPythonInterface::getSettings)
.def("setSettings", &DetectorPythonInterface::setSettings)
.def("getSettingsDir", &DetectorPythonInterface::getSettingsDir)
.def("setSettingsDir", &DetectorPythonInterface::setSettingsDir)
.def("loadTrimbitFile", &DetectorPythonInterface::loadTrimbitFile)
.def("setTrimEnergies", &DetectorPythonInterface::setTrimEnergies)
.def("getTrimEnergies", &DetectorPythonInterface::getTrimEnergies)
.def("pulseChip", &DetectorPythonInterface::pulseChip)
.def("pulseAllPixels", &DetectorPythonInterface::pulseAllPixels)
.def("pulseDiagonal", &DetectorPythonInterface::pulseDiagonal)
.def("getRunStatus", &DetectorPythonInterface::getRunStatus)
.def("readConfigurationFile",
&DetectorPythonInterface::readConfigurationFile)
.def("readParametersFile", &DetectorPythonInterface::readParametersFile)
.def("checkOnline", &DetectorPythonInterface::checkOnline)
.def("setReadoutClockSpeed",
&DetectorPythonInterface::setReadoutClockSpeed)
.def("getReadoutClockSpeed",
&DetectorPythonInterface::getReadoutClockSpeed)
.def("getSyncClkSpeed", &DetectorPythonInterface::getSyncClkSpeed)
.def("getHostname", &DetectorPythonInterface::getHostname)
.def("setHostname", &DetectorPythonInterface::setHostname)
.def("getReceiverPort", &DetectorPythonInterface::getReceiverPort)
.def("setReceiverPort", &DetectorPythonInterface::setReceiverPort)
.def("isChipPowered", &DetectorPythonInterface::isChipPowered)
.def("powerChip", &DetectorPythonInterface::powerChip)
.def("readRegister", &DetectorPythonInterface::readRegister)
.def("writeRegister", &DetectorPythonInterface::writeRegister)
.def("writeAdcRegister", &DetectorPythonInterface::writeAdcRegister)
.def("setBitInRegister", &DetectorPythonInterface::setBitInRegister)
.def("clearBitInRegister", &DetectorPythonInterface::clearBitInRegister)
.def("setDynamicRange", &DetectorPythonInterface::setDynamicRange)
.def("getDynamicRange", &DetectorPythonInterface::getDynamicRange)
.def("getFirmwareVersion", &DetectorPythonInterface::getFirmwareVersion)
.def("getServerVersion", &DetectorPythonInterface::getServerVersion)
.def("getClientVersion", &DetectorPythonInterface::getClientVersion)
.def("getReceiverVersion", &DetectorPythonInterface::getReceiverVersion)
.def("getDetectorNumber", &DetectorPythonInterface::getDetectorNumber)
.def("getRateCorrection", &DetectorPythonInterface::getRateCorrection)
.def("setRateCorrection", &DetectorPythonInterface::setRateCorrection)
.def("startAcquisition", &DetectorPythonInterface::startAcquisition)
.def("stopAcquisition", &DetectorPythonInterface::stopAcquisition)
.def("startReceiver", &DetectorPythonInterface::startReceiver)
.def("stopReceiver", &DetectorPythonInterface::stopReceiver)
.def("getFilePath",
(std::string(DetectorPythonInterface::*)()) &
DetectorPythonInterface::getFilePath,
"Using multiSlsDetector")
.def("getFilePath",
(std::string(DetectorPythonInterface::*)(int)) &
DetectorPythonInterface::getFilePath,
"File path for individual detector")
.def("setFilePath", (void (DetectorPythonInterface::*)(std::string)) &
DetectorPythonInterface::setFilePath)
.def("setFileName", &DetectorPythonInterface::setFileName)
.def("getFileName", &DetectorPythonInterface::getFileName)
.def("setFileIndex", &DetectorPythonInterface::setFileIndex)
.def("getFileIndex", &DetectorPythonInterface::getFileIndex)
.def("setExposureTime", &DetectorPythonInterface::setExposureTime)
.def("getExposureTime", &DetectorPythonInterface::getExposureTime)
.def("setSubExposureTime", &DetectorPythonInterface::setSubExposureTime)
.def("getSubExposureTime", &DetectorPythonInterface::getSubExposureTime)
.def("setPeriod", &DetectorPythonInterface::setPeriod)
.def("getPeriod", &DetectorPythonInterface::getPeriod)
.def("setSubExposureDeadTime", &DetectorPythonInterface::setSubExposureDeadTime)
.def("getSubExposureDeadTime", &DetectorPythonInterface::getSubExposureDeadTime)
.def("getCycles", &DetectorPythonInterface::getCycles)
.def("setCycles", &DetectorPythonInterface::setCycles)
.def("getNumberOfGates", &DetectorPythonInterface::getNumberOfGates)
.def("setNumberOfGates", &DetectorPythonInterface::setNumberOfGates)
.def("getDelay", &DetectorPythonInterface::getDelay)
.def("setDelay", &DetectorPythonInterface::setDelay)
.def("setStoragecellStart", &DetectorPythonInterface::setStoragecellStart)
.def("getStoragecellStart", &DetectorPythonInterface::getStoragecellStart)
.def("setNumberOfStorageCells", &DetectorPythonInterface::setNumberOfStorageCells)
.def("getNumberOfStorageCells", &DetectorPythonInterface::getNumberOfStorageCells)
.def("getTimingMode", &DetectorPythonInterface::getTimingMode)
.def("setTimingMode", &DetectorPythonInterface::setTimingMode)
.def("getDetectorType", &DetectorPythonInterface::getDetectorType)
.def("setThresholdTemperature", &DetectorPythonInterface::setThresholdTemperature)
.def("getThresholdTemperature", &DetectorPythonInterface::getThresholdTemperature)
.def("setTemperatureControl", &DetectorPythonInterface::setTemperatureControl)
.def("getTemperatureControl", &DetectorPythonInterface::getTemperatureControl)
.def("getTemperatureEvent", &DetectorPythonInterface::getTemperatureEvent)
.def("resetTemperatureEvent", &DetectorPythonInterface::resetTemperatureEvent)
.def("getRxDataStreamStatus", &DetectorPythonInterface::getRxDataStreamStatus)
.def("setRxDataStreamStatus", &DetectorPythonInterface::setRxDataStreamStatus)
// Network stuff
.def("getReceiverHostname",
&DetectorPythonInterface::getReceiverHostname,
py::arg("det_id") = -1)
.def("setReceiverHostname",
&DetectorPythonInterface::setReceiverHostname, py::arg("hostname"),
py::arg("det_id") = -1)
.def("getReceiverStreamingPort",
&DetectorPythonInterface::getReceiverStreamingPort)
.def("setReceiverStreamingPort",
&DetectorPythonInterface::setReceiverStreamingPort)
.def("getReceiverUDPPort", &DetectorPythonInterface::getReceiverUDPPort)
.def("getReceiverUDPPort2",
&DetectorPythonInterface::getReceiverUDPPort2)
.def("setReceiverUDPPort", &DetectorPythonInterface::setReceiverUDPPort)
.def("setReceiverUDPPort2",
&DetectorPythonInterface::setReceiverUDPPort2)
.def("setReceiverUDPIP", &DetectorPythonInterface::setReceiverUDPIP)
.def("getReceiverUDPIP", &DetectorPythonInterface::getReceiverUDPIP)
.def("getReceiverUDPMAC", &DetectorPythonInterface::getReceiverUDPMAC)
.def("setReceiverUDPMAC", &DetectorPythonInterface::setReceiverUDPMAC)
.def("getReceiverPort", &DetectorPythonInterface::getReceiverPort)
.def("setReceiverPort", &DetectorPythonInterface::setReceiverPort)
.def("configureNetworkParameters",
&DetectorPythonInterface::configureNetworkParameters)
.def("getDelayFrame", &DetectorPythonInterface::getDelayFrame)
.def("setDelayFrame", &DetectorPythonInterface::setDelayFrame)
.def("getDelayLeft", &DetectorPythonInterface::getDelayLeft)
.def("setDelayLeft", &DetectorPythonInterface::setDelayLeft)
.def("getDelayRight", &DetectorPythonInterface::getDelayRight)
.def("setDelayRight", &DetectorPythonInterface::setDelayRight)
.def("getLastClientIP", &DetectorPythonInterface::getLastClientIP)
.def("getReceiverLastClientIP",
&DetectorPythonInterface::getReceiverLastClientIP)
.def("setFramesPerFile", &DetectorPythonInterface::setFramesPerFile)
.def("getFramesPerFile", &DetectorPythonInterface::getFramesPerFile)
.def("setReceiverFifoDepth",
&DetectorPythonInterface::setReceiverFifoDepth)
.def("getReceiverFifoDepth",
&DetectorPythonInterface::getReceiverFifoDepth)
.def("getReceiverFrameDiscardPolicy",
&DetectorPythonInterface::getReceiverFrameDiscardPolicy)
.def("setReceiverFramesDiscardPolicy",
&DetectorPythonInterface::setReceiverFramesDiscardPolicy)
.def("setPartialFramesPadding",
&DetectorPythonInterface::setPartialFramesPadding)
.def("getPartialFramesPadding",
&DetectorPythonInterface::getPartialFramesPadding)
.def("getUserDetails", &DetectorPythonInterface::getUserDetails)
.def("checkDetectorVersionCompatibility",
&DetectorPythonInterface::checkDetectorVersionCompatibility)
.def("checkReceiverVersionCompatibility",
&DetectorPythonInterface::checkReceiverVersionCompatibility)
.def("getMeasuredPeriod", &DetectorPythonInterface::getMeasuredPeriod)
.def("getMeasuredSubPeriod",
&DetectorPythonInterface::getMeasuredSubPeriod)
.def("setFileWrite", &DetectorPythonInterface::setFileWrite)
.def("getFileWrite", &DetectorPythonInterface::getFileWrite)
.def("setFileOverWrite", &DetectorPythonInterface::setFileOverWrite)
.def("getFileOverWrite", &DetectorPythonInterface::getFileOverWrite)
.def("getDacVthreshold", &DetectorPythonInterface::getDacVthreshold)
.def("setDacVthreshold", &DetectorPythonInterface::setDacVthreshold)
.def("setNumberOfFrames", &DetectorPythonInterface::setNumberOfFrames)
.def("getNumberOfFrames", &DetectorPythonInterface::getNumberOfFrames)
// Overloaded calls
.def("getFramesCaughtByReceiver",
(int (DetectorPythonInterface::*)()) &
DetectorPythonInterface::getFramesCaughtByReceiver)
.def("getFramesCaughtByReceiver",
(int (DetectorPythonInterface::*)(int)) &
DetectorPythonInterface::getFramesCaughtByReceiver)
.def("resetFramesCaught", &DetectorPythonInterface::resetFramesCaught)
.def("getReceiverCurrentFrameIndex",
&DetectorPythonInterface::getReceiverCurrentFrameIndex)
.def("getGapPixels", &DetectorPythonInterface::getGapPixels)
.def("setGapPixels", &DetectorPythonInterface::setGapPixels)
.def("getFlippedDataX", &DetectorPythonInterface::getFlippedDataX)
.def("getFlippedDataY", &DetectorPythonInterface::getFlippedDataY)
.def("setFlippedDataX", &DetectorPythonInterface::setFlippedDataX)
.def("setFlippedDataY", &DetectorPythonInterface::setFlippedDataY)
.def("getServerLock", &DetectorPythonInterface::getServerLock)
.def("setServerLock", &DetectorPythonInterface::setServerLock)
.def("getReceiverLock", &DetectorPythonInterface::getReceiverLock)
.def("setReceiverLock", &DetectorPythonInterface::setReceiverLock)
.def("getReadoutFlags", &DetectorPythonInterface::getReadoutFlags)
.def("setReadoutFlag", &DetectorPythonInterface::setReadoutFlag)
.def("setFileFormat", &DetectorPythonInterface::setFileFormat)
.def("getFileFormat", &DetectorPythonInterface::getFileFormat)
.def("getActive", &DetectorPythonInterface::getActive)
.def("setActive", &DetectorPythonInterface::setActive)
.def("getTenGigabitEthernet",
&DetectorPythonInterface::getTenGigabitEthernet)
.def("setTenGigabitEthernet",
&DetectorPythonInterface::setTenGigabitEthernet)
.def("getPatternLoops", &DetectorPythonInterface::getPatternLoops,
py::arg("level"), py::arg("det_id") = -1)
.def("setPatternLoops", &DetectorPythonInterface::setPatternLoops,
py::arg("level"), py::arg("start"), py::arg("stop"), py::arg("n"),
py::arg("det_id") = -1)
.def("setPatternWord", &DetectorPythonInterface::setPatternWord,
py::arg("addr"), py::arg("word"), py::arg("det_id") = -1)
.def("getPatternWord", &DetectorPythonInterface::getPatternWord,
py::arg("addr"), py::arg("det_id") = -1)
.def("setPatternIOControl",
&DetectorPythonInterface::setPatternIOControl, py::arg("word"),
py::arg("det_id") = -1)
.def("setPatternClockControl",
&DetectorPythonInterface::setPatternClockControl, py::arg("word"),
py::arg("det_id") = -1)
.def("setPatternWaitAddr", &DetectorPythonInterface::setPatternWaitAddr,
py::arg("level"), py::arg("addr"), py::arg("det_id") = -1)
.def("getPatternWaitAddr", &DetectorPythonInterface::getPatternWaitAddr,
py::arg("level"), py::arg("det_id") = -1)
.def("setPatternWaitTime", &DetectorPythonInterface::setPatternWaitTime,
py::arg("level"), py::arg("duration"), py::arg("det_id") = -1)
.def("getPatternWaitTime", &DetectorPythonInterface::getPatternWaitTime,
py::arg("level"), py::arg("det_id") = -1)
.def("getImageSize", &DetectorPythonInterface::getImageSize)
.def("setImageSize", &DetectorPythonInterface::setImageSize)
.def("getNumberOfDetectors",
&DetectorPythonInterface::getNumberOfDetectors)
.def("getDetectorGeometry",
&DetectorPythonInterface::getDetectorGeometry);
py::module io = m.def_submodule("io", "Submodule for io"); py::module io = m.def_submodule("io", "Submodule for io");

View File

@ -1,39 +0,0 @@
/*
This file contains Python bindings for the IpAddr and MacAddr
classes.
*/
#include <pybind11/chrono.h>
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "network_utils.h"
namespace py = pybind11;
using sls::IpAddr;
using sls::MacAddr;
void init_network(py::module &m) {
py::class_ <IpAddr> IpAddr(m, "IpAddr");
IpAddr.def(py::init())
.def(py::init<const std::string&>())
.def(py::init<uint32_t>())
.def("hex", &IpAddr::hex)
.def("uint32", &IpAddr::uint32)
.def(py::self == py::self)
.def("__repr__", &IpAddr::str)
.def("str", &IpAddr::str);
py::class_ <MacAddr> MacAddr(m, "MacAddr");
MacAddr.def(py::init())
.def(py::init<const std::string&>())
.def(py::init<uint64_t>())
.def("hex", &MacAddr::hex)
.def(py::self == py::self)
.def("uint64", &MacAddr::uint64)
.def("__repr__", &MacAddr::str)
.def("str", &MacAddr::str);
}

View File

@ -1,13 +1,8 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Testing the Detector python class by mocking calls. Testing parameters and methods of the Detector class using mocks
Should only be used when there is functionality in
the detector.py file.
An example is converting a mask to a list of set bits.
""" """
from unittest.mock import Mock from unittest.mock import Mock
import pytest import pytest
from pytest_mock import mocker from pytest_mock import mocker
@ -18,471 +13,459 @@ sys.path.append('/home/l_frojdh/slsdetectorgrup/sls_detector')
import _sls_detector import _sls_detector
from sls_detector.errors import DetectorValueError, DetectorError from sls_detector.errors import DetectorValueError, DetectorError
from sls_detector.utils import all_equal, element_if_equal from sls_detector.utils import all_equal, element_if_equal
@pytest.fixture @pytest.fixture
def d(): def d():
from sls_detector import Detector from sls_detector import Detector
return Detector() return Detector()
def test_length(d, mocker):
m = mocker.patch('sls_detector.Detector.size')
m.return_value = 5
assert(len(d) == 5)
def test_counters_single(d, mocker): def test_length_zero(d):
m = mocker.patch('sls_detector.Detector.getCounterMask') assert len(d) == 0
m.return_value = [7]
assert(d.counters == [0,1,2])
def test_counters_multi(d, mocker): def test_acq_call(d, mocker):
m = mocker.patch('sls_detector.Detector.getCounterMask') m = mocker.patch('_sls_detector.DetectorApi.acq')
m.return_value = [7, 9] d.acq()
assert(d.counters == [[0,1,2],[0,3]]) m.assert_called_once_with()
def test_set_counters_single(d, mocker):
m = mocker.patch('sls_detector.Detector.setCounterMask')
d.counters = [0,2] def test_busy_call(d, mocker):
m.assert_called_once_with(5) m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag')
m.return_value = False
assert d.busy == False
# def test_busy_call(d, mocker): def test_set_busy(d):
# m = mocker.patch('_sls_detector.DetectorApi.getAcquiringFlag') d.busy = True
# m.return_value = False assert d.busy == True
# assert d.busy == False assert d._api.getAcquiringFlag() == True
d.busy = False
# def test_set_busy(d): assert d.busy == False
# d.busy = True assert d._api.getAcquiringFlag() == False
# assert d.busy == True
# assert d._api.getAcquiringFlag() == True def test_error_mask(d):
# d.busy = False d._api.setErrorMask(1)
# assert d.busy == False assert d.error_mask == 1
# assert d._api.getAcquiringFlag() == False d.clear_errors()
# def test_error_mask(d): def test_error_handling(d):
# d._api.setErrorMask(1) with pytest.raises(DetectorError):
# assert d.error_mask == 1 d._provoke_error()
# d.clear_errors()
def test_assign_to_detector_type(d):
# def test_error_handling(d): with pytest.raises(AttributeError):
# with pytest.raises(DetectorError): d.detector_type = 'Eiger'
# d._provoke_error()
def test_det_type(d, mocker):
# def test_assign_to_detector_type(d): m = mocker.patch('_sls_detector.DetectorApi.getDetectorType')
# with pytest.raises(AttributeError): m.return_value = 'Eiger'
# d.detector_type = 'Eiger' assert d.detector_type == 'Eiger'
# def test_det_type(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorType') def test_get_exposure_time(d, mocker):
# m.return_value = 'Eiger' m = mocker.patch('_sls_detector.DetectorApi.getExposureTime')
# assert d.detector_type == 'Eiger' m.return_value = 100000000
assert d.exposure_time == 0.1
# def test_get_exposure_time(d, mocker): def test_set_exposure_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getExposureTime') m = mocker.patch('_sls_detector.DetectorApi.setExposureTime')
# m.return_value = 100000000 d.exposure_time = 1.5
# assert d.exposure_time == 0.1 m.assert_called_once_with(1500000000)
# def test_set_exposure_time(d, mocker): def test_set_exposure_time_less_than_zero(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setExposureTime') mocker.patch('_sls_detector.DetectorApi.setExposureTime')
# d.exposure_time = 1.5 with pytest.raises(DetectorValueError):
# m.assert_called_once_with(1500000000) d.exposure_time = -7
# def test_set_exposure_time_less_than_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setExposureTime') def test_get_file_index(d, mocker):
# with pytest.raises(DetectorValueError): m = mocker.patch('_sls_detector.DetectorApi.getFileIndex')
# d.exposure_time = -7 m.return_value = 8
assert d.file_index == 8
# def test_get_file_index(d, mocker): def test_set_file_index(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileIndex') m = mocker.patch('_sls_detector.DetectorApi.setFileIndex')
# m.return_value = 8 d.file_index = 9
# assert d.file_index == 8 m.assert_called_with(9)
# def test_set_file_index(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileIndex') def file_index_with_no_detector(d):
# d.file_index = 9 assert d.file_index == -100
# m.assert_called_with(9)
def dr_with_no_detector(d):
assert d.dynamic_range == -100
# def file_index_with_no_detector(d):
# assert d.file_index == -100 def test_set_file_index_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setFileIndex')
# def dr_with_no_detector(d): with pytest.raises(ValueError):
# assert d.dynamic_range == -100 d.file_index = -9
# def test_set_file_index_raises_on_neg(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setFileIndex') def test_get_file_name(d, mocker):
# with pytest.raises(ValueError): m = mocker.patch('_sls_detector.DetectorApi.getFileName')
# d.file_index = -9 d.file_name
m.assert_called_once_with()
# def test_get_file_name(d, mocker): def test_set_file_name(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileName') m = mocker.patch('_sls_detector.DetectorApi.setFileName')
# d.file_name d.file_name = 'hej'
# m.assert_called_once_with() m.assert_called_once_with('hej')
# def test_set_file_name(d, mocker): def test_get_file_path(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileName') m = mocker.patch('_sls_detector.DetectorApi.getFilePath')
# d.file_name = 'hej' d.file_path
# m.assert_called_once_with('hej') m.assert_called_once_with()
# def test_get_file_path(d, mocker): def test_set_file_path_when_path_exists(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFilePath') m = mocker.patch('_sls_detector.DetectorApi.setFilePath')
# d.file_path #To avoid raising an exception because path is not there
# m.assert_called_once_with() mock_os = mocker.patch('os.path.exists')
mock_os.return_value = True
# def test_set_file_path_when_path_exists(d, mocker): d.file_path = '/path/to/something/'
# m = mocker.patch('_sls_detector.DetectorApi.setFilePath') m.assert_called_once_with('/path/to/something/')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.exists') def test_set_file_path_raises_when_not_exists(d, mocker):
# mock_os.return_value = True mocker.patch('_sls_detector.DetectorApi.setFilePath')
# d.file_path = '/path/to/something/' mock_os = mocker.patch('os.path.exists')
# m.assert_called_once_with('/path/to/something/') mock_os.return_value = False
with pytest.raises(FileNotFoundError):
# def test_set_file_path_raises_when_not_exists(d, mocker): d.file_path = '/path/to/something/'
# mocker.patch('_sls_detector.DetectorApi.setFilePath')
# mock_os = mocker.patch('os.path.exists') def test_get_file_write(d, mocker):
# mock_os.return_value = False m = mocker.patch('_sls_detector.DetectorApi.getFileWrite')
# with pytest.raises(FileNotFoundError): m.return_value = False
# d.file_path = '/path/to/something/' assert d.file_write == False
# def test_get_file_write(d, mocker): def test_set_file_write(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getFileWrite') m = mocker.patch('_sls_detector.DetectorApi.setFileWrite')
# m.return_value = False d.file_write = True
# assert d.file_write == False m.assert_called_once_with(True)
# def test_set_file_write(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setFileWrite') def test_get_firmware_version(d, mocker):
# d.file_write = True m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion')
# m.assert_called_once_with(True) m.return_value = 20
assert d.firmware_version == 20
# def test_get_firmware_version(d, mocker): def test_cannot_set_fw_version(d):
# m = mocker.patch('_sls_detector.DetectorApi.getFirmwareVersion') with pytest.raises(AttributeError):
# m.return_value = 20 d.firmware_version = 20
# assert d.firmware_version == 20
def test_get_high_voltage_call_signature(d, mocker):
# def test_cannot_set_fw_version(d): m = mocker.patch('_sls_detector.DetectorApi.getDac')
# with pytest.raises(AttributeError): d.high_voltage
# d.firmware_version = 20 m.assert_called_once_with('vhighvoltage', -1)
# def test_get_high_voltage_call_signature(d, mocker): def test_get_high_voltage(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac') m = mocker.patch('_sls_detector.DetectorApi.getDac')
# d.high_voltage m.return_value = 80
# m.assert_called_once_with('vhighvoltage', -1) assert d.high_voltage == 80
# def test_get_high_voltage(d, mocker): #self._api.setDac('vhighvoltage', -1, voltage)
# m = mocker.patch('_sls_detector.DetectorApi.getDac') def test_set_high_voltage(d, mocker):
# m.return_value = 80 m = mocker.patch('_sls_detector.DetectorApi.setDac')
# assert d.high_voltage == 80 d.high_voltage = 80
m.assert_called_once_with('vhighvoltage', -1, 80)
# #self._api.setDac('vhighvoltage', -1, voltage)
# def test_set_high_voltage(d, mocker): def test_decode_hostname_two_names(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setDac') m = mocker.patch('_sls_detector.DetectorApi.getHostname')
# d.high_voltage = 80 m.return_value = 'beb059+beb048+'
# m.assert_called_once_with('vhighvoltage', -1, 80) assert d.hostname == ['beb059', 'beb048']
# def test_decode_hostname_two_names(d, mocker): def test_decode_hostname_four_names(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname') m = mocker.patch('_sls_detector.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+' m.return_value = 'beb059+beb048+beb120+beb153+'
# assert d.hostname == ['beb059', 'beb048'] assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153']
# def test_decode_hostname_four_names(d, mocker): def test_decode_hostname_blank(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname') m = mocker.patch('_sls_detector.DetectorApi.getHostname')
# m.return_value = 'beb059+beb048+beb120+beb153+' m.return_value = ''
# assert d.hostname == ['beb059', 'beb048', 'beb120', 'beb153'] assert d.hostname == []
# def test_decode_hostname_blank(d, mocker): def test_get_image_size_gives_correct_size(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getHostname') m = mocker.patch('_sls_detector.DetectorApi.getImageSize')
# m.return_value = '' m.return_value = (512,1024)
# assert d.hostname == [] im_size = d.image_size
assert im_size.rows == 512
# def test_get_image_size_gives_correct_size(d, mocker): assert im_size.cols == 1024
# m = mocker.patch('_sls_detector.DetectorApi.getImageSize')
# m.return_value = (512,1024)
# im_size = d.image_size
# assert im_size.rows == 512 def test_load_config(d, mocker):
# assert im_size.cols == 1024 m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
#To avoid raising an exception because path is not there
mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
# def test_load_config(d, mocker): d.load_config('/path/to/my/file.config')
# m = mocker.patch('_sls_detector.DetectorApi.readConfigurationFile') m.assert_called_once_with('/path/to/my/file.config')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile') def test_load_config_raises_when_file_is_not_found(d, mocker):
# mock_os.return_value = True mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
# d.load_config('/path/to/my/file.config') mock_os = mocker.patch('os.path.isfile')
# m.assert_called_once_with('/path/to/my/file.config') mock_os.return_value = False
with pytest.raises(FileNotFoundError):
# def test_load_config_raises_when_file_is_not_found(d, mocker): d.load_config('/path/to/my/file.config')
# mocker.patch('_sls_detector.DetectorApi.readConfigurationFile')
# mock_os = mocker.patch('os.path.isfile') def test_load_parameters(d, mocker):
# mock_os.return_value = False m = mocker.patch('_sls_detector.DetectorApi.readParametersFile')
# with pytest.raises(FileNotFoundError): #To avoid raising an exception because path is not there
# d.load_config('/path/to/my/file.config') mock_os = mocker.patch('os.path.isfile')
mock_os.return_value = True
# def test_load_parameters(d, mocker): d.load_parameters('/path/to/my/file.par')
# m = mocker.patch('_sls_detector.DetectorApi.readParametersFile') m.assert_called_once_with('/path/to/my/file.par')
# #To avoid raising an exception because path is not there
# mock_os = mocker.patch('os.path.isfile') def test_load_parameters_raises_when_file_is_not_found(d, mocker):
# mock_os.return_value = True mocker.patch('_sls_detector.DetectorApi.readParametersFile')
# d.load_parameters('/path/to/my/file.par') mock_os = mocker.patch('os.path.isfile')
# m.assert_called_once_with('/path/to/my/file.par') mock_os.return_value = False
with pytest.raises(FileNotFoundError):
# def test_load_parameters_raises_when_file_is_not_found(d, mocker): d.load_parameters('/path/to/my/file.par')
# mocker.patch('_sls_detector.DetectorApi.readParametersFile')
# mock_os = mocker.patch('os.path.isfile') #getDetectorGeometry
# mock_os.return_value = False def test_get_module_geometry_gives_correct_size(d, mocker):
# with pytest.raises(FileNotFoundError): m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
# d.load_parameters('/path/to/my/file.par') m.return_value = (13,7)
g = d.module_geometry
# #getDetectorGeometry assert g.vertical == 7
# def test_get_module_geometry_gives_correct_size(d, mocker): assert g.horizontal == 13
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
# m.return_value = (13,7) def test_get_module_geometry_access(d, mocker):
# g = d.module_geometry m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry')
# assert g.vertical == 7 m.return_value = (12,3)
# assert g.horizontal == 13 assert d.module_geometry[0] == 12
assert d.module_geometry[1] == 3
# def test_get_module_geometry_access(d, mocker): assert d.module_geometry.vertical == 3
# m = mocker.patch('_sls_detector.DetectorApi.getDetectorGeometry') assert d.module_geometry.horizontal == 12
# m.return_value = (12,3)
# assert d.module_geometry[0] == 12 def test_module_geometry_without_detectors(d):
# assert d.module_geometry[1] == 3 t = d.module_geometry
# assert d.module_geometry.vertical == 3 assert t.horizontal == 0
# assert d.module_geometry.horizontal == 12 assert t.vertical == 0
# def test_module_geometry_without_detectors(d): def test_get_n_frames(d, mocker):
# t = d.module_geometry m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames')
# assert t.horizontal == 0 m.return_value = 3
# assert t.vertical == 0 assert d.n_frames == 3
# def test_get_n_frames(d, mocker): def test_set_n_frames(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNumberOfFrames') m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
# m.return_value = 3 d.n_frames = 9
# assert d.n_frames == 3 m.assert_called_once_with(9)
# def test_set_n_frames(d, mocker): def test_nframes_without_detector(d):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') assert d.n_frames == -100
# d.n_frames = 9
# m.assert_called_once_with(9) def test_set_n_frames_raises_on_neg(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
# def test_nframes_without_detector(d): with pytest.raises(DetectorValueError):
# assert d.n_frames == -100 d.n_frames = -1
# def test_set_n_frames_raises_on_neg(d, mocker): def test_set_n_frames_raises_on_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames')
# with pytest.raises(DetectorValueError): with pytest.raises(DetectorValueError):
# d.n_frames = -1 d.n_frames = 0
# def test_set_n_frames_raises_on_zero(d, mocker): def test_n_cycles_without_detector(d):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfFrames') assert d.n_cycles == -100
# with pytest.raises(DetectorValueError):
# d.n_frames = 0 def test_set_n_cycles_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setCycles')
# def test_n_cycles_without_detector(d): with pytest.raises(DetectorValueError):
# assert d.n_cycles == -100 d.n_cycles = 0
# def test_set_n_cycles_raises_on_zero(d, mocker): def test_set_n_cycles(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setCycles') m = mocker.patch('_sls_detector.DetectorApi.setCycles')
# with pytest.raises(DetectorValueError): d.n_cycles = 56
# d.n_cycles = 0 m.assert_called_once_with(56)
# def test_set_n_cycles(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setCycles')
# d.n_cycles = 56 def test_n_measurements_without_detector(d):
# m.assert_called_once_with(56) assert d.n_measurements == -100
def test_set_n_measurements_raises_on_zero(d, mocker):
mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
# def test_n_measurements_without_detector(d): with pytest.raises(DetectorValueError):
# assert d.n_measurements == -100 d.n_measurements = 0
# def test_set_n_measurements_raises_on_zero(d, mocker): def test_set_n_measurements(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements') m = mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements')
# with pytest.raises(DetectorValueError): d.n_measurements = 560
# d.n_measurements = 0 m.assert_called_once_with(560)
# def test_set_n_measurements(d, mocker): def test_get_n_modules_no_detector(d):
# m = mocker.patch('_sls_detector.DetectorApi.setNumberOfMeasurements') assert d.n_modules == 0
# d.n_measurements = 560
# m.assert_called_once_with(560) def test_get_n_modules(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
# def test_get_n_modules_no_detector(d): m.return_value = 12
# assert d.n_modules == 0 assert d.n_modules == 12
# def test_get_n_modules(d, mocker): def test_get_period_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') m = mocker.patch('_sls_detector.DetectorApi.getPeriod')
# m.return_value = 12 m.return_value = 130000000
# assert d.n_modules == 12 assert d.period == 0.13
# def test_get_period_time(d, mocker): def test_set_period_time(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getPeriod') m = mocker.patch('_sls_detector.DetectorApi.setPeriod')
# m.return_value = 130000000 d.period = 1.953
# assert d.period == 0.13 m.assert_called_once_with(1953000000)
# def test_set_period_time(d, mocker): def test_set_period_time_less_than_zero(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setPeriod') mocker.patch('_sls_detector.DetectorApi.setPeriod')
# d.period = 1.953 with pytest.raises(ValueError):
# m.assert_called_once_with(1953000000) d.period = -7
# def test_set_period_time_less_than_zero(d, mocker):
# mocker.patch('_sls_detector.DetectorApi.setPeriod') def test_get_online(d, mocker):
# with pytest.raises(ValueError): m = mocker.patch('_sls_detector.DetectorApi.getOnline')
# d.period = -7 d.online
m.assert_called_once_with()
# def test_get_online(d, mocker): def test_set_online(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getOnline') m = mocker.patch('_sls_detector.DetectorApi.setOnline')
# d.online d.online = True
# m.assert_called_once_with() m.assert_called_once_with(True)
# def test_set_online(d, mocker): def test_last_client_ip_no_detector(d):
# m = mocker.patch('_sls_detector.DetectorApi.setOnline') assert d.last_client_ip == ''
# d.online = True
# m.assert_called_once_with(True) def test_last_cliten_ip_call(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getLastClientIP')
# def test_last_client_ip_no_detector(d): d.last_client_ip
# assert d.last_client_ip == '' m.assert_called_once_with()
# def test_last_cliten_ip_call(d, mocker): #-------------------------------------------------------------Rate correction
# m = mocker.patch('_sls_detector.DetectorApi.getLastClientIP') def test_get_rate_correction(d, mocker):
# d.last_client_ip m = mocker.patch('_sls_detector.DetectorApi.getRateCorrection')
# m.assert_called_once_with() m.return_value = [132,129]
assert d.rate_correction == [132,129]
# #-------------------------------------------------------------Rate correction
# def test_get_rate_correction(d, mocker): def test_set_rate_correction(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRateCorrection') m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
# m.return_value = [132,129] mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
# assert d.rate_correction == [132,129] mock_n.return_value = 3
d.rate_correction = [123,90,50]
# def test_set_rate_correction(d, mocker): m.assert_called_once_with([123,90,50])
# m = mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker):
# mock_n.return_value = 3 mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
# d.rate_correction = [123,90,50] mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors')
# m.assert_called_once_with([123,90,50]) mock_n.return_value = 4
with pytest.raises(ValueError):
# def test_set_rate_correction_raises_on_wrong_number_of_values(d, mocker): d.rate_correction = [123,90,50]
# mocker.patch('_sls_detector.DetectorApi.setRateCorrection')
# mock_n = mocker.patch('_sls_detector.DetectorApi.getNumberOfDetectors') #----------------------------------------------------------------Readout clock
# mock_n.return_value = 4 def test_get_readout_clock_0(d, mocker):
# with pytest.raises(ValueError): m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
# d.rate_correction = [123,90,50] m.return_value = 0
assert d.readout_clock == 'Full Speed'
# #----------------------------------------------------------------Readout clock
# def test_get_readout_clock_0(d, mocker): def test_get_readout_clock_1(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
# m.return_value = 0 m.return_value = 1
# assert d.readout_clock == 'Full Speed' assert d.readout_clock == 'Half Speed'
# def test_get_readout_clock_1(d, mocker): def test_get_readout_clock_2(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
# m.return_value = 1 m.return_value = 2
# assert d.readout_clock == 'Half Speed' assert d.readout_clock == 'Quarter Speed'
# def test_get_readout_clock_2(d, mocker): def test_get_readout_clock_3(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed')
# m.return_value = 2 m.return_value = 3
# assert d.readout_clock == 'Quarter Speed' assert d.readout_clock == 'Super Slow Speed'
# def test_get_readout_clock_3(d, mocker): def test_set_readout_clock_0(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
# m.return_value = 3 d.readout_clock = 'Full Speed'
# assert d.readout_clock == 'Super Slow Speed' m.assert_called_once_with(0)
# def test_set_readout_clock_0(d, mocker): def test_set_readout_clock_1(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Full Speed' d.readout_clock = 'Half Speed'
# m.assert_called_once_with(0) m.assert_called_once_with(1)
# def test_set_readout_clock_1(d, mocker): def test_set_readout_clock_2(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Half Speed' d.readout_clock = 'Quarter Speed'
# m.assert_called_once_with(1) m.assert_called_once_with(2)
# def test_set_readout_clock_2(d, mocker): def test_set_readout_clock_3(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed')
# d.readout_clock = 'Quarter Speed' d.readout_clock = 'Super Slow Speed'
# m.assert_called_once_with(2) m.assert_called_once_with(3)
# def test_set_readout_clock_3(d, mocker): #----------------------------------------------------------------rx_datastream
# m = mocker.patch('_sls_detector.DetectorApi.setReadoutClockSpeed') def test_get_rx_datastream(d, mocker):
# d.readout_clock = 'Super Slow Speed' m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus')
# m.assert_called_once_with(3) m.return_value = False
assert d.rx_datastream == False
# #----------------------------------------------------------------rx_datastream
# def test_get_rx_datastream(d, mocker): def test_set_rx_datastream(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRxDataStreamStatus') m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus')
# m.return_value = False d.rx_datastream = True
# assert d.rx_datastream == False m.assert_called_once_with(True)
# def test_set_rx_datastream(d, mocker): def test_get_rx_zmqip(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setRxDataStreamStatus') m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# d.rx_datastream = True d.rx_zmqip
# m.assert_called_once_with(True) m.assert_called_once_with('rx_zmqip')
# def test_get_rx_zmqip(d, mocker): def test_get_rx_zmqport_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# d.rx_zmqip d.rx_zmqport
# m.assert_called_once_with('rx_zmqip') m.assert_called_once_with('rx_zmqport')
# def test_get_rx_zmqport_call(d, mocker): def test_get_rx_zmqport_decode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# d.rx_zmqport m.return_value = ['30001', '30003']
# m.assert_called_once_with('rx_zmqport') assert d.rx_zmqport == [30001, 30003]
# def test_get_rx_zmqport_decode(d, mocker): def test_get_rx_zmqport_empty(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter')
# m.return_value = ['30001', '30003'] m.return_value = ''
# assert d.rx_zmqport == [30001, 30003] assert d.rx_zmqport == []
# def test_get_rx_zmqport_empty(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getNetworkParameter') #--------------------------------------------------------------------status
# m.return_value = '' def test_status_call(d, mocker):
# assert d.rx_zmqport == [] m = mocker.patch('_sls_detector.DetectorApi.getRunStatus')
d.status
m.assert_called_once_with()
# #--------------------------------------------------------------------status
# def test_status_call(d, mocker): def test_start_detecor(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getRunStatus') m = mocker.patch('_sls_detector.DetectorApi.startAcquisition')
# d.status d.start_detector()
# m.assert_called_once_with() m.assert_called_once_with()
# def test_start_detecor(d, mocker): def test_stop_acq_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.startAcquisition') m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition')
# d.start_detector() d.stop_detector()
# m.assert_called_once_with() m.assert_called_once_with()
# def test_stop_acq_call(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.stopAcquisition')
# d.stop_detector() #------------------------------------------------------------------timing mode
# m.assert_called_once_with() def test_get_timing_mode(d, mocker):
m = mocker.patch('_sls_detector.DetectorApi.getTimingMode')
d.timing_mode
m.assert_called_once_with()
# #------------------------------------------------------------------timing mode
# def test_get_timing_mode(d, mocker): def test_set_timing_mode(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getTimingMode') m = mocker.patch('_sls_detector.DetectorApi.setTimingMode')
# d.timing_mode d.timing_mode = 'auto'
# m.assert_called_once_with() m.assert_called_once_with('auto')
# def test_set_timing_mode(d, mocker): #----------------------------------------------------------------vthreshold
# m = mocker.patch('_sls_detector.DetectorApi.setTimingMode') def test_get_vthreshold(d, mocker):
# d.timing_mode = 'auto' m = mocker.patch('_sls_detector.DetectorApi.getDac')
# m.assert_called_once_with('auto') d.vthreshold
m.assert_called_once_with('vthreshold', -1)
# #----------------------------------------------------------------vthreshold
# def test_get_vthreshold(d, mocker): def test_set_vthreshold(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.getDac') m = mocker.patch('_sls_detector.DetectorApi.setDac')
# d.vthreshold d.vthreshold = 1675
# m.assert_called_once_with('vthreshold', -1) m.assert_called_once_with('vthreshold', -1, 1675)
# def test_set_vthreshold(d, mocker):
# m = mocker.patch('_sls_detector.DetectorApi.setDac')
# d.vthreshold = 1675
# m.assert_called_once_with('vthreshold', -1, 1675)

View File

@ -1,12 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Testing functions from utils.py Testing parameters and methods of the Detector class using mocks
""" """
import pytest import pytest
from sls_detector.utils import * from sls_detector.utils import eiger_register_to_time
from sls_detector.utils import all_equal, element_if_equal
def test_convert_zero(): def test_convert_zero():
assert eiger_register_to_time(0) == 0 assert eiger_register_to_time(0) == 0
@ -48,15 +48,3 @@ def test_element_if_equal_str():
def test_element_if_equal_int_fails(): def test_element_if_equal_int_fails():
assert element_if_equal([5, 6, 7]) == [5, 6, 7] assert element_if_equal([5, 6, 7]) == [5, 6, 7]
def test_get_set_bits():
assert(get_set_bits(0) == [])
assert get_set_bits(7) == [0, 1, 2]
def test_list_to_mask():
assert(list_to_bitmask([0,1,2]) == 7)
assert(list_to_bitmask([]) == 0)
assert(list_to_bitmask([0]) == 1)
assert(list_to_bitmask([1]) == 2)
assert(list_to_bitmask([3]) == 8)
assert(list_to_bitmask([1,1,1]) == 2)

View File

@ -47,7 +47,7 @@ using std::chrono::seconds;
int main() { int main() {
Detector d; Detector d;
// d.setConfig("/home/l_frojdh/virtual.config"); d.setConfig("/home/l_frojdh/virtual.config");
// d.setExptime(nanoseconds(500)); // set exptime of all modules // d.setExptime(nanoseconds(500)); // set exptime of all modules
// auto t0 = d.getExptime(); // auto t0 = d.getExptime();

View File

@ -1,46 +0,0 @@
#include <chrono>
#include <iostream>
#include <string>
#include <memory>
#include "Result.h"
#include "Detector.h"
#include "container_utils.h"
#include "ToString.h"
#include <algorithm>
std::chrono::nanoseconds to_nano(double val, const std::string &unit) {
if (unit == "us")
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::micro>(val));
else if (unit == "ms")
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double, std::milli>(val));
else if (unit == "s")
return std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::duration<double>(val));
}
int main() {
// std::cout << "5.8 us is " << to_nano(5.8, "us").count() << " ns\n";
// std::cout << "7 ms is " << to_nano(7, "ms").count() << " ns\n";
// std::cout << "3.123 s is " << to_nano(3.123, "s").count() << " ns\n";
// sls::Result<int> res{1,0,6,4,0,4};
// std::unique_ptr<sls::Detector>
auto d = sls::make_unique<sls::Detector>(0);
std::cout << d->getHostname() << "\n";
auto s= sls::ToString(d->getHostname());
std::cout << s << "\n";
std::string str;
for (const auto& s : d->getHostname())
str += s;
std::cout << str << "\n";
}

View File

@ -1,43 +1,38 @@
/** Examples on how to use Result<T> */
#include "Result.h" #include "Result.h"
#include "ToString.h" #include "ToString.h"
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
using sls::Result;
using sls::ToString;
auto main() -> int { auto main() -> int {
using sls::Result; // declared in namespace sls
using sls::ToString;
std::cout << "Examples on usage of Result<T>\n"; std::cout << "Examples on usage of Result<T>\n";
/** Constructing Result<T> can be done in the same way as vectors */ // Result exposes the underlying constructors of std::vector
Result<int> res{1, 2, 3, 4, 5}; Result<int> res{1, 2, 3, 4, 5};
std::cout << "res: " << res << '\n'; std::cout << "res: " << res << '\n';
Result<double> res2(5, 3.7); Result<double> res2(5, 3.7);
std::cout << "res2: " << res2 << '\n'; std::cout << "res2: " << res2 << '\n';
/** and Result can be converted to and from a vector. However, the // and can be converted to and from a vector. However, the
* conversion to a vector is not efficient since a copy is made // conversion to a vector is not efficient since a copy is made
* and should only be done when a vector is needed for further use // and should only be done when a vector is needed for further use
* in most cases Result behaved as a vector, for example with standard // in most sense and in standard algorithms Result<T> behaves as a
* algorithms */ // vector.
std::vector<int> vec(5, 5); std::vector<int> vec(5, 5);
std::cout << "vec: " << ToString(vec) << "\n"; std::cout << "vec: " << ToString(vec) << "\n";
//Result from vector
Result<int> res3 = vec; Result<int> res3 = vec;
std::cout << "res3: " << res3 << '\n'; std::cout << "res3: " << res3 << '\n';
// Vector from Result
std::vector<int> vec2 = res3; std::vector<int> vec2 = res3;
std::cout << "vec2: " << ToString(vec2) << "\n"; std::cout << "vec2: " << ToString(vec2) << "\n";
// Using squash we can convert to a single value
// Using squash we can also convert to a single value
std::cout << "res.squash(): " << res.squash() << '\n'; std::cout << "res.squash(): " << res.squash() << '\n';
std::cout << "res3.squash(): " << res3.squash() << '\n'; std::cout << "res3.squash(): " << res3.squash() << '\n';
@ -45,17 +40,11 @@ auto main() -> int {
std::cout << "res.squash(-1): " << res.squash(-1) << '\n'; std::cout << "res.squash(-1): " << res.squash(-1) << '\n';
std::cout << "res3.squash(-1): " << res3.squash(-1) << '\n'; std::cout << "res3.squash(-1): " << res3.squash(-1) << '\n';
Result<int> ivec{1, 3, 5}; std::vector<int> ivec{1, 3, 5};
Result<sls::time::ns> nres(ivec); Result<sls::time::ns> nres(ivec);
// for (const auto& i : ivec)
// nres.push_back(sls::time::ns(i));
std::cout << "nres: " << sls::ToString(nres) << '\n'; std::cout << "nres: " << sls::ToString(nres) << '\n';
//
/* Convert from Result<int> to Result<bool> */
Result<int> int_result{0, 1, 0, 3, -5};
Result<bool> bool_result{int_result};
std::cout << bool_result << '\n';
// Result can be printed using <<
Result<std::string> string_res{"ein", "zwei", "drei"};
std::cout << string_res << '\n';
} }

View File

@ -31,19 +31,18 @@ class MovingStat
*/ */
void Set(double val, double rms=0, int m=-1) void Set(double val, double rms=0, int m=-1)
{ {
if (m>0) m_n = m; else m_n = n; if (m>=0) m_n = m; else m_n = n;
m_newM=val*m_n; m_newM=val*m_n;
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
SetRMS(rms); SetRMS(rms);
} }
/** /**
clears the moving average number of samples parameter, mean and standard deviation clears the moving average number of samples parameter, mean and standard deviation
*/ */
void SetRMS(double rms) void SetRMS(double rms)
{ {
if (rms<=0) { if (rms<=0) {
m_newM2=m_newM*m_newM/n; m_newM2=m_newM*m_newM/n;
//m_n=0; m_n=0;
} else { } else {
if (m_n>0) if (m_n>0)
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n); m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
@ -121,7 +120,6 @@ class MovingStat
*/ */
inline double Mean() const inline double Mean() const
{ {
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl;
return (m_n > 0) ? m_newM/m_n : 0.0; return (m_n > 0) ? m_newM/m_n : 0.0;
} }

View File

@ -62,7 +62,7 @@ template <class dataType> class analogDetector {
analogDetector(slsDetectorData<dataType> *d, int sign=1, analogDetector(slsDetectorData<dataType> *d, int sign=1,
commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<dataType> *gs=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), dataSign(sign), iframe(-1), gmap(gm), ghSum(gs), id(0) { commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<dataType> *gs=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), iframe(-1), dataSign(sign), gmap(gm), ghSum(gs), id(0) {
if (det) if (det)
det->getDetectorSize(nx,ny); det->getDetectorSize(nx,ny);
@ -154,15 +154,8 @@ template <class dataType> class analogDetector {
hs9=(TH2F*)(orig->hs9)->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
#endif #endif
if (orig->cmSub) { if (orig->cmSub) cmSub=(orig->cmSub)->Clone();
cmSub=(orig->cmSub)->Clone(); if (orig->ghSum) ghSum=(orig->ghSum)->Clone();
cout <<"cloning cm" << endl;
}
else cmSub=NULL;
if (orig->ghSum) {
ghSum=(orig->ghSum)->Clone();
cout <<"cloning gs" << endl;
}
else ghSum=NULL; else ghSum=NULL;
} }
@ -231,10 +224,9 @@ template <class dataType> class analogDetector {
if (gm) { if (gm) {
if (gmap) delete [] gmap; if (gmap) delete [] gmap;
gmap=new double[nnx*nny]; gmap=new double[nnx*nny];
for (int iy=0; iy<nny; iy++) { for (int iy=0; iy<nny; iy++) {
for (int ix=0; ix<nnx; ix++) { for (int ix=0; ix<nnx; ix++) {
gmap[iy*nnx+ix]=gm[iy*nnx+ix]; gmap[iy*nnx+ix]=gm[iy*nnx+ix];
// cout << gmap[iy*nnx+ix] << " " ;
} }
} }
return gmap; return gmap;
@ -288,12 +280,7 @@ template <class dataType> class analogDetector {
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();}; virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();};
/** resets the commonModeSubtraction and increases the frame index */ /** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(char *data){ virtual void newFrame(char *data){iframe++; if (cmSub) cmSub->newFrame(); calcGhost(data);};
iframe++;
if (cmSub) cmSub->newFrame();
calcGhost(data);
// cout << getId() << " Calc ghost " << getGhost(15,15) << endl;
};
/** sets the commonModeSubtraction algorithm to be used /** sets the commonModeSubtraction algorithm to be used
@ -328,7 +315,7 @@ template <class dataType> class analogDetector {
\param iy pixel y coordinate \param iy pixel y coordinate
\param cm 1 adds the value to common mod, 0 skips it. Defaults to 0. - not properly implemented \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, int cm=0){ virtual void addToPedestal(double val, int ix, int iy=0, int cm=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
// cout << val << " " ; // cout << val << " " ;
@ -348,17 +335,15 @@ template <class dataType> class analogDetector {
} }
double getCommonMode(int ix, int iy) { double getCommonMode(int ix, int iy) {
if (cmSub) { if (cmSub) return cmSub->getCommonMode(ix, iy);
return cmSub->getCommonMode(ix, iy); else return 0;
}
return 0;
} }
virtual void addToCommonMode(char *data){ virtual void addToCommonMode(char *data){
// cout << "+"<< getId() << endl; // cout << "+"<< endl;
if (cmSub) { if (cmSub) {
//cout << "*" << endl; // cout << "*" << endl;
for (int iy=ymin; iy<ymax; iy++) { for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) { for (int ix=xmin; ix<xmax; ix++) {
// if (getNumpedestals(ix,iy)>0) // if (getNumpedestals(ix,iy)>0)
@ -373,22 +358,12 @@ template <class dataType> class analogDetector {
} }
virtual void addToCommonMode(char *data, int ix, int iy=0){ virtual void addToCommonMode(char *data, int ix, int iy=0){
// cout <<".";
if (cmSub) { if (cmSub) {
//cout <<":";
if (det) if (det->isGood(ix, iy)==0) return; if (det) if (det->isGood(ix, iy)==0) return;
if (getNumpedestals(ix,iy)>0){ if (getNumpedestals(ix,iy)>0){
double val; cmSub->addToCommonMode(subtractPedestal(data,ix,iy,0), ix, iy);
if (det) { // cout << ":";
/* if (det->getChannel(data, ix, iy)>=0x3fff) */ // cout << ix << " " <<" " << iy << subtractPedestal(data,ix,iy,0) << endl;
/* cout << ix << " " << iy << " " << det->getChannel(data, ix, iy) <<endl; */
val= (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,0));
} else
val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy));
val+=getGhost(ix,iy);
cmSub->addToCommonMode(val, ix, iy);
//cout << ":";
} }
} }
} }
@ -400,12 +375,11 @@ template <class dataType> class analogDetector {
\returns pedestal value \returns pedestal value
*/ */
virtual double getPedestal (int ix, int iy, int cm=0){ virtual double getPedestal (int ix, int iy, int cm=0){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { if (ix>=0 && ix<nx && iy>=0 && iy<ny)
if (cmSub && cm>0) { if (cmSub && cm>0)
return stat[iy][ix].getPedestal()+getCommonMode(ix,iy); return stat[iy][ix].getPedestal()+getCommonMode(ix,iy);
else return stat[iy][ix].getPedestal();
} else return stat[iy][ix].getPedestal(); else return -1;
} else return -1;
}; };
@ -416,22 +390,15 @@ template <class dataType> class analogDetector {
\returns pedestal rms \returns pedestal rms
*/ */
virtual double getPedestalRMS(int ix, int iy){ virtual double getPedestalRMS(int ix, int iy){
double g=1; if (ix>=0 && ix<nx && iy>=0 && iy<ny)
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { return stat[iy][ix].getPedestalRMS();
if (gmap) { else return -1;
g=gmap[iy*nx+ix];
if (g==0) g=-1.;
}
return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
}
return -1;
}; };
virtual int getNumpedestals(int ix, int iy){ virtual int getNumpedestals(int ix, int iy){
if (ix>=0 && ix<nx && iy>=0 && iy<ny) if (ix>=0 && ix<nx && iy>=0 && iy<ny)
return stat[iy][ix].getNumpedestals(); return stat[iy][ix].getNumpedestals();
return -1; else return -1;
}; };
/** /**
gets pedestal (and common mode) gets pedestal (and common mode)
@ -443,10 +410,10 @@ template <class dataType> class analogDetector {
virtual double* getPedestal(double *ped){ virtual double* getPedestal(double *ped){
if (ped==NULL) if (ped==NULL)
ped=new double[nx*ny]; ped=new double[nx*ny];
for (int iy=0; iy<ny; iy++) { for (int iy=0; iy<ny; iy++) {
for (int ix=0; ix<nx; ix++) { for (int ix=0; ix<nx; ix++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal(); ped[iy*nx+ix]=stat[iy][ix].getPedestal();
//cout << ped[iy*nx+ix] << " " ; //cout << ped[iy*nx+ix] << " " ;
} }
} }
return ped; return ped;
@ -501,11 +468,10 @@ template <class dataType> class analogDetector {
*/ */
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){ virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
double rr=0; double rr=0;
for (int iy=ymin; iy<ymax; iy++) { for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) { for (int ix=xmin; ix<xmax; ix++) {
if (rms) rr=rms[iy*nx+ix]; if (rms) rr=rms[iy*nx+ix];
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m); stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy][ix].getPedestal() << endl;
}; };
}; };
@ -539,24 +505,10 @@ template <class dataType> class analogDetector {
} }
virtual void calcGhost(char *data, int ix, int iy=1) { virtual void calcGhost(char *data, int ix, int iy=1) {if (ghSum) ghSum->calcGhost(data, ix, iy);};
if (ghSum) {
ghSum->calcGhost(data, ix, iy);
}
}; virtual void calcGhost(char *data){if (ghSum) ghSum->calcGhost(data);};
virtual double getGhost(int ix, int iy) {if (ghSum) return ghSum->getGhost(ix, iy); return 0;};
virtual void calcGhost(char *data){if (ghSum) {
ghSum->calcGhost(data);
// cout << getId() << " @ " << ghSum->getXTalk() << " " << ghSum->getGhost(15,15) << endl;
}
};
virtual double getGhost(int ix, int iy) {if (ghSum) return ghSum->getGhost(ix, iy); return 0;};
/** /**
write 32bit tiff file with detector image data write 32bit tiff file with detector image data
@ -764,21 +716,20 @@ template <class dataType> class analogDetector {
virtual void addToPedestal(char *data, int cm=0) { virtual void addToPedestal(char *data, int cm=0) {
// cout << "add to pedestal " << endl; // cout << "add to pedestal " << endl;
newFrame(data); newFrame(data);
//calcGhost(data); //calcGhost(data);
if (cmSub && cm) { if (cmSub && cm) {
// cout <<",";
addToCommonMode(data); addToCommonMode(data);
} }
//cout << xmin << " " << xmax << endl; //cout << xmin << " " << xmax << endl;
// cout << ymin << " " << ymax << endl; // cout << ymin << " " << ymax << endl;
for (int iy=ymin; iy<ymax; iy++) { for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) { for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) { if (det->isGood(ix,iy)) {
// addToPedestal(data,ix,iy,1); // addToPedestal(data,ix,iy,1);
addToPedestal(data,ix,iy,cm); addToPedestal(data,ix,iy,cm);
@ -861,7 +812,7 @@ template <class dataType> class analogDetector {
*/ */
virtual void addToPedestal(char *data, int ix, int iy, int cm=0) { virtual void addToPedestal(char *data, int ix, int iy=0, int cm=0) {
double val; double val;
@ -929,7 +880,7 @@ template <class dataType> class analogDetector {
virtual double subtractPedestal(char *data, int ix, int iy=0, int cm=0) { virtual double subtractPedestal(char *data, int ix, int iy=0, int cm=0) {
double g=1.; double g=1.;
double val =0; double val;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
if (gmap) { if (gmap) {
g=gmap[iy*nx+ix]; g=gmap[iy*nx+ix];
@ -943,9 +894,6 @@ template <class dataType> class analogDetector {
} else } else
val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g; val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g;
//if (val>=0.5*thr)
// cout << val << " " << (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm)) << " " << g << " ";
val+=getGhost(ix,iy)/g; val+=getGhost(ix,iy)/g;
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
@ -979,7 +927,6 @@ template <class dataType> class analogDetector {
#endif #endif
return val; return val;
} }
return val;
}; };
@ -1007,7 +954,8 @@ template <class dataType> class analogDetector {
int nph=0; int nph=0;
double v; double v;
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
v=subtractPedestal(data,ix,iy,1); v=subtractPedestal(data,ix,iy);
/* // cout << v << " " ; */ /* // cout << v << " " ; */
/* #ifdef ROOTSPECTRUM */ /* #ifdef ROOTSPECTRUM */
/* // cout << (iy-ymin)*(xmax-xmin)+(ix-xmin) << endl; */ /* // cout << (iy-ymin)*(xmax-xmin)+(ix-xmin) << endl; */
@ -1016,14 +964,8 @@ template <class dataType> class analogDetector {
if (thr>0) { if (thr>0) {
v+=0.5*thr; v+=0.5*thr;
nph=v/thr; nph=v/thr;
if (nph>0)
/* if (ix ==10 && iy<20) */
/* cout << det->getValue(data,ix,iy) << " " << stat[iy][ix].getPedestal() << " " << getCommonMode(ix,iy) << " " << getPedestal(ix,iy,0)<< " " << getPedestal(ix,iy,1) << endl; */
// cout << subtractPedestal(data,ix,iy,0) << " " << subtractPedestal(data,ix,iy,1) << " " << nph << endl;
if (nph>0) {
//cout << " " << nph << endl;
return nph; return nph;
}
return 0; return 0;
} }
return v; return v;
@ -1039,16 +981,15 @@ template <class dataType> class analogDetector {
*/ */
int *getNPhotons(char *data, int *nph=NULL) { int *getNPhotons(char *data, int *nph=NULL) {
//double val; double val;
if (nph==NULL) if (nph==NULL)
nph=image; nph=image;
newFrame(data); newFrame(data);
//calcGhost(data); //calcGhost(data);
addToCommonMode(data); addToCommonMode(data);
for (int iy=ymin; iy<ymax; iy++) { for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) { for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) if (det->isGood(ix,iy))
nph[iy*nx+ix]+=getNPhotons(data, ix, iy); nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
} }
@ -1153,7 +1094,7 @@ template <class dataType> class analogDetector {
switch(fMode) { switch(fMode) {
case ePedestal: case ePedestal:
//cout << "analog ped " << endl; //cout << "analog ped " << endl;
addToPedestal(data,1); addToPedestal(data);
break; break;
default: default:
// cout << "analog " << endl; // cout << "analog " << endl;

View File

@ -14,7 +14,7 @@ class commonModeSubtraction {
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector \param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
*/ */
commonModeSubtraction(int iroi=1, int ns=3) : nsigma(ns), nROI(iroi) { commonModeSubtraction(int iroi=1, int ns=3) : nROI(iroi), nsigma(ns) {
mean=new double[nROI]; mean=new double[nROI];
mean2=new double[nROI]; mean2=new double[nROI];
nCm=new double[nROI]; nCm=new double[nROI];
@ -28,7 +28,7 @@ class commonModeSubtraction {
/* } */ /* } */
virtual commonModeSubtraction *Clone() { virtual commonModeSubtraction *Clone() {
return new commonModeSubtraction(this->nROI, this->nsigma); new commonModeSubtraction(this->nROI, this->nsigma);
} }
/** clears the moving average and the sum of pedestals calculation - virtual func*/ /** clears the moving average and the sum of pedestals calculation - virtual func*/
@ -41,7 +41,6 @@ class commonModeSubtraction {
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/ /** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
virtual void newFrame(){ virtual void newFrame(){
//cout << "Reset CM" << endl;
for (int i=0; i<nROI; i++) { for (int i=0; i<nROI; i++) {
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]); // if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
nCm[i]=0; nCm[i]=0;
@ -61,7 +60,6 @@ class commonModeSubtraction {
// else val=-100; // else val=-100;
// if (isc>=0 && isc<nROI) { // if (isc>=0 && isc<nROI) {
// cout << ix << " " << iy << " " << iroi << endl; // cout << ix << " " << iy << " " << iroi << endl;
//if (ix==15 && iy==15) cout << "=" << val << endl;
if (iroi>=0 && iroi<nROI) { if (iroi>=0 && iroi<nROI) {
// cout << ix << " " << iy << " " << iroi << endl; // cout << ix << " " << iy << " " << iroi << endl;
mean[iroi]+=val; mean[iroi]+=val;
@ -82,7 +80,6 @@ class commonModeSubtraction {
/* else */ /* else */
/* return -100; */ /* return -100; */
// cout << "*" << ix << " " << iy << " " << iroi << " " << mean[iroi] << " " << nCm[iroi]<< endl; // cout << "*" << ix << " " << iy << " " << iroi << " " << mean[iroi] << " " << nCm[iroi]<< endl;
// if (ix==15 && iy==15) cout << "-" << mean[iroi]/nCm[iroi] << endl;
if (iroi>=0 && iroi<nROI) { if (iroi>=0 && iroi<nROI) {
if (nCm[iroi]>0) if (nCm[iroi]>0)
return mean[iroi]/nCm[iroi]; return mean[iroi]/nCm[iroi];

View File

@ -45,7 +45,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) { virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
// off=0; // off=0;
//int iarg; int iarg;
int64_t word, *wp; int64_t word, *wp;
short unsigned int* val=new short unsigned int[nch]; short unsigned int* val=new short unsigned int[nch];
int bit[64]; int bit[64];

View File

@ -49,7 +49,7 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) { virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
// off=0; // off=0;
//int iarg; int iarg;
int64_t word, *wp; int64_t word, *wp;
short unsigned int* val=new short unsigned int[nch]; short unsigned int* val=new short unsigned int[nch];
int bit[64]; int bit[64];
@ -57,7 +57,7 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
int ioff=0; int ioff=0;
int idr=0; int idr=0;
int ib=0; int ib=0;
//int ich=0; int ich=0;
int ii=0; int ii=0;
int iw=0; int iw=0;
bit[0]=17;//19; bit[0]=17;//19;

View File

@ -8,9 +8,9 @@ class deserializer : public slsDetectorData<int> {
public: public:
deserializer( std::vector <int> dbl, int nch=64*3,int dr=24, int off=2): slsDetectorData<int>(nch,1,nch*dr*8+off*8,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {}; deserializer( std::vector <int> dbl, int nch=64*3,int dr=24, int off=2): slsDetectorData<int>(nch,1,nch*dr*8+off*8,NULL,NULL,NULL), dbitlist(dbl), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) {};
deserializer( std::vector <int> dbl, int nch,int dr, int off, int ds): slsDetectorData<int>(nch,1,ds,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {}; deserializer( std::vector <int> dbl, int nch,int dr, int off, int ds): slsDetectorData<int>(nch,1,ds,NULL,NULL,NULL), dbitlist(dbl), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) {};
virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;};
@ -51,7 +51,7 @@ class deserializer : public slsDetectorData<int> {
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) { static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0; // off=0;
//int iarg; int iarg;
int64_t word, *wp; int64_t word, *wp;
int* val=new int[nch]; int* val=new int[nch];
int ioff=0; int ioff=0;
@ -107,10 +107,10 @@ class deserializer : public slsDetectorData<int> {
static int* deserializeList(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) { static int* deserializeList(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0; // off=0;
//int iarg; int iarg;
// int64_t word; int64_t word;
int* val=new int[nch]; int* val=new int[nch];
//int ioff=0; int ioff=0;
int idr=0; int idr=0;
int ib=0; int ib=0;
int iw=0; int iw=0;
@ -129,7 +129,7 @@ class deserializer : public slsDetectorData<int> {
ib=0; ib=0;
ich=0; ich=0;
for (const auto &bit : dbl) { for (const auto &bit : dbl) {
//ioff=off; ioff=off;
idr=0; idr=0;
for (iw=0; iw<(nch*dr/nb)/8; iw++) { for (iw=0; iw<(nch*dr/nb)/8; iw++) {
val[ich]|=(*dval)<<idr; val[ich]|=(*dval)<<idr;

View File

@ -101,9 +101,6 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
row=200+i/sc_width; row=200+i/sc_width;
} }
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1); dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
#ifdef HIGHZ
dataMask[row][col]=0x3fff; //invert data
#endif
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32) if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
} }

View File

@ -1,268 +0,0 @@
#ifndef MOENCH03T1ZMQDATA_H
#define MOENCH03T1ZMQDATA_H
#include "slsDetectorData.h"
class moench03T1ZmqData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int nPackets; /**<number of UDP packets constituting one frame */
const int packetSize; /**< size of a udp packet */
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
*/
moench03T1ZmqData(int npackets=40, int ps=8192): slsDetectorData<uint16_t>(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<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=adc_nr[iadc]+(i%sc_width);
if (adc4%2==0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (int ipacket=0; ipacket<npackets; ipacket++) {
for (int ibyte=0; ibyte< 8192/2; ibyte++) {
i=ipacket*8208/2+ibyte;
/* if (ibyte<8) { */
/* //header! */
/* xmap[i]=-1; */
/* ymap[i]=-1; */
/* } else { */
// ii=ibyte+128*32*ipacket;
isample=ii/nadc;
iadc=ii%nadc;
adc4 = (int)iadc/4;
ix=isample%sc_width;
iy=isample/sc_width;
if (adc4%2==0) {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2-1-iy;
} else {
xmap[i]=adc_nr[iadc]+ix;
ymap[i]=ny/2+iy;
}
ii++;
// }
}
}
iframe=0;
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return iframe;};//*((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 0;}//((*(((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[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<packetSize*nPackets) ndata=dsize;
else ndata=packetSize*nPackets;
return data;
}
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -276,15 +276,15 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) { virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
//char *retval=0; char *retval=0;
// int nd; int nd;
//int fnum = -1; int fnum = -1;
np=0; np=0;
// int pn; int pn;
// if (ff>=0) if (ff>=0)
// fnum=ff; fnum=ff;
if (filebin.is_open()) { if (filebin.is_open()) {
if (filebin.read(data, 32*2*nSamples) ){ if (filebin.read(data, 32*2*nSamples) ){

View File

@ -1,294 +0,0 @@
#ifndef MOENCH04REC10GBDATA_H
#define MOENCH04REC10GBDATA_H
#include "slsDetectorData.h"
//#define VERSION_V2
/**
@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 */
uint64_t packetCaught[8]; /**< is the version number of this structure format */
} sls_detector_header;
class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
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
*/
moench04CtbReceiver10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
int nadc=32;
int sc_width=25;
int sc_height=200;
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
int adc4(0);
for (int ip=0; ip<npackets; ip++) {
for (int is=0; is<128; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=128*ip+is;
adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
// if (adc4%2==0) {
if (iadc/16>0) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
if (nds>0)
dataMap[row][col]=sizeof(sls_detector_header)+((nadc+4)*i+iadc)*2;//+16*(ip+1);
else
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
}
int ipacket;
int ibyte;
int ii=0;
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
xmap[ibyte]=-1;
ymap[ibyte]=-1;
}
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
};
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((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<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

Some files were not shown because too many files have changed in this diff Show More