Compare commits

..

1 Commits

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

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

@ -46,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,4 +1,4 @@
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)
@ -42,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)
@ -69,7 +66,6 @@ target_compile_options(slsProjectWarnings INTERFACE
-Wredundant-decls -Wredundant-decls
# -Wconversion # -Wconversion
-Wdouble-promotion -Wdouble-promotion
-Werror=return-type
) )
@ -106,10 +102,11 @@ 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_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined) #target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined)
target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread) target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread) # target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
endif() endif()
#rapidjson #rapidjson
@ -156,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)
@ -179,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: ..
@ -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,17 +893,7 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
} }
} else } else
ndbit=dbitlist.size(); ndbit=dbitlist.size();
if (tenG){
if (nDigitalSamples && nAnalogSamples){
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; 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,10 +967,6 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
ig=ii; ig=ii;
else else
ig=adclist.at(ii); ig=adclist.at(ii);
// if (tenG)
// aval=data->getChannel(i);
// else
aval=data->getChannel(i);//*((uint16_t*)(data->cvalues+i*2));// aval=data->getChannel(i);//*((uint16_t*)(data->cvalues+i*2));//
if (plotFlag[ig]) { if (plotFlag[ig]) {
@ -994,7 +983,6 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
i++; i++;
} }
if (tenG) i+=4;
} }
@ -1004,9 +992,7 @@ 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);
else
dval=*(d_data+ip*8+ig); dval=*(d_data+ip*8+ig);
for (ib=(ig)*8; ib<(ig+1)*8; ib++) { for (ib=(ig)*8; ib<(ig+1)*8; 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:
try {
auto retval = myDet->getTenGiga().tsquash("Different values");
if (retval) {
dataStructure=new moench04CtbZmq10GbData(nAnalogSamples, nDigitalSamples);
} else {
dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples); 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;
} }
} }
@ -1449,64 +1427,73 @@ 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);
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eFname->SetState(b); eFname->SetState(b);
eOutdir->SetState(b); eOutdir->SetState(b);
} CATCH_DISPLAY ("Could not set file write", "ctbAcquisition::setFsave")
} }
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")
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); setReadoutMode(roMode);
} CATCH_DISPLAY ("Could not get readout mode", "ctbAcquisition::update") //nChannels=myDet->getTotalNumberOfChannels();
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;
if (stop)
break;
} }
cout << im << endl;
if (stop) 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();
} catch (...) {
cout << "Do nothing for this error" << endl;
}
dbitlist.clear(); dbitlist.clear();
if (!retval.empty()) { if (dbl.empty())
for (const auto &value : retval) ;
else {
for (const auto &value : dbl)
dbitlist.push_back(value); dbitlist.push_back(value);
} }
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans") uint32_t reg;
// adc mask
try { try {
auto retval = myDet->getADCEnableMask().tsquash("Different values"); reg=myDet->getADCEnableMask();
} catch (...) {
cout << "Do nothing for this error" << endl;
}
/* adc updated */
adclist.clear(); adclist.clear();
if (retval!=0xffffffff) { // // updateChans();
if (reg!=0xffffffff) {
for (int i=0; i<NADCS; i++) { for (int i=0; i<NADCS; i++) {
if (retval&(1<<i)) { if (reg&(1<<i))
adclist.push_back(i); adclist.push_back(i);
// // else enableFlag[i]=1;
} }
} }
}
} 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());
} catch (...) {
cout << "Do nothing for this error" << endl;
}
char s[100];
cout << "dac " << id << " " << val << endl; cout << "dac " << id << " " << val << endl;
dacsValue->SetText(to_string(val).c_str()); sprintf(s,"%d",val);
if (val >= 0) { dacsValue->SetText(s);
if (val>=0) {
dacsLabel->SetOn(kTRUE); dacsLabel->SetOn(kTRUE);
} else { } else {
dacsLabel->SetOn(kFALSE); dacsLabel->SetOn(kFALSE);
} }
return val;
} CATCH_DISPLAY ("Could not get dac " + to_string(id) + ".", "ctbDac::getValue")
return -1;
return val;
} }
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;
@ -61,27 +61,31 @@ int main(int argc, char **argv) {
cout << " *** " << endl; cout << " *** " << endl;
sls::Detector *myDet = nullptr;
try {
/****** Create detector ****************/ /****** Create detector ****************/
myDet=new sls::Detector(id); multiSlsDetector *myDet=new multiSlsDetector(id);
cout << "Created multi detector id " << id << endl; // myDet->setOnline(slsDetectorDefs::ONLINE_FLAG);
//cout << id << " " << myDet << " " << myDet->setOnline() << endl;
if (cf) { if (cf) {
myDet->loadConfig(cfname); myDet->readConfigurationFile(cfname);
cout << "Config file loaded successfully" << endl; } else
} else {
cout << "No config file specified" << endl; cout << "No config file specified" << endl;
}
cout << "hostname " << myDet->getHostname() << endl;
cout << "aa" << endl;
cout << "Created multi detector id " << id << " hostname " << myDet->getHostname() << endl;
cout << "bb" << endl;
if (pf) { if (pf) {
myDet->loadParameters(pfname); myDet->retrieveDetectorSetup(pfname);
cout << "Loaded parameter file successfully" << endl; } else
} else{
cout << "No parameter file specified" << endl; 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;
@ -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() {
int start, stop, n;
start=-1;
stop=-1;
n=eLoopNumber->GetNumber();
try{ try{
myDet->setPatternLoopCycles(id, eLoopNumber->GetNumber()); myDet->setPatternLoops(id,start, stop,n);
} CATCH_DISPLAY ("Could not set number of pattern loops for level " + to_string(id) + ".", "ctbLoop::setNLoops") } 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 (...) {
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); cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kTRUE); cbDigital->SetOn(kTRUE);
break; } else if (flags&slsDetectorDefs::DIGITAL_ONLY) {
case slsDetectorDefs::DIGITAL_ONLY: cout << "digital only" << hex << slsDetectorDefs::DIGITAL_ONLY << dec << endl;
cout << "digital only" << endl;
cbAnalog->SetOn(kFALSE); cbAnalog->SetOn(kFALSE);
cbDigital->SetOn(kTRUE); cbDigital->SetOn(kTRUE);
break; }// else if (flags==slsDetectorDefs::NORMAL_READOUT) {
case slsDetectorDefs::ANALOG_ONLY: // cbAnalog->SetOn(kTRUE);
// cbDigital->SetOn(kFALSE);
// }
else {
cout << "analog only" << endl; cout << "analog only" << endl;
flags=slsDetectorDefs::NORMAL_READOUT;
cbAnalog->SetOn(kTRUE); cbAnalog->SetOn(kTRUE);
cbDigital->SetOn(kFALSE); 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; 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));
} catch (...) {
cout << "Do nothing for this error" << endl;
}
eAnalogSamples->SetNumber((Double_t)n);
Emit("analogSamplesChanged(const int)", eAnalogSamples->GetNumber()); Emit("analogSamplesChanged(const int)", eAnalogSamples->GetNumber());
return eAnalogSamples->GetNumber(); return eAnalogSamples->GetNumber();
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
return -1;
} }
int ctbPattern::getDigitalSamples() { int ctbPattern::getDigitalSamples() {
try{ int n;
auto retval = myDet->getNumberOfDigitalSamples().tsquash("Different values"); try {
eDigitalSamples->SetNumber((Double_t)retval);
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()); Emit("digitalSamplesChanged(const int)", eDigitalSamples->GetNumber());
return eDigitalSamples->GetNumber(); return eDigitalSamples->GetNumber();
} CATCH_DISPLAY ("Could not get number of triggers.", "ctbPattern::update")
return -1;
} }
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,68 +398,63 @@ 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"));
char val[1000];
cout << hex << oreg << dec << endl; cout << hex << oreg << dec << endl;
// cout << hex << creg << dec << endl;
sprintf(val,"%llX",oreg);
// eIOCntrlRegister->SetHexNumber(oreg);
for (int idac=0; idac<NIOSIGNALS; idac++) { for (int idac=0; idac<NIOSIGNALS; idac++) {
signals[idac]->setOutput(oreg); signals[idac]->setOutput(oreg);
} }
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update") Long64_t mask;
std::vector <int> dbitlist=myDet->getReceiverDbitList();
try { if (dbitlist.empty())
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all
if (dbitlist.empty()) {
for (int is=0; is<64; is++) { for (int is=0; is<64; is++) {
signals[is]->setDbitList(1); signals[is]->setDbitList(1);
} }
}
else { else {
// disable all for (int is=0; is<64; is++) signals[is]->setDbitList(0);
for (int is=0; is<64; is++) {
signals[is]->setDbitList(0);
}
// enable selected
for (const auto &value : dbitlist) { for (const auto &value : dbitlist) {
signals[value]->setDbitList(1); 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 << val << dec << endl; line << "patioctrl " << hex << myDet->setPatternIOControl() << dec << endl;//setCTBWord(-1,-1)
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 oreg=myDet->setPatternIOControl();//setCTBWord(-1,-1);
Long64_t m=((Long64_t)1)<<mask; Long64_t m=((Long64_t)1)<<mask;
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg; cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg;
if (signals[mask]->isOutput()) { if (signals[mask]->isOutput()) {
cout << " or " << m ; cout << " or " << m ;
oreg|=m; oreg|=m;
@ -434,61 +464,55 @@ void ctbSignals::ToggledOutReg(Int_t mask) {
} }
cout << " after " << oreg << endl; cout << " after " << oreg << endl;
myDet->setPatternIOControl(static_cast<uint64_t>(oreg)); myDet->setPatternIOControl(oreg);//setCTBWord(-1,oreg);
oreg = static_cast<Long64_t>(myDet->getPatternIOControl().tsquash("Different values")); oreg=myDet->setPatternIOControl();//myDet->setCTBWord(-1,-1);
cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl; cout << dec << sizeof(Long64_t) << " " << mask << " " << hex << m << " ioreg " << oreg << endl;
eIOCntrlRegister->SetText(to_string(oreg).c_str()); sprintf(val,"%llX",oreg);
// eIOCntrlRegister->SetHexNumber(oreg);
} CATCH_DISPLAY ("Could not get/set patternIOcontrol.", "ctbSignals::ToggledOutReg") 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())) { cout << "************* Here" << endl;
;
}
// set the dbitlist
else {
std::vector <int> new_dbitlist; std::vector <int> new_dbitlist;
std::vector <int> old_dbitlist=myDet->getReceiverDbitList();
char val[1000];
Long64_t m=((Long64_t)1)<<mask;
if (old_dbitlist.empty() && signals[mask]->isDbitList())
;
else {
int ns=0;
for (int is=0; is<64; is++) { for (int is=0; is<64; is++) {
if (signals[is]->isDbitList()){ if (signals[is]->isDbitList()){
new_dbitlist.push_back(is); new_dbitlist.push_back(is);
cout << is << " " << new_dbitlist.size() - 1 << endl; ns++;
cout << is << " " << ns << endl;
} }
} }
if (new_dbitlist.size() > 64) if (ns>63) new_dbitlist.clear();
new_dbitlist.clear(); myDet->setReceiverDbitList(new_dbitlist);
myDet->setRxDbitList(new_dbitlist);
// get list again
dbitlist = myDet->getRxDbitList().tsquash("Different values");
} }
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);
// 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/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; return val;
}
// mv
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

@ -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

@ -5,6 +5,8 @@ pybind11_add_module(_sls_detector
src/experimental.cpp src/experimental.cpp
) )
target_link_libraries(_sls_detector PUBLIC target_link_libraries(_sls_detector PUBLIC
slsDetectorShared slsDetectorShared
slsReceiverShared slsReceiverShared
@ -24,12 +26,12 @@ set( PYTHON_FILES
dacs.py dacs.py
decorators.py decorators.py
detector_property.py detector_property.py
# detector.py detector.py
# eiger.py eiger.py
errors.py errors.py
experimental.py experimental.py
# jungfrau_ctb.py jungfrau_ctb.py
# jungfrau.py jungfrau.py
registers.py registers.py
utils.py utils.py
@ -45,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,9 +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, Jungfrau, Detector, defs from sls_detector import Eiger, Detector
from sls_detector import Detector from sls_detector import ExperimentalDetector
from sls_detector import dacIndex
from _sls_detector.io import read_my302_file
d = Detector() d = Detector()
e = ExperimentalDetector()

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,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,13 +0,0 @@
import re
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)

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

@ -1,17 +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 .experimental import Detector from .experimental import ExperimentalDetector
from .jungfrau import Jungfrau
# from .jungfrau import Jungfrau 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

1493
python/sls_detector/detector.py Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,11 @@
from _sls_detector import CppDetectorApi from _sls_detector import multiDetectorApi
from _sls_detector import slsDetectorDefs from _sls_detector import slsDetectorDefs
runStatus = slsDetectorDefs.runStatus runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel
dacIndex = slsDetectorDefs.dacIndex
from .utils import element_if_equal, all_equal from .utils import element_if_equal, all_equal
from .utils import Geometry, to_geo
import datetime as dt import datetime as dt
from functools import wraps from functools import wraps
from collections import namedtuple
class Register:
"""
Helper class to read and write to registers using a
more Pythonic syntax
"""
def __init__(self, detector):
self._detector = detector
def __getitem__(self, key):
return self._detector.readRegister(key)
def __setitem__(self, key, value):
self._detector.writeRegister(key, value)
def freeze(cls): def freeze(cls):
@ -54,176 +35,72 @@ def freeze(cls):
@freeze @freeze
class Detector(CppDetectorApi): class ExperimentalDetector(multiDetectorApi):
""" """
This class is the base for detector specific This class is the base for detector specific
interfaces. Most functions exists in two versions interfaces. Most functions exists in two versions
like the getExptime() function that uses the like the getExptime() function that uses the
C++ API directly and the simplified exptime property. C++ API directly and the simplified exptime property.
""" """
def __init__(self, multi_id = 0):
def __init__(self, multi_id=0):
""" """
multi_id refers to the shared memory id of the multi_id refers to the shared memory id of the
slsDetectorPackage. Default value is 0. slsDetectorPackage. Default value is 0.
""" """
super().__init__(multi_id) super().__init__(multi_id)
self._register = Register(self)
# CONFIGURATION
def __len__(self):
return self.size()
def __repr__(self):
return '{}(id = {})'.format(self.__class__.__name__,
self.getShmId())
def free(self):
self.freeSharedMemory()
# Acq
@property @property
def config(self): def rx_status(self):
return NotImplementedError("config is set only") """
Read the status of the receiver
"""
return element_if_equal(self.getReceiverStatus())
@config.setter @rx_status.setter
def config(self, fname): def rx_status(self, status_str):
self.loadConfig(fname) if status_str == "start":
self.startReceiver()
@property elif status_str == "stop":
def parameters(self): self.stopReceiver()
return NotImplementedError("parameters is set only")
@parameters.setter
def parameters(self, fname):
self.loadParameters(fname)
@property
def hostname(self):
return self.getHostname()
@hostname.setter
def hostname(self, hostnames):
if isinstance(hostnames, str):
hostnames = [hostnames]
if isinstance(hostnames, list):
self.setHostname(hostnames)
else: else:
raise ValueError("hostname needs to be string or list of strings") raise NotImplementedError("Unknown argument to rx_status")
@property @property
def fw_version(self): def busy(self):
return element_if_equal(self.getFirmwareVersion()) """
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
@property .. note ::
def server_version(self):
#TODO! handle hex print
return element_if_equal(self.getDetectorServerVersion())
@property Only works when the measurement is launched using acquire, not with status start!
def client_version(self):
return element_if_equal(self.getClientVersion())
@property Returns
def rx_version(self): --------
return element_if_equal(self.getReceiverVersion()) bool
:py:obj:`True` if the detector is acquiring otherwise :py:obj:`False`
@property Examples
def detector_type(self): ----------
return element_if_equal(self.getDetectorType())
@property ::
def dr(self):
return element_if_equal(self.getDynamicRange())
@dr.setter d.busy
def dr(self, dr): >> True
self.setDynamicRange(dr)
@property #If the detector is stuck reset by:
def module_geometry(self): d.busy = False
return to_geo(self.getModuleGeometry())
@property
def module_size(self):
ms = [to_geo(item) for item in self.getModuleSize()]
return element_if_equal(ms)
@property
def detector_size(self):
return to_geo(self.getDetectorSize())
@property
def settings(self):
return element_if_equal(self.getSettings())
@settings.setter
def settings(self, value):
self.setSettings(value)
@property
def frames(self):
return element_if_equal(self.getNumberOfFrames())
@frames.setter
def frames(self, n_frames):
self.setNumberOfFrames(n_frames)
@property """
def exptime(self): return self.getAcquiringFlag()
res = self.getExptime()
return element_if_equal([it.total_seconds() for it in res])
@exptime.setter
def exptime(self, t):
if isinstance(t, dt.timedelta):
self.setExptime(t)
else:
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):
if isinstance(t, dt.timedelta):
self.setSubExptime(t)
else:
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):
if isinstance(t, dt.timedelta):
self.setPeriod(t)
else:
self.setPeriod(dt.timedelta(seconds=t))
# Time
#TODO! Rename to rx_framescaught
@property
def framescaught(self):
return element_if_equal(self.getFramesCaught())
@busy.setter
def busy(self, value):
self.setAcquiringFlag(value)
# Configuration
@property @property
def startingfnum(self): def startingfnum(self):
return element_if_equal(self.getStartingFrameNumber()) return element_if_equal(self.getStartingFrameNumber())
@ -232,108 +109,22 @@ class Detector(CppDetectorApi):
def startingfnum(self, value): def startingfnum(self, value):
self.setStartingFrameNumber(value) self.setStartingFrameNumber(value)
#TODO! testing switches on automatically?
@property @property
def flowcontrol_10g(self): def config(self):
return element_if_equal(self.getTenGigaFlowControl()) return NotImplementedError("config is set only")
@flowcontrol_10g.setter @config.setter
def flowcontrol_10g(self, enable): def config(self, fname):
self.setTenGigaFlowControl(enable) self.setConfig(fname)
#TODO! add txdelay
@property
def use_receiver(self):
return element_if_equal(self.getUseReceiverFlag())
@property
def rx_hostname(self):
return element_if_equal(self.getRxHostname())
@rx_hostname.setter
def rx_hostname(self, hostname):
self.setRxHostname(hostname)
@property
def rx_tcpport(self):
return element_if_equal(self.getRxPort())
@rx_tcpport.setter
def rx_tcpport(self, port):
self.setRxPort(port)
@property
def rx_fifodepth(self):
return element_if_equal(self.getRxFifoDepth())
@rx_fifodepth.setter
def rx_fifodepth(self, frames):
self.setRxFifoDepth(frames)
@property
def rx_silent(self):
return element_if_equal(self.getRxSilentMode())
@rx_silent.setter
def rx_silent(self, value):
self.setRxSilentMode(value)
@property
def rx_discardpolicy(self):
return element_if_equal(self.getRxFrameDiscardPolicy())
@rx_discardpolicy.setter
def rx_discardpolicy(self, policy):
self.setRxFrameDiscardPolicy()
@property
def rx_padding(self):
return element_if_equal(self.getPartialFramesPadding())
@rx_padding.setter
def rx_padding(self, policy):
self.setPartialFramesPadding(policy)
@property
def rx_lock(self):
"""Lock the receiver to a specific IP"""
return element_if_equal(self.getRxLock())
@rx_lock.setter
def rx_lock(self, value):
self.setRxLock(value)
@property
def rx_lastclient(self):
return element_if_equal(self.getRxLastClientIP())
#FILE
@property
def fformat(self):
return element_if_equal(self.getFileFormat())
@fformat.setter
def fformat(self, format):
self.setFileFormat(format)
@property
def findex(self):
return element_if_equal(self.getAcquisitionIndex())
@findex.setter
def findex(self, index):
self.setAcquisitionIndex(index)
# File
@property @property
def fname(self): def fname(self):
return element_if_equal(self.getFileNamePrefix()) return element_if_equal(self.getFileName())
@fname.setter @fname.setter
def fname(self, file_name): def fname(self, file_name):
self.setFileNamePrefix(file_name) self.setFileName(file_name)
@property @property
def fpath(self): def fpath(self):
@ -359,275 +150,31 @@ class Detector(CppDetectorApi):
def foverwrite(self, value): def foverwrite(self, value):
self.setFileOverWrite(value) self.setFileOverWrite(value)
# Time
@property @property
def fmaster(self): def exptime(self):
return element_if_equal(self.getMasterFileWrite()) res = self.getExptime()
return element_if_equal([it.total_seconds() for it in res])
@fmaster.setter @exptime.setter
def fmaster(self, enable): def exptime(self, t):
self.setMasterFileWrite(enable) self.setExptime(dt.timedelta(seconds=t))
@property @property
def rx_framesperfile(self): def subexptime(self):
return element_if_equal(self.getFramesPerFile()) res = self.getSubExptime()
return element_if_equal([it.total_seconds() for it in res])
@rx_framesperfile.setter @subexptime.setter
def rx_framesperfile(self, n_frames): def subexptime(self, t):
self.setFramesPerFile(n_frames) self.setSubExptime(dt.timedelta(seconds=t))
# ZMQ Streaming Parameters (Receiver<->Client)
@property @property
def rx_datastream(self): def period(self):
return element_if_equal(self.getRxZmqDataStream()) res = self.getPeriod()
return element_if_equal([it.total_seconds() for it in res])
@rx_datastream.setter @period.setter
def rx_zmqdatastream(self, enable): def period(self, t):
self.setRxZmqDataStream(enable) self.setPeriod(dt.timedelta(seconds=t))
@property
def rx_readfreq(self):
return element_if_equal(self.getRxZmqFrequency())
@rx_readfreq.setter
def rx_readfreq(self, nth_frame):
self.setRxZmqFrequency(nth_frame)
@property
def rx_zmqport(self):
return element_if_equal(self.getRxZmqPort())
@rx_zmqport.setter
def rx_zmqport(self, port):
self.setRxZmqPort(port)
@property
def zmqport(self):
return element_if_equal(self.getClientZmqPort())
@zmqport.setter
def zmqport(self, port):
self.setClientZmqPort(port)
@property
def rx_zmqip(self):
return element_if_equal(self.getRxZmqIP())
@rx_zmqip.setter
def rx_zmqip(self, ip):
self.setRxZmqIP(ip)
@property
def zmqip(self):
return element_if_equal(self.getClientZmqIp())
@zmqip.setter
def zmqip(self, ip):
self.setClientZmqIp(ip)
@property
def udp_dstip(self):
return element_if_equal(self.getDestinationUDPIP())
@udp_dstip.setter
def udp_dstip(self, ip):
self.getDestinationUDPIP(ip)
@property
def udp_dstip2(self):
return element_if_equal(self.getDestinationUDPIP2())
@udp_dstip2.setter
def udp_dstip2(self, ip):
self.getDestinationUDPIP2(ip)
@property
def udp_dstmac(self):
return element_if_equal(self.getDestinationUDPMAC())
@udp_dstmac.setter
def udp_dstmac(self, mac):
self.getDestinationUDPMAC2(mac)
@property
def udp_dstmac2(self):
return element_if_equal(self.getDestinationUDPMAC2())
@udp_dstmac2.setter
def udp_dstmac2(self, mac):
self.getDestinationUDPMAC2(mac)
@property
def udp_dstport(self):
return element_if_equal(self.getDestinationUDPPort())
@udp_dstport.setter
def udp_dstport(self, port):
self.setDestinationUDPPort(port)
@property
def udp_dstport2(self):
return element_if_equal(self.getDestinationUDPPort2())
@udp_dstport2.setter
def udp_dstport2(self, port):
self.setDestinationUDPPort2(port)
@property
def src_udpmac(self):
return element_if_equal(self.getSourceUDPMAC())
@src_udpmac.setter
def src_udpmac(self, mac):
self.setSourceUDPMAC(mac)
@property
def src_udpip2(self):
return element_if_equal(self.getSourceUDPIP())
@src_udpip2.setter
def src_udpip2(self, ip):
self.setSourceUDPIP(ip)
@property
def src_udpip(self):
return element_if_equal(self.getSourceUDPIP())
@src_udpip.setter
def src_udpip(self, ip):
self.setSourceUDPIP(ip)
@property
def src_udpmac2(self):
return element_if_equal(self.getSourceUDPMAC2())
@src_udpmac2.setter
def src_udpmac2(self, mac):
self.setSourceUDPMAC2(mac)
@property
def vhighvoltage(self):
return element_if_equal(self.getHighVoltage())
@vhighvoltage.setter
def vhighvoltage(self, v):
self.setHighVoltage(v)
@property
def user(self):
return self.getUserDetails()
@property
def settingspath(self):
return element_if_equal(self.getSettingsPath())
@settingspath.setter
def settingspath(self, path):
self.setSettingsPath(path)
@property
def status(self):
return element_if_equal(self.getDetectorStatus())
@property
def rx_status(self):
return element_if_equal(self.getReceiverStatus())
@property
def rx_udpsocksize(self):
return element_if_equal(self.getRxUDPSocketBufferSize())
@rx_udpsocksize.setter
def rx_udpsocksize(self, buffer_size):
self.setRxUDPSocketBufferSize(buffer_size)
@property
def rx_realudpsocksize(self):
return element_if_equal(self.getRxRealUDPSocketBufferSize())
@property
def trimbits(self):
return NotImplementedError('trimbits are set only')
@trimbits.setter
def trimbits(self, fname):
self.loadTrimbits(fname)
@property
def lock(self):
return element_if_equal(self.getDetectorLock())
@lock.setter
def lock(self, value):
self.setDetectorLock(value)
@property
def rx_lock(self):
return element_if_equal(self.getRxLock())
@rx_lock.setter
def rx_lock(self, value):
self.setRxLock(value)
@property
def lastclient(self):
return element_if_equal(self.getLastClientIP())
@property
def reg(self):
return self._register
@property
def ratecorr(self):
""" tau in ns """
return element_if_equal(self.getRateCorrection())
@ratecorr.setter
def ratecorr(self, tau):
self.setRateCorrection(tau)
@property
def clkdivider(self):
res = [int(value) for value in self.getSpeed()]
return element_if_equal(res)
@clkdivider.setter
def clkdivider(self, value):
self.setSpeed(speedLevel(value))
@property
def frameindex(self):
return self.getRxCurrentFrameIndex()
@property
def threshold(self):
return element_if_equal(self.getThresholdEnergy())
@threshold.setter
def threshold(self, eV):
self.setThresholdEnergy(eV)
@property
def timing(self):
return element_if_equal(self.getTimingMode())
@timing.setter
def timing(self, mode):
self.setTimingMode(mode)
@property
def trimen(self):
return element_if_equal(self.getTrimEnergies())
@trimen.setter
def trimen(self, energies):
self.setTrimEnergies(energies)
@property
def vthreshold(self):
return element_if_equal(self.getDAC(dacIndex.THRESHOLD))

259
python/sls_detector/jungfrau.py Executable file
View File

@ -0,0 +1,259 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Jungfrau detector class and support functions.
Inherits from Detector.
"""
from .adcs import Adc, DetectorAdcs
from .detector import Detector
from .dacs import DetectorDacs
from .utils import element_if_equal
class JungfrauDacs(DetectorDacs):
_dacs = [('vb_comp', 0, 4000, 1220),
('vdd_prot', 0, 4000, 3000),
('vin_com', 0, 4000, 1053),
('vref_prech', 0, 4000, 1450),
('vb_pixbuff', 0, 4000, 750),
('vb_ds', 0, 4000, 1000),
('vref_ds', 0, 4000, 480),
('vref_comp', 0, 4000, 420),
]
_dacnames = [_d[0] for _d in _dacs]
class Jungfrau(Detector):
"""
Class used to control a Jungfrau detector. Inherits from the Detector class but a specialized
class is needed to provide the correct dacs and unique functions.
"""
_detector_dynamic_range = [4, 8, 16, 32]
_settings = ['dynamichg0',
'dynamicgain',
'fixgain1',
'fixgain2',
'forceswitchg1',
'forceswitchg2']
"""Available settings for Jungfrau"""
def __init__(self, multi_id=0):
#Init on base calss
super().__init__(multi_id)
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
def dacs(self):
"""
An instance of DetectorDacs used for accessing the dacs of a single
or multi detector.
Examples
---------
::
#Jungfrau
"""
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

@ -2,16 +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
Geometry = namedtuple('Geometry', ['x', 'y'])
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"""

File diff suppressed because it is too large Load Diff

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

@ -4,112 +4,38 @@
#include <pybind11/stl.h> #include <pybind11/stl.h>
#include "Detector.h" #include "Detector.h"
#include "ToString.h"
#include "network_utils.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "typecaster.h" #include "typecaster.h"
namespace py = pybind11; namespace py = pybind11;
void init_experimental(py::module &m) { 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::Detector;
using sls::Positions; using sls::Positions;
using defs = slsDetectorDefs; py::class_<Detector> multiDetectorApi(m, "multiDetectorApi");
multiDetectorApi
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi
.def(py::init<int>()) .def(py::init<int>())
// Configuration // Acq related
.def("freeSharedMemory", (void (Detector::*)()) &Detector::freeSharedMemory)
.def("loadConfig", &Detector::loadConfig)
.def("loadParameters", &Detector::loadParameters)
.def("setHostname", &Detector::setHostname)
.def("getHostname", &Detector::getHostname, py::arg() = Positions{})
.def("getShmId", &Detector::getShmId)
.def("getFirmwareVersion", &Detector::getFirmwareVersion,
py::arg() = Positions{})
.def("getDetectorServerVersion", &Detector::getDetectorServerVersion,
py::arg() = Positions{})
.def("getSerialNumber", &Detector::getSerialNumber,
py::arg() = Positions{})
.def("getClientVersion", &Detector::getClientVersion)
.def("getReceiverVersion", &Detector::getReceiverVersion,
py::arg() = Positions{})
.def("getDetectorType", &Detector::getDetectorType,
py::arg() = Positions{})
.def("size", &Detector::size)
.def("getModuleGeometry", &Detector::getModuleGeometry)
.def("getModuleSize", &Detector::getModuleSize, py::arg() = Positions{})
.def("getDetectorSize", &Detector::getDetectorSize)
.def("setDetectorSize", &Detector::setDetectorSize)
.def("getSettings", &Detector::getSettings, py::arg() = Positions{})
.def("setSettings", &Detector::setSettings, py::arg(),
py::arg() = Positions{})
// TODO! Python funcs for callbacks?
// Acquisition Parameters
.def("getNumberOfFrames", &Detector::getNumberOfFrames)
.def("setNumberOfFrames", &Detector::setNumberOfFrames)
.def("getNumberOfTriggers", &Detector::getNumberOfTriggers)
.def("setNumberOfTriggers", &Detector::setNumberOfTriggers)
.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("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("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("getADCPhaseInDegrees", &Detector::getADCPhaseInDegrees,
py::arg() = Positions{})
.def("setADCPhaseInDegrees", &Detector::setADCPhaseInDegrees, 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() = false,
py::arg() = Positions{})
.def("setDAC", &Detector::setDAC, 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{})
// ACQUISITION
.def("acquire", &Detector::acquire) .def("acquire", &Detector::acquire)
.def("startDetector", &Detector::startDetector) .def("startReceiver", &Detector::startReceiver, py::arg() = Positions{})
.def("stopDetector", &Detector::stopDetector) .def("stopReceiver", &Detector::stopReceiver, py::arg() = Positions{})
.def("startReceiver", &Detector::startReceiver) .def("getAcquiringFlag", &Detector::getAcquiringFlag)
.def("stopReceiver", &Detector::stopReceiver) .def("setAcquiringFlag", &Detector::setAcquiringFlag)
.def("clearAcquiringFlag", &Detector::clearAcquiringFlag)
.def("getDetectorStatus", &Detector::getDetectorStatus,
py::arg() = Positions{})
.def("getReceiverStatus", &Detector::getReceiverStatus, .def("getReceiverStatus", &Detector::getReceiverStatus,
py::arg() = Positions{}) py::arg() = Positions{})
.def("getFramesCaught", &Detector::getFramesCaught, // 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{}) py::arg() = Positions{})
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber, .def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
@ -117,233 +43,11 @@ void init_experimental(py::module &m) {
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber, .def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
py::arg(), py::arg() = Positions{}) py::arg(), py::arg() = Positions{})
.def("sendSoftwareTrigger", &Detector::sendSoftwareTrigger, // File
py::arg() = Positions{}) .def("getFileName", &Detector::getFileName)
.def("setFileName", &Detector::setFileName, py::arg())
// Network Configuration (Detector<->Receiver)
.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{})
// Using lambda to allow for conversion from IpAddr
.def("getSourceUDPIP",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPIP(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPIP",
[](Detector &d, std::string ip, Positions pos) {
d.setSourceUDPIP(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getSourceUDPIP2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPIP2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPIP2",
[](Detector &d, std::string ip, Positions pos) {
d.setSourceUDPIP2(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getSourceUDPMAC",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPMAC(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPMAC",
[](Detector &d, std::string mac, Positions pos) {
d.setSourceUDPMAC(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getSourceUDPMAC2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getSourceUDPMAC2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setSourceUDPMAC2",
[](Detector &d, std::string mac, Positions pos) {
d.setSourceUDPMAC2(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPIP",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPIP(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPIP",
[](Detector &d, std::string ip, Positions pos) {
d.setDestinationUDPIP(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPIP2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPIP2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPIP2",
[](Detector &d, std::string ip, Positions pos) {
d.setDestinationUDPIP2(sls::IpAddr(ip), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPMAC",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPMAC(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPMAC",
[](Detector &d, std::string mac, Positions pos) {
d.setDestinationUDPMAC(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPMAC2",
[](const Detector &d, Positions pos) {
std::vector<std::string> res;
for (const auto &s : d.getDestinationUDPMAC2(pos))
res.push_back(s.str());
return res;
},
py::arg() = Positions{})
.def("setDestinationUDPMAC2",
[](Detector &d, std::string mac, Positions pos) {
d.setDestinationUDPMAC2(sls::MacAddr(mac), pos);
},
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPPort", &Detector::getDestinationUDPPort,
py::arg() = Positions{})
.def("setDestinationUDPPort", &Detector::setDestinationUDPPort,
py::arg(), py::arg() = Positions{})
.def("getDestinationUDPPort2", &Detector::getDestinationUDPPort2,
py::arg() = Positions{})
.def("setDestinationUDPPort2", &Detector::setDestinationUDPPort2,
py::arg(), py::arg() = Positions{})
.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{})
/**************************************************
* *
* RECEIVER CONFIG *
* *
* ************************************************/
.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() = Positions{})
.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{})
/**************************************************
* *
* FILE *
* *
* ************************************************/
.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("getFilePath", &Detector::getFilePath) .def("getFilePath", &Detector::getFilePath)
.def("setFilePath", &Detector::setFilePath, py::arg(), .def("setFilePath", &Detector::setFilePath, py::arg())
py::arg() = Positions{})
.def("getAcquisitionIndex", &Detector::getAcquisitionIndex,
py::arg() = Positions{})
.def("setAcquisitionIndex", &Detector::setAcquisitionIndex, py::arg(),
py::arg() = Positions{})
.def("setFileWrite", &Detector::setFileWrite, py::arg(), .def("setFileWrite", &Detector::setFileWrite, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getFileWrite", &Detector::getFileWrite, py::arg() = Positions{}) .def("getFileWrite", &Detector::getFileWrite, py::arg() = Positions{})
@ -351,264 +55,14 @@ void init_experimental(py::module &m) {
py::arg() = Positions{}) py::arg() = Positions{})
.def("getFileOverWrite", &Detector::getFileOverWrite, .def("getFileOverWrite", &Detector::getFileOverWrite,
py::arg() = Positions{}) py::arg() = Positions{})
.def("setMasterFileWrite", &Detector::setMasterFileWrite, py::arg(),
py::arg() = Positions{})
.def("getMasterFileWrite", &Detector::getMasterFileWrite,
py::arg() = Positions{})
.def("setFramesPerFile", &Detector::setFramesPerFile, py::arg(),
py::arg() = Positions{})
.def("getFramesPerFile", &Detector::getFramesPerFile,
py::arg() = Positions{})
/**************************************************
* *
* ZMQ Streaming Parameters (Receiver<->Client)*
* *
* ************************************************/
.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() = Positions{})
.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() = -1)
.def("getClientZmqIp", &Detector::getClientZmqIp,
py::arg() = Positions{})
.def("setClientZmqIp", &Detector::setClientZmqIp, py::arg(),
py::arg() = Positions{})
/**************************************************
* *
* Eiger Specific *
* *
* ************************************************/
.def("getDynamicRange", &Detector::getDynamicRange,
py::arg() = Positions{})
.def("setDynamicRange", &Detector::setDynamicRange)
.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() = defs::STANDARD, py::arg() = true,
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)
.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("setRateCorrection", &Detector::setRateCorrection, py::arg(),
py::arg() = Positions{})
.def("setDefaultRateCorrection", &Detector::setDefaultRateCorrection,
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)
/**************************************************
* *
* Jungfrau Specific *
* *
* ************************************************/
.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)
.def("setNumberOfAdditionalStorageCells",
&Detector::setNumberOfAdditionalStorageCells)
.def("getStorageCellStart", &Detector::getStorageCellStart,
py::arg() = Positions{})
.def("setStoragecellStart", &Detector::setStoragecellStart, py::arg(),
py::arg() = Positions{})
.def("setStorageCellDelay", &Detector::setStorageCellDelay, py::arg(),
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("readRegister", &Detector::readRegister, py::arg(),
py::arg() = Positions{})
.def("writeRegister", &Detector::writeRegister, py::arg(), py::arg(),
py::arg() = Positions{})
.def("getStartingFrameNumber", &Detector::getStartingFrameNumber,
py::arg() = Positions{})
.def("setStartingFrameNumber", &Detector::setStartingFrameNumber,
py::arg(), py::arg() = Positions{})
/**************************************************
* *
* Insignificant *
* *
* ************************************************/
.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{})
/**************************************************
* *
* CTB Specific *
* *
* ************************************************/
.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{})
// Time // 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(), .def("setSubExptime", &Detector::setSubExptime, py::arg(),
py::arg() = Positions{}) py::arg() = Positions{})
.def("getSubExptime", &Detector::getSubExptime, .def("getSubExptime", &Detector::getSubExptime,

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,6 +12,14 @@
#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>;
@ -31,6 +40,308 @@ PYBIND11_MODULE(_sls_detector, m) {
init_enums(m); init_enums(m);
init_experimental(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");
io.def("read_my302_file", &read_my302_file, "some"); io.def("read_my302_file", &read_my302_file, "some");

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,9 +31,8 @@ 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);
} }
/** /**
@ -43,7 +42,7 @@ class MovingStat
{ {
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;
} }
@ -234,7 +227,6 @@ template <class dataType> class analogDetector {
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)
@ -505,7 +472,6 @@ template <class dataType> class analogDetector {
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,23 +505,9 @@ 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);
// cout << getId() << " @ " << ghSum->getXTalk() << " " << ghSum->getGhost(15,15) << endl;
}
};
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 double getGhost(int ix, int iy) {if (ghSum) return ghSum->getGhost(ix, iy); return 0;};
/** /**
@ -771,7 +723,6 @@ template <class dataType> class analogDetector {
if (cmSub && cm) { if (cmSub && cm) {
// cout <<",";
addToCommonMode(data); addToCommonMode(data);
} }
@ -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,10 +981,9 @@ 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);
@ -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

View File

@ -1,290 +0,0 @@
#ifndef MOENCH04ZMQ10GBDATA_H
#define MOENCH04ZMQ10GBDATA_H
#include "slsDetectorData.h"
class moench04CtbZmq10GbData : 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
*/
//moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, (nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
/* int ds; */
/* if (nas && nds) */
/* if (nds>nas) */
/* ds=nds*(32*2+8); */
/* else */
/* ds=nas*(32*2+8); */
/* else */
/* ds=nas*32*2+nds*8; */
/* new slsDetectorData<uint16_t>(400, 400, ds); */
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 is=0; is<aSamples; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=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) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
if (nds>0)
dataMap[row][col]=((nadc+4)*i+iadc)*2;//+16*(ip+1);
else
dataMap[row][col]=(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;
}
}
}
/* 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;
}
int getGain(char *data, int x, int y) {
// int aoff=aSamples*2*32;
int irow;
int isc=x/sc_width;
int icol=x%sc_width;
if (y<200) irow=sc_height-1-y;
else {
irow=y-sc_height;
isc++;
}
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
int isample=irow*sc_width+icol;
uint64_t sample;
char *ptr;
if (isc<0 || isc>=32) return 0;
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
if (dSamples>isample) {
ptr=data+32*(isample+1)+8*isample;
sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else
return 0;
} else
return 0;
}
/**
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;};//((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

View File

@ -28,20 +28,20 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
\param c crosstalk parameter for the output buffer \param c crosstalk parameter for the output buffer
*/ */
moench04CtbZmqData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) { moench04CtbZmqData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), 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 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 row, col;
//int isample; int isample;
int iadc; int iadc;
//int ix, iy; int ix, iy;
// int npackets=40; int npackets=40;
int i; int i;
//int adc4(0); int adc4(0);
for (int is=0; is<aSamples; is++) { for (int is=0; is<aSamples; is++) {
@ -223,15 +223,15 @@ class moench04CtbZmqData : 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;
// cout << dataSize << endl; // cout << dataSize << endl;
if (ff>=0) if (ff>=0)
// fnum=ff; fnum=ff;
if (filebin.is_open()) { if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){ if (filebin.read(data, dataSize) ){

View File

@ -28,20 +28,19 @@ template <class dataType> class ghostSummation {
~ghostSummation() {delete [] ghost;}; ~ghostSummation() {delete [] ghost;};
virtual ghostSummation *Clone() { virtual ghostSummation *Clone() {
return new ghostSummation(this); new ghostSummation(this);
} }
double getXTalk(){return xtalk;}; double getXTalk(){return xtalk;};
void setXTalk(double g) {xtalk=g;}; void setXTalk(double g) {xtalk=g;};
virtual double calcGhost(char *data, int ix, int iy=1){ghost[iy*nx+ix]=0; return 0;}; virtual double calcGhost(char *data, int ix, int iy=1){ghost[iy*nx+ix]=0;};
virtual void calcGhost(char *data){ virtual void calcGhost(char *data){
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++)
ghost[iy*nx+ix]=calcGhost(data, ix, iy); ghost[iy*nx+ix]=calcGhost(data, ix, iy);
} }
virtual double getGhost(int ix, int iy) { virtual double getGhost(int ix, int iy) {
if (ix<0 || ix>=nx || iy<0 || iy>=ny) return 0; if (ix<0 || ix>=nx || iy<0 || iy>=ny) return 0;
return ghost[iy*nx+ix]; return ghost[iy*nx+ix];

View File

@ -139,8 +139,8 @@ class interpolatingDetector : public singlePhotonDetector {
nph=addFrame(data,val,0); nph=addFrame(data,val,0);
if (interp) if (interp)
return interp->getInterpolatedImage(); return interp->getInterpolatedImage();
//else else
return singlePhotonDetector::getImage(); singlePhotonDetector::getImage();
//return NULL; //return NULL;
}; };
@ -233,7 +233,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
}; };
virtual slsInterpolation *setInterpolation(slsInterpolation *ii){ virtual slsInterpolation *setInterpolation(slsInterpolation *ii){
// int ok; int ok;
interp=ii; interp=ii;
/* pthread_mutex_lock(fi); /* pthread_mutex_lock(fi);
if (interp) if (interp)

View File

@ -33,7 +33,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
{ {
double sDum[2][2]; double sDum[2][2];
double tot, totquad; double tot, totquad;
double etax=0,etay=0; double etax,etay;
int corner; int corner;
corner=calcQuad(data, tot, totquad, sDum); corner=calcQuad(data, tot, totquad, sDum);
@ -49,7 +49,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
{ {
double sDum[2][2]; double sDum[2][2];
double tot, totquad; double tot, totquad;
double etax=0,etay=0; double etax,etay;
int corner; int corner;
corner=calcQuad(data, tot, totquad, sDum); corner=calcQuad(data, tot, totquad, sDum);
@ -71,7 +71,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) { virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
double cc[2][2]; double cc[2][2];
int xoff=0, yoff=0; int xoff, yoff;
switch (quad) { switch (quad) {
case BOTTOM_LEFT: case BOTTOM_LEFT:
xoff=0; xoff=0;
@ -92,7 +92,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
default: default:
; ;
} }
double etax=0, etay=0; double etax, etay;
if (nSubPixels>2) { if (nSubPixels>2) {
cc[0][0]=cl[xoff+3*yoff]; cc[0][0]=cl[xoff+3*yoff];
cc[1][0]=cl[xoff+3*(yoff+1)]; cc[1][0]=cl[xoff+3*(yoff+1)];
@ -100,7 +100,6 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
cc[1][1]=cl[xoff+1+3*(yoff+1)]; cc[1][1]=cl[xoff+1+3*(yoff+1)];
calcEta(totquad,cc,etax,etay); calcEta(totquad,cc,etax,etay);
} }
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
} }
@ -110,7 +109,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) { virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
double cc[2][2]; double cc[2][2];
int xoff=0, yoff=0; int xoff, yoff;
switch (quad) { switch (quad) {
case BOTTOM_LEFT: case BOTTOM_LEFT:
@ -132,7 +131,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
default: default:
; ;
} }
double etax=0, etay=0; double etax, etay;
if (nSubPixels>2) { if (nSubPixels>2) {
cc[0][0]=cl[xoff+3*yoff]; cc[0][0]=cl[xoff+3*yoff];
cc[1][0]=cl[xoff+3*(yoff+1)]; cc[1][0]=cl[xoff+3*(yoff+1)];
@ -223,7 +222,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) { virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
double cc[2][2]; double cc[2][2];
int xoff=0, yoff=0; int xoff, yoff;
switch (quad) { switch (quad) {
case BOTTOM_LEFT: case BOTTOM_LEFT:
@ -261,7 +260,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) { virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
double cc[2][2]; double cc[2][2];
int xoff=0, yoff=0; int xoff, yoff;
switch (quad) { switch (quad) {
case BOTTOM_LEFT: case BOTTOM_LEFT:
@ -309,12 +308,11 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual int addToFlatField(double *cluster, double &etax, double &etay){ virtual int addToFlatField(double *cluster, double &etax, double &etay){
double sDum[2][2]; double sDum[2][2];
double tot, totquad; double tot, totquad;
// int corner; int corner;
//corner= corner=calcQuad(cluster, tot, totquad, sDum);
calcQuad(cluster, tot, totquad, sDum);
//double xpos_eta,ypos_eta; double xpos_eta,ypos_eta;
//double dX,dY; double dX,dY;
calcEta(totquad, sDum, etax, etay); calcEta(totquad, sDum, etax, etay);
@ -326,12 +324,11 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
virtual int addToFlatField(int *cluster, double &etax, double &etay){ virtual int addToFlatField(int *cluster, double &etax, double &etay){
double sDum[2][2]; double sDum[2][2];
double tot, totquad; double tot, totquad;
//int corner; int corner;
//corner= corner=calcQuad(cluster, tot, totquad, sDum);
calcQuad(cluster, tot, totquad, sDum);
// double xpos_eta,ypos_eta; double xpos_eta,ypos_eta;
//double dX,dY; double dX,dY;
calcEta(totquad, sDum, etax, etay); calcEta(totquad, sDum, etax, etay);

View File

@ -59,10 +59,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
//////////// /*It return position hit for the event in input */ ////////////// //////////// /*It return position hit for the event in input */ //////////////
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y) virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
{ {
double tot; double tot, totquad;
double etax,etay; double etax,etay;
int corner=calcEta3(data,etax,etay, tot); int corner=calcEta3(data,etax,etay, totquad);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -72,11 +72,11 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y) virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
{ {
//double sDum[2][2]; double sDum[2][2];
double tot; double tot, totquad;
double etax,etay; double etax,etay;
int corner=calcEta3(data,etax,etay, tot); int corner=calcEta3(data,etax,etay, totquad);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);

View File

@ -190,7 +190,7 @@ float *gethhx()
void debugSaveAll(int ind=0) { void debugSaveAll(int ind=0) {
int ibx, iby; int ib, ibx, iby;
char tit[10000]; char tit[10000];
float tot_eta=0; float tot_eta=0;
@ -204,7 +204,7 @@ float *gethhx()
etah[ii]=heta[ii]; etah[ii]=heta[ii];
tot_eta+=heta[ii]; tot_eta+=heta[ii];
} }
sprintf(tit,"/scratch/eta_%d.tiff",ind); sprintf(tit,"/scratch/eta.tiff",ind);
WriteToTiff(etah, tit, etabins, etabins); WriteToTiff(etah, tit, etabins, etabins);
@ -284,7 +284,7 @@ float *gethhx()
double calcDiff(double avg, float *hx, float *hy) { double calcDiff(double avg, float *hx, float *hy) {
//double p_tot=0; //double p_tot=0;
double diff=0, d; double diff=0, d;
//double bsize=1./nSubPixels; double bsize=1./nSubPixels;
int nbad=0; int nbad=0;
double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels]; double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels];
double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels; double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels;
@ -351,9 +351,9 @@ float *gethhx()
return sqrt(diff); return sqrt(diff);
} }
int *heta;
float *hhx; float *hhx;
float *hhy; float *hhy;
int *heta;
int nbeta; int nbeta;
double etamin, etamax, etastep; double etamin, etamax, etastep;
double rangeMin, rangeMax; double rangeMin, rangeMax;

View File

@ -35,7 +35,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
///*Eta Distribution Rebinning*/// ///*Eta Distribution Rebinning*///
// double bsize=1./nSubPixels; //precision double bsize=1./nSubPixels; //precision
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl; // cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
double tot_eta=0; double tot_eta=0;
double tot_eta_x=0; double tot_eta_x=0;
@ -50,8 +50,8 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
double hy[nbeta]; //profile y double hy[nbeta]; //profile y
double hix[nbeta]; //integral of projection x double hix[nbeta]; //integral of projection x
double hiy[nbeta]; //integral of projection y double hiy[nbeta]; //integral of projection y
// int ii=0; int ii=0;
double etax;//, etay; double etax, etay;
for (int ib=0; ib<nbeta; ib++) { for (int ib=0; ib<nbeta; ib++) {
tot_eta_x=0; tot_eta_x=0;
@ -81,7 +81,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
hiy[iby]=hiy[iby-1]+hy[iby]; hiy[iby]=hiy[iby-1]+hy[iby];
} }
// ii=0; ii=0;
tot_eta_x=hix[nbeta-1]+1; tot_eta_x=hix[nbeta-1]+1;
tot_eta_y=hiy[nbeta-1]+1; tot_eta_y=hiy[nbeta-1]+1;
@ -98,7 +98,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
/* if (ii!=(nSubPixels-1)) */ /* if (ii!=(nSubPixels-1)) */
/* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */ /* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */
//ii=0; ii=0;
for (int ibx=0; ibx<nbeta; ibx++) { for (int ibx=0; ibx<nbeta; ibx++) {
if (tot_eta_y<=0) { if (tot_eta_y<=0) {

View File

@ -9,24 +9,16 @@ public:
virtual int getROI(int ix, int iy){return ix+(iy/200)*400;}; virtual int getROI(int ix, int iy){return ix+(iy/200)*400;};
virtual void addToCommonMode(double val, int ix=0, int iy=0) { virtual void addToCommonMode(double val, int ix=0, int iy=0) {
if (iy<rows || iy>399-rows) { if (ix<rows || ix>399-rows) {
int iroi=getROI(ix,iy); int iroi=getROI(ix,iy);
// cout << iy << " " << ix << " " << iroi ;
if (iroi>=0 && iroi<nROI) { if (iroi>=0 && iroi<nROI) {
mean[iroi]+=val; mean[iroi]+=val;
mean2[iroi]+=val*val; mean2[iroi]+=val*val;
nCm[iroi]++; nCm[iroi]++;
if (nCm[iroi]>rows) cout << "Too many pixels added " << nCm[iroi] << endl;
/* if (ix==10 && iy<20) */
/* cout << " ** "<<val << " " << mean[iroi] << " " << nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */
} }
} }
}; };
virtual commonModeSubtractionColumn *Clone() {
return new commonModeSubtractionColumn(this->rows);
}
private: private:
int rows; int rows;
}; };
@ -55,6 +47,7 @@ class moench03CommonMode : public commonModeSubtractionColumn {
moench03CommonMode(int nr=20) : commonModeSubtractionColumn(nr){} ; moench03CommonMode(int nr=20) : commonModeSubtractionColumn(nr){} ;
}; };

View File

@ -22,12 +22,6 @@ class moench03GhostSummation : public ghostSummation<uint16_t> {
} }
}; };
moench03GhostSummation(moench03GhostSummation *orig) : ghostSummation(orig) {
}
virtual moench03GhostSummation *Clone() {
return new moench03GhostSummation(this);
}
virtual double calcGhost(char *data, int x, int y=0){ virtual double calcGhost(char *data, int x, int y=0){
int ix=x%25; int ix=x%25;
@ -43,7 +37,6 @@ class moench03GhostSummation : public ghostSummation<uint16_t> {
// cout << val << " " ; // cout << val << " " ;
} }
ghost[iy*nx+ix]=xtalk*val; ghost[iy*nx+ix]=xtalk*val;
// if (ix==15 && iy==15) cout << ":" << ghost[iy*nx+ix] << " " << val << endl;
return ghost[iy*nx+ix]; return ghost[iy*nx+ix];
}; };

View File

@ -1,7 +1,7 @@
#ifndef MOENCHCOMMONMODE_H #ifndef MOENCHCOMMONMODE_H
#define MOENCHCOMMONMODE_H #define MOENCHCOMMONMODE_H
#include "commonModeSubtractionNew.h" #include "commonModeSubtraction.h"
class moenchCommonMode : public commonModeSubtraction { class moenchCommonMode : public commonModeSubtraction {
/** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */ /** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */
@ -9,36 +9,35 @@ class moenchCommonMode : public commonModeSubtraction {
/** constructor - initalizes a commonModeSubtraction with 4 different regions of interest /** constructor - initalizes a commonModeSubtraction with 4 different regions of interest
\param nn number of samples for the moving average \param nn number of samples for the moving average
*/ */
moenchCommonMode(int nn=1000) : commonModeSubtraction(nn,4){} ;
moenchCommonMode(int nn=0) : commonModeSubtraction(0){} ;
/* /\** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; */ /** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
/* \param val value to add to the common mode */ \param val value to add to the common mode
/* \param ix pixel coordinate in the x direction */ \param ix pixel coordinate in the x direction
/* \param iy pixel coordinate in the y direction */ \param iy pixel coordinate in the y direction
/* *\/ */ */
/* virtual void addToCommonMode(double val, int ix=0, int iy=0) { */ virtual void addToCommonMode(double val, int ix=0, int iy=0) {
/* (void) iy; */ (void) iy;
/* int isc=ix/40; */ int isc=ix/40;
/* if (isc>=0 && isc<nROI) { */ if (isc>=0 && isc<nROI) {
/* cmPed[isc]+=val; */ cmPed[isc]+=val;
/* nCm[isc]++; */ nCm[isc]++;
/* } */ }
/* }; */ };
/* /\**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; */ /**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
/* \param ix pixel coordinate in the x direction */ \param ix pixel coordinate in the x direction
/* \param iy pixel coordinate in the y direction */ \param iy pixel coordinate in the y direction
/* \returns common mode value */ \returns common mode value
/* *\/ */ */
/* virtual double getCommonMode(int ix=0, int iy=0) { */ virtual double getCommonMode(int ix=0, int iy=0) {
/* (void) iy; */ (void) iy;
/* int isc=ix/40; */ int isc=ix/40;
/* if (isc>=0 && isc<nROI) { */ if (isc>=0 && isc<nROI) {
/* if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); */ if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean();
/* } */ }
/* return 0; */ return 0;
/* }; */ };
}; };

View File

@ -13,13 +13,6 @@ all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
moenchClusterFinderHighZ: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinderHighZ moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DHIGHZ
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
@ -35,12 +28,6 @@ moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounterHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
clean: clean:
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog

View File

@ -1,6 +1,6 @@
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11 -Wall LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11
#-L../../bin -lhdf5 -L. #-L../../bin -lhdf5 -L.
#DESTDIR?=../bin #DESTDIR?=../bin

View File

@ -2,10 +2,6 @@
#include <iostream> #include <iostream>
#define CORR #define CORR
#define C_GHOST 0.0004
#define CM_ROWS 50
//#define VERSION_V1 //#define VERSION_V1
//#include "moench03T1ZmqData.h" //#include "moench03T1ZmqData.h"
@ -52,7 +48,7 @@ int main(int argc, char *argv[]) {
if (argc<4) { if (argc<4) {
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax] [gainmap]" << endl; cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax]" << endl;
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl; cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl; cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl;
return 1; return 1;
@ -60,7 +56,7 @@ int main(int argc, char *argv[]) {
int p=10000; int p=10000;
int fifosize=1000; int fifosize=1000;
int nthreads=10; int nthreads=1;
int nsubpix=25; int nsubpix=25;
int etabins=nsubpix*10; int etabins=nsubpix*10;
double etamin=-1, etamax=2; double etamin=-1, etamax=2;
@ -96,24 +92,32 @@ int main(int argc, char *argv[]) {
decoder->getDetectorSize(nx,ny); decoder->getDetectorSize(nx,ny);
int ncol_cm=CM_ROWS; int ncol_cm=20;
double xt_ghost=C_GHOST; double xt_ghost=0.0004;
moench03CommonMode *cm=NULL; moench03CommonMode *cm=NULL;
moench03GhostSummation *gs; moench03GhostSummation *gs;
double *gainmap=NULL; double *gainmap=NULL;
float *gm; #ifdef CORR
cout << "Applying common mode and ghost correction " << endl;
cm=new moench03CommonMode(ncol_cm);
gs=new moench03GhostSummation(decoder, xt_ghost);
#endif
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
int size = 327680;////atoi(argv[3]); int size = 327680;////atoi(argv[3]);
int* image; int* image;
//int* image =new int[327680/sizeof(int)]; //int* image =new int[327680/sizeof(int)];
filter->newDataSet();
int ff, np; int ff, np;
int dsize=decoder->getDataSize();
//cout << " data size is " << dsize; //cout << " data size is " << dsize;
char data[dsize];
ifstream filebin; ifstream filebin;
char *indir=argv[1]; char *indir=argv[1];
@ -140,7 +144,7 @@ int main(int argc, char *argv[]) {
double thr1=1; double thr1=1;
if (argc>=8) { if (argc>=8) {
thr=atof(argv[7]); thr=atoi(argv[7]);
} }
@ -158,12 +162,6 @@ int main(int argc, char *argv[]) {
} }
char *gainfname=NULL;
if (argc>13) {
gainfname=argv[13];
cout << "Gain map file name is: " << gainfname << endl;
}
@ -183,59 +181,13 @@ int main(int argc, char *argv[]) {
cout << "runmax is " << runmax << endl; cout << "runmax is " << runmax << endl;
if (pedfile) if (pedfile)
cout << "pedestal file is " << pedfile << endl; cout << "pedestal file is " << pedfile << endl;
if (thr>0)
cout << "threshold is " << thr << endl;
uint32 nnx, nny;
double *gmap;
// if (gainfname) {
// gm=ReadFromTiff(gainfname, nny, nnx);
// if (gm && nnx==nx && nny==ny) {
// gmap=new double[nx*ny];
// for (int i=0; i<nx*ny; i++) {
// gmap[i]=gm[i];
// }
// delete gm;
// } else
// cout << "Could not open gain map " << gainfname << endl;
// }
#ifdef CORR
cout << "Applying common mode " << ncol_cm << endl;
cm=new moench03CommonMode(ncol_cm);
cout << "Applying ghost corrections " << xt_ghost << endl;
gs=new moench03GhostSummation(decoder, xt_ghost);
#endif
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
if (gainfname) {
if (filter->readGainMap(gainfname))
cout << "using gain map " << gainfname << endl;
else
cout << "Could not open gain map " << gainfname << endl;
} else
thr=0.15*thr;
filter->newDataSet();
int dsize=decoder->getDataSize();
char data[dsize];
//#ifndef ANALOG //#ifndef ANALOG
if (thr>0) { if (thr>0) {
cout << "threshold is " << thr << endl; cout << "threshold is " << thr << endl;
//#ifndef ANALOG
#ifndef ANALOG
filter->setThreshold(thr); filter->setThreshold(thr);
//#endif #endif
cf=0; cf=0;
} else } else
@ -263,7 +215,7 @@ int main(int argc, char *argv[]) {
mt->setDetectorMode(eAnalog); mt->setDetectorMode(eAnalog);
cout << "Analog!" << endl; cout << "Analog!" << endl;
cf=0; cf=0;
//thr1=thr; thr1=thr;
#endif #endif
// } // }
@ -275,17 +227,14 @@ int main(int argc, char *argv[]) {
int ifr=0; int ifr=0;
double ped[nx*ny], *ped1;
if (pedfile) { if (pedfile) {
cout << "PEDESTAL " ;
cout << "PEDESTAL " << endl;
sprintf(imgfname,"%s/pedestals.tiff",outdir);
if (string(pedfile).find(".tif")==std::string::npos){
sprintf(fname,"%s.raw",pedfile); sprintf(fname,"%s.raw",pedfile);
cout << fname << endl ; cout << fname << endl ;
sprintf(imgfname,"%s/pedestals.tiff",outdir,fformat);
std::time(&end_time); std::time(&end_time);
cout << "aaa" << std::ctime(&end_time) << endl; cout << "aaa" << std::ctime(&end_time) << endl;
@ -310,31 +259,12 @@ int main(int argc, char *argv[]) {
} }
filebin.close(); filebin.close();
while (mt->isBusy()) {;} while (mt->isBusy()) {;}
} else
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
} else {
float *pp=ReadFromTiff(pedfile, nny, nnx);
if (pp && nnx==nx && nny==ny) {
for (int i=0; i<nx*ny; i++) {
ped[i]=pp[i];
}
delete [] pp;
mt->setPedestal(ped);
// ped1=mt->getPedestal();
// for (int i=0; i<nx*ny; i++) {
// cout << ped[i]<<"/"<<ped1[i] << " " ;
// }
cout << "Pedestal set from tiff file " << pedfile << endl;
} else {
cout << "Could not open pedestal tiff file "<< pedfile << " for reading " << endl;
}
}
mt->writePedestal(imgfname); mt->writePedestal(imgfname);
std::time(&end_time); std::time(&end_time);
cout << std::ctime(&end_time) << endl; cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
} }
@ -388,10 +318,6 @@ int main(int argc, char *argv[]) {
mt->nextThread(); mt->nextThread();
// // // cout << " " << (void*)buff; // // // cout << " " << (void*)buff;
mt->popFree(buff); mt->popFree(buff);
ifr++; ifr++;
if (ifr%100==0) cout << ifr << " " << ff << endl; if (ifr%100==0) cout << ifr << " " << ff << endl;
if (nframes>0) { if (nframes>0) {

View File

@ -1,9 +1,4 @@
#define WRITE_QUAD #define WRITE_QUAD
#define DEVELOPER
#define C_GHOST 0.0004
#define CM_ROWS 20
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "ZmqSocket.h" #include "ZmqSocket.h"
@ -51,11 +46,9 @@ int main(int argc, char *argv[]) {
int fifosize=5000; int fifosize=5000;
int etabins=1000;//nsubpix*2*100; int etabins=1000;//nsubpix*2*100;
double etamin=-1, etamax=2; double etamin=-1, etamax=2;
int nSubPixels=2;
// int emin, emax;
// help // help
if (argc < 3 ) { if (argc < 3 ) {
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [gainmap] [etafile]\n"); cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [etafile]\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -67,7 +60,6 @@ int main(int argc, char *argv[]) {
char* socketip2 = 0; char* socketip2 = 0;
uint32_t portnum2 = 0; uint32_t portnum2 = 0;
uint32_t nSigma=5;
int ok; int ok;
@ -93,23 +85,18 @@ int main(int argc, char *argv[]) {
nthreads=atoi(argv[5]); nthreads=atoi(argv[5]);
cout << "Number of threads is: " << nthreads << endl; cout << "Number of threads is: " << nthreads << endl;
int nSubPixels=2;
if (argc>6) if (argc>6)
nSubPixels=atoi(argv[6]); nSubPixels=atoi(argv[6]);
cout << "Number of subpixels is: " << nSubPixels << endl; cout << "Number of subpixels is: " << nSubPixels << endl;
char *gainfname=NULL;
if (argc>7) {
gainfname=argv[7];
cout << "Gain map file name is: " << gainfname << endl;
}
char *etafname=NULL; char *etafname=NULL;
if (argc>8) { if (argc>7) {
etafname=argv[8]; etafname=argv[7];
cout << "Eta file name is: " << etafname << endl; cout << "Eta file name is: " << etafname << endl;
} }
//slsDetectorData *det=new moench03T1ZmqDataNew(); //slsDetectorData *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(); moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
cout << endl << " det" <<endl; cout << endl << " det" <<endl;
@ -121,44 +108,20 @@ int main(int argc, char *argv[]) {
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]); int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
int size= maxSize;//32*2*5000; int size= maxSize;//32*2*5000;
//int multisize=size; int multisize=size;
//int dataSize=size; int dataSize=size;
char dummybuff[size]; char dummybuff[size];
int ncol_cm=20;
int ncol_cm=CM_ROWS; double xt_ghost=0.00045;
double xt_ghost=C_GHOST;
moench03CommonMode *cm=new moench03CommonMode(ncol_cm); moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost); moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
double *gainmap=NULL; double *gainmap=NULL;
float *gm;
double *gmap=NULL;
uint32_t nnnx, nnny;
if (gainfname) {
gm=ReadFromTiff(gainfname, nnny, nnnx);
if (gm && nnnx==(uint)npx && nnny==(uint)npy) {
gmap=new double[npx*npy];
for (int i=0; i<npx*npy; i++) {
gmap[i]=gm[i];
}
delete [] gm;
} else
cout << "Could not open gain map " << gainfname << endl;
}
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000); //analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
#ifndef INTERP #ifndef INTERP
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, cm, 1000, 10, -1, -1, gainmap, gs);
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize); multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
@ -169,7 +132,7 @@ int main(int argc, char *argv[]) {
if (etafname) interp->readFlatField(etafname); if (etafname) interp->readFlatField(etafname);
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, cm, 1000, 10, -1, -1, gainmap, gs);
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize); multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
#endif #endif
@ -260,22 +223,21 @@ int main(int argc, char *argv[]) {
// header variables // header variables
uint64_t acqIndex = -1; uint64_t acqIndex = -1;
uint64_t frameIndex = -1; uint64_t frameIndex = -1;
//uint32_t subFrameIndex = -1; uint32_t subFrameIndex = -1;
uint64_t fileindex = -1; uint64_t fileindex = -1;
string filename = ""; string filename = "";
// char* image = new char[size]; // char* image = new char[size];
//int* image = new int[(size/sizeof(int))](); //int* image = new int[(size/sizeof(int))]();
//uint32_t flippedDataX = -1; uint32_t flippedDataX = -1;
//int *nph; int *nph;
int iframe=0; int iframe=0;
char ofname[10000]; char ofname[10000];
char fname[10000]; char fname[10000];
// int length; int length;
int *detimage; int *detimage;
int nnx, nny,nns; int nnx, nny,nns;
//uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
//uint32_t dynamicRange = 0;
// infinite loop // infinite loop
uint32_t packetNumber = 0; uint32_t packetNumber = 0;
uint64_t bunchId = 0; uint64_t bunchId = 0;
@ -289,10 +251,11 @@ int main(int argc, char *argv[]) {
//int16_t *dout;//=new int16_t [nnx*nny]; //int16_t *dout;//=new int16_t [nnx*nny];
uint32_t dr = 32; uint32_t dr = 32;
int32_t *dout=NULL;//=new int32_t [nnx*nny]; int32_t *dout=NULL;//=new int32_t [nnx*nny];
uint32_t nSigma=5;
uint16_t roundRNumber = 0; uint16_t roundRNumber = 0;
uint8_t detType = 0; uint8_t detType = 0;
uint8_t version = 0; uint8_t version = 0;
// int* flippedData = 0; int* flippedData = 0;
char* additionalJsonHeader = 0; char* additionalJsonHeader = 0;
int32_t threshold=0; int32_t threshold=0;
@ -301,14 +264,15 @@ int main(int argc, char *argv[]) {
string frameMode_s, detectorMode_s, intMode_s; string frameMode_s, detectorMode_s, intMode_s;
// int resetFlat=0; int emin, emax;
//int resetPed=0; int resetFlat=0;
// int nsubPixels=1; int resetPed=0;
//int isPedestal=0; int nsubPixels=1;
//int isFlat=0; int isPedestal;
int isFlat=0;
int newFrame=1; int newFrame=1;
detectorMode dMode=eAnalog; detectorMode dMode;
frameMode fMode=eFrame; frameMode fMode;
double *ped; double *ped;
filter->getImageSize(nnx, nny,nns); filter->getImageSize(nnx, nny,nns);
@ -353,20 +317,20 @@ int main(int argc, char *argv[]) {
} }
} else { } else {
if (fMode==ePedestal) { if (fMode==ePedestal) {
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex); sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
mt->writePedestal(ofname); mt->writePedestal(ofname);
cout << "Writing pedestal to " << ofname << endl; cout << "Writing pedestal to " << ofname << endl;
} }
#ifdef INTERP #ifdef INTERP
else if (fMode==eFlat) { else if (fMode==eFlat) {
mt->prepareInterpolation(ok); mt->prepareInterpolation(ok);
sprintf(ofname,"%s_%ld_eta.tiff",fname,fileindex); sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
mt->writeFlatField(ofname); mt->writeFlatField(ofname);
cout << "Writing eta to " << ofname << endl; cout << "Writing eta to " << ofname << endl;
} }
#endif #endif
else { else {
sprintf(ofname,"%s_%ld.tiff",fname,fileindex); sprintf(ofname,"%s_%d.tiff",fname,fileindex);
mt->writeImage(ofname); mt->writeImage(ofname);
cout << "Writing image to " << ofname << endl; cout << "Writing image to " << ofname << endl;
} }
@ -395,7 +359,7 @@ int main(int argc, char *argv[]) {
#ifdef INTERP #ifdef INTERP
else if (fMode==eFlat) { else if (fMode==eFlat) {
int nb; int nb;
double emi=0, ema=1; double emi, ema;
int *ff=mt->getFlatField(nb, emi, ema); int *ff=mt->getFlatField(nb, emi, ema);
nnx=nb; nnx=nb;
nny=nb; nny=nb;
@ -445,47 +409,8 @@ int main(int argc, char *argv[]) {
// char* additionalJsonHeader = 0) { // char* additionalJsonHeader = 0) {
// cout << "Sending image size " << nnx << " " << nny << endl; // cout << "Sending image size " << nnx << " " << nny << endl;
#ifndef DEVELOPER
#ifndef MOENCH_BRANCH
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader); zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
#endif
#endif
#ifdef DEVELOPER
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
#endif
#ifdef MOENCH_BRANCH
/*
int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL,
uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
uint64_t bunchId = 0, uint64_t timestamp = 0,
uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
uint32_t debug = 0, uint16_t roundRNumber = 0,
uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0,
char* additionalJsonHeader = 0) {
int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEADER_VERSION , uint32_t dr, uint64_t fileindex, uint32_t 0, uint32_t 0, uint32_t, uint64_t, uint64_t, char*, uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, int*, char*)
*/
//zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version);//, 0,additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
/* old
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
*/
/*
new
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,additionalJsonHeader);
*/
#endif
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8); zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
cprintf(GREEN, "Sent Data\n"); cprintf(GREEN, "Sent Data\n");
@ -524,7 +449,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
// acqIndex, frameIndex, subframeIndex, filename, fileindex // acqIndex, frameIndex, subframeIndex, filename, fileindex
size = doc["size"].GetUint(); size = doc["size"].GetUint();
// multisize = size;// * zmqsocket->size(); // multisize = size;// * zmqsocket->size();
// dynamicRange = doc["bitmode"].GetUint(); dynamicRange = doc["bitmode"].GetUint();
// nPixelsX = doc["shape"][0].GetUint(); // nPixelsX = doc["shape"][0].GetUint();
// nPixelsY = doc["shape"][1].GetUint(); // nPixelsY = doc["shape"][1].GetUint();
filename = doc["fname"].GetString(); filename = doc["fname"].GetString();
@ -541,7 +466,7 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
//detType=doc["detType"].GetUint(); //detType=doc["detType"].GetUint();
//version=doc["version"].GetUint(); //version=doc["version"].GetUint();
//dataSize=size; dataSize=size;
strcpy(fname,filename.c_str()); strcpy(fname,filename.c_str());
@ -575,8 +500,8 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version); // flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
/* Analog detector commands */ /* Analog detector commands */
//isPedestal=0; isPedestal=0;
//isFlat=0; isFlat=0;
fMode=eFrame; fMode=eFrame;
frameMode_s="frame"; frameMode_s="frame";
cprintf(MAGENTA, "Frame mode: "); cprintf(MAGENTA, "Frame mode: ");
@ -585,28 +510,28 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
frameMode_s=doc["frameMode"].GetString(); frameMode_s=doc["frameMode"].GetString();
if (frameMode_s == "pedestal"){ if (frameMode_s == "pedestal"){
fMode=ePedestal; fMode=ePedestal;
//isPedestal=1; isPedestal=1;
} else if (frameMode_s == "newPedestal"){ } else if (frameMode_s == "newPedestal"){
mt->newDataSet(); //resets pedestal mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n"); // cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal; fMode=ePedestal;
//isPedestal=1; isPedestal=1;
} }
#ifdef INTERP #ifdef INTERP
else if (frameMode_s == "flatfield") { else if (frameMode_s == "flatfield") {
fMode=eFlat; fMode=eFlat;
//isFlat=1; isFlat=1;
} else if (frameMode_s == "newFlatfield") { } else if (frameMode_s == "newFlatfield") {
mt->resetFlatField(); mt->resetFlatField();
//isFlat=1; isFlat=1;
cprintf(MAGENTA, "Resetting flatfield\n"); cprintf(MAGENTA, "Resetting flatfield\n");
fMode=eFlat; fMode=eFlat;
} }
#endif #endif
else { else {
fMode=eFrame; fMode=eFrame;
//isPedestal=0; isPedestal=0;
//isFlat=0; isFlat=0;
fMode=eFrame; fMode=eFrame;
frameMode_s="frame"; frameMode_s="frame";
} }
@ -739,10 +664,10 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
// cout << "data " << endl; // cout << "data " << endl;
if (of==NULL) { if (of==NULL) {
#ifdef WRITE_QUAD #ifdef WRITE_QUAD
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex); sprintf(ofname,"%s_%d.clust2",filename.c_str(),fileindex);
#endif #endif
#ifndef WRITE_QUAD #ifndef WRITE_QUAD
sprintf(ofname,"%s_%ld.clust",filename.c_str(),fileindex); sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
#endif #endif
of=fopen(ofname,"w"); of=fopen(ofname,"w");
if (of) { if (of) {
@ -767,15 +692,13 @@ int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEAD
if (packetNumber>=40) { if (packetNumber>=40) {
//*((int*)buff)=frameIndex; //*((int*)buff)=frameIndex;
memcpy(buff,&frameIndex,sizeof(int)); memcpy(buff,&frameIndex,sizeof(int));
//length = length = zmqsocket->ReceiveData(0, buff+sizeof(int), size);
zmqsocket->ReceiveData(0, buff+sizeof(int), size);
mt->pushData(buff); mt->pushData(buff);
mt->nextThread(); mt->nextThread();
mt->popFree(buff); mt->popFree(buff);
} else { } else {
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber); cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
//length = length = zmqsocket->ReceiveData(0, dummybuff, size);
zmqsocket->ReceiveData(0, dummybuff, size);
} }

View File

@ -32,11 +32,11 @@ class threadedAnalogDetector
{ {
public: public:
threadedAnalogDetector(analogDetector<uint16_t> *d, int fs=10000) { threadedAnalogDetector(analogDetector<uint16_t> *d, int fs=10000) {
char *mm;//*mem, char *mem, *mm;
det=d; det=d;
fifoFree=new CircularFifo<char>(fs); fifoFree=new CircularFifo<char>(fs);
fifoData=new CircularFifo<char>(fs); fifoData=new CircularFifo<char>(fs);
// mem==NULL;
/* mem=(char*)calloc(fs, det->getDataSize()); */ /* mem=(char*)calloc(fs, det->getDataSize()); */
/* if (mem) */ /* if (mem) */
/* memset(mem,0, fs*det->getDataSize()); */ /* memset(mem,0, fs*det->getDataSize()); */
@ -46,7 +46,6 @@ public:
// mm=mem+i*det->getDataSize(); // mm=mem+i*det->getDataSize();
// cout << i << endl; // cout << i << endl;
mm=(char*)calloc(1, det->getDataSize()); mm=(char*)calloc(1, det->getDataSize());
if (mm) { if (mm) {
//memset(mm,0, det->getDataSize()); //memset(mm,0, det->getDataSize());
fifoFree->push(mm); fifoFree->push(mm);
@ -63,7 +62,6 @@ public:
} }
virtual int setFrameMode(int fm) { virtual int setFrameMode(int fm) {
if (fm>=0) { if (fm>=0) {
det->setFrameMode((frameMode)fm); det->setFrameMode((frameMode)fm);
@ -98,14 +96,11 @@ public:
virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);}; virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);};
virtual int getDetectorSize(int &nnx, int &nny) {return det->getDetectorSize(nnx, nny);}; virtual int getDetectorSize(int &nnx, int &nny) {return det->getDetectorSize(nnx, nny);};
virtual ~threadedAnalogDetector() {StopThread(); delete fifoFree; delete fifoData;} ~threadedAnalogDetector() {StopThread(); free(mem); delete fifoFree; delete fifoData;}
/** Returns true if the thread was successfully started, false if there was an error starting the thread */ /** Returns true if the thread was successfully started, false if there was an error starting the thread */
virtual bool StartThread() virtual bool StartThread()
{ stop=0; { stop=0;
cout << "Detector number " << det->getId() << endl;
cout << "common mode is " << det->getCommonModeSubtraction()<< endl;
cout << "ghos summation is " << det->getGhostSummation()<< endl;
return (pthread_create(&_thread, NULL, processData, this) == 0); return (pthread_create(&_thread, NULL, processData, this) == 0);
} }
@ -116,11 +111,11 @@ public:
virtual bool pushData(char* &ptr) { virtual bool pushData(char* &ptr) {
return fifoData->push(ptr); fifoData->push(ptr);
} }
virtual bool popFree(char* &ptr) { virtual bool popFree(char* &ptr) {
return fifoFree->pop(ptr); fifoFree->pop(ptr);
} }
virtual int isBusy() {return busy;} virtual int isBusy() {return busy;}
@ -187,19 +182,16 @@ FILE *getFilePointer(){return det->getFilePointer();};
void *writeFlatField(const char * imgname) { void *writeFlatField(const char * imgname) {
slsInterpolation *interp=(det)->getInterpolation(); slsInterpolation *interp=(det)->getInterpolation();
//cout << "interp " << interp << endl; cout << "interp " << interp << endl;
if (interp) { if (interp) {
cout << imgname << endl; cout << imgname << endl;
return interp->writeFlatField(imgname); interp->writeFlatField(imgname);
} }
return NULL;
} }
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){ void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
slsInterpolation *interp=(det)->getInterpolation(); slsInterpolation *interp=(det)->getInterpolation();
if (interp) if (interp)
return interp->readFlatField(imgname, nb, emin, emax); interp->readFlatField(imgname, nb, emin, emax);
return NULL;
} }
virtual int *getFlatField(int &nb, double emi, double ema){ virtual int *getFlatField(int &nb, double emi, double ema){
@ -236,6 +228,7 @@ protected:
int dMode; int dMode;
int *dataSize; int *dataSize;
pthread_t _thread; pthread_t _thread;
char *mem;
CircularFifo<char> *fifoFree; CircularFifo<char> *fifoFree;
CircularFifo<char> *fifoData; CircularFifo<char> *fifoData;
int stop; int stop;
@ -299,15 +292,15 @@ public:
StopThreads(); StopThreads();
for (int i=0; i<nThreads; i++) for (int i=0; i<nThreads; i++)
delete dets[i]; delete dets[i];
/* for (int i=1; i<nThreads; i++) */ for (int i=1; i<nThreads; i++)
/* delete dd[i]; */ delete dd[i];
//delete [] image; //delete [] image;
} }
virtual int setFrameMode(int fm) { int ret=dets[0]->setFrameMode(fm); for (int i=1; i<nThreads; i++) { dets[i]->setFrameMode(fm);} return ret;}; virtual int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) { ret=dets[i]->setFrameMode(fm);} return ret;};
virtual double setThreshold(int fm) { double ret=dets[0]->setThreshold(fm); for (int i=1; i<nThreads; i++) dets[i]->setThreshold(fm); return ret;}; virtual double setThreshold(int fm) { double ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setThreshold(fm); return ret;};
virtual int setDetectorMode(int dm) { int ret=dets[0]->setDetectorMode(dm);; for (int i=1; i<nThreads; i++) dets[i]->setDetectorMode(dm); return ret;}; virtual int setDetectorMode(int dm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setDetectorMode(dm); return ret;};
virtual void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; i<nThreads; i++) dets[i]->setROI(xmin, xmax,ymin,ymax);}; virtual void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; i<nThreads; i++) dets[i]->setROI(xmin, xmax,ymin,ymax);};
@ -415,12 +408,12 @@ public:
virtual bool pushData(char* &ptr) { virtual bool pushData(char* &ptr) {
return dets[ithread]->pushData(ptr); dets[ithread]->pushData(ptr);
} }
virtual bool popFree(char* &ptr) { virtual bool popFree(char* &ptr) {
// cout << ithread << endl; // cout << ithread << endl;
return dets[ithread]->popFree(ptr); dets[ithread]->popFree(ptr);
} }
virtual int nextThread() { virtual int nextThread() {
@ -506,15 +499,14 @@ public:
uint32 nny; uint32 nny;
float *gm=ReadFromTiff(imgname, nnx, nny); float *gm=ReadFromTiff(imgname, nnx, nny);
if (ped) delete [] ped; if (ped) delete [] ped;
if (nnx>(uint)nx) nx=nnx; if (nnx>nx) nx=nnx;
if (nny>(uint)ny) ny=nny; if (nny>ny) ny=nny;
ped=new double[nx*ny]; ped=new double[nx*ny];
for (int ix=0; ix<nx*ny; ix++) { for (int ix=0; ix<nx*ny; ix++) {
ped[ix]=gm[ix]; ped[ix]=gm[ix];
} }
delete [] gm; delete [] gm;
return setPedestal(); return setPedestal();
}; };

View File

@ -25,7 +25,7 @@ class multiThreadedCountingDetector : public multiThreadedAnalogDetector
public: public:
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { }; multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { };
virtual double setNSigma(double n) {double ret=(dets[0])->setNSigma(n); for (int i=1; i<nThreads; i++) (dets[i])->setNSigma(n); return ret;}; virtual double setNSigma(double n) {double ret; for (int i=0; i<nThreads; i++) ret=(dets[i])->setNSigma(n); return ret;};
virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) (dets[i])->setEnergyRange(emi,ema);}; virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) (dets[i])->setEnergyRange(emi,ema);};
}; };

View File

@ -37,12 +37,12 @@ public:
}; };
void *writeFlatField(const char * imgname){ void *writeFlatField(const char * imgname){
return dets[0]->writeFlatField(imgname); dets[0]->writeFlatField(imgname);
}; };
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){ void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
return (dets[0])->readFlatField(imgname, nb, emin, emax); (dets[0])->readFlatField(imgname, nb, emin, emax);
}; };
@ -56,7 +56,7 @@ public:
\returns current file pointer \returns current file pointer
*/ */
virtual slsInterpolation *setInterpolation(slsInterpolation *f){ virtual slsInterpolation *setInterpolation(slsInterpolation *f){
//int ok; int ok;
for (int i=0; i<nThreads; i++) for (int i=0; i<nThreads; i++)
(dets[i])->setInterpolation(f); (dets[i])->setInterpolation(f);
return (dets[0])->getInterpolation(); return (dets[0])->getInterpolation();

View File

@ -58,7 +58,7 @@ public analogDetector<uint16_t> {
int sign=1, int sign=1,
commonModeSubtraction *cm=NULL, commonModeSubtraction *cm=NULL,
int nped=1000, int nped=1000,
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm, gs), nDark(nd), eventMask(NULL),nSigma (nsigma), eMin(-1), eMax(-1), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) { int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm, gs), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0), eMin(-1), eMax(-1) {
@ -183,13 +183,13 @@ public analogDetector<uint16_t> {
//nph=new int[nx*ny]; //nph=new int[nx*ny];
double rest[ny][nx]; double rest[ny][nx];
//int cy=(clusterSizeY+1)/2; //quad size int cy=(clusterSizeY+1)/2; //quad size
//int cs=(clusterSize+1)/2; //quad size int cs=(clusterSize+1)/2; //quad size
//int ccs=clusterSize; //cluster size int ccs=clusterSize; //cluster size
//int ccy=clusterSizeY; //cluster size int ccy=clusterSizeY; //cluster size
//double g=1.; double g=1.;
double tthr=thr, tthr1, tthr2; double tthr=thr, tthr1, tthr2;
@ -201,10 +201,10 @@ public analogDetector<uint16_t> {
if (cmSub) cm=1; if (cmSub) cm=1;
if (thr>0) { if (thr>0) {
//cy=1; cy=1;
//cs=1; cs=1;
//ccs=1; ccs=1;
//ccy=1; ccy=1;
} }
if (iframe<nDark) { if (iframe<nDark) {
// cout << "ped " << iframe << endl; // cout << "ped " << iframe << endl;
@ -349,9 +349,9 @@ int *getClusters(char *data, int *ph=NULL) {
double val[ny][nx]; double val[ny][nx];
int cy=(clusterSizeY+1)/2; int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2; int cs=(clusterSize+1)/2;
//int ir, ic; int ir, ic;
double max=0, tl=0, tr=0, bl=0,br=0, *v; double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
int cm=0; int cm=0;
int good=1; int good=1;
if (cmSub) cm=1; if (cmSub) cm=1;
@ -592,7 +592,7 @@ int *getClusters(char *data, int *ph=NULL) {
switch(fMode) { switch(fMode) {
case ePedestal: case ePedestal:
//cout <<"spc add to ped " << endl; //cout <<"spc add to ped " << endl;
addToPedestal(data,1); addToPedestal(data);
break; break;
default: default:
switch (dMode) { switch (dMode) {

View File

@ -119,7 +119,7 @@ class single_photon_hit {
if (fread((void*)qq, 1, 4*sizeof(int), myFile)) { if (fread((void*)qq, 1, 4*sizeof(int), myFile)) {
quad=TOP_RIGHT; quad=TOP_RIGHT;
/* int mm=qq[0]; */ int mm=qq[0];
/* for (int i=1; i<4; i++) { */ /* for (int i=1; i<4; i++) { */
/* if (qq[i]>mm) { */ /* if (qq[i]>mm) { */
/* switch (i) { */ /* switch (i) { */
@ -211,7 +211,7 @@ class single_photon_hit {
void print() { void print() {
// int ix, iy; int ix, iy;
for (int iy=0; iy<dy; iy++) { for (int iy=0; iy<dy; iy++) {
for (int ix=0; ix<dx; ix++) { for (int ix=0; ix<dx; ix++) {

View File

@ -4,20 +4,20 @@
#include<iostream> #include<iostream>
using namespace std; using namespace std;
// #undef cbf_failnez // #undef cbf_failnez
// #define cbf_failnez(x) // #define cbf_failnez(x) \
// { // { \
// int err; // int err; \
// err = (x); // err = (x); \
// if (err) { // if (err) { \
// fprintf(stderr,"\nCBFlib fatal error %x \n",err); // fprintf(stderr,"\nCBFlib fatal error %x \n",err); \
// exit(-1); // exit(-1); \
// } // } \
// } // }
void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
int sampleperpixel=1; int sampleperpixel=1;
// unsigned char * buff=NULL; // unsigned char * buff=NULL;
//tsize_t linebytes; tsize_t linebytes;
// cout << "--" <<endl; // cout << "--" <<endl;
TIFF * tif = TIFFOpen(imgname,"w"); TIFF * tif = TIFFOpen(imgname,"w");
if (tif) { if (tif) {
@ -30,7 +30,7 @@ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP); TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
//linebytes = sampleperpixel*ncol; linebytes = sampleperpixel*ncol;
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, ncol*sampleperpixel)); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, ncol*sampleperpixel));
for(int irow=0; irow<nrow; irow++){ for(int irow=0; irow<nrow; irow++){
TIFFWriteScanline(tif,&imgData[irow*ncol],irow,0); TIFFWriteScanline(tif,&imgData[irow*ncol],irow,0);
@ -50,7 +50,7 @@ float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol){
if (tif){ if (tif){
uint32 bps; uint32 bps;
uint32 sampleperpixel=1; uint32 sampleperpixel=1;
//tsize_t linebytes; tsize_t linebytes;
uint32 imagelength; uint32 imagelength;
@ -61,9 +61,9 @@ float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol){
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
float * imgData=new float[ncol*nrow]; float * imgData=new float[ncol*nrow];
//linebytes = sampleperpixel*ncol; linebytes = sampleperpixel*ncol;
// TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, ncol*sampleperpixel)); // TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, ncol*sampleperpixel));
for(uint32 irow=0; irow<nrow; irow++){ for(int irow=0; irow<nrow; irow++){
//tiffreadscanline(tif, buf, row); //tiffreadscanline(tif, buf, row);
TIFFReadScanline(tif,&imgData[irow*ncol],irow); TIFFReadScanline(tif,&imgData[irow*ncol],irow);
} }

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