Compare commits

...

146 Commits

Author SHA1 Message Date
dac9998161 updated all servers 2020-05-08 13:42:07 +02:00
1dfac6ae6a Merge pull request #95 from slsdetectorgroup/trim
Trim
2020-05-08 13:39:42 +02:00
2e75f36fa0 pr fixes 2020-05-08 12:24:12 +02:00
c1902c713d mythne3 binary 2020-05-08 11:16:10 +02:00
61f5564bb7 Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 11:15:34 +02:00
ec2f7db729 mythen3: settings file of dac -1 fix 2020-05-08 11:15:27 +02:00
676055837f mythen3: binaries for 1 chip fix 2020-05-08 11:04:47 +02:00
cce028b825 Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 11:04:13 +02:00
d468641138 fix 2020-05-08 11:04:04 +02:00
01d1c86403 mythen3 trim one chip fix 2020-05-08 11:03:00 +02:00
2ac7451a99 eiger server 2020-05-08 10:53:34 +02:00
15b57b29fb all binaries except eiger 2020-05-08 10:18:54 +02:00
902616a09d Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 10:18:38 +02:00
eb3971fedc all binaries except eiger 2020-05-08 10:18:29 +02:00
64f0aa98ab Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-08 10:17:43 +02:00
61b86962bd no binaries yet, malloc need no casting 2020-05-08 10:17:36 +02:00
0e5a96e1ed binaries mythen3, gotthard2 2020-05-08 09:42:29 +02:00
2f11dbc2c9 nios, for variable delcaration in loop 2020-05-08 09:39:36 +02:00
9b21f44d94 binary 2020-05-07 17:41:56 +02:00
e56b431dc3 trim crash fix 2020-05-07 17:41:23 +02:00
1741c84406 binary 2020-05-07 17:22:43 +02:00
1623448086 minor 2020-05-07 17:14:51 +02:00
1a39f92f8f binary 2020-05-07 17:14:20 +02:00
4ea1f2c7e3 Merge branch 'trim' of github.com:slsdetectorgroup/slsDetectorPackage into trim 2020-05-07 17:07:56 +02:00
66d30cb2f1 remove printouts during trimming 2020-05-07 17:07:44 +02:00
8f021fe4ac binaries 2020-05-07 16:48:27 +02:00
7f42f5cadb trim change mythen3 2020-05-07 16:40:09 +02:00
999c548aa1 mythen3: trim: removing printout while tirmming 2020-05-07 16:36:09 +02:00
6872f24037 mythen3: binary 2020-05-07 16:07:24 +02:00
1a75170eed mythen3: set trimbits (not settings, threshold yet), set all trimbits 2020-05-07 16:04:30 +02:00
a12d47da36 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-05-06 12:02:54 +02:00
c16411ba00 new regex for version 2020-05-06 12:02:42 +02:00
379b9b53b4 fixed still one index in cluster finder 2020-05-06 12:02:22 +02:00
d76f43f5fd Fixed problem in cluster finder 2020-05-06 11:59:49 +02:00
7d94ad51ab format slsdetectorservers .c 2020-05-05 15:30:44 +02:00
671cf45fd7 format slsdetectorservers 2020-05-05 15:23:11 +02:00
31ec3c8cf7 check for clang-format version 2020-05-05 10:37:17 +02:00
8ff9b0cdac format GUI 2020-05-05 10:12:05 +02:00
ea4044e4b1 format support lib 2020-05-05 10:07:19 +02:00
e599bb7c24 format receiver 2020-05-05 10:04:52 +02:00
3618f6e5d3 removed obsolete tests 2020-05-05 09:20:05 +02:00
959fd562d3 clang-format 2020-05-04 16:30:00 +02:00
32662baef8 cleaning 2020-05-04 16:18:55 +02:00
4e4f06560c Adding support for clang-format (#94) 2020-05-04 16:16:23 +02:00
efcb6cf480 Merge branch 'static' into developer 2020-04-30 18:06:55 +02:00
9ae933b177 WIP 2020-04-30 18:04:30 +02:00
f87e8d3c19 WIP 2020-04-30 18:03:17 +02:00
903ebb2679 WIP 2020-04-30 17:58:31 +02:00
f41083842f WIP 2020-04-30 17:09:14 +02:00
9a87ba610a WIP 2020-04-30 15:26:50 +02:00
7224ad989a WIP 2020-04-30 14:04:50 +02:00
64f5c0f34b jungfrau virtual bug fix: sends multiple frames for both interfaces now 2020-04-29 18:07:59 +02:00
3238ecfc8d WIP 2020-04-29 18:02:57 +02:00
395d7ba98a Merge branch 'developer' into static 2020-04-29 14:20:12 +02:00
96ec3b2123 merge conflict resolved 2020-04-29 14:17:07 +02:00
b7805ae0d4 gotthard2, moench: remove leading spaces in config file on board detector server 2020-04-29 14:09:35 +02:00
1f6b0b5887 gotthard2: new default clk dividers 2020-04-29 12:51:05 +02:00
b1cdc79bd4 Merge branch 'developer' into static 2020-04-28 18:31:11 +02:00
f626db454e updated gotthard2, mythen3 binaries 2020-04-28 17:07:18 +02:00
86b39853a3 gotthard2, mythen3: making them clkdivider dependant and not clkfrequency, binaries not loaded yet 2020-04-28 17:04:57 +02:00
e3044689dd WIP 2020-04-28 14:26:59 +02:00
337e56d9bf cleaned up LTO detection 2020-04-23 08:23:36 +02:00
eb257154c6 added triggers 2020-04-22 09:15:31 +02:00
c1ae67ac46 Small refactor on ThreadObject and listener (#93)
* removed pointer, slight cleaning of loop

* removed semaphore, use getters

* removed redundant log msg

* removed comment

* added const

* removed comment

* changed header
2020-04-21 09:45:29 +02:00
68f76e5356 more like UdpRxSocket 2020-04-20 17:24:53 +02:00
8afa11ed33 removed pointer to server socket 2020-04-20 17:20:33 +02:00
bc389f4825 moved data members to top 2020-04-20 14:51:48 +02:00
095ced153c removed need for pointer 2020-04-20 14:31:10 +02:00
a1a5a20845 from thread sanitizer 2020-04-17 09:35:38 +02:00
c725a05ef8 fix RH7 2020-04-16 15:51:28 +02:00
815b6a37aa moved flag to base class 2020-04-16 13:22:51 +02:00
655a410d43 cleaned up UdpRxSocket 2020-04-16 09:45:44 +02:00
97ba81d923 fixed test 2020-04-14 16:58:37 +02:00
3d00eed0f0 Change SetTrimbits() and SaveAllTrimbits() to rely on top/bottom signal instead of TopAddressIsValid() for further cleanup. 2020-04-14 16:13:26 +02:00
a7f5300455 Merge pull request #92 from slsdetectorgroup/setrxhostname
Setrxhostname
2020-04-09 11:52:46 +02:00
2f33a1a479 updated binaries 2020-04-09 09:35:46 +02:00
39fa5e0185 client recieve rx parameters as a struct 2020-04-09 09:34:20 +02:00
ba4985ed4d Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-04-09 09:32:09 +02:00
f811c065d1 corrected a delete [] in multiThreadedAnalogDetector 2020-04-09 09:31:43 +02:00
3a1d87728c updated client api 2020-04-09 08:38:37 +02:00
0652ff6b5a updated binaries 2020-04-09 08:37:27 +02:00
373e177274 WIP 2020-04-09 08:35:30 +02:00
6dd6685e7d minor 2020-04-09 08:24:16 +02:00
38c31fdada WIP 2020-04-08 20:27:10 +02:00
b3fe0e79bc WIP 2020-04-08 16:43:28 +02:00
215e4a56fd Merge branch 'developer' into setrxhostname 2020-04-08 12:00:21 +02:00
71a68c2022 eiger transmitting fix in 10g mode (stop servers informed about 10g mode) 2020-04-08 11:58:59 +02:00
55f8497eac WIP 2020-04-08 11:05:06 +02:00
738f341265 eiger server compiled from previous commit 2020-04-08 08:41:39 +02:00
c4ae876ca7 Add Eiger server Init() modification also to initStopServer() 2020-04-07 17:45:53 +02:00
07cd71f0c7 removed update shared memory from detector, check if eiger firmware >=26: have same top and bottom addresses 2020-04-07 17:19:47 +02:00
9f3ad4e2f4 merge from 4.2.0 2020-04-07 15:14:27 +02:00
ab9fed45fb Merge pull request #91 from slsdetectorgroup/testing
Testing
2020-04-07 12:15:37 +02:00
a86ae0cb47 WIP 2020-04-07 12:14:22 +02:00
bdf0f9e2b9 fixed start stop tests 2020-04-07 10:39:50 +02:00
fad10273ed fix for server crashing when sending udp packets if no udp server present to listen to it (receiver): cannot use connect and write 2020-04-07 09:57:22 +02:00
83283b672a WIP 2020-04-06 19:38:35 +02:00
456b96446f WIP 2020-04-06 17:59:06 +02:00
80e55cd4da WIP 2020-04-06 17:28:05 +02:00
47b0e46f15 Merge branch 'developer' into testing 2020-04-06 10:55:41 +02:00
fdb6e3f3d4 Removeshm (#90)
* eiger: moved rate correction outside, fixed threshold energy bug in client (binaries not  updated yet)

* removed dr and deadtiem from shm

* help for rx_status and status to point them to rx_Start, rx_stop, start and stop

* moved progress to receiver

* removed currentsettings from eiger shm

* updated server binaries, and client api

* moench and ctb virtual servers compile fix

* gui: moved acquire to a concurrent qt thread so it doesnt block updateplot
2020-04-06 10:44:44 +02:00
eeed102bf3 somewhere between fork and pipes, crashes at sendingudppacket at print 2020-04-03 20:18:16 +02:00
7c7f7e8c70 testing WIP 2020-04-03 16:20:05 +02:00
262b4b0b16 more tests 2020-03-31 18:19:32 +02:00
83010de9f4 updated all binaries, previous ones may not work 2020-03-31 16:58:35 +02:00
f2dd146e56 updates on servers (mainly virtual): indices, dbit clock not allowed for moench anymore 2020-03-31 16:54:35 +02:00
03af145ee8 test delay fix 2020-03-31 13:38:11 +02:00
043e62f9fd delay test 2020-03-31 13:35:04 +02:00
6289163ac8 virtual servers checked 2020-03-31 10:40:42 +02:00
3ba9e5ec22 eiger, jungfrau, ctb, moench, gotthard virtual servers checked 2020-03-30 18:24:42 +02:00
719157f5c3 python funcs 2020-03-30 14:59:08 +02:00
d58eb1dc6e Gappixels (#89)
* WIP

* WIP virtual delays, imagetest for saturation

* WIP, vertical and horizontal

* WIP

* gap pixels work, fixed 32 bit data out (10gbe=0) for virtual servers

* quad works (also in virtual), handling gappixels and quad

* jungfrau gapppixels work

* jungfrau: done

* complete image or missing packets given in json header and gui

* eiger virtual 4 bit mode bug fix

* working version of zmq add json header, except printout

* printout bug

* fix for json para

* to map WIP

* map done

* map print , mapwith result left

* json result works, testing added

* updated server binaries

* compiling on rhels7, variable size char array iniitalization

* zmqsocket parsing didnt need Document

* const to map, json para is strings not map

* json add header: mapping cleaner without insert make_pair
2020-03-30 14:54:35 +02:00
6a6af528ef testing WIP 2020-03-30 13:25:39 +02:00
112d120a89 testing WIP 2020-03-27 18:54:46 +01:00
8dfb55d476 testing 2020-03-27 17:00:14 +01:00
d488f4bea8 updated all receiver testing 2020-03-27 16:59:16 +01:00
58ab3c4123 gold linker 2020-03-27 08:22:24 +01:00
02d7381788 compile manuals 2020-03-26 18:42:01 +01:00
fb051355b8 moved string conversion to .cpp 2020-03-26 15:06:23 +01:00
4d8a63eee1 ToString of Result<map> 2020-03-26 14:10:06 +01:00
d0c3e006fb printing of std::map 2020-03-26 12:39:56 +01:00
f22f23849d minor 2020-03-26 11:56:38 +01:00
94bddb9908 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-24 12:03:59 +01:00
ed20e17c3a fixed bug in pedestal cloning and changed cluster finder file format- tested only for 3x3 2020-03-24 12:03:29 +01:00
8fc1578a5e added support for MSG_PEEK 2020-03-24 09:20:38 +01:00
9753d075f0 added headers to install 2020-03-24 09:06:36 +01:00
865b4e50ad Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 17:12:44 +01:00
597c359ef8 added overload signatures in python binding 2020-03-19 17:12:35 +01:00
a108a4df4c fixed also the moench oofline cluster finder 2020-03-19 15:42:24 +01:00
0a6b04ee76 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 15:25:33 +01:00
78dd96357d fixed slsDeetctorcalibration - including interpolation for rectangular pixels 2020-03-19 15:25:00 +01:00
9230182e35 rxr: dont update index if fwrite 0 2020-03-19 15:21:21 +01:00
8f7adb130f conflict fix 2020-03-19 14:07:33 +01:00
16d5321885 rx_hostname can be added with port and also concatenated 2020-03-19 14:06:16 +01:00
9a6f521f6a other replacements for string 2020-03-19 12:39:42 +01:00
dee0aea378 replace stoi with StringTo<int> 2020-03-19 12:33:13 +01:00
0e3cd00579 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 11:56:49 +01:00
6091271f37 somenthing on calibration 2020-03-19 11:41:55 +01:00
272a8bfaf1 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 11:36:44 +01:00
75692c3539 zmq server address copy warning fix 2020-03-19 11:36:32 +01:00
46e9b450c0 assume dec unless 0x 2020-03-19 11:09:20 +01:00
40c5ccfe37 Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer 2020-03-19 10:30:15 +01:00
bf1b1a2d9e string conversion for uint 2020-03-19 10:30:05 +01:00
b608ec6fbd zmqsocket: fname to string to remove warning in copying maxstr in maxstr in json header 2020-03-19 10:24:08 +01:00
4813b5567a Minimal shared memory for receiver 2020-03-19 07:01:32 +01:00
8ab742c2b7 docs 2020-03-18 17:53:57 +01:00
282 changed files with 42551 additions and 36984 deletions

View File

@ -3,4 +3,5 @@ IndentWidth: 4
UseTab: Never UseTab: Never
ColumnLimit: 80 ColumnLimit: 80
AlignConsecutiveAssignments: false AlignConsecutiveAssignments: false
AlignConsecutiveMacros: true

View File

@ -46,7 +46,32 @@ option(SLS_BUILD_DOCS "docs" OFF)
option(SLS_BUILD_EXAMPLES "examples" OFF) option(SLS_BUILD_EXAMPLES "examples" OFF)
option(SLS_TUNE_LOCAL "tune to local machine" OFF) option(SLS_TUNE_LOCAL "tune to local machine" OFF)
# set(ClangFormat_BIN_NAME clang-format)
set(ClangFormat_EXCLUDE_PATTERNS "build/"
"libs/"
"slsDetectorCalibration/"
"ctbGui/"
"manual/"
"python/"
"sample/"
${CMAKE_BINARY_DIR})
find_package(ClangFormat)
#Enable LTO if available
check_ipo_supported(RESULT SLS_LTO_AVAILABLE)
# Use ld.gold if it is available and isn't disabled explicitly
option(SLS_USE_LD_GOLD "Use GNU gold linker" ON)
if (SLS_USE_LD_GOLD)
execute_process(COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
if ("${LD_VERSION}" MATCHES "GNU gold")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=gold")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=gold")
else ()
message(WARNING "GNU gold linker isn't available, using the default system linker.")
endif ()
endif ()
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)

View File

@ -0,0 +1,39 @@
# Find Clang format
if(NOT ClangFormat_BIN_NAME)
set(ClangFormat_BIN_NAME clang-format)
endif()
# if custom path check there first
if(ClangFormat_ROOT_DIR)
find_program(ClangFormat_BIN
NAMES
${ClangFormat_BIN_NAME}
PATHS
"${ClangFormat_ROOT_DIR}"
NO_DEFAULT_PATH)
endif()
find_program(ClangFormat_BIN NAMES ${ClangFormat_BIN_NAME})
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
ClangFormat
DEFAULT_MSG
ClangFormat_BIN)
mark_as_advanced(
ClangFormat_BIN)
if(ClangFormat_FOUND)
exec_program(${ClangFormat_BIN} ${CMAKE_CURRENT_SOURCE_DIR} ARGS --version OUTPUT_VARIABLE CLANG_VERSION_TEXT)
string(REGEX MATCH "([0-9]+)\\.[0-9]+\\.[0-9]+" CLANG_VERSION ${CLANG_VERSION_TEXT})
if((${CLANG_VERSION} GREATER "9") OR (${CLANG_VERSION} EQUAL "9"))
# A CMake script to find all source files and setup clang-format targets for them
message(STATUS "found clang-format \"${CLANG_VERSION}\" adding formatting targets")
include(clang-format)
else()
message(STATUS "clang-format version \"${CLANG_VERSION}\" found but need at least 9. Not setting up format targets")
endif()
else()
message(STATUS "clang-format not found. Not setting up format targets")
endif()

47
cmake/clang-format.cmake Normal file
View File

@ -0,0 +1,47 @@
# A CMake script to find all source files and setup clang-format targets for them
# Find all source files
set(ClangFormat_CXX_FILE_EXTENSIONS ${ClangFormat_CXX_FILE_EXTENSIONS} *.cpp *.h *.cxx *.hxx *.hpp *.cc *.ipp *.c)
file(GLOB_RECURSE ALL_SOURCE_FILES ${ClangFormat_CXX_FILE_EXTENSIONS})
# Don't include some common build folders
set(ClangFormat_EXCLUDE_PATTERNS ${ClangFormat_EXCLUDE_PATTERNS} "/CMakeFiles/" "cmake")
# get all project files file
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
foreach (EXCLUDE_PATTERN ${ClangFormat_EXCLUDE_PATTERNS})
string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND)
if (NOT ${EXCLUDE_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
endforeach ()
#target for formatting soruce files
add_custom_target(format
COMMENT "Running clang-format to change files"
COMMAND ${ClangFormat_BIN}
-style=file
-i
${ALL_SOURCE_FILES}
)
#target to check format on source files
add_custom_target(format-check
COMMENT "Checking clang-format changes"
# Use ! to negate the result for correct output
COMMAND !
${ClangFormat_BIN}
-style=file
-output-replacements-xml
${ALL_SOURCE_FILES}
| grep -q "replacement offset"
)
# debug to check which file will be formatted
add_custom_target(
listformatfiles
COMMAND
echo ${ALL_SOURCE_FILES}
)

19
cmk.sh
View File

@ -11,6 +11,7 @@ PYTHON=0
TESTS=0 TESTS=0
SIMULATOR=0 SIMULATOR=0
CTBGUI=0 CTBGUI=0
MANUALS=0
CLEAN=0 CLEAN=0
@ -19,7 +20,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] [u] [i] [m] [-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
@ -34,6 +35,7 @@ Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [u] [i] [-h] [-d <HDF5 directory>]
-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
-m: Manuals
Rebuild when you switch to a new build and compile in parallel: Rebuild when you switch to a new build and compile in parallel:
./cmk.sh -bj5 ./cmk.sh -bj5
@ -69,7 +71,7 @@ For rebuilding only certain sections
" ; exit 1; } " ; exit 1; }
while getopts ":bpchd:j:trgeisu" opt ; do while getopts ":bpchd:j:trgeisum" opt ; do
case $opt in case $opt in
b) b)
echo "Building of CMake files Required" echo "Building of CMake files Required"
@ -124,6 +126,10 @@ while getopts ":bpchd:j:trgeisu" opt ; do
echo "Compiling Options: Simulator" echo "Compiling Options: Simulator"
SIMULATOR=1 SIMULATOR=1
;; ;;
m)
echo "Compiling Manuals"
MANUALS=1
;;
u) u)
echo "Compiling Options: Chip Test Gui" echo "Compiling Options: Chip Test Gui"
CTBGUI=1 CTBGUI=1
@ -198,6 +204,12 @@ if [ $SIMULATOR -eq 1 ]; then
echo "Simulator Option enabled" echo "Simulator Option enabled"
fi fi
#Manuals
if [ $MANUALS -eq 1 ]; then
CMAKE_POST+=" -DSLS_BUILD_DOCS=ON "
echo "Manuals Option enabled"
fi
#Chip Test Gui #Chip Test Gui
if [ $CTBGUI -eq 1 ]; then if [ $CTBGUI -eq 1 ]; then
CMAKE_POST+=" -DSLS_USE_CTBGUI=ON " CMAKE_POST+=" -DSLS_USE_CTBGUI=ON "
@ -251,6 +263,9 @@ else
make make
fi fi
if [ $MANUALS -eq 1 ]; then
make docs
fi

View File

@ -1646,10 +1646,13 @@ void ctbAcquisition::update() {
} }
try { if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values"); dBitOffset = 0;
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update") } else {
try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::update")
}
try { try {
tenG = myDet->getTenGiga().tsquash("Different values"); tenG = myDet->getTenGiga().tsquash("Different values");
} CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update") } CATCH_DISPLAY ("Could not get ten giga enable", "ctbAcquisition::update")
@ -1735,9 +1738,13 @@ void ctbAcquisition::toggleAcquisition() {
setDigitalSamples(retval); setDigitalSamples(retval);
} CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition") } CATCH_DISPLAY ("Could not get number of digital samples", "ctbAcquisition::toggleAcquisition")
if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
dBitOffset = 0;
} else {
try { try {
dBitOffset = myDet->getRxDbitOffset().tsquash("Different values"); dBitOffset = myDet->getRxDbitOffset().tsquash("Different values");
} CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition") } CATCH_DISPLAY ("Could not get receiver dbit offset", "ctbAcquisition::toggleAcquisition")
}
try { try {
roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values")); roMode = static_cast<int>(myDet->getReadoutMode().tsquash("Different values"));
@ -1974,14 +1981,18 @@ void ctbAcquisition::setDbitEnable(Int_t reg){
void ctbAcquisition::updateChans() { void ctbAcquisition::updateChans() {
// dbit list // dbit list
try { if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
auto retval = myDet->getRxDbitList().tsquash("Different values");
dbitlist.clear(); dbitlist.clear();
if (!retval.empty()) { } else {
for (const auto &value : retval) try {
dbitlist.push_back(value); auto retval = myDet->getRxDbitList().tsquash("Different values");
} dbitlist.clear();
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans") if (!retval.empty()) {
for (const auto &value : retval)
dbitlist.push_back(value);
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbAcquisition::updateChans")
}
// adc mask // adc mask
try { try {

View File

@ -374,33 +374,43 @@ void ctbSignals::update() {
} CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update") } CATCH_DISPLAY ("Could not get patternIOcontrol.", "ctbSignals::update")
try { if (myDet->getDetectorType().squash() == slsDetectorDefs::MOENCH) {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all // 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); }
} eDbitOffset->SetNumber(0);
} }
else {
// disable all // ctb
for (int is=0; is<64; is++) { else {
signals[is]->setDbitList(0); try {
auto dbitlist = myDet->getRxDbitList().tsquash("Different values");
// enable all
if (dbitlist.empty()) {
for (int is=0; is<64; is++) {
signals[is]->setDbitList(1);
}
} }
// enable selected else {
for (const auto &value : dbitlist) { // disable all
signals[value]->setDbitList(1); for (int is=0; is<64; is++) {
signals[is]->setDbitList(0);
}
// enable selected
for (const auto &value : dbitlist) {
signals[value]->setDbitList(1);
}
} }
}
} CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update") } CATCH_DISPLAY ("Could not get receiver dbit list.", "ctbSignals::update")
try {
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
try {
auto val = myDet->getRxDbitOffset().tsquash("Different values");
eDbitOffset->SetNumber(val);
} CATCH_DISPLAY ("Could not get receiver dbit offset.", "ctbSignals::update")
}
} }

View File

@ -21,6 +21,7 @@ if [ -f "$infile" ]
then then
gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ; gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
echo compiling echo compiling
echo gcc -DINFILE="\"$infile\"" -DOUTFILE="\"$outfile\"" -DOUTFILEBIN="\"$outfilebin\"" -o $exe generator.c ;
$exe ; $exe ;
echo cleaning echo cleaning
rm $exe rm $exe

View File

@ -1,71 +1,69 @@
find_package(Doxygen) find_package(Doxygen REQUIRED)
find_package(Sphinx) find_package(Sphinx REQUIRED)
if (DOXYGEN_FOUND AND SPHINX_FOUND)
# message(${CMAKE_PROJECT_SORURCE_DIR}/slsDetectorSoftware/src)
# Utility to generate command line documentation
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
slsDetectorShared
)
set_target_properties(gendoc PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
#Doxygen # Utility to generate command line documentation
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) add_executable(gendoc src/gendoc.cpp)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) # This is a bit hacky, but better than exposing stuff?
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) target_include_directories(gendoc PRIVATE ${PROJECT_SOURCE_DIR}/slsDetectorSoftware/src)
target_link_libraries(gendoc PRIVATE
slsDetectorShared
)
set_target_properties(gendoc PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
#Sphinx
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})
set(SPHINX_SOURCE_FILES
src/commandline.rst
src/container_utils.rst
src/consuming.rst
src/dependencies.rst
src/detector.rst
src/index.rst
src/installation.rst
src/pydetector.rst
src/pyenums.rst
src/pyexamples.rst
src/receiver.rst
src/result.rst
src/type_traits.rst
src/ToString.rst
src/examples.rst
)
foreach(filename ${SPHINX_SOURCE_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${filename}
"${SPHINX_BUILD}/${filename}")
endforeach(filename ${SPHINX_SOURCE_FILES})
configure_file( #Doxygen
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in" set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
"${SPHINX_BUILD}/conf.py" set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
@ONLY) configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
#Sphinx
set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR})
set(SPHINX_SOURCE_FILES
src/commandline.rst
src/container_utils.rst
src/consuming.rst
src/dependencies.rst
src/detector.rst
src/index.rst
src/installation.rst
src/pydetector.rst
src/pyenums.rst
src/pyexamples.rst
src/receiver.rst
src/result.rst
src/type_traits.rst
src/ToString.rst
src/examples.rst
)
foreach(filename ${SPHINX_SOURCE_FILES})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${filename}
"${SPHINX_BUILD}/${filename}")
endforeach(filename ${SPHINX_SOURCE_FILES})
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in"
"${SPHINX_BUILD}/conf.py"
@ONLY)
add_custom_target(docs
gendoc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
COMMAND ${SPHINX_EXECUTABLE} -a -b html
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
-c "${SPHINX_BUILD}"
${SPHINX_BUILD}/src
${SPHINX_BUILD}/html
COMMENT "Generating documentation with Sphinx")
add_custom_target(docs
gendoc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
COMMAND ${SPHINX_EXECUTABLE} -a -b html
-Dbreathe_projects.slsDetectorPackage=${CMAKE_CURRENT_BINARY_DIR}/xml
-c "${SPHINX_BUILD}"
${SPHINX_BUILD}/src
${SPHINX_BUILD}/html
COMMENT "Generating documentation with Sphinx")
else (DOXYGEN_FOUND AND SPHINX_FOUND)
message("Doxygen and Sphinx are needed to build documentation")
endif (DOXYGEN_FOUND AND SPHINX_FOUND)

View File

@ -62,6 +62,27 @@ you should be able to configure and build your project in this way.
A minimal example is available at: https://github.com/slsdetectorgroup/minimal-cmake A minimal example is available at: https://github.com/slsdetectorgroup/minimal-cmake
CMake: find_package and conda
----------------------------------
.. note::
conda can also be used for installing dependencies such as zmq, Qt4 etc.
find_package(slsDetectorPackage) also works if you have installed slsDetectorPackage using conda.
The only difference is that you point CMake to $CONDA_PREFIX
.. code-block:: bash
#assuming myenv contains slsdetlib
conda activate myenv
cmake ../path/to/your/source -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make
Depending on your system compiler you might also have to install gxx_linux-64 to compiled.
No tools minimal approach No tools minimal approach
----------------------------- -----------------------------

View File

@ -1,7 +1,7 @@
/** /**
* Utility program to generate input files for the command line * Utility program to generate input files for the command line
* documentation. Uses the string returned from sls_detector_help cmd * documentation. Uses the string returned from sls_detector_help cmd
* *
*/ */
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -9,7 +9,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "CmdProxy.h" #include "CmdProxy.h"
#include "Detector.h" #include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
@ -52,5 +51,4 @@ int main() {
auto help = replace_all(tmp, "\n\t", "\n\t\t"); auto help = replace_all(tmp, "\n\t", "\n\t\t");
fs << '\t' << cmd << usage << help << "\n"; fs << '\t' << cmd << usage << help << "\n";
} }
} }

View File

@ -21,5 +21,49 @@ Build from source using CMake
make -j12 make -j12
make install make install
Install binaries using conda
--------------------------------
.. code-block:: bash
#Add channels for dependencies and our library
conda config --add channels conda-forge
conda config --add channels slsdetectorgroup
conda config --set channel_priority strict
#cerate an environment with our library, then activate
conda create -n myenv slsdetlib=2020.03.18.dev2
codna activate myenv
#ready to use
sls_detector_get exptime
etc ...
Build from source on old distributions
-----------------------------------------
If your linux distribution doesn't come with a C++11 compiler (gcc>4.8) then
it's possible to install a newer gcc using conda and build the slsDetectorPackage
using this compiler
.. code-block:: bash
#Create an environment with the dependencies
conda create -n myenv gxx_linux-64 cmake zmq
conda activate myenv
cmake ../slsDetectorPackage -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
make -j12
Build this documentation
-------------------------------
The documentation for the slsDetectorPackage is build using a combination
of Doxygen, Sphinx and Breathe. The easiest way to install the dependencies
is to use conda
.. code-block:: bash
conda create -n myenv python sphinx sphinx_rtd_theme

View File

@ -430,13 +430,13 @@ patwaittime2 0
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
#0:udp_dstip 10.1.1.102 0:udp_dstip 10.1.1.102
0:udp_dstip 129.129.202.136 #0:udp_dstip 129.129.202.136
############################################# #############################################
### edit with any number in the subnet of your server (first 3 numbers as above) ### edit with any number in the subnet of your server (first 3 numbers as above)
############################################ ############################################
#0:udp_srcip 10.1.1.19 0:udp_srcip 10.1.1.19
0:udp_srcip 129.129.202.13 #0:udp_srcip 129.129.202.13
0:udp_dstport 33410 0:udp_dstport 33410
############################################# #############################################
@ -457,7 +457,7 @@ patwaittime2 0
############################################ ############################################
rx_hostname mpc2011 rx_hostname mpc2011
tengiga 0 tengiga 1
rx_datastream 1 rx_datastream 1
rx_readfreq 1 rx_readfreq 1

View File

@ -1,11 +1,15 @@
#initialchecks 0 initialchecks 0
############################################# #############################################
### edit with hostname or IP address of your detector ### edit with hostname or IP address of your detector
############################################ ############################################
hostname bchip181+ hostname bchip181+
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
rx_tcpport 1954
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
@ -14,24 +18,20 @@ udp_dstip 10.1.1.102
### edit with any number in the subnet of your server (first 3 numbers as above) ### edit with any number in the subnet of your server (first 3 numbers as above)
############################################ ############################################
udp_srcip 10.1.1.19 udp_srcip 10.1.1.19
udp_dstport 33410 udp_dstport 32411
############################################# #############################################
### edit with 10 Gbs IP of your server ### edit with 10 Gbs IP of your server
############################################ ############################################
#rx_zmqip 10.1.1.102 rx_zmqip 10.1.1.102
#rx_zmqport 30001 rx_zmqport 50003
############################################# #############################################
### edit with 1 Gbs IP of PC where you will run the GUI ### edit with 1 Gbs IP of PC where you will run the GUI
############################################ ############################################
#zmqip 129.129.202.136 zmqip 129.129.202.136
#zmqport 40001 zmqport 50001
#############################################
### edit with hostname or 1Gbs IP address of your server
############################################
rx_hostname mpc2011
tengiga 1 tengiga 1
@ -39,8 +39,8 @@ rx_datastream 1
frames 1 frames 100000
period 0.001 period 0.0006
############################################# #############################################
### edit with directory you want to write to ### edit with directory you want to write to
############################################ ############################################
@ -48,8 +48,8 @@ fpath /mnt/moench_data/scratch/
fwrite 0 fwrite 0
rx_datastream 1 rx_datastream 1
rx_jsonpara frameMode newpedestal rx_jsonpara frameMode frame
rx_jsonpara detectorMode analog rx_jsonpara detectorMode counting
rx_discardpolicy discardpartial rx_discardpolicy discardpartial
@ -58,4 +58,6 @@ adcpipeline 15
powerchip 1 powerchip 1
vhighvoltage 90 vhighvoltage 90
adcreg 14 40 #adcreg 0x14 0x40

View File

@ -1,5 +1,5 @@
#include "catch.hpp"
#include "DetectorImpl.h" #include "DetectorImpl.h"
#include "catch.hpp"
#include "string_utils.h" #include "string_utils.h"
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>

52
integrationTests/test-integrationDectector.cpp Executable file → Normal file
View File

@ -2,9 +2,9 @@
#include "catch.hpp" #include "catch.hpp"
#include "ClientSocket.h" #include "ClientSocket.h"
#include "logger.h"
#include "DetectorImpl.h" #include "DetectorImpl.h"
#include "Module.h" #include "Module.h"
#include "logger.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "Timer.h" #include "Timer.h"
@ -79,7 +79,6 @@ TEST_CASE("Set control port then create a new object with this control port",
d.freeSharedMemory(); d.freeSharedMemory();
} }
TEST_CASE("single EIGER detector no receiver basic set and get", TEST_CASE("single EIGER detector no receiver basic set and get",
"[.integration][eiger]") { "[.integration][eiger]") {
// TODO! this test should take command line arguments for config // TODO! this test should take command line arguments for config
@ -130,8 +129,6 @@ TEST_CASE("single EIGER detector no receiver basic set and get",
d.freeSharedMemory(); d.freeSharedMemory();
} }
TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") { TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
Module d(test::type); Module d(test::type);
d.setHostname(test::hostname); d.setHostname(test::hostname);
@ -154,13 +151,12 @@ TEST_CASE("Locking mechanism and last ip", "[.integration][.single]") {
d.freeSharedMemory(); d.freeSharedMemory();
} }
TEST_CASE("Set settings", "[.integration][.single]"){ TEST_CASE("Set settings", "[.integration][.single]") {
Module d(test::type); Module d(test::type);
d.setHostname(test::hostname); d.setHostname(test::hostname);
CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD); CHECK(d.setSettings(defs::STANDARD) == defs::STANDARD);
} }
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 triggers */ ACQUISITION_TIME,
@ -204,8 +200,7 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
if (test::type != dt::EIGER) { if (test::type != dt::EIGER) {
auto delay = 10000; auto delay = 10000;
d.setDelayAfterTrigger(delay); d.setDelayAfterTrigger(delay);
CHECK(d.getDelayAfterTrigger() == CHECK(d.getDelayAfterTrigger() == delay);
delay);
} }
auto triggers = 2; auto triggers = 2;
@ -218,10 +213,9 @@ TEST_CASE("Timer functions", "[.integration][cli]") {
CHECK(d.getSubExptime() == subtime); CHECK(d.getSubExptime() == subtime);
} }
// for (int i =0; i!=frames; ++i) // for (int i =0; i!=frames; ++i)
d.startAndReadAll(); d.startAndReadAll();
d.freeSharedMemory(); d.freeSharedMemory();
} }
// TEST_CASE("Aquire", "[.integration][eiger]"){ // TEST_CASE("Aquire", "[.integration][eiger]"){
@ -382,8 +376,8 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") {
} }
} }
TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert",
TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegration][dbit]") { "[.ctbintegration][dbit]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
@ -403,27 +397,27 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
// dbit list // dbit list
std::vector <int> list = m.getReceiverDbitList(); std::vector<int> list = m.getReceiverDbitList();
list.clear(); list.clear();
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
list.push_back(i); list.push_back(i);
m.setReceiverDbitList(list); m.setReceiverDbitList(list);
CHECK(m.getReceiverDbitList().size() == 10); CHECK(m.getReceiverDbitList().size() == 10);
list.push_back(64); list.push_back(64);
CHECK_THROWS_AS(m.setReceiverDbitList(list), sls::RuntimeError); CHECK_THROWS_AS(m.setReceiverDbitList(list), sls::RuntimeError);
CHECK_THROWS_WITH(m.setReceiverDbitList(list), CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be between 0 and 63")); Catch::Matchers::Contains("be between 0 and 63"));
list.clear(); list.clear();
for (int i = 0; i < 65; ++i) for (int i = 0; i < 65; ++i)
list.push_back(i); list.push_back(i);
CHECK(list.size() == 65); CHECK(list.size() == 65);
CHECK_THROWS_WITH(m.setReceiverDbitList(list), CHECK_THROWS_WITH(m.setReceiverDbitList(list),
Catch::Matchers::Contains("be greater than 64")); Catch::Matchers::Contains("be greater than 64"));
list.clear(); list.clear();
m.setReceiverDbitList(list); m.setReceiverDbitList(list);
CHECK(m.getReceiverDbitList().empty()); CHECK(m.getReceiverDbitList().empty());
@ -441,8 +435,8 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
m.setExternalSamplingSource(62); m.setExternalSamplingSource(62);
CHECK(m.getExternalSamplingSource() == 62); CHECK(m.getExternalSamplingSource() == 62);
CHECK_THROWS_WITH(m.setExternalSamplingSource(64), CHECK_THROWS_WITH(m.setExternalSamplingSource(64),
Catch::Matchers::Contains("be 0-63")); Catch::Matchers::Contains("be 0-63"));
CHECK(m.getExternalSamplingSource() == 62); CHECK(m.getExternalSamplingSource() == 62);
m.setExternalSampling(1); m.setExternalSampling(1);
CHECK(m.getExternalSampling() == 1); CHECK(m.getExternalSampling() == 1);
m.setExternalSampling(0); m.setExternalSampling(0);
@ -450,20 +444,23 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
m.setExternalSampling(1); m.setExternalSampling(1);
CHECK(m.getExternalSampling() == 1); CHECK(m.getExternalSampling() == 1);
CHECK(m.readRegister(0x7b) == 0x1003E); CHECK(m.readRegister(0x7b) == 0x1003E);
} }
TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegration][startingfnum]") { TEST_CASE("Eiger or Jungfrau startingfnum",
"[.eigerintegration][.jungfrauintegration][startingfnum]") {
SingleDetectorConfig c; SingleDetectorConfig c;
// pick up multi detector from shm id 0 // pick up multi detector from shm id 0
DetectorImpl m(0); DetectorImpl m(0);
// ensure ctb detector type, hostname and online // ensure ctb detector type, hostname and online
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.setNumberOfFrames(1) == 1);
// starting fnum // starting fnum
uint64_t val = 8; uint64_t val = 8;
@ -498,7 +495,8 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
DetectorImpl m(0); DetectorImpl m(0);
// ensure detector type, hostname // ensure detector type, hostname
REQUIRE((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER)); REQUIRE(
(m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER));
REQUIRE(m.getHostname() == c.hostname); REQUIRE(m.getHostname() == c.hostname);
m.setDynamicRange(16); m.setDynamicRange(16);
@ -507,7 +505,7 @@ TEST_CASE("Eiger readnlines", "[.eigerintegration][readnlines]") {
CHECK(m.getReadNLines() == 256); CHECK(m.getReadNLines() == 256);
m.setReadNLines(1); m.setReadNLines(1);
CHECK(m.getReadNLines() == 1); CHECK(m.getReadNLines() == 1);
m.setDynamicRange(8); m.setDynamicRange(8);
m.setReadNLines(256); m.setReadNLines(256);
CHECK(m.getReadNLines() == 256); CHECK(m.getReadNLines() == 256);

6
integrationTests/test-integrationMulti.cpp Executable file → Normal file
View File

@ -1,5 +1,5 @@
#include "catch.hpp"
#include "DetectorImpl.h" #include "DetectorImpl.h"
#include "catch.hpp"
#include "string_utils.h" #include "string_utils.h"
#include "tests/globals.h" #include "tests/globals.h"
#include <iostream> #include <iostream>
@ -24,8 +24,6 @@ TEST_CASE("Initialize a multi detector", "[.integration][.multi]") {
d.freeSharedMemory(); d.freeSharedMemory();
} }
TEST_CASE("Set and read timers", "[.integration][.multi]") { TEST_CASE("Set and read timers", "[.integration][.multi]") {
DetectorImpl d(0, true, true); DetectorImpl d(0, true, true);
@ -57,7 +55,6 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
// PROGRESS, /**< fraction of measurement elapsed - only get! */ // PROGRESS, /**< fraction of measurement elapsed - only get! */
// MEASUREMENTS_NUMBER, // MEASUREMENTS_NUMBER,
// FRAMES_FROM_START, // FRAMES_FROM_START,
// FRAMES_FROM_START_PG, // FRAMES_FROM_START_PG,
// SAMPLES, // SAMPLES,
@ -78,7 +75,6 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
CHECK(d.setSubFrameExposureDeadTime(-1) == Approx(subframe_deadtime)); CHECK(d.setSubFrameExposureDeadTime(-1) == Approx(subframe_deadtime));
} }
if (test::type == dt::EIGER) { if (test::type == dt::EIGER) {
// 32bit is needed for subframe exposure // 32bit is needed for subframe exposure
d.setDynamicRange(32); d.setDynamicRange(32);

View File

@ -13,12 +13,18 @@ import argparse
from parse import system_include_paths from parse import system_include_paths
default_build_path = "/home/l_frojdh/sls/build/" default_build_path = "/home/l_frojdh/sls/build/"
fpath = "../../slsDetectorSoftware/src/Detector.cpp" fpath = "../../slsDetectorSoftware/src/Detector.cpp"
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("-p", "--build_path", help="Path to the build database", type = str, default=default_build_path) parser.add_argument(
"-p",
"--build_path",
help="Path to the build database",
type=str,
default=default_build_path,
)
cargs = parser.parse_args() cargs = parser.parse_args()
db = cindex.CompilationDatabase.fromDirectory(cargs.build_path) db = cindex.CompilationDatabase.fromDirectory(cargs.build_path)
@ -26,7 +32,7 @@ index = cindex.Index.create()
args = db.getCompileCommands(fpath) args = db.getCompileCommands(fpath)
args = list(iter(args).__next__().arguments)[0:-1] args = list(iter(args).__next__().arguments)[0:-1]
args = args + "-x c++ --std=c++11".split() args = args + "-x c++ --std=c++11".split()
syspath = system_include_paths('clang++') syspath = system_include_paths("clang++")
incargs = ["-I" + inc for inc in syspath] incargs = ["-I" + inc for inc in syspath]
args = args + incargs args = args + incargs
@ -39,6 +45,7 @@ ag = []
lines = [] lines = []
ag2 = []
def get_arguments(node): def get_arguments(node):
args = [a.type.spelling for a in node.get_arguments()] args = [a.type.spelling for a in node.get_arguments()]
@ -46,9 +53,21 @@ def get_arguments(node):
"py::arg() = Positions{}" if item == "sls::Positions" else "py::arg()" "py::arg() = Positions{}" if item == "sls::Positions" else "py::arg()"
for item in args for item in args
] ]
args = ', '.join(args) args = ", ".join(args)
if args: if args:
args = f', {args}' args = f", {args}"
return args
def get_fdec(node):
args = [a.type.spelling for a in node.get_arguments()]
if node.result_type.spelling:
return_type = node.result_type.spelling
else:
return_type = 'void'
args = ", ".join(args)
args = f'({return_type}(Detector::*)({args}))'
return args return args
@ -62,23 +81,36 @@ def visit(node):
): ):
m.append(child) m.append(child)
args = get_arguments(child) args = get_arguments(child)
lines.append(f'.def(\"{child.spelling}\", &Detector::{child.spelling}{args})') fs = get_fdec(child)
lines.append(
f'.def("{child.spelling}",{fs} &Detector::{child.spelling}{args})'
)
for child in node.get_children(): for child in node.get_children():
visit(child) visit(child)
# .def("setRxHostname",
# (void (Detector::*)(const std::string &, Positions)) &
# Detector::setRxHostname,
# py::arg(), py::arg() = Positions{})
# .def("setRxHostname",
# (void (Detector::*)(const std::vector<std::string> &)) &
# Detector::setRxHostname,
# py::arg())
visit(tu.cursor) visit(tu.cursor)
with open('../src/detector_in.cpp') as f: with open("../src/detector_in.cpp") as f:
data = f.read() data = f.read()
s = ''.join(lines) s = "".join(lines)
s += ';' s += ";"
text = data.replace('[[FUNCTIONS]]', s) text = data.replace("[[FUNCTIONS]]", s)
warning = '/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n' warning = "/* WARINING This file is auto generated any edits might be overwritten without warning */\n\n"
with open('../src/detector.cpp', 'w') as f: with open("../src/detector.cpp", "w") as f:
f.write(warning) f.write(warning)
f.write(text) f.write(text)
# run clang format on the output # run clang format on the output
subprocess.run(['clang-format', '../src/detector.cpp', '-i']) subprocess.run(["clang-format", "../src/detector.cpp", "-i"])

0
python/scripts/list_tested_cmd.py Normal file → Executable file
View File

View File

@ -1,5 +1,6 @@
from _slsdet import CppDetectorApi from _slsdet import CppDetectorApi
from _slsdet import slsDetectorDefs from _slsdet import slsDetectorDefs
from _slsdet import IpAddr, MacAddr
runStatus = slsDetectorDefs.runStatus runStatus = slsDetectorDefs.runStatus
speedLevel = slsDetectorDefs.speedLevel speedLevel = slsDetectorDefs.speedLevel
@ -12,12 +13,13 @@ import datetime as dt
from functools import wraps from functools import wraps
from collections import namedtuple from collections import namedtuple
import socket
def freeze(cls): def freeze(cls):
cls._frozen = False cls._frozen = False
def frozensetattr(self, key, value): def frozensetattr(self, key, value):
if self._frozen and not hasattr(self, key): if self._frozen and not key in dir(self):
raise AttributeError( raise AttributeError(
"Class {} is frozen. Cannot set {} = {}".format( "Class {} is frozen. Cannot set {} = {}".format(
cls.__name__, key, value cls.__name__, key, value
@ -58,7 +60,6 @@ class Detector(CppDetectorApi):
self._adc_register = Adc_register(self) self._adc_register = Adc_register(self)
# CONFIGURATION # CONFIGURATION
def __len__(self): def __len__(self):
return self.size() return self.size()
@ -71,9 +72,6 @@ class Detector(CppDetectorApi):
def free(self): def free(self):
self.freeSharedMemory() self.freeSharedMemory()
@property @property
def config(self): def config(self):
return NotImplementedError("config is set only") return NotImplementedError("config is set only")
@ -92,6 +90,7 @@ class Detector(CppDetectorApi):
@property @property
def hostname(self): def hostname(self):
print('getting host!')
return self.getHostname() return self.getHostname()
@hostname.setter @hostname.setter
@ -161,6 +160,13 @@ class Detector(CppDetectorApi):
def frames(self, n_frames): def frames(self, n_frames):
self.setNumberOfFrames(n_frames) self.setNumberOfFrames(n_frames)
@property
def triggers(self):
return element_if_equal(self.getNumberOfTriggers())
@triggers.setter
def triggers(self, n_triggers):
self.setNumberOfTriggers(n_triggers)
@property @property
def exptime(self): def exptime(self):
@ -422,7 +428,9 @@ class Detector(CppDetectorApi):
@udp_dstip.setter @udp_dstip.setter
def udp_dstip(self, ip): def udp_dstip(self, ip):
self.getDestinationUDPIP(ip) if ip == 'auto':
ip = socket.gethostbyname(self.rx_hostname)
self.setDestinationUDPIP(IpAddr(ip))
@property @property
def udp_dstip2(self): def udp_dstip2(self):
@ -430,7 +438,9 @@ class Detector(CppDetectorApi):
@udp_dstip2.setter @udp_dstip2.setter
def udp_dstip2(self, ip): def udp_dstip2(self, ip):
self.getDestinationUDPIP2(ip) if ip == 'auto':
ip = socket.gethostbyname(self.rx_hostname)
self.setDestinationUDPIP2(IpAddr(ip))
@property @property
def udp_dstmac(self): def udp_dstmac(self):
@ -438,7 +448,7 @@ class Detector(CppDetectorApi):
@udp_dstmac.setter @udp_dstmac.setter
def udp_dstmac(self, mac): def udp_dstmac(self, mac):
self.getDestinationUDPMAC2(mac) self.setDestinationUDPMAC(MacAddr(mac))
@property @property
def udp_dstmac2(self): def udp_dstmac2(self):
@ -446,7 +456,7 @@ class Detector(CppDetectorApi):
@udp_dstmac2.setter @udp_dstmac2.setter
def udp_dstmac2(self, mac): def udp_dstmac2(self, mac):
self.getDestinationUDPMAC2(mac) self.setDestinationUDPMAC2(MacAddr(mac))
@property @property
@ -455,7 +465,7 @@ class Detector(CppDetectorApi):
@udp_srcip.setter @udp_srcip.setter
def udp_srcip(self, ip): def udp_srcip(self, ip):
self.setSourceUDPIP(ip) self.setSourceUDPIP(IpAddr(ip))
@property @property
def udp_srcip2(self): def udp_srcip2(self):
@ -487,7 +497,7 @@ class Detector(CppDetectorApi):
@src_udpmac.setter @src_udpmac.setter
def src_udpmac(self, mac): def src_udpmac(self, mac):
self.setSourceUDPMAC(mac) self.setSourceUDPMAC(MacAddr(mac))
@property @property
def src_udpip2(self): def src_udpip2(self):
@ -495,7 +505,7 @@ class Detector(CppDetectorApi):
@src_udpip2.setter @src_udpip2.setter
def src_udpip2(self, ip): def src_udpip2(self, ip):
self.setSourceUDPIP(ip) self.setSourceUDPIP(IpAddr(ip))
@property @property
def src_udpip(self): def src_udpip(self):
@ -503,7 +513,7 @@ class Detector(CppDetectorApi):
@src_udpip.setter @src_udpip.setter
def src_udpip(self, ip): def src_udpip(self, ip):
self.setSourceUDPIP(ip) self.setSourceUDPIP(IpAddr(ip))
@property @property
@ -512,7 +522,7 @@ class Detector(CppDetectorApi):
@src_udpmac2.setter @src_udpmac2.setter
def src_udpmac2(self, mac): def src_udpmac2(self, mac):
self.setSourceUDPMAC2(mac) self.setSourceUDPMAC2(MacAddr(mac))
@property @property
def vhighvoltage(self): def vhighvoltage(self):

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,8 @@ namespace py = pybind11;
void init_det(py::module &m) { void init_det(py::module &m) {
using sls::Detector; using sls::Detector;
using sls::Positions; using sls::Positions;
using sls::Result;
using sls::defs;
py::class_<Detector> CppDetectorApi(m, "CppDetectorApi"); py::class_<Detector> CppDetectorApi(m, "CppDetectorApi");
CppDetectorApi CppDetectorApi

View File

@ -184,6 +184,11 @@ void init_enums(py::module &m) {
.value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF) .value("VB_PIXBUF", slsDetectorDefs::dacIndex::VB_PIXBUF)
.value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM) .value("VIN_COM", slsDetectorDefs::dacIndex::VIN_COM)
.value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT) .value("VDD_PROT", slsDetectorDefs::dacIndex::VDD_PROT)
.value("VBP_COLBUF", slsDetectorDefs::dacIndex::VBP_COLBUF)
.value("VB_SDA", slsDetectorDefs::dacIndex::VB_SDA)
.value("VCASC_SFP", slsDetectorDefs::dacIndex::VCASC_SFP)
.value("VIPRE_CDS", slsDetectorDefs::dacIndex::VIPRE_CDS)
.value("IBIAS_SFP", slsDetectorDefs::dacIndex::IBIAS_SFP)
.value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A) .value("V_POWER_A", slsDetectorDefs::dacIndex::V_POWER_A)
.value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B) .value("V_POWER_B", slsDetectorDefs::dacIndex::V_POWER_B)
.value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C) .value("V_POWER_C", slsDetectorDefs::dacIndex::V_POWER_C)
@ -224,6 +229,18 @@ void init_enums(py::module &m) {
.value("FORCESWITCHG2", .value("FORCESWITCHG2",
slsDetectorDefs::detectorSettings::FORCESWITCHG2) slsDetectorDefs::detectorSettings::FORCESWITCHG2)
.value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN) .value("VERYLOWGAIN", slsDetectorDefs::detectorSettings::VERYLOWGAIN)
.value("G1_HIGHGAIN", slsDetectorDefs::detectorSettings::G1_HIGHGAIN)
.value("G1_LOWGAIN", slsDetectorDefs::detectorSettings::G1_LOWGAIN)
.value("G2_HIGHCAP_HIGHGAIN",
slsDetectorDefs::detectorSettings::G2_HIGHCAP_HIGHGAIN)
.value("G2_HIGHCAP_LOWGAIN",
slsDetectorDefs::detectorSettings::G2_HIGHCAP_LOWGAIN)
.value("G2_LOWCAP_HIGHGAIN",
slsDetectorDefs::detectorSettings::G2_LOWCAP_HIGHGAIN)
.value("G2_LOWCAP_LOWGAIN",
slsDetectorDefs::detectorSettings::G2_LOWCAP_LOWGAIN)
.value("G4_HIGHGAIN", slsDetectorDefs::detectorSettings::G4_HIGHGAIN)
.value("G4_LOWGAIN", slsDetectorDefs::detectorSettings::G4_LOWGAIN)
.value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED) .value("UNDEFINED", slsDetectorDefs::detectorSettings::UNDEFINED)
.value("UNINITIALIZED", .value("UNINITIALIZED",
slsDetectorDefs::detectorSettings::UNINITIALIZED) slsDetectorDefs::detectorSettings::UNINITIALIZED)

View File

@ -15,10 +15,11 @@ using sls::IpAddr;
using sls::MacAddr; using sls::MacAddr;
void init_network(py::module &m) { void init_network(py::module &m) {
py::class_ <IpAddr> IpAddr(m, "IpAddr"); py::class_ <IpAddr>(m, "IpAddr")
IpAddr.def(py::init()) .def(py::init())
.def(py::init<const std::string&>()) .def(py::init<const std::string&>())
.def(py::init<uint32_t>()) .def(py::init<uint32_t>())
.def(py::init<const IpAddr&>())
.def("hex", &IpAddr::hex) .def("hex", &IpAddr::hex)
.def("uint32", &IpAddr::uint32) .def("uint32", &IpAddr::uint32)
.def(py::self == py::self) .def(py::self == py::self)
@ -26,10 +27,11 @@ void init_network(py::module &m) {
.def("str", &IpAddr::str); .def("str", &IpAddr::str);
py::class_ <MacAddr> MacAddr(m, "MacAddr"); py::class_ <MacAddr>(m, "MacAddr")
MacAddr.def(py::init()) .def(py::init())
.def(py::init<const std::string&>()) .def(py::init<const std::string&>())
.def(py::init<uint64_t>()) .def(py::init<uint64_t>())
.def(py::init<const MacAddr&>())
.def("hex", &MacAddr::hex) .def("hex", &MacAddr::hex)
.def(py::self == py::self) .def(py::self == py::self)
.def("uint64", &MacAddr::uint64) .def("uint64", &MacAddr::uint64)

View File

@ -14,27 +14,27 @@ class MovingStat
/** constructor /** constructor
\param nn number of samples parameter to be used \param nn number of samples parameter to be used
*/ */
MovingStat(int nn=1000) : n(nn), m_n(0) {} MovingStat(int nn) : n(nn), m_n(0), m_newM(0),m_newM2(0) {}
// void setPointers(double *me, double *va) {mean=me; var=va;}
/** /**
clears the moving average number of samples parameter, mean and standard deviation clears the moving average number of samples parameter, mean and standard deviation
*/ */
void Clear() void Clear()
{ {
m_n = 0; m_n = 0;
m_newM=0; m_newM=0;
m_newM2=0; m_newM2=0;
} }
/** /**
clears the moving average number of samples parameter, mean and standard deviation clears the moving average number of samples parameter, mean and standard deviation
*/ */
void 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);
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
} }
/** /**
clears the moving average number of samples parameter, mean and standard deviation clears the moving average number of samples parameter, mean and standard deviation
@ -42,12 +42,15 @@ class MovingStat
void SetRMS(double rms) void SetRMS(double rms)
{ {
if (rms<=0) { if (rms<=0) {
m_newM2=m_newM*m_newM/n; if (m_n>0)
m_newM2=m_newM*m_newM/m_n;
else
m_newM2=0;
//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);
else { } else {
m_newM2=(m_n*rms*rms+m_newM*m_newM/n); m_newM2=(m_n*rms*rms+m_newM*m_newM/n);
m_n=0; m_n=0;
} }
@ -102,13 +105,14 @@ class MovingStat
m_newM = x; m_newM = x;
m_newM2 = x*x; m_newM2 = x*x;
m_n++; m_n++;
} else { }
m_newM = m_newM + x - m_newM/m_n; else {
m_newM2 = m_newM2 + x*x - m_newM2/m_n; m_newM = m_newM + x - m_newM/m_n;
} m_newM2 = m_newM2 + x*x - m_newM2/m_n;
}
} }
/** returns the current number of elements of the moving average /** returns the current number of elements of the moving average
\returns returns the current number of elements of the moving average \returns returns the current number of elements of the moving average
*/ */
@ -122,7 +126,9 @@ class MovingStat
inline double Mean() const inline double Mean() const
{ {
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl; // 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;
} }
/** returns the squared mean, 0 if no elements are inside /** returns the squared mean, 0 if no elements are inside
@ -138,7 +144,7 @@ class MovingStat
*/ */
inline double Variance() const inline double Variance() const
{ {
return ( (m_n > 1) ? (M2()-Mean()*Mean()) : 0.0 ); return (m_n > 0) ? m_newM2/m_n-m_newM/m_n*m_newM/m_n : 0.0;
} }
/** returns the standard deviation, 0 if no elements are inside /** returns the standard deviation, 0 if no elements are inside
@ -146,7 +152,8 @@ class MovingStat
*/ */
inline double StandardDeviation() const inline double StandardDeviation() const
{ {
return ( (Variance() > 0) ? sqrt( Variance() ) : -1 );
return sqrt(Variance());//
} }
private: private:

View File

@ -68,10 +68,15 @@ template <class dataType> class analogDetector {
det->getDetectorSize(nx,ny); det->getDetectorSize(nx,ny);
stat=new pedestalSubtraction*[ny]; stat=new pedestalSubtraction*[ny];
/* pedMean=new double*[ny]; */
/* pedVariance=new double*[ny]; */
for (int i=0; i<ny; i++) { for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx]; stat[i]=new pedestalSubtraction[nx];
for (int ix=0; ix<nx; ix++) { /* pedMean[i]=new double[nx]; */
/* pedVariance[i]=new double[nx]; */
for (ix=0; ix<nx; ++ix) {
stat[i][ix].SetNPedestals(nped); stat[i][ix].SetNPedestals(nped);
/* stat[i][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix])); */
} }
} }
image=new int[nx*ny]; image=new int[nx*ny];
@ -95,7 +100,16 @@ template <class dataType> class analogDetector {
/** /**
destructor. Deletes the pdestalSubtraction array and the image destructor. Deletes the pdestalSubtraction array and the image
*/ */
virtual ~analogDetector() {for (int i=0; i<ny; i++) delete [] stat[i]; delete [] stat; delete [] image; virtual ~analogDetector() {
for (int i=0; i<ny; i++) {
delete [] stat[i];
/* delete [] pedMean[i]; */
/* delete [] pedVariance[i]; */
};
/* delete [] pedMean; */
/* delete [] pedVariance; */
delete [] stat;
delete [] image;
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
delete hs; delete hs;
#ifdef ROOTCLUST #ifdef ROOTCLUST
@ -132,16 +146,23 @@ template <class dataType> class analogDetector {
stat=new pedestalSubtraction*[ny]; stat=new pedestalSubtraction*[ny];
/* pedMean=new double*[ny]; */
/* pedVariance=new double*[ny]; */
for (int i=0; i<ny; i++) { for (int i=0; i<ny; i++) {
stat[i]=new pedestalSubtraction[nx]; stat[i]=new pedestalSubtraction[nx];
/* pedMean[i]=new double[nx]; */
/* pedVariance[i]=new double[nx]; */
} }
int nped=orig->SetNPedestals(); int nped=orig->SetNPedestals();
//cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl; //cout << nped << " " << orig->getPedestal(ix,iy) << orig->getPedestalRMS(ix,iy) << endl;
for (int iy=0; iy<ny; iy++) { for (iy=0; iy<ny; ++iy) {
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
//stat[iy][ix].setPointers(&(pedMean[iy][ix]),&(pedVariance[iy][ix]));
stat[iy][ix].SetNPedestals(nped); stat[iy][ix].SetNPedestals(nped);
setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy)); setPedestal(ix,iy,orig->getPedestal(ix,iy),orig->getPedestalRMS(ix,iy),orig->GetNPedestals(ix,iy));
/* if (ix==50 && iy==50) */
/* cout << "clone ped " << " " << ix << " " << iy << " " << getPedestal(ix,iy) << " " << getPedestalRMS(ix,iy)<< " " << GetNPedestals(ix,iy) << endl; */
} }
} }
image=new int[nx*ny]; image=new int[nx*ny];
@ -199,7 +220,7 @@ template <class dataType> class analogDetector {
\param nns reference to number of subpixels for interpolating detector, will always be 1 in this case \param nns reference to number of subpixels for interpolating detector, will always be 1 in this case
\returns number of pixels of the detector image \returns number of pixels of the detector image
*/ */
virtual int getImageSize(int &nnx, int &nny, int &nns){nnx=nx; nny=ny; nns=1; return nx*ny;}; virtual int getImageSize(int &nnx, int &nny, int &nnsx, int &nnsy){nnx=nx; nny=ny; nnsx=1; nnsy=1; return nx*ny;};
/** /**
Returns data size of the detector image matrix Returns data size of the detector image matrix
\param nnx reference to pixel size in x \param nnx reference to pixel size in x
@ -231,8 +252,8 @@ template <class dataType> class analogDetector {
if (gm) { if (gm) {
if (gmap) delete [] gmap; if (gmap) delete [] gmap;
gmap=new double[nnx*nny]; gmap=new double[nnx*nny];
for (int iy=0; iy<nny; iy++) { for (iy=0; iy<nny; ++iy) {
for (int ix=0; ix<nnx; ix++) { for (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] << " " ; // cout << gmap[iy*nnx+ix] << " " ;
} }
@ -251,8 +272,8 @@ template <class dataType> class analogDetector {
void *ret; void *ret;
if (gmap) { if (gmap) {
gm=new float[nx*ny]; gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) { for (iy=0; iy<ny; ++iy) {
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
gm[iy*nx+ix]=gmap[iy*nx+ix]; gm[iy*nx+ix]=gmap[iy*nx+ix];
} }
} }
@ -267,8 +288,8 @@ template <class dataType> class analogDetector {
virtual void newDataSet(){ virtual void newDataSet(){
iframe=-1; iframe=-1;
for (int iy=0; iy<ny; iy++) for (iy=0; iy<ny; ++iy)
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
stat[iy][ix].Clear(); stat[iy][ix].Clear();
image[iy*nx+ix]=0; image[iy*nx+ix]=0;
} }
@ -285,15 +306,17 @@ template <class dataType> class analogDetector {
}; };
/** resets the commonModeSubtraction and increases the frame index */ /** resets the commonModeSubtraction and increases the frame index */
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();}; virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame(); det->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++; iframe++;
if (cmSub) cmSub->newFrame(); if (cmSub) cmSub->newFrame();
det->newFrame();
// det->getData(data);
calcGhost(data); calcGhost(data);
// cout << getId() << " Calc ghost " << getGhost(15,15) << endl; // cout << getId() << " Calc ghost " << getGhost(15,15) << endl;
}; };
/** sets the commonModeSubtraction algorithm to be used /** sets the commonModeSubtraction algorithm to be used
@ -359,8 +382,8 @@ template <class dataType> class analogDetector {
// cout << "+"<< getId() << endl; // cout << "+"<< getId() << endl;
if (cmSub) { if (cmSub) {
//cout << "*" << endl; //cout << "*" << endl;
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
// if (getNumpedestals(ix,iy)>0) // if (getNumpedestals(ix,iy)>0)
// if (det->isGood(ix,iy)) { // if (det->isGood(ix,iy)) {
addToCommonMode(data, ix, iy); addToCommonMode(data, ix, iy);
@ -403,8 +426,10 @@ template <class dataType> class analogDetector {
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);
//return pedMean[iy][ix]+getCommonMode(ix,iy);
} else return stat[iy][ix].getPedestal(); }
//return pedMean[iy][ix];
return stat[iy][ix].getPedestal();
} else return -1; } else return -1;
}; };
@ -422,8 +447,8 @@ template <class dataType> class analogDetector {
g=gmap[iy*nx+ix]; g=gmap[iy*nx+ix];
if (g==0) g=-1.; if (g==0) g=-1.;
} }
// return sqrt(pedVariance[iy][ix])/g;
return stat[iy][ix].getPedestalRMS();//divide by gain? return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
} }
return -1; return -1;
}; };
@ -441,10 +466,11 @@ template <class dataType> class analogDetector {
\returns pedestal value \returns pedestal value
*/ */
virtual double* getPedestal(double *ped){ virtual double* getPedestal(double *ped){
if (ped==NULL) if (ped==NULL) {
ped=new double[nx*ny]; ped=new double[nx*ny];
for (int iy=0; iy<ny; iy++) { }
for (int ix=0; ix<nx; ix++) { for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal(); ped[iy*nx+ix]=stat[iy][ix].getPedestal();
//cout << ped[iy*nx+ix] << " " ; //cout << ped[iy*nx+ix] << " " ;
} }
@ -459,10 +485,11 @@ template <class dataType> class analogDetector {
\returns pedestal rms \returns pedestal rms
*/ */
virtual double* getPedestalRMS(double *ped=NULL){ virtual double* getPedestalRMS(double *ped=NULL){
if (ped==NULL) if (ped==NULL) {
ped=new double[nx*ny]; ped=new double[nx*ny];
for (int iy=0; iy<ny; iy++) { }
for (int ix=0; ix<nx; ix++) { for (iy=0; iy<ny; ++iy) {
for (ix=0; ix<nx; ++ix) {
ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS(); ped[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
} }
} }
@ -501,8 +528,8 @@ template <class dataType> class analogDetector {
*/ */
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){ virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
double rr=0; double rr=0;
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (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; // cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy][ix].getPedestal() << endl;
@ -531,8 +558,8 @@ template <class dataType> class analogDetector {
\param rms pointer to array of pedestal rms \param rms pointer to array of pedestal rms
*/ */
virtual void setPedestalRMS(double *rms){ virtual void setPedestalRMS(double *rms){
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]); stat[iy][ix].setPedestalRMS(rms[iy*nx+ix]);
}; };
}; };
@ -572,8 +599,8 @@ template <class dataType> class analogDetector {
#endif #endif
gm=new float[nx*ny]; gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) { for (iy=0; iy<ny; ++iy) {
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
gm[iy*nx+ix]=image[iy*nx+ix]; gm[iy*nx+ix]=image[iy*nx+ix];
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]); hmap->SetBinContent(ix+1, iy+1,image[iy*nx+ix]);
@ -620,8 +647,8 @@ template <class dataType> class analogDetector {
TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5); TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5);
#endif #endif
for (int iy=0; iy<ny; iy++) { for (iy=0; iy<ny; ++iy) {
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
/* if (cmSub) */ /* if (cmSub) */
/* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */ /* gm[iy*nx+ix]=stat[iy][ix].getPedestal()-cmSub->getCommonMode(); */
/* else */ /* else */
@ -667,15 +694,15 @@ template <class dataType> class analogDetector {
if (gm) { if (gm) {
for (int iy=0; iy<nny; iy++) { for (iy=0; iy<nny; ++iy) {
for (int ix=0; ix<nnx; ix++) { for (ix=0; ix<nnx; ++ix) {
stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1); stat[iy][ix].setPedestal(gm[iy*nx+ix],-1,-1);
} }
} }
delete [] gm; delete [] gm;
return 1; return 1;
} }
return NULL; return 0;
} }
/** /**
@ -692,15 +719,15 @@ template <class dataType> class analogDetector {
if (gm) { if (gm) {
for (int iy=0; iy<nny; iy++) { for (iy=0; iy<nny; ++iy) {
for (int ix=0; ix<nnx; ix++) { for (ix=0; ix<nnx; ++ix) {
image[iy*nx+ix]=gm[iy*nx+ix]; image[iy*nx+ix]=gm[iy*nx+ix];
} }
} }
delete [] gm; delete [] gm;
return 1; return 1;
} }
return NULL; return 0;
} }
@ -718,9 +745,9 @@ template <class dataType> class analogDetector {
float *gm=NULL; float *gm=NULL;
void *ret; void *ret;
gm=new float[nx*ny]; gm=new float[nx*ny];
for (int iy=0; iy<ny; iy++) { for (iy=0; iy<ny; ++iy) {
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS(); gm[iy*nx+ix]=stat[iy][ix].getPedestalRMS();
} }
} }
ret=WriteToTiff(gm, imgname, ny, nx); ret=WriteToTiff(gm, imgname, ny, nx);
@ -740,8 +767,8 @@ template <class dataType> class analogDetector {
if (nnx>nx) nnx=nx; if (nnx>nx) nnx=nx;
if (nny>ny) nny=ny; if (nny>ny) nny=ny;
if (gm) { if (gm) {
for (int iy=0; iy<nny; iy++) { for (iy=0; iy<nny; ++iy) {
for (int ix=0; ix<nnx; ix++) { for (ix=0; ix<nnx; ++ix) {
stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]); stat[iy][ix].setPedestalRMS(gm[iy*nx+ix]);
} }
} }
@ -777,11 +804,13 @@ template <class dataType> class analogDetector {
//cout << xmin << " " << xmax << endl; //cout << xmin << " " << xmax << endl;
// cout << ymin << " " << ymax << endl; // cout << ymin << " " << ymax << endl;
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)) { if (det->isGood(ix,iy)) {
// addToPedestal(data,ix,iy,1); // addToPedestal(data,ix,iy,1);
addToPedestal(data,ix,iy,cm); addToPedestal(data,ix,iy,cm);
/* if (ix==50 && iy==50) */
/* cout<< "*ped* " << id << " " << ix << " " << iy << " " << det->getChannel(data,ix,iy) << " " << stat[iy][ix].getPedestal() << " " << stat[iy][ix].getPedestalRMS() <<" " << stat[iy][ix]. GetNPedestals() << endl; */
//if (ix==10 && iy==10) //if (ix==10 && iy==10)
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl; // cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
@ -905,8 +934,8 @@ template <class dataType> class analogDetector {
//calcGhost(data); //calcGhost(data);
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)) if (det->isGood(ix,iy))
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm); val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
} }
@ -952,8 +981,8 @@ template <class dataType> class analogDetector {
hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin)); hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin));
#ifdef ROOTCLUST #ifdef ROOTCLUST
double v3=0,v5=0,v7=0,v9=0; double v3=0,v5=0,v7=0,v9=0;
for (int iix=-4; iix<5; iix++) for (int iix=-4; iix<5; i++ix)
for (int iiy=-4; iiy<5; iiy++) { for (int iiy=-4; iiy<5; i++iy) {
if (det) if (det)
val= (dataSign*det->getValue(data, ix+iix, iy+iiy)-getPedestal(ix+iix,iy+iiy,cm))/g; val= (dataSign*det->getValue(data, ix+iix, iy+iiy)-getPedestal(ix+iix,iy+iiy,cm))/g;
else else
@ -1047,8 +1076,8 @@ template <class dataType> class analogDetector {
//calcGhost(data); //calcGhost(data);
addToCommonMode(data); addToCommonMode(data);
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)) if (det->isGood(ix,iy))
nph[iy*nx+ix]+=getNPhotons(data, ix, iy); nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
} }
@ -1062,8 +1091,8 @@ template <class dataType> class analogDetector {
*/ */
virtual void clearImage(){ virtual void clearImage(){
for (int iy=0; iy<ny; iy++) { for (iy=0; iy<ny; ++iy) {
for (int ix=0; ix<nx; ix++) { for (ix=0; ix<nx; ++ix) {
image[iy*nx+ix]=0; image[iy*nx+ix]=0;
} }
} }
@ -1093,8 +1122,8 @@ template <class dataType> class analogDetector {
int SetNPedestals(int i=-1) { int SetNPedestals(int i=-1) {
int ix=0, iy=0; int ix=0, iy=0;
if (i>0) if (i>0)
for (iy=0; iy<ny; iy++) for (iy=0; iy<ny; ++iy)
for (ix=0; ix<nx; ix++) for (ix=0; ix<nx; ++ix)
stat[iy][ix].SetNPedestals(i); stat[iy][ix].SetNPedestals(i);
return stat[0][0].SetNPedestals(); return stat[0][0].SetNPedestals();
}; };
@ -1129,8 +1158,8 @@ template <class dataType> class analogDetector {
newFrame(data); newFrame(data);
//calcGhost(data); //calcGhost(data);
addToCommonMode(data); addToCommonMode(data);
for (int iy=ymi; iy<yma; iy++) for (iy=ymi; iy<yma; ++iy)
for (int ix=xmi; ix<xma; ix++) for (ix=xmi; ix<xma; ++ix)
if (det->isGood(ix,iy)) { if (det->isGood(ix,iy)) {
if (ix>=0 && ix<nx && iy>=0 && iy<ny) if (ix>=0 && ix<nx && iy>=0 && iy<ny)
val+=getNPhotons(data, ix, iy); val+=getNPhotons(data, ix, iy);
@ -1233,6 +1262,8 @@ FILE *getFilePointer(){return myFile;};
int nx; /**< Size of the detector in x direction */ int nx; /**< Size of the detector in x direction */
int ny; /**< Size of the detector in y direction */ int ny; /**< Size of the detector in y direction */
pedestalSubtraction **stat; /**< pedestalSubtraction class */ pedestalSubtraction **stat; /**< pedestalSubtraction class */
/* double **pedMean; /\**< pedestalSubtraction class *\/ */
/* double **pedVariance; /\**< pedestalSubtraction class *\/ */
commonModeSubtraction *cmSub;/**< commonModeSubtraction class */ commonModeSubtraction *cmSub;/**< commonModeSubtraction class */
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */ int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */ int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */
@ -1250,6 +1281,7 @@ FILE *getFilePointer(){return myFile;};
frameMode fMode; /**< current detector frame mode */ frameMode fMode; /**< current detector frame mode */
detectorMode dMode; /**< current detector frame mode */ detectorMode dMode; /**< current detector frame mode */
FILE *myFile; /**< file pointer to write to */ FILE *myFile; /**< file pointer to write to */
int ix, iy;
#ifdef ROOTSPECTRUM #ifdef ROOTSPECTRUM
TH2F *hs; TH2F *hs;
#ifdef ROOTCLUST #ifdef ROOTCLUST

View File

@ -44,6 +44,28 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
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 };
/*
iadc=ptr%32
isample=ptr/32
col=(adc_nr[iadc]%16)*25+isample%25
if (adc_nr[iadc]<16)
row=199-isample/25;
else
row=200+isample/25
adc0 col(9*25..10*25-1) row(199..0)
adc1 col(8*25..9*25-1) row(199..0)
adc2 col(11*25..12*25-1) row(199..0)
adc3 col(10*25..11*25-1) row(199..0)
adc4 col(13*25..14*25-1) row(199..0)
adc5 col(12*25..13*25-1) row(199..0)
adc6 col(15*25..16*25-1) row(199..0)
adc7 col(14*25..15*25-1) row(199..0)
adc8 col(1*25..2*25-1) row(199..0)
*/
int row, col; int row, col;
//int isample; //int isample;
@ -134,7 +156,7 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
if (dSamples>isample) { if (dSamples>isample) {
ptr=data+32*(isample+1)+8*isample; ptr=data+32*(isample+1)+8*isample;
sample=*((uint64_t*)ptr); sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl; // cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc])) if (sample & (1<<ibit[isc]))
return 1; return 1;
else else

View File

@ -120,7 +120,7 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
if (dSamples>isample) { if (dSamples>isample) {
ptr=data+aoff+8*isample; ptr=data+aoff+8*isample;
sample=*((uint64_t*)ptr); sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl; // cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc])) if (sample & (1<<ibit[isc]))
return 1; return 1;
else else

View File

@ -20,6 +20,8 @@ class slsDetectorData {
int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */ int **dataROIMask; /**< Array of size nx*ny 1 if channel is good (or in the ROI), 0 if bad channel (or out of ROI) */
int *xmap; int *xmap;
int *ymap; int *ymap;
dataType **orderedData;
int isOrdered;
public: public:
@ -37,35 +39,29 @@ class slsDetectorData {
\param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s. \param dROI Array of size nx*ny. The elements are 1s if the channel is good or in the ROI, 0 is bad or out of the ROI. NULL (default) means all 1s.
*/ */
slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize) { slsDetectorData(int npx, int npy, int dsize, int **dMap=NULL, dataType **dMask=NULL, int **dROI=NULL): nx(npx), ny(npy), dataSize(dsize), orderedData(NULL), isOrdered(0) {
int el=dsize/sizeof(dataType);
xmap=new int[dsize/sizeof(dataType)]; xmap=new int[el];
ymap=new int[dsize/sizeof(dataType)]; ymap=new int[el];
// if (dataMask==NULL) {
dataMask=new dataType*[ny];
for(int i = 0; i < ny; i++) {
dataMask[i] = new dataType[nx];
}
// }
// if (dataMap==NULL) { orderedData=new dataType*[ny];
dataMap=new int*[ny]; dataMap=new int*[ny];
for(int i = 0; i < ny; i++) { dataMask=new dataType*[ny];
dataMap[i] = new int[nx];
}
// }
// if (dataROIMask==NULL) {
dataROIMask=new int*[ny]; dataROIMask=new int*[ny];
for(int i = 0; i < ny; i++) { for(int i = 0; i < ny; i++) {
dataMap[i] = new int[nx];
orderedData[i]=new dataType[nx];
dataMask[i] = new dataType[nx];
dataROIMask[i] = new int[nx]; dataROIMask[i] = new int[nx];
for (int j=0; j<nx; j++) for (int j=0; j<nx; j++)
dataROIMask[i][j]=1; dataROIMask[i][j]=1;
}
// } }
for (int ip=0; ip<dsize/sizeof(dataType); ip++){
for (int ip=0; ip<el; ip++){
xmap[ip]=-1; xmap[ip]=-1;
ymap[ip]=-1; ymap[ip]=-1;
} }
@ -74,22 +70,24 @@ class slsDetectorData {
setDataMask(dMask); setDataMask(dMask);
setDataROIMask(dROI); setDataROIMask(dROI);
}; }
virtual ~slsDetectorData() { virtual ~slsDetectorData() {
for(int i = 0; i < ny; i++) { for(int i = 0; i < ny; i++) {
delete [] dataMap[i]; delete [] dataMap[i];
delete [] dataMask[i]; delete [] dataMask[i];
delete [] dataROIMask[i]; delete [] dataROIMask[i];
delete [] orderedData[i];
} }
delete [] dataMap; delete [] dataMap;
delete [] dataMask; delete [] dataMask;
delete [] dataROIMask; delete [] dataROIMask;
delete [] orderedData;
delete [] xmap; delete [] xmap;
delete [] ymap; delete [] ymap;
}; };
virtual int getPointer(int ix,int iy) {return dataMap[iy][ix];};
/** /**
defines the data map (as offset) - no error checking if datasize and offsets are compatible! defines the data map (as offset) - no error checking if datasize and offsets are compatible!
\param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset). If NULL (default),the data are arranged as if read out row by row (dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);) \param dMap array of size nx*ny storing the pointers to the data in the dataset (as offset). If NULL (default),the data are arranged as if read out row by row (dataMap[iy][ix]=(iy*nx+ix)*sizeof(dataType);)
@ -202,27 +200,32 @@ class slsDetectorData {
int setDataSize(int d) {dataSize=d; return dataSize;}; int setDataSize(int d) {dataSize=d; return dataSize;};
virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];}; virtual void getPixel(int ip, int &x, int &y) {x=xmap[ip]; y=ymap[ip];};
virtual dataType **getData(char *ptr, int dsize=-1) { virtual dataType **getData(char *ptr, int dsize=-1) {
int el=dsize/sizeof(dataType);
dataType **data; //dataType **data;
int ix,iy; int ix,iy;
data=new dataType*[ny]; //data=new dataType*[ny];
for(int i = 0; i < ny; i++) { //for(int i = 0; i < ny; i++) {
data[i]=new dataType[nx]; // data[i]=new dataType[nx];
} //}
isOrdered=0;
if (dsize<=0 || dsize>dataSize) dsize=dataSize; if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) {
for (int ip=0; ip<(el); ip++) {
getPixel(ip,ix,iy); getPixel(ip,ix,iy);
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
data[iy][ix]=getChannel(ptr,ix,iy); //data[iy][ix]=getChannel(ptr,ix,iy);
orderedData[iy][ix]=*(ptr+ip);//getChannel(ptr,ix,iy);
} }
} }
return data; isOrdered=1;
return orderedData;
}; }
void newFrame(){isOrdered=0;};
virtual double **getImage(char *ptr, int dsize=-1) { virtual double **getImage(char *ptr, int dsize=-1) {
double **data; double **data;
@ -231,15 +234,15 @@ class slsDetectorData {
for(int i = 0; i < ny; i++) { for(int i = 0; i < ny; i++) {
data[i]=new double[nx]; data[i]=new double[nx];
} }
int el=dsize/sizeof(dataType);
if (dsize<=0 || dsize>dataSize) dsize=dataSize; if (dsize<=0 || dsize>dataSize) dsize=dataSize;
for (int ip=0; ip<(dsize/sizeof(dataType)); ip++) { for (int ip=0; ip<el; ip++) {
getPixel(ip,ix,iy); getPixel(ip,ix,iy);
if (ix>=0 && ix<nx && iy>=0 && iy<ny) { if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
data[iy][ix]=getValue(ptr,ix,iy); data[iy][ix]=getValue(ptr,ix,iy);
} }
} }
return data; return data;
}; };
/** /**
@ -256,7 +259,10 @@ class slsDetectorData {
// cout << ix << " " << iy << " " ; // cout << ix << " " << iy << " " ;
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl; //cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
m=dataMask[iy][ix]; m=dataMask[iy][ix];
d=*((dataType*)(data+dataMap[iy][ix])); if (isOrdered==0)
d=*((dataType*)(data+getPointer(ix,iy)));
else
d=orderedData[iy][ix];
} }
return d^m; return d^m;
}; };

View File

@ -13,7 +13,7 @@ template <class dataType> class ghostSummation {
/** constructor /** constructor
\param xt crosstalk \param xt crosstalk
*/ */
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d) { ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d), nx(1), ny(1) {
if (det) if (det)
det->getDetectorSize(nx,ny); det->getDetectorSize(nx,ny);
ghost=new double[nx*ny]; ghost=new double[nx*ny];
@ -22,6 +22,9 @@ template <class dataType> class ghostSummation {
ghostSummation(ghostSummation *orig) { ghostSummation(ghostSummation *orig) {
xtalk=orig->xtalk; xtalk=orig->xtalk;
det=orig->det; det=orig->det;
nx=1;
ny=1;
det->getDetectorSize(nx,ny);
ghost=new double[nx*ny]; ghost=new double[nx*ny];
} }

View File

@ -107,11 +107,11 @@ class interpolatingDetector : public singlePhotonDetector {
singlePhotonDetector::clearImage(); singlePhotonDetector::clearImage();
}; };
int getImageSize(int &nnx, int &nny, int &ns) { int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
if (interp) if (interp)
return interp->getImageSize(nnx, nny, ns); return interp->getImageSize(nnx, nny, nsx, nsy);
else else
return analogDetector<uint16_t>::getImageSize(nnx, nny, ns); return analogDetector<uint16_t>::getImageSize(nnx, nny, nsx, nsy);
}; };
@ -251,6 +251,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
} }
virtual int getNSubPixels(){ if (interp) return interp->getNSubPixels(); else return 1;} virtual int getNSubPixels(){ if (interp) return interp->getNSubPixels(); else return 1;}
virtual int setNSubPixels(int ns) { virtual int setNSubPixels(int ns) {
if (interp) { if (interp) {
pthread_mutex_lock(fi); pthread_mutex_lock(fi);

View File

@ -13,7 +13,7 @@
class eta2InterpolationBase : public virtual etaInterpolationBase { class eta2InterpolationBase : public virtual etaInterpolationBase {
public: public:
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) { eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax) {
/* if (etamin>=etamax) { */ /* if (etamin>=etamax) { */
/* etamin=-1; */ /* etamin=-1; */
@ -37,7 +37,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
int corner; int corner;
corner=calcQuad(data, tot, totquad, sDum); corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixels>2) if (nSubPixelsX>2 || nSubPixelsY>2)
calcEta(totquad, sDum, etax, etay); calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -53,7 +53,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
int corner; int corner;
corner=calcQuad(data, tot, totquad, sDum); corner=calcQuad(data, tot, totquad, sDum);
if (nSubPixels>2) if (nSubPixelsX>2 || nSubPixelsY>2 )
calcEta(totquad, sDum, etax, etay); calcEta(totquad, sDum, etax, etay);
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
@ -93,7 +93,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
; ;
} }
double etax=0, etay=0; double etax=0, etay=0;
if (nSubPixels>2) { if (nSubPixelsX>2 || nSubPixelsY>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)];
cc[0][1]=cl[xoff+1+3*yoff]; cc[0][1]=cl[xoff+1+3*yoff];
@ -133,7 +133,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
; ;
} }
double etax=0, etay=0; double etax=0, etay=0;
if (nSubPixels>2) { if (nSubPixelsX>2 || nSubPixelsY>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)];
cc[0][1]=cl[xoff+1+3*yoff]; cc[0][1]=cl[xoff+1+3*yoff];
@ -182,31 +182,31 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
} }
if (nSubPixels>2) { if (nSubPixelsX>2 || nSubPixelsY>2 ) {
ex=(etax-etamin)/etastep; ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastep; ey=(etay-etamin)/etastepY;
if (ex<0) { if (ex<0) {
cout << "x*"<< ex << endl; cout << "x*"<< ex << endl;
ex=0; ex=0;
} }
if (ex>=nbeta) { if (ex>=nbetaX) {
cout << "x?"<< ex << endl; cout << "x?"<< ex << endl;
ex=nbeta-1; ex=nbetaX-1;
} }
if (ey<0) { if (ey<0) {
cout << "y*"<< ey << endl; cout << "y*"<< ey << " " << nbetaY << endl;
ey=0; ey=0;
} }
if (ey>=nbeta) { if (ey>=nbetaY) {
cout << "y?"<< ey << endl; cout << "y?"<< ey << " " << nbetaY << endl;
ey=nbeta-1; ey=nbetaY-1;
} }
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels); xpos_eta=(((double)hhx[(ey*nbetaX+ex)]))+dX ;///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels); ypos_eta=(((double)hhy[(ey*nbetaX+ex)]))+dY ;///((double)nSubPixels);
} else { } else {
xpos_eta=0.5*dX+0.25; xpos_eta=0.5*dX+0.25;
@ -347,10 +347,10 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
#endif #endif
#ifndef MYROOT1 #ifndef MYROOT1
int ex,ey; int ex,ey;
ex=(etax-etamin)/etastep; ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastep; ey=(etay-etamin)/etastepY;
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0) if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbeta+ex]++; heta[ey*nbetaX+ex]++;
#endif #endif
return 0; return 0;
}; };
@ -360,22 +360,22 @@ class eta2InterpolationBase : public virtual etaInterpolationBase {
// cout << "ff" << endl; // cout << "ff" << endl;
calcDiff(1, hhx, hhy); //get flat calcDiff(1, hhx, hhy); //get flat
double avg=0; double avg=0;
for (ipx=0; ipx<nSubPixels; ipx++) for (ipx=0; ipx<nSubPixelsX; ipx++)
for (ipy=0; ipy<nSubPixels; ipy++) for (ipy=0; ipy<nSubPixelsY; ipy++)
avg+=flat[ipx+ipy*nSubPixels]; avg+=flat[ipx+ipy*nSubPixelsX];
avg/=nSubPixels*nSubPixels; avg/=nSubPixelsY*nSubPixelsX;
for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) { for (int ibx=0 ; ibx<nSubPixelsX*nPixelsX; ibx++) {
ipx=ibx%nSubPixels-nSubPixels/2; ipx=ibx%nSubPixelsX-nSubPixelsX/2;
if (ipx<0) ipx=nSubPixels+ipx; if (ipx<0) ipx=nSubPixelsX+ipx;
for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) { for (int iby=0 ; iby<nSubPixelsY*nPixelsY; iby++) {
ipy=iby%nSubPixels-nSubPixels/2; ipy=iby%nSubPixelsY-nSubPixelsY/2;
if (ipy<0) ipy=nSubPixels+ipy; if (ipy<0) ipy=nSubPixelsY+ipy;
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl; // cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
if (flat[ipx+ipy*nSubPixels]>0) if (flat[ipx+ipy*nSubPixelsX]>0)
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]); hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX]*(avg/flat[ipx+ipy*nSubPixelsX]);
else else
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]; hintcorr[ibx+iby*nSubPixelsX*nPixelsX]=hint[ibx+iby*nSubPixelsX*nPixelsX];
} }

View File

@ -13,35 +13,12 @@
class eta3InterpolationBase : public virtual etaInterpolationBase { class eta3InterpolationBase : public virtual etaInterpolationBase {
public: public:
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) { eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nsy, nb, nby, emin, emax) {
// cout << "e3ib " << nb << " " << emin << " " << emax << endl; // cout << "e3ib " << nb << " " << emin << " " << emax << endl;
/* if (nbeta<=0) { */ /* if (nbeta<=0) { */
/* nbeta=nSubPixels*10; */ /* nbeta=nSubPixels*10; */
/* } */ /* } */
if (etamin>=etamax) {
etamin=-1;
etamax=1;
}
etastep=(etamax-etamin)/nbeta;
#ifdef MYROOT1
delete heta;
delete hhx;
delete hhy;
heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax);
hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax);
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
#endif
#ifndef MYROOT1
/* delete [] heta; */
/* delete [] hhx; */
/* delete [] hhy; */
/* heta=new int[nbeta*nbeta]; */
/* hhx=new float[nbeta*nbeta]; */
/* hhy=new float[nbeta*nbeta]; */
#endif
// cout << nbeta << " " << etamin << " " << etamax << endl; // cout << nbeta << " " << etamin << " " << etamax << endl;
}; };
@ -88,7 +65,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double etax, etay; double etax, etay;
if (nSubPixels>2) { if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad); calcEta3(cl,etax,etay, totquad);
} }
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
@ -101,7 +78,7 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double etax, etay; double etax, etay;
if (nSubPixels>2) { if (nSubPixelsX>2 || nSubPixelsY>2 ) {
calcEta3(cl,etax,etay, totquad); calcEta3(cl,etax,etay, totquad);
} }
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y); return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
@ -117,38 +94,38 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
double xpos_eta=0,ypos_eta=0; double xpos_eta=0,ypos_eta=0;
int ex,ey; int ex,ey;
if (nSubPixels>2) { if (nSubPixelsX>2 || nSubPixelsY>2 ) {
#ifdef MYROOT1 #ifdef MYROOT1
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsX);
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels); ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixelsY);
#endif #endif
#ifndef MYROOT1 #ifndef MYROOT1
ex=(etax-etamin)/etastep; ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastep; ey=(etay-etamin)/etastepY;
if (ex<0) { if (ex<0) {
/* cout << etax << " " << etamin << " "; */ /* cout << etax << " " << etamin << " "; */
/* cout << "3x*"<< ex << endl; */ /* cout << "3x*"<< ex << endl; */
ex=0; ex=0;
} }
if (ex>=nbeta) { if (ex>=nbetaX) {
/* cout << etax << " " << etamin << " "; */ /* cout << etax << " " << etamin << " "; */
/* cout << "3x?"<< ex << endl; */ /* cout << "3x?"<< ex << endl; */
ex=nbeta-1; ex=nbetaX-1;
} }
if (ey<0) { if (ey<0) {
/* cout << etay << " " << etamin << " "; */ /* cout << etay << " " << etamin << " "; */
/* cout << "3y*"<< ey << endl; */ /* cout << "3y*"<< ey << endl; */
ey=0; ey=0;
} }
if (ey>=nbeta) { if (ey>=nbetaY) {
/* cout << etay << " " << etamin << " "; */ /* cout << etay << " " << etamin << " "; */
/* cout << "3y?"<< ey << endl; */ /* cout << "3y?"<< ey << endl; */
ey=nbeta-1; ey=nbetaY-1;
} }
xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels); xpos_eta=(((double)hhx[(ey*nbetaX+ex)]));///((double)nSubPixels);
ypos_eta=(((double)hhy[(ey*nbeta+ex)]));///((double)nSubPixels); ypos_eta=(((double)hhy[(ey*nbetaX+ex)]));///((double)nSubPixels);
#endif #endif
@ -265,10 +242,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase {
#endif #endif
#ifndef MYROOT1 #ifndef MYROOT1
int ex,ey; int ex,ey;
ex=(etax-etamin)/etastep; ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastep; ey=(etay-etamin)/etastepY;
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0) if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbeta+ex]++; heta[ey*nbetaX+ex]++;
#endif #endif
return 0; return 0;
}; };

View File

@ -7,7 +7,7 @@
#include <TH2D.h> #include <TH2D.h>
#include <TH2F.h> #include <TH2F.h>
#endif #endif
#include <cmath>
#include "slsInterpolation.h" #include "slsInterpolation.h"
#include "tiffIO.h" #include "tiffIO.h"
@ -15,44 +15,51 @@ class etaInterpolationBase : public slsInterpolation {
public: public:
etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns), hhx(NULL), hhy(NULL), heta(NULL), nbeta(nb), etamin(emin), etamax(emax) { etaInterpolationBase(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : slsInterpolation(nx,ny,ns,nsy), hhx(NULL), hhy(NULL), heta(NULL), nbetaX(nb), nbetaY(nby), etamin(emin), etamax(emax) {
// cout << "eb " << nb << " " << emin << " " << emax << endl; // cout << "eb " << nb << " " << emin << " " << emax << endl;
// cout << nb << " " << etamin << " " << etamax << endl; // cout << nb << " " << etamin << " " << etamax << endl;
if (nbeta<=0) { if (nbetaX<=0) {
//cout << "aaa:" <<endl; //cout << "aaa:" <<endl;
nbeta=nSubPixels*10; nbetaX=nSubPixelsX*10;
}
if (nbetaY<=0) {
//cout << "aaa:" <<endl;
nbetaY=nSubPixelsY*10;
} }
if (etamin>=etamax) { if (etamin>=etamax) {
etamin=-1; etamin=-1;
etamax=2; etamax=2;
} }
etastep=(etamax-etamin)/nbeta; etastepX=(etamax-etamin)/nbetaX;
heta=new int[nbeta*nbeta]; etastepY=(etamax-etamin)/nbetaY;
hhx=new float[nbeta*nbeta]; heta=new int[nbetaX*nbetaY];
hhy=new float[nbeta*nbeta]; hhx=new float[nbetaX*nbetaY];
hhy=new float[nbetaX*nbetaY];
rangeMin=etamin; rangeMin=etamin;
rangeMax=etamax; rangeMax=etamax;
flat= new double[nSubPixels*nSubPixels]; flat= new double[nSubPixelsX*nSubPixelsY];
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY]; hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY];
}; };
etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){ etaInterpolationBase(etaInterpolationBase *orig): slsInterpolation(orig){
nbeta=orig->nbeta; nbetaX=orig->nbetaX;
nbetaY=orig->nbetaY;
etamin=orig->etamin; etamin=orig->etamin;
etamax=orig->etamax; etamax=orig->etamax;
rangeMin=orig->rangeMin; rangeMin=orig->rangeMin;
rangeMax=orig->rangeMax; rangeMax=orig->rangeMax;
etastep=(etamax-etamin)/nbeta; etastepX=(etamax-etamin)/nbetaX;
heta=new int[nbeta*nbeta]; etastepY=(etamax-etamin)/nbetaY;
memcpy(heta,orig->heta,nbeta*nbeta*sizeof(int)); heta=new int[nbetaX*nbetaY];
hhx=new float[nbeta*nbeta]; memcpy(heta,orig->heta,nbetaX*nbetaY*sizeof(int));
memcpy(hhx,orig->hhx,nbeta*nbeta*sizeof(float)); hhx=new float[nbetaX*nbetaY];
hhy=new float[nbeta*nbeta]; memcpy(hhx,orig->hhx,nbetaX*nbetaY*sizeof(float));
memcpy(hhy,orig->hhy,nbeta*nbeta*sizeof(float)); hhy=new float[nbetaX*nbetaY];
hintcorr=new int [nSubPixels*nSubPixels*nPixelsX*nPixelsY]; memcpy(hhy,orig->hhy,nbetaX*nbetaY*sizeof(float));
hintcorr=new int [nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY];
}; };
@ -61,7 +68,7 @@ class etaInterpolationBase : public slsInterpolation {
virtual void resetFlatField() { virtual void resetFlatField() {
for (int ibx=0; ibx<nbeta*nbeta; ibx++) { for (int ibx=0; ibx<nbetaX*nbetaY; ibx++) {
heta[ibx]=0; heta[ibx]=0;
hhx[ibx]=0; hhx[ibx]=0;
hhy[ibx]=0; hhy[ibx]=0;
@ -70,13 +77,16 @@ class etaInterpolationBase : public slsInterpolation {
}; };
int *setEta(int *h, int nb=-1, double emin=1, double emax=0) int *setEta(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
{ {
if (h) { if (h) {
if (heta) delete [] heta; if (heta) delete [] heta;
heta=h; heta=h;
nbeta=nb; nbetaX=nb;
if (nb<=0) nbeta=nSubPixels*10; nbetaY=nby;
if (nbetaX<=0) nbetaX=nSubPixelsX*10;
if (nbetaY<=0) nbetaY=nSubPixelsY*10;
etamin=emin; etamin=emin;
etamax=emax; etamax=emax;
if (etamin>=etamax) { if (etamin>=etamax) {
@ -85,22 +95,24 @@ class etaInterpolationBase : public slsInterpolation {
} }
rangeMin=etamin; rangeMin=etamin;
rangeMax=etamax; rangeMax=etamax;
etastep=(etamax-etamin)/nbeta; etastepX=(etamax-etamin)/nbetaX;
etastepY=(etamax-etamin)/nbetaY;
} }
return heta; return heta;
}; };
int *setFlatField(int *h, int nb=-1, double emin=1, double emax=0) int *setFlatField(int *h, int nb=-1, int nby=-1, double emin=1, double emax=0)
{ {
return setEta(h, nb, emin, emax); return setEta(h, nb, nby, emin, emax);
}; };
int *getFlatField(){return setEta(NULL);}; int *getFlatField(){return setEta(NULL);};
int *getFlatField(int &nb, double &emin, double &emax){ int *getFlatField(int &nb, int &nby, double &emin, double &emax){
nb=nbeta; nb=nbetaX;
nby=nbetaY;
emin=etamin; emin=etamin;
emax=etamax; emax=etamax;
return getFlatField(); return getFlatField();
@ -109,13 +121,13 @@ class etaInterpolationBase : public slsInterpolation {
void *writeFlatField(const char * imgname) { void *writeFlatField(const char * imgname) {
float *gm=NULL; float *gm=NULL;
gm=new float[nbeta*nbeta]; gm=new float[nbetaX*nbetaY];
for (int ix=0; ix<nbeta; ix++) { for (int ix=0; ix<nbetaX; ix++) {
for (int iy=0; iy<nbeta; iy++) { for (int iy=0; iy<nbetaY; iy++) {
gm[iy*nbeta+ix]=heta[iy*nbeta+ix]; gm[iy*nbetaX+ix]=heta[iy*nbetaX+ix];
} }
} }
WriteToTiff(gm, imgname, nbeta, nbeta); WriteToTiff(gm, imgname, nbetaX, nbetaY);
delete [] gm; delete [] gm;
return NULL; return NULL;
}; };
@ -129,16 +141,18 @@ class etaInterpolationBase : public slsInterpolation {
etamax=2; etamax=2;
} }
etastep=(etamax-etamin)/nbeta; etastepX=(etamax-etamin)/nbetaX;
etastepY=(etamax-etamin)/nbetaY;
uint32 nnx; uint32 nnx;
uint32 nny; uint32 nny;
float *gm=ReadFromTiff(imgname, nnx, nny); float *gm=ReadFromTiff(imgname, nnx, nny);
if (nnx!=nny) { /* if (nnx!=nny) { */
cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl; /* cout << "different number of bins in x " << nnx << " and y " << nny<< " !"<< endl; */
cout << "Aborting read"<< endl; /* cout << "Aborting read"<< endl; */
return 0; /* return 0; */
} /* } */
nbeta=nnx; nbetaX=nnx;
nbetaY=nny;
if (gm) { if (gm) {
if (heta) { if (heta) {
delete [] heta; delete [] heta;
@ -146,13 +160,13 @@ class etaInterpolationBase : public slsInterpolation {
delete [] hhy; delete [] hhy;
} }
heta=new int[nbeta*nbeta]; heta=new int[nbetaX*nbetaY];
hhx=new float[nbeta*nbeta]; hhx=new float[nbetaX*nbetaY];
hhy=new float[nbeta*nbeta]; hhy=new float[nbetaX*nbetaY];
for (int ix=0; ix<nbeta; ix++) { for (int ix=0; ix<nbetaX; ix++) {
for (int iy=0; iy<nbeta; iy++) { for (int iy=0; iy<nbetaY; iy++) {
heta[iy*nbeta+ix]=gm[iy*nbeta+ix]; heta[iy*nbetaX+ix]=gm[iy*nbetaX+ix];
} }
} }
delete [] gm; delete [] gm;
@ -178,10 +192,10 @@ float *gethhx()
}; };
virtual int addToFlatField(double etax, double etay){ virtual int addToFlatField(double etax, double etay){
int ex,ey; int ex,ey;
ex=(etax-etamin)/etastep; ex=(etax-etamin)/etastepX;
ey=(etay-etamin)/etastep; ey=(etay-etamin)/etastepY;
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0) if (ey<nbetaY && ex<nbetaX && ex>=0 && ey>=0)
heta[ey*nbeta+ex]++; heta[ey*nbetaX+ex]++;
return 0; return 0;
}; };
@ -195,80 +209,80 @@ float *gethhx()
float tot_eta=0; float tot_eta=0;
float *etah=new float[nbeta*nbeta]; float *etah=new float[nbetaX*nbetaY];
int etabins=nbeta; // int etabins=nbeta;
int ibb=0; int ibb=0;
for (int ii=0; ii<etabins*etabins; ii++) { for (int ii=0; ii<nbetaX*nbetaY; ii++) {
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_%d.tiff",ind);
WriteToTiff(etah, tit, etabins, etabins); WriteToTiff(etah, tit, nbetaX, nbetaY);
for (int ii=0; ii<etabins*etabins; ii++) { for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibb=(hhx[ii]*nSubPixels); ibb=(hhx[ii]*nSubPixelsX);
etah[ii]=ibb; etah[ii]=ibb;
} }
sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind); sprintf(tit,"/scratch/eta_hhx_%d.tiff",ind);
WriteToTiff(etah, tit, etabins, etabins); WriteToTiff(etah, tit, nbetaX, nbetaY);
for (int ii=0; ii<etabins*etabins; ii++) { for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibb=hhy[ii]*nSubPixels; ibb=hhy[ii]*nSubPixelsY;
etah[ii]=ibb; etah[ii]=ibb;
} }
sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind); sprintf(tit,"/scratch/eta_hhy_%d.tiff",ind);
WriteToTiff(etah, tit, etabins, etabins); WriteToTiff(etah, tit, nbetaX, nbetaY);
float *ftest=new float[nSubPixels*nSubPixels]; float *ftest=new float[nSubPixelsX*nSubPixelsY];
for (int ib=0; ib<nSubPixels*nSubPixels; ib++) ftest[ib]=0; for (int ib=0; ib<nSubPixelsX*nSubPixelsY; ib++) ftest[ib]=0;
//int ibx=0, iby=0; //int ibx=0, iby=0;
for (int ii=0; ii<nbeta*nbeta; ii++) { for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibx=nSubPixels*hhx[ii]; ibx=nSubPixelsX*hhx[ii];
iby=nSubPixels*hhy[ii]; iby=nSubPixelsY*hhy[ii];
if (ibx<0) ibx=0; if (ibx<0) ibx=0;
if (iby<0) iby=0; if (iby<0) iby=0;
if (ibx>=nSubPixels) ibx=nSubPixels-1; if (ibx>=nSubPixelsX) ibx=nSubPixelsX-1;
if (iby>=nSubPixels) iby=nSubPixels-1; if (iby>=nSubPixelsY) iby=nSubPixelsY-1;
if (ibx>=0 && ibx<nSubPixels && iby>=0 && iby<nSubPixels) { if (ibx>=0 && ibx<nSubPixelsX && iby>=0 && iby<nSubPixelsY) {
// //
// if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl; // if (ibx>0 && iby>0) cout << ibx << " " << iby << " " << ii << endl;
ftest[ibx+iby*nSubPixels]+=heta[ii]; ftest[ibx+iby*nSubPixelsX]+=heta[ii];
} else } else
cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl; cout << "Bad interpolation "<< ii << " " << ibx << " " << iby<< endl;
} }
sprintf(tit,"/scratch/ftest_%d.tiff",ind); sprintf(tit,"/scratch/ftest_%d.tiff",ind);
WriteToTiff(ftest, tit, nSubPixels, nSubPixels); WriteToTiff(ftest, tit, nSubPixelsX, nSubPixelsY);
//int ibx=0, iby=0; //int ibx=0, iby=0;
tot_eta/=nSubPixels*nSubPixels; tot_eta/=nSubPixelsX*nSubPixelsY;
int nbad=0; int nbad=0;
for (int ii=0; ii<etabins*etabins; ii++) { for (int ii=0; ii<nbetaX*nbetaY; ii++) {
ibx=nSubPixels*hhx[ii]; ibx=nSubPixelsX*hhx[ii];
iby=nSubPixels*hhy[ii]; iby=nSubPixelsY*hhy[ii];
if (ftest[ibx+iby*nSubPixels]<tot_eta*0.5) { if (ftest[ibx+iby*nSubPixelsX]<tot_eta*0.5) {
etah[ii]=1; etah[ii]=1;
nbad++; nbad++;
} else if(ftest[ibx+iby*nSubPixels]>tot_eta*2.){ } else if(ftest[ibx+iby*nSubPixelsX]>tot_eta*2.){
etah[ii]=2; etah[ii]=2;
nbad++; nbad++;
} else } else
etah[ii]=0; etah[ii]=0;
} }
sprintf(tit,"/scratch/eta_bad_%d.tiff",ind); sprintf(tit,"/scratch/eta_bad_%d.tiff",ind);
WriteToTiff(etah, tit, etabins, etabins); WriteToTiff(etah, tit, nbetaX, nbetaY);
// cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl; // cout << "Index: " << ind << "\t Bad bins: "<< nbad << endl;
//int ibx=0, iby=0; //int ibx=0, iby=0;
@ -286,46 +300,44 @@ float *gethhx()
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[nSubPixelsX], p_tot_y[nSubPixelsY], p_tot[nSubPixelsX*nSubPixelsY];
double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels; double maxdiff=0, mindiff=avg*nSubPixelsX*nSubPixelsY;
int ipx, ipy; int ipx, ipy;
for (ipy=0; ipy<nSubPixels; ipy++) { for (ipy=0; ipy<nSubPixelsY; ipy++) {
for (ipx=0; ipx<nSubPixels; ipx++) { for (ipx=0; ipx<nSubPixelsX; ipx++) {
p_tot[ipx+ipy*nSubPixels]=0; p_tot[ipx+ipy*nSubPixelsX]=0;
} }
p_tot_y[ipy]=0; p_tot_y[ipy]=0;
p_tot_x[ipy]=0; p_tot_x[ipy]=0;
} }
for (int ibx=0; ibx<nbeta; ibx++) { for (int ibx=0; ibx<nbetaX; ibx++) {
for (int iby=0; iby<nbeta; iby++) { for (int iby=0; iby<nbetaY; iby++) {
ipx=hx[ibx+iby*nbeta]*nSubPixels; ipx=hx[ibx+iby*nbetaX]*nSubPixelsX;
if (ipx<0) ipx=0; if (ipx<0) ipx=0;
if (ipx>=nSubPixels) ipx=nSubPixels-1; if (ipx>=nSubPixelsX) ipx=nSubPixelsX-1;
ipy=hy[ibx+iby*nbeta]*nSubPixels; ipy=hy[ibx+iby*nbetaX]*nSubPixelsY;
if (ipy<0) ipy=0; if (ipy<0) ipy=0;
if (ipy>=nSubPixels) ipy=nSubPixels-1; if (ipy>=nSubPixelsY) ipy=nSubPixelsY-1;
p_tot[ipx+ipy*nSubPixels]+=heta[ibx+iby*nbeta]; p_tot[ipx+ipy*nSubPixelsX]+=heta[ibx+iby*nbetaX];
p_tot_y[ipy]+=heta[ibx+iby*nbeta]; p_tot_y[ipy]+=heta[ibx+iby*nbetaX];
p_tot_x[ipx]+=heta[ibx+iby*nbeta]; p_tot_x[ipx]+=heta[ibx+iby*nbetaX];
} }
} }
// cout << endl << endl; // cout << endl << endl;
for (ipy=0; ipy<nSubPixels; ipy++) { for (ipy=0; ipy<nSubPixelsY; ipy++) {
cout.width(5); cout.width(5);
//flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels; //flat_y[ipy]=p_tot_y[ipy];//avg/nSubPixels;
for (ipx=0; ipx<nSubPixels; ipx++) { for (ipx=0; ipx<nSubPixelsX; ipx++) {
// flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels; // flat_x[ipx]=p_tot_x[ipx];///avg/nSubPixels;
flat[ipx+nSubPixels*ipy]=p_tot[ipx+nSubPixels*ipy];///avg; flat[ipx+nSubPixelsX*ipy]=p_tot[ipx+nSubPixelsX*ipy];///avg;
d=p_tot[ipx+nSubPixels*ipy]-avg; d=p_tot[ipx+nSubPixelsX*ipy]-avg;
if (d<0) d*=-1.; if (d<0) d*=-1.;
if (d>5*sqrt(avg) ) if (d>5*sqrt(avg) )
nbad++; nbad++;
@ -354,8 +366,8 @@ float *gethhx()
float *hhx; float *hhx;
float *hhy; float *hhy;
int *heta; int *heta;
int nbeta; int nbetaX, nbetaY;
double etamin, etamax, etastep; double etamin, etamax, etastepX, etastepY;
double rangeMin, rangeMax; double rangeMin, rangeMax;

View File

@ -9,7 +9,7 @@
class etaInterpolationPosXY : public virtual etaInterpolationBase{ class etaInterpolationPosXY : public virtual etaInterpolationBase{
public: public:
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){ etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax){
// cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl; // cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl;
}; };
@ -24,14 +24,6 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
virtual void prepareInterpolation(int &ok) virtual void prepareInterpolation(int &ok)
{ {
ok=1; ok=1;
#ifdef MYROOT1
if (hhx) delete hhx;
if (hhy) delete hhy;
hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
#endif
///*Eta Distribution Rebinning*/// ///*Eta Distribution Rebinning*///
@ -40,106 +32,128 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
double tot_eta=0; double tot_eta=0;
double tot_eta_x=0; double tot_eta_x=0;
double tot_eta_y=0; double tot_eta_y=0;
for (int ip=0; ip<nbeta*nbeta; ip++) for (int ip=0; ip<nbetaX*nbetaY; ip++)
tot_eta+=heta[ip]; tot_eta+=heta[ip];
cout << "total eta entries is :"<< tot_eta << endl; cout << "total eta entries is :"<< tot_eta << endl;
if (tot_eta<=0) {ok=0; return;}; if (tot_eta<=0) {ok=0; return;};
double hx[nbeta]; //profile x double hx[nbetaX]; //profile x
double hy[nbeta]; //profile y double hy[nbetaY]; //profile y
double hix[nbeta]; //integral of projection x double hix[nbetaX]; //integral of projection x
double hiy[nbeta]; //integral of projection y double hiy[nbetaY]; //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<nbetaX; ib++) {
tot_eta_x=0;
tot_eta_y=0; //tot_eta_y=0;
for (int iby=0; iby<nbeta; iby++) { for (int iby=0; iby<nbetaY; iby++) {
etax=etamin+iby*etastep; etay=etamin+iby*etastepY;
//cout << etax << endl; //cout << etax << endl;
if (etax>=0 && etax<=1)
hx[iby]=heta[iby+ib*nbeta];
else {
hx[iby]=0;
}
// tot_eta_x+=hx[iby]; // tot_eta_x+=hx[iby];
if (etax>=0 && etax<=1) if (etay>=0 && etay<=1)
hy[iby]=heta[ib+iby*nbeta]; hy[iby]=heta[ib+iby*nbetaX];
else else
hy[iby]=0; hy[iby]=0;
// tot_eta_y+=hy[iby]; // tot_eta_y+=hy[iby];
} }
hix[0]=hx[0];
hiy[0]=hy[0]; hiy[0]=hy[0];
for (int iby=1; iby<nbeta; iby++) { for (int iby=1; iby<nbetaY; iby++) {
hix[iby]=hix[iby-1]+hx[iby];
hiy[iby]=hiy[iby-1]+hy[iby]; hiy[iby]=hiy[iby-1]+hy[iby];
} }
// ii=0; tot_eta_y=hiy[nbetaY-1]+1;
tot_eta_x=hix[nbeta-1]+1;
tot_eta_y=hiy[nbeta-1]+1;
for (int ibx=0; ibx<nbeta; ibx++) { for (int iby=0; iby<nbetaY; iby++) {
if (tot_eta_x<=0) {
hhx[ibx+ib*nbeta]=-1;
//ii=(ibx)/nbeta;
} else //if (hix[ibx]>(ii+1)*tot_eta_x*bsize)
{
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
hhx[ibx+ib*nbeta]=hix[ibx]/tot_eta_x;
}
}
/* if (ii!=(nSubPixels-1)) */
/* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */
//ii=0;
for (int ibx=0; ibx<nbeta; ibx++) {
if (tot_eta_y<=0) { if (tot_eta_y<=0) {
hhy[ib+ibx*nbeta]=-1; hhy[ib+iby*nbetaX]=-1;
//ii=(ibx*nSubPixels)/nbeta; //ii=(ibx*nSubPixels)/nbeta;
} else { } else {
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++; //if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
hhy[ib+ibx*nbeta]=hiy[ibx]/tot_eta_y; hhy[ib+iby*nbetaX]=hiy[iby]/tot_eta_y;
} }
} }
} }
for (int ib=0; ib<nbetaY; ib++) {
for (int ibx=0; ibx<nbetaX; ibx++) {
etax=etamin+ibx*etastepX;
//cout << etax << endl;
if (etax>=0 && etax<=1)
hx[ibx]=heta[ibx+ib*nbetaX];
else {
hx[ibx]=0;
}
}
hix[0]=hx[0];
for (int ibx=1; ibx<nbetaX; ibx++) {
hix[ibx]=hix[ibx-1]+hx[ibx];
}
tot_eta_x=hix[nbetaX-1]+1;
for (int ibx=0; ibx<nbetaX; ibx++) {
if (tot_eta_x<=0) {
hhx[ibx+ib*nbetaX]=-1;
}
else {
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
}
}
for (int ibx=0; ibx<nbetaX; ibx++) {
if (tot_eta_x<=0) {
hhx[ibx+ib*nbetaX]=-1;
} else {
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
}
}
}
int ibx, iby, ib; int ibx, iby, ib;
iby=0; iby=0;
while (hhx[iby*nbeta+nbeta/2]<0) iby++; while (hhx[iby*nbetaY+nbetaY/2]<0) iby++;
for (ib=0; ib<iby;ib++) { for (ib=0; ib<iby;ib++) {
for (ibx=0; ibx<nbeta;ibx++) for (ibx=0; ibx<nbetaX;ibx++)
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby]; hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
} }
iby=nbeta-1; iby=nbetaY-1;
while (hhx[iby*nbeta+nbeta/2]<0) iby--; while (hhx[iby*nbetaY+nbetaY/2]<0) iby--;
for (ib=iby+1; ib<nbeta;ib++) { for (ib=iby+1; ib<nbetaY;ib++) {
for (ibx=0; ibx<nbeta;ibx++) for (ibx=0; ibx<nbetaX;ibx++)
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby]; hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby];
} }
iby=0; iby=0;
while (hhy[nbeta/2*nbeta+iby]<0) iby++; while (hhy[nbetaX/2*nbetaX+iby]<0) iby++;
for (ib=0; ib<iby;ib++) { for (ib=0; ib<iby;ib++) {
for (ibx=0; ibx<nbeta;ibx++) for (ibx=0; ibx<nbetaY;ibx++)
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx]; hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
} }
iby=nbeta-1; iby=nbetaX-1;
while (hhy[nbeta/2*nbeta+iby]<0) iby--; while (hhy[nbetaX/2*nbetaX+iby]<0) iby--;
for (ib=iby+1; ib<nbeta;ib++) { for (ib=iby+1; ib<nbetaX;ib++) {
for (ibx=0; ibx<nbeta;ibx++) for (ibx=0; ibx<nbetaY;ibx++)
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx]; hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx];
} }
@ -156,9 +170,16 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
}; };
class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virtual etaInterpolationPosXY { class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virtual etaInterpolationPosXY {
public: public:
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){ eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl; // cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
}; };
@ -172,8 +193,8 @@ class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virt
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY { class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
public: public:
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){ eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl; // cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
}; };
eta3InterpolationPosXY(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {}; eta3InterpolationPosXY(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};

View File

@ -29,19 +29,21 @@ class slsInterpolation
{ {
public: public:
slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) { slsInterpolation(int nx=400, int ny=400, int ns=25, int nsy=-1) :nPixelsX(nx), nPixelsY(ny), nSubPixelsX(ns), nSubPixelsY(nsy),id(0) {
hint=new int[ns*nx*ns*ny]; if (nSubPixelsY<=0) nSubPixelsY=nSubPixelsX;
hint=new int[nSubPixelsX*nx*nSubPixelsY*ny];
}; };
slsInterpolation(slsInterpolation *orig){ slsInterpolation(slsInterpolation *orig){
nPixelsX=orig->nPixelsX; nPixelsX=orig->nPixelsX;
nPixelsY=orig->nPixelsY; nPixelsY=orig->nPixelsY;
nSubPixels=orig->nSubPixels; nSubPixelsX=orig->nSubPixelsX;
nSubPixelsY=orig->nSubPixelsY;
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY]; hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int)); memcpy(hint, orig->hint,nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY*sizeof(int));
}; };
@ -51,23 +53,37 @@ class slsInterpolation
return new slsInterpolation(this); return new slsInterpolation(this);
}*/ }*/
int getNSubPixels() {return nSubPixels;}; int getNSubPixelsX() {return nSubPixelsX;};
int getNSubPixelsY() {return nSubPixelsY;};
int getNSubPixels() {if (nSubPixelsX==nSubPixelsY) return nSubPixelsX; else return 0;};
void getNSubPixels(int &nsx, int &nsy) {nsx=nSubPixelsX; nsy=nsx=nSubPixelsY;}
void setNSubPixels(int ns, int nsy=-1) {
int setNSubPixels(int ns) {
if (ns>0 && ns!=nSubPixels) {
delete [] hint; delete [] hint;
nSubPixels=ns; nSubPixelsX=ns;
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY]; if (nsy>0) nSubPixelsY=nsy;
} else nSubPixelsY=ns;
return nSubPixels;
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
//return nSubPixels;
} }
int getImageSize(int &nnx, int &nny, int &ns) {
nnx=nSubPixels*nPixelsX;
nny=nSubPixels*nPixelsY;
ns=nSubPixels; int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
return nSubPixels*nSubPixels*nPixelsX*nPixelsY; nnx=nSubPixelsX*nPixelsX;
nny=nSubPixelsY*nPixelsY;
nsx=nSubPixelsX;
nsy=nSubPixelsY;
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
};
int getImageSize() {
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
}; };
@ -92,14 +108,14 @@ class slsInterpolation
//cout << "!" <<endl; //cout << "!" <<endl;
float *gm=NULL; float *gm=NULL;
int *dummy=getInterpolatedImage(); int *dummy=getInterpolatedImage();
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY]; gm=new float[ nSubPixelsX* nSubPixelsY* nPixelsX*nPixelsY];
if (gm) { if (gm) {
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) { for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) { for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
gm[iy*nPixelsX*nSubPixels+ix]=dummy[iy*nPixelsX*nSubPixels+ix]; gm[iy*nPixelsX*nSubPixelsX+ix]=dummy[iy*nPixelsX*nSubPixelsX+ix];
} }
} }
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY); WriteToTiff(gm, imgname,nSubPixelsY* nPixelsX ,nSubPixelsY* nPixelsY);
delete [] gm; delete [] gm;
} else cout << "Could not allocate float image " << endl; } else cout << "Could not allocate float image " << endl;
return NULL; return NULL;
@ -120,9 +136,9 @@ class slsInterpolation
virtual void clearInterpolatedImage() { virtual void clearInterpolatedImage() {
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) { for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) { for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
hint[iy*nPixelsX*nSubPixels+ix]=0; hint[iy*nPixelsX*nSubPixelsX+ix]=0;
} }
} }
@ -133,11 +149,11 @@ class slsInterpolation
virtual int *addToImage(double int_x, double int_y){ virtual int *addToImage(double int_x, double int_y){
int iy=((double)nSubPixels)*int_y; int iy=((double)nSubPixelsY)*int_y;
int ix=((double)nSubPixels)*int_x; int ix=((double)nSubPixelsX)*int_x;
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){ if (ix>=0 && ix<(nPixelsX*nSubPixelsX) && iy<(nSubPixelsY*nPixelsY) && iy>=0 ){
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels]; // cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels];
(*(hint+ix+iy*nPixelsX*nSubPixels))+=1; (*(hint+ix+iy*nPixelsX*nSubPixelsX))+=1;
// cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl; // cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl;
}// else }// else
// cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl; // cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
@ -180,11 +196,12 @@ class slsInterpolation
/* cluster[2]=cl+6; */ /* cluster[2]=cl+6; */
sum=0; sum=0;
int xoff=0, yoff=0;
#ifndef WRITE_QUAD
double sumBL=0; double sumBL=0;
double sumTL=0; double sumTL=0;
double sumBR=0; double sumBR=0;
double sumTR=0; double sumTR=0;
int xoff=0, yoff=0;
for (int ix=0; ix<3; ix++) { for (int ix=0; ix<3; ix++) {
for (int iy=0; iy<3; iy++) { for (int iy=0; iy<3; iy++) {
sum+=cl[ix+3*iy]; sum+=cl[ix+3*iy];
@ -204,34 +221,95 @@ class slsInterpolation
if(sumTL >= totquad){ if(sumTL >= totquad){
/* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; */ /* #ifdef WRITE_QUAD */
/* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; */ /* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumTL ==sum) { */
/* #endif */
corner = TOP_LEFT; corner = TOP_LEFT;
totquad=sumTL; totquad=sumTL;
xoff=0; xoff=0;
yoff=1; yoff=1;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
} }
if(sumBR >= totquad){ if(sumBR >= totquad){
/* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */ /* sDum[0][0] = cluster[0][1]; sDum[1][0] = cluster[1][1]; */
/* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */ /* sDum[0][1] = cluster[0][2]; sDum[1][1] = cluster[1][2]; */
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumBR ==sum) { */
/* #endif */
corner = BOTTOM_RIGHT;
xoff=1; xoff=1;
yoff=0; yoff=0;
corner = BOTTOM_RIGHT;
totquad=sumBR; totquad=sumBR;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
} }
if(sumTR >= totquad){ if(sumTR >= totquad){
/* #ifdef WRITE_QUAD */
/* /\* sDum[0][0] = cluster[1][0]; sDum[1][0] = cluster[2][0]; *\/ */
/* /\* sDum[0][1] = cluster[1][1]; sDum[1][1] = cluster[2][1]; *\/ */
/* if (sumTR ==sum) { */
/* #endif */
xoff=1; xoff=1;
yoff=1; yoff=1;
/* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */ /* sDum[0][0] = cluster[1][1]; sDum[1][0] = cluster[2][1]; */
/* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */ /* sDum[0][1] = cluster[1][2]; sDum[1][1] = cluster[2][2]; */
corner = TOP_RIGHT; corner = TOP_RIGHT;
totquad=sumTR; totquad=sumTR;
/* #ifdef WRITE_QUAD */
/* } */
/* #endif */
} }
#endif
#ifdef WRITE_QUAD
double sumB=0;
double sumT=0;
double sumR=0;
double sumL=0;
for (int ix=0; ix<3; ix++) {
for (int iy=0; iy<3; iy++) {
sum+=cl[ix+3*iy];
if (ix<1 ) sumL+=cl[ix+iy*3];
if (ix>1) sumR+=cl[ix+iy*3];
if (iy<1) sumB=cl[ix+iy*3];
if (iy>1) sumT+=cl[ix+iy*3];
}
}
totquad=sum;
if ( sumT==0 && sumR==0) {
corner = BOTTOM_LEFT;
xoff=0;
yoff=0;
} else if ( sumB==0 && sumR==0 ) {
corner = TOP_LEFT;
xoff=0;
yoff=1;
} else if ( sumT==0 && sumL==0) {
corner = BOTTOM_RIGHT;
xoff=1;
yoff=0;
} else if ( sumB==0 && sumL==0) {
xoff=1;
yoff=1;
corner = TOP_RIGHT;
} else
printf("** bad 2x2 cluster!\n");
#endif
for (int ix=0; ix<2; ix++) { for (int ix=0; ix<2; ix++) {
for (int iy=0; iy<2; iy++) { for (int iy=0; iy<2; iy++) {
@ -495,7 +573,7 @@ class slsInterpolation
protected: protected:
int nPixelsX, nPixelsY; int nPixelsX, nPixelsY;
int nSubPixels; int nSubPixelsX, nSubPixelsY;
int id; int id;
int *hint; int *hint;
}; };

View File

@ -1,18 +1,21 @@
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/ INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/ -I../../libs/rapidjson/
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 -std=c++11 -Wall -L../../build/bin/ -lSlsSupport
#-L../../bin -lhdf5 -L. #-L../../bin -lhdf5 -L.
#DESTDIR?=../bin #DESTDIR?=../bin
all: moenchZmqProcess moenchZmqProcessCtbGui all: moenchZmqProcess moenchZmq04Process
#moenchZmqProcessCtbGui
moenchZmqProcess: moenchZmqProcess.cpp clean moenchZmqProcess: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean moenchZmq04Process: moenchZmqProcess.cpp clean
g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI g++ -o moench04ZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DMOENCH04
#moenchZmqProcessCtbGui: moenchZmqProcess.cpp clean
# g++ -o moenchZmqProcessCtbGui moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DCTBGUI
clean: clean:
rm -f moenchZmqProcess rm -f moenchZmqProcess

View File

@ -16,7 +16,8 @@
//#include "etaInterpolationPosXY.h" //#include "etaInterpolationPosXY.h"
#include "noInterpolation.h" #include "noInterpolation.h"
#include "etaInterpolationCleverAdaptiveBins.h" #include "etaInterpolationPosXY.h"
//#include "etaInterpolationCleverAdaptiveBins.h"
//#include "etaInterpolationRandomBins.h" //#include "etaInterpolationRandomBins.h"
using namespace std; using namespace std;
#define NC 400 #define NC 400

View File

@ -1,13 +1,24 @@
#define WRITE_QUAD //#define WRITE_QUAD
#define DEVELOPER #define DEVELOPER
#undef CORR
#define C_GHOST 0.0004 #define C_GHOST 0.0004
#define CM_ROWS 20 #define CM_ROWS 20
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "ZmqSocket.h" #include "ZmqSocket.h"
#ifndef RECT
#ifndef MOENCH04
#include "moench03T1ZmqDataNew.h" #include "moench03T1ZmqDataNew.h"
#endif
#ifdef MOENCH04
#include "moench04CtbZmq10GbData.h"
#endif
#endif
#ifdef RECT
#include "moench03T1ZmqDataNewRect.h"
#endif
#include "moench03GhostSummation.h" #include "moench03GhostSummation.h"
#include "moench03CommonMode.h" #include "moench03CommonMode.h"
#include <vector> #include <vector>
@ -31,12 +42,12 @@
#include "ansi.h" #include "ansi.h"
#include <iostream> #include <iostream>
//#include <chrono> #include <chrono>
#include <ctime> // time_t #include <ctime> // time_t
#include <cstdio> #include <cstdio>
using namespace std; using namespace std;
//using namespace std::chrono; using namespace std::chrono;
//#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 //#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
@ -49,10 +60,11 @@ int main(int argc, char *argv[]) {
*/ */
FILE *of=NULL; FILE *of=NULL;
int fifosize=5000; int fifosize=5000;
int etabins=1000;//nsubpix*2*100; int etabins=1000, etabinsy=1000;//nsubpix*2*100;
double etamin=-1, etamax=2; double etamin=-1, etamax=2;
int nSubPixels=2; int nSubPixelsX=2;
// int emin, emax; // int emin, emax;
int nSubPixelsY=2;
// 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] [gainmap] [etafile]\n");
@ -67,21 +79,20 @@ int main(int argc, char *argv[]) {
char* socketip2 = 0; char* socketip2 = 0;
uint32_t portnum2 = 0; uint32_t portnum2 = 0;
zmqHeader zHeader, outHeader;
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
outHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
uint32_t nSigma=5; uint32_t nSigma=5;
int ok; int ok;
// high_resolution_clock::time_point t1; high_resolution_clock::time_point t1;
// high_resolution_clock::time_point t2 ; high_resolution_clock::time_point t2 ;
time_t begin,end,finished; std::chrono::steady_clock::time_point begin,end,finished;
//time_t begin,end,finished;
int rms=0; int rms=0;
int nped=1000, nped0=100;
#ifdef PTC
nped=10000;
nped0=10000;
#endif
if (argc > 4) { if (argc > 4) {
@ -101,10 +112,14 @@ 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;
if (argc>6) if (argc>6) {
nSubPixels=atoi(argv[6]); nSubPixelsX=atoi(argv[6]);
cout << "Number of subpixels is: " << nSubPixels << endl; nSubPixelsY=nSubPixelsX;
#ifdef RECT
nSubPixelsX=2;
#endif
}
cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY << endl;
char *gainfname=NULL; char *gainfname=NULL;
if (argc>7) { if (argc>7) {
@ -119,12 +134,17 @@ int main(int argc, char *argv[]) {
} }
//slsDetectorData *det=new moench03T1ZmqDataNew(); //slsDetectorData *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(5000,sizeof(int)); #ifndef MOENCH04
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
#endif
#ifdef MOENCH04
moench04CtbZmq10GbData *det=new moench04CtbZmq10GbData();
#endif
cout << endl << " det" <<endl; cout << endl << " det" <<endl;
int npx, npy; int npx, npy;
det->getDetectorSize(npx, npy); det->getDetectorSize(npx, npy);
int send_something=0;
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]); int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
@ -135,17 +155,16 @@ int main(int argc, char *argv[]) {
char dummybuff[size]; char dummybuff[size];
int ncol_cm=CM_ROWS;
double xt_ghost=C_GHOST;
moench03CommonMode *cm=NULL; moench03CommonMode *cm=NULL;
moench03GhostSummation *gs=NULL; moench03GhostSummation *gs=NULL;
#ifdef CORR #ifdef CORR
cm=new moench03CommonMode(ncol_cm);
gs=new moench03GhostSummation(det, xt_ghost); //int ncol_cm=CM_ROWS;
#endif //double xt_ghost=C_GHOST;
cm=new moench03CommonMode(CM_ROWS);
gs=new moench03GhostSummation(det, C_GHOST);
#endif
double *gainmap=NULL; double *gainmap=NULL;
float *gm; float *gm;
double *gmap=NULL; double *gmap=NULL;
@ -173,18 +192,18 @@ int main(int argc, char *argv[]) {
//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, nped, nped0, -1, -1, gainmap, gs); singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 100, -1, -1, gainmap, gs);
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize); multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); // multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
#endif #endif
#ifdef INTERP #ifdef INTERP
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax); eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixelsX,nSubPixelsY, etabins, etabinsy, etamin, etamax);
if (etafname) interp->readFlatField(etafname); if (etafname) interp->readFlatField(etafname);
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs); interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize); multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
#endif #endif
@ -275,7 +294,17 @@ 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; #ifdef MOENCH_BRANCH
uint32_t subFrameIndex = -1;
int* flippedData = 0;
#endif
uint64_t subframes=0;
//uint64_t isubframe=0;
uint64_t insubframe=0;
double subnorm=1;
uint64_t f0=-1, nsubframes=0, nnsubframe=0;
uint64_t fileindex = -1; uint64_t fileindex = -1;
string filename = ""; string filename = "";
// char* image = new char[size]; // char* image = new char[size];
@ -285,10 +314,10 @@ int main(int argc, char *argv[]) {
int iframe=0; int iframe=0;
char ofname[10000]; char ofname[10000];
char fname[10000]; string fname;
// int length; // int length;
int *detimage; int *detimage=NULL;
int nnx, nny,nns; int nnx, nny,nnsx, nnsy;
//uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, //uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0,
//uint32_t dynamicRange = 0; //uint32_t dynamicRange = 0;
// infinite loop // infinite loop
@ -296,20 +325,20 @@ int main(int argc, char *argv[]) {
uint64_t bunchId = 0; uint64_t bunchId = 0;
uint64_t timestamp = 0; uint64_t timestamp = 0;
int16_t modId = 0; int16_t modId = 0;
uint32_t expLength=0;
uint16_t xCoord = 0; uint16_t xCoord = 0;
uint16_t yCoord = 0; uint16_t yCoord = 0;
uint16_t zCoord = 0; //uint16_t zCoord = 0;
uint32_t debug = 0; uint32_t debug = 0;
//uint32_t dr = 16; //uint32_t dr = 16;
//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];
float *doutf=NULL;//=new int32_t [nnx*nny];
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; string additionalJsonHeader="" ;
string* additionalJsonHeader = 0;
//char* additionalJsonHeader = 0;
int32_t threshold=0; int32_t threshold=0;
@ -327,9 +356,10 @@ int main(int argc, char *argv[]) {
frameMode fMode=eFrame; frameMode fMode=eFrame;
double *ped; double *ped;
filter->getImageSize(nnx, nny,nns); filter->getImageSize(nnx, nny,nnsx, nnsy);
std::map<std::string, std::string> addJsonHeader;
@ -339,21 +369,21 @@ int main(int argc, char *argv[]) {
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl; // cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
// get header, (if dummy, fail is on parse error or end of acquisition) // get header, (if dummy, fail is on parse error or end of acquisition)
#ifndef NEWZMQ
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
#endif
#ifdef NEWZMQ
rapidjson::Document doc;
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) { // rapidjson::Document doc;
if (!zmqsocket->ReceiveHeader(0, zHeader, SLS_DETECTOR_JSON_HEADER_VERSION)) {
/* zmqsocket->CloseHeaderMessage();*/ /* zmqsocket->CloseHeaderMessage();*/
#endif
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) { // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
// cprintf(RED, "Got Dummy\n"); cprintf(RED, "Got Dummy\n");
// t1=high_resolution_clock::now(); // t1=high_resolution_clock::now();
time(&end); //time(&end);
//cout << "Measurement lasted " << difftime(end,begin) << endl;
end = std::chrono::steady_clock::now();
cout << "Measurement lasted " << (end-begin).count()*0.000001 << " ms" << endl;
while (mt->isBusy()) {;}//wait until all data are processed from the queues while (mt->isBusy()) {;}//wait until all data are processed from the queues
@ -364,44 +394,83 @@ int main(int argc, char *argv[]) {
if (newFrame>0) { if (newFrame>0) {
cprintf(RED,"DIDn't receive any data!\n"); cprintf(RED,"DIDn't receive any data!\n");
if (send) { if (send) {
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
//zHeader.data = false;
outHeader.data=false;
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
zmqsocket2->SendHeader(0,outHeader);
cprintf(RED, "Sent Dummy\n"); cprintf(RED, "Sent Dummy\n");
} }
} else { } else {
if (fMode==ePedestal) { send_something=0;
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex); if (fMode==ePedestal) {
mt->writePedestal(ofname); sprintf(ofname,"%s_%ld_ped.tiff",fname.c_str(),fileindex);
cout << "Writing pedestal to " << ofname << endl; mt->writePedestal(ofname);
if (rms) { cout << "Writing pedestal to " << ofname << endl;
sprintf(ofname,"%s_%ld_var.tiff",fname,fileindex); if (rms){
mt->writePedestalRMS(ofname); sprintf(ofname,"%s_%ld_var.tiff",fname.c_str(),fileindex);
cout << "Writing pedestal variance to " << ofname << endl; mt->writePedestalRMS(ofname);
}
} }
send_something=1;
}
#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_%ld_eta.tiff",fname.c_str(),fileindex);
mt->writeFlatField(ofname); mt->writeFlatField(ofname);
cout << "Writing eta to " << ofname << endl; cout << "Writing eta to " << ofname << endl;
} send_something=1;
}
#endif #endif
else { else {
sprintf(ofname,"%s_%ld.tiff",fname,fileindex); if (subframes>0 ) {
mt->writeImage(ofname); if (insubframe>0) {
cout << "Writing image to " << ofname << endl; sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
} // mt->writeImage(ofname);
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl; doutf= new float[nnx*nny];
if (subframes>0 && insubframe!=subframes && insubframe>0)
subnorm=((double)subframes)/((double)insubframe);
else
subnorm=1.;
for (int ix=0; ix<nnx*nny; ix++) {
doutf[ix]=detimage[ix]*subnorm;
if (doutf[ix]<0) doutf[ix]=0;
}
cout << "Writing image to " << ofname << endl;
WriteToTiff(doutf,ofname ,nnx, nny);
if (doutf)
delete [] doutf;
doutf=NULL;
nsubframes++;
insubframe=0;
send_something=1;
}
} else {
sprintf(ofname,"%s_%ld.tiff",fname.c_str(),fileindex);
mt->writeImage(ofname);
send_something=1;
}
cout << "Writing image to " << ofname << endl;
}
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
if (send) { if (send) {
if (fMode==ePedestal) { if (fMode==ePedestal) {
cprintf(MAGENTA,"Get pedestal!\n"); cprintf(MAGENTA,"Get pedestal!\n");
nns=1; nnsx=1;
nnsy=1;
nnx=npx; nnx=npx;
nny=npy; nny=npy;
//dout= new int16_t[nnx*nny*nns*nns]; //dout= new int16_t[nnx*nny*nns*nns];
dout= new int32_t[nnx*nny*nns*nns]; dout= new int32_t[nnx*nny*nnsx*nnsy];
// cout << "get pedestal " << endl; // cout << "get pedestal " << endl;
ped=mt->getPedestal(); ped=mt->getPedestal();
// cout << "got pedestal " << endl; // cout << "got pedestal " << endl;
@ -409,7 +478,7 @@ int main(int argc, char *argv[]) {
dout[ix]=ped[ix]; dout[ix]=ped[ix];
// if (ix<100*400) // if (ix<100*400)
// cout << ix << " " << ped[ix] << " "<< dout[ix] << endl; // cout << ix << " " << ped[ix] << endl;
} }
} }
@ -427,15 +496,19 @@ int main(int argc, char *argv[]) {
} }
#endif #endif
else { else {
detimage=mt->getImage(nnx,nny,nns); detimage=mt->getImage(nnx,nny,nnsx, nnsy);
cprintf(MAGENTA,"Get image!\n"); cprintf(MAGENTA,"Get image!\n");
cout << nnx << " " << nny << " " << nns << endl; cout << nnx << " " << nny << " " << nnsx << " " << nnsy << endl;
// nns=1; // nns=1;
// nnx=npx; // nnx=npx;
// nny=npy; // nny=npy;
// nnx=nnx*nns; // nnx=nnx*nns;
//nny=nny*nns; //nny=nny*nns;
dout= new int32_t[nnx*nny]; dout= new int32_t[nnx*nny];
if (subframes>0 && insubframe!=subframes && insubframe>0)
subnorm=((double)subframes)/((double)insubframe);
else
subnorm=1.;
for (int ix=0; ix<nnx*nny; ix++) { for (int ix=0; ix<nnx*nny; ix++) {
// for (int iy=0; iy<nny*nns; iy++) { // for (int iy=0; iy<nny*nns; iy++) {
// for (int isx=0; isx<nns; isx++) { // for (int isx=0; isx<nns; isx++) {
@ -447,102 +520,157 @@ int main(int argc, char *argv[]) {
// } // }
// } // }
dout[ix]=detimage[ix]; dout[ix]=detimage[ix]*subnorm;
if (dout[ix]<0) dout[ix]=0; if (dout[ix]<0) dout[ix]=0;
//cout << ix << " " << dout[ix] << endl; // cout << ix << " " << dout[ix] << endl;
// } // }
} }
} }
//if ((insubframe>0 && subframes>0) || (subframes<=0) ){
if(send_something) {
//// int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
// uint32_t ndetx = 0, uint32_t ndety = 0, uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0, // zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,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);
// uint64_t acqIndex = 0, uint64_t fIndex = 0, const char* fname = NULL,
// uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0, outHeader.data=true;
// uint64_t bunchId = 0, uint64_t timestamp = 0, outHeader.dynamicRange=dr;
// uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0, outHeader.fileIndex=fileindex;
// uint32_t debug = 0, uint16_t roundRNumber = 0, outHeader.ndetx=1;
// uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0, outHeader.ndety=1;
// char* additionalJsonHeader = 0) { outHeader.npixelsx=nnx;
outHeader.npixelsy=nny;
outHeader.imageSize=nnx*nny*dr/8;
outHeader.acqIndex=acqIndex;
// cout << "Sending image size " << nnx << " " << nny << endl; outHeader.frameIndex=frameIndex;
outHeader.fname=fname;
// #ifndef DEVELOPER outHeader.frameNumber=acqIndex;
// #ifndef MOENCH_BRANCH outHeader.expLength=expLength;
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 1,1, 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); outHeader.packetNumber=packetNumber;
// #endif outHeader.bunchId=bunchId;
// #endif outHeader.timestamp=timestamp;
outHeader.modId=modId;
outHeader.row=xCoord;
// #ifdef DEVELOPER outHeader.column=yCoord;
// #ifdef CTBGUI outHeader.debug=debug;
// 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); outHeader.roundRNumber=roundRNumber;
// #endif outHeader.detType=detType;
// #ifndef CTBGUI outHeader.version=version;
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,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 zmqsocket2->SendHeader(0,outHeader);
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
cprintf(GREEN, "Sent Data\n");
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8); }
cprintf(GREEN, "Sent Data\n"); outHeader.data=false;
zmqsocket2->SendHeader(0,outHeader);
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION); // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
cprintf(RED, "Sent Dummy\n"); cprintf(RED, "Sent Dummy\n");
if (dout) if (dout)
delete [] dout; delete [] dout;
dout=NULL; dout=NULL;
} }
} }
mt->clearImage(); mt->clearImage();
newFrame=1; newFrame=1;
//t2 = high_resolution_clock::now();
time(&finished);
// auto meas_duration = duration_cast<microseconds>( t2 - t0 ).count();
// auto real_duration = duration_cast<microseconds>( t2 - t1 ).count();
cout << "Measurement lasted " << difftime(end,begin) << endl; //time(&finished);
cout << "Processing lasted " << difftime(finished,begin) << endl; //cout << "Processing lasted " << difftime(finished,begin) << endl;
finished = std::chrono::steady_clock::now();
cout << "Processing lasted " << (finished-begin).count()*0.000001 << " ms" << endl;
#ifdef OPTIMIZE
return 0;
#endif
continue; //continue to not get out continue; //continue to not get out
} }
#ifdef NEWZMQ //#ifdef NEWZMQ
if (newFrame) { if (newFrame) {
time(&begin); begin = std::chrono::steady_clock::now();
// t0 = high_resolution_clock::now();
//cout <<"new frame" << endl; size = zHeader.imageSize;//doc["size"].GetUint();
// dynamicRange = zheader.dynamicRange; //doc["bitmode"].GetUint();
// nPixelsX = zHeader.npixelsx; //doc["shape"][0].GetUint();
// nPixelsY = zHeader.npixelsy;// doc["shape"][1].GetUint();
filename = zHeader.fname;//doc["fname"].GetString();
acqIndex = zHeader.acqIndex; //doc["acqIndex"].GetUint64();
// frameIndex = zHeader.frameIndex;//doc["fIndex"].GetUint64();
fileindex = zHeader.fileIndex;//doc["fileIndex"].GetUint64();
expLength = zHeader.expLength;//doc["expLength"].GetUint();
packetNumber=zHeader.packetNumber;//doc["packetNumber"].GetUint();
bunchId=zHeader.bunchId;//doc["bunchId"].GetUint();
timestamp=zHeader.timestamp;//doc["timestamp"].GetUint();
modId=zHeader.modId;//doc["modId"].GetUint();
debug=zHeader.debug;//doc["debug"].GetUint();
// roundRNumber=r.roundRNumber;//doc["roundRNumber"].GetUint();
detType=zHeader.detType;//doc["detType"].GetUint();
version=zHeader.version;//doc["version"].GetUint();
/*document["bitmode"].GetUint(); zHeader.dynamicRange
// acqIndex, frameIndex, subframeIndex, filename, fileindex document["fileIndex"].GetUint64(); zHeader.fileIndex
size = doc["size"].GetUint();
// multisize = size;// * zmqsocket->size();
// dynamicRange = doc["bitmode"].GetUint();
// nPixelsX = doc["shape"][0].GetUint();
// nPixelsY = doc["shape"][1].GetUint();
filename = doc["fname"].GetString();
//acqIndex = doc["acqIndex"].GetUint64();
//frameIndex = doc["fIndex"].GetUint64();
fileindex = doc["fileIndex"].GetUint64();
//subFrameIndex = doc["expLength"].GetUint();
//packetNumber=doc["packetNumber"].GetUint();
//bunchId=doc["bunchId"].GetUint();
//timestamp=doc["timestamp"].GetUint();
//modId=doc["modId"].GetUint();
//debug=doc["debug"].GetUint();
//roundRNumber=doc["roundRNumber"].GetUint();
//detType=doc["detType"].GetUint();
//version=doc["version"].GetUint();
document["detshape"][0].GetUint();
zHeader.ndetx
document["detshape"][1].GetUint();
zHeader.ndety
document["shape"][0].GetUint();
zHeader.npixelsx
document["shape"][1].GetUint();
zHeader.npixelsy
document["size"].GetUint(); zHeader.imageSize
document["acqIndex"].GetUint64(); zHeader.acqIndex
document["frameIndex"].GetUint64(); zHeader.frameIndex
document["fname"].GetString(); zHeader.fname
document["frameNumber"].GetUint64(); zHeader.frameNumber
document["expLength"].GetUint(); zHeader.expLength
document["packetNumber"].GetUint(); zHeader.packetNumber
document["bunchId"].GetUint64(); zHeader.bunchId
document["timestamp"].GetUint64(); zHeader.timestamp
document["modId"].GetUint(); zHeader.modId
document["row"].GetUint(); zHeader.row
document["column"].GetUint(); zHeader.column
document["reserved"].GetUint(); zHeader.reserved
document["debug"].GetUint(); zHeader.debug
document["roundRNumber"].GetUint(); zHeader.roundRNumber
document["detType"].GetUint(); zHeader.detType
document["version"].GetUint(); zHeader.version
document["flippedDataX"].GetUint(); zHeader.flippedDataX
document["quad"].GetUint(); zHeader.quad
document["completeImage"].GetUint(); zHeader.completeImage
*/
//dataSize=size; //dataSize=size;
strcpy(fname,filename.c_str()); //strcpy(fname,filename.c_str());
fname=filename;
// cprintf(BLUE, "Header Info:\n" // cprintf(BLUE, "Header Info:\n"
// "size: %u\n" // "size: %u\n"
// "multisize: %u\n" // "multisize: %u\n"
@ -572,6 +700,8 @@ int main(int argc, char *argv[]) {
// xCoord, yCoord,zCoord, // xCoord, yCoord,zCoord,
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version); // flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
addJsonHeader=zHeader.addJsonHeader;
/* Analog detector commands */ /* Analog detector commands */
//isPedestal=0; //isPedestal=0;
//isFlat=0; //isFlat=0;
@ -579,13 +709,14 @@ int main(int argc, char *argv[]) {
fMode=eFrame; fMode=eFrame;
frameMode_s="frame"; frameMode_s="frame";
cprintf(MAGENTA, "Frame mode: "); cprintf(MAGENTA, "Frame mode: ");
if (doc.HasMember("frameMode")) { // if (doc.HasMember("frameMode")) {
if (doc["frameMode"].IsString()) { if (addJsonHeader.find("frameMode")!= addJsonHeader.end()) {
frameMode_s=doc["frameMode"].GetString(); // if (doc["frameMode"].IsString()) {
frameMode_s=addJsonHeader.at("frameMode");//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;
@ -594,8 +725,8 @@ int main(int argc, char *argv[]) {
mt->newDataSet(); //resets pedestal mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n"); // cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal; fMode=ePedestal;
rms=1;
//isPedestal=1; //isPedestal=1;
rms=1;
} }
#ifdef INTERP #ifdef INTERP
else if (frameMode_s == "flatfield") { else if (frameMode_s == "flatfield") {
@ -607,7 +738,7 @@ int main(int argc, char *argv[]) {
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;
@ -615,21 +746,23 @@ int main(int argc, char *argv[]) {
fMode=eFrame; fMode=eFrame;
frameMode_s="frame"; frameMode_s="frame";
} }
} //}
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str()); }
} else cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setFrameMode(fMode); mt->setFrameMode(fMode);
threshold=0; // threshold=0;
cprintf(MAGENTA, "Threshold: "); cprintf(MAGENTA, "Threshold: ");
if (doc.HasMember("threshold")) { if (addJsonHeader.find("threshold")!= addJsonHeader.end()) {
if (doc["threshold"].IsInt()) { istringstream(addJsonHeader.at("threshold")) >>threshold;
threshold=doc["threshold"].GetInt(); // threshold=atoi(addJsonHeader.at("threshold").c_str());//doc["frameMode"].GetString();
mt->setThreshold(threshold); }
} //if (doc.HasMember("threshold")) {
} //if (doc["threshold"].IsInt()) {
// threshold=doc["threshold"].GetInt();
mt->setThreshold(threshold);
// }
// }
cprintf(MAGENTA, "%d\n", threshold); cprintf(MAGENTA, "%d\n", threshold);
xmin=0; xmin=0;
@ -637,40 +770,47 @@ int main(int argc, char *argv[]) {
ymin=0; ymin=0;
ymax=npy; ymax=npy;
cprintf(MAGENTA, "ROI: "); cprintf(MAGENTA, "ROI: ");
if (doc.HasMember("roi")) {
if (doc["roi"].IsArray()) { if (addJsonHeader.find("roi")!= addJsonHeader.end()) {
if (doc["roi"].Size() > 0 ) istringstream(addJsonHeader.at("roi")) >> xmin >> xmax >> ymin >> ymax ;
if (doc["roi"][0].IsInt()) // if (doc.HasMember("roi")) {
xmin=doc["roi"][0].GetInt(); //if (doc["roi"].IsArray()) {
// if (doc["roi"].Size() > 0 )
// if (doc["roi"][0].IsInt())
// xmin=doc["roi"][0].GetInt();
if (doc["roi"].Size() > 1 ) // if (doc["roi"].Size() > 1 )
if (doc["roi"][1].IsInt()) // if (doc["roi"][1].IsInt())
xmax=doc["roi"][1].GetInt(); // xmax=doc["roi"][1].GetInt();
if (doc["roi"].Size() > 2 ) // if (doc["roi"].Size() > 2 )
if (doc["roi"][2].IsInt()) // if (doc["roi"][2].IsInt())
ymin=doc["roi"][2].GetInt(); // ymin=doc["roi"][2].GetInt();
if (doc["roi"].Size() > 3 ) // if (doc["roi"].Size() > 3 )
if (doc["roi"][3].IsInt()) // if (doc["roi"][3].IsInt())
ymax=doc["roi"][3].GetInt(); // ymax=doc["roi"][3].GetInt();
} // }
} }
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax); cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
mt->setROI(xmin, xmax, ymin, ymax); mt->setROI(xmin, xmax, ymin, ymax);
if (addJsonHeader.find("dynamicRange")!= addJsonHeader.end()) {
if (doc.HasMember("dynamicRange")) { istringstream(addJsonHeader.at("dynamicRange")) >> dr ;
dr=doc["dynamicRange"].GetUint();
dr=32; dr=32;
} }
// if (doc.HasMember("dynamicRange")) {
// dr=doc["dynamicRange"].GetUint();
// dr=32;
// }
dMode=eAnalog; dMode=eAnalog;
detectorMode_s="analog"; detectorMode_s="analog";
cprintf(MAGENTA, "Detector mode: "); cprintf(MAGENTA, "Detector mode: ");
if (doc.HasMember("detectorMode")) { if (addJsonHeader.find("detectorMode")!= addJsonHeader.end()) {;
if (doc["detectorMode"].IsString()) { //if (doc.HasMember("detectorMode")) {
detectorMode_s=doc["detectorMode"].GetString(); //if (doc["detectorMode"].IsString()) {
detectorMode_s=addJsonHeader.at("detectorMode");//=doc["detectorMode"].GetString();
#ifdef INTERP #ifdef INTERP
if (detectorMode_s == "interpolating"){ if (detectorMode_s == "interpolating"){
dMode=eInterpolating; dMode=eInterpolating;
@ -688,13 +828,12 @@ int main(int argc, char *argv[]) {
mt->setInterpolation(NULL); mt->setInterpolation(NULL);
#endif #endif
} }
} // }
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str()); }
} else
cprintf(RED, "%s\n" , frameMode_s.c_str());
mt->setDetectorMode(dMode); mt->setDetectorMode(dMode);
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
// cout << "done " << endl; // cout << "done " << endl;
@ -737,6 +876,21 @@ int main(int argc, char *argv[]) {
// mt->setNSubPixels(nSubPixels); // mt->setNSubPixels(nSubPixels);
// } // }
// threshold=0;
// cprintf(MAGENTA, "Subframes: ");
// subframes=0;
// //isubframe=0;
// insubframe=0;
// subnorm=1;
// f0=0;
// nnsubframe=0;
// if (doc.HasMember("subframes")) {
// if (doc["subframes"].IsInt()) {
// subframes=doc["subframes"].GetInt();
// }
// }
// cprintf(MAGENTA, "%ld\n", subframes);
newFrame=0; newFrame=0;
/* zmqsocket->CloseHeaderMessage();*/ /* zmqsocket->CloseHeaderMessage();*/
@ -745,7 +899,7 @@ int main(int argc, char *argv[]) {
// cout << "file" << endl; // cout << "file" << endl;
// cout << "data " << endl; // cout << "data " << endl;
if (of==NULL && dMode!=eAnalog && fMode!=ePedestal && threshold<=0) { if (of==NULL) {
#ifdef WRITE_QUAD #ifdef WRITE_QUAD
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex); sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
#endif #endif
@ -760,33 +914,100 @@ int main(int argc, char *argv[]) {
mt->setFilePointer(NULL); mt->setFilePointer(NULL);
} }
} }
// cout << "data" << endl; // cout << "data" << endl;
// get data // get data
// acqIndex = doc["acqIndex"].GetUint64(); // acqIndex = doc["acqIndex"].GetUint64();
frameIndex = doc["fIndex"].GetUint64();
frameIndex = zHeader.frameIndex;////doc["fIndex"].GetUint64();
// subFrameIndex = doc["expLength"].GetUint(); // subFrameIndex = doc["expLength"].GetUint();
// bunchId=doc["bunchId"].GetUint(); // bunchId=doc["bunchId"].GetUint();
// timestamp=doc["timestamp"].GetUint(); // timestamp=doc["timestamp"].GetUint();
packetNumber=doc["packetNumber"].GetUint(); packetNumber=zHeader.packetNumber; //doc["packetNumber"].GetUint();
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl; // cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
if (packetNumber>=40) { //cprintf(GREEN, "frame\n");
//*((int*)buff)=frameIndex; if (packetNumber>=40) {
memcpy(buff,&frameIndex,sizeof(int)); //*((int*)buff)=frameIndex;
//length = if (insubframe==0) f0=frameIndex;
zmqsocket->ReceiveData(0, buff+sizeof(int), size); memcpy(buff,&frameIndex,sizeof(int));
mt->pushData(buff); //length =
mt->nextThread(); zmqsocket->ReceiveData(0, buff+sizeof(int), size);
mt->popFree(buff); mt->pushData(buff);
cprintf(GREEN, "Frame\n"); mt->nextThread();
} else { mt->popFree(buff);
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber); insubframe++;
//length = nsubframes=frameIndex+1-f0;
zmqsocket->ReceiveData(0, dummybuff, size); } else {
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
//length =
zmqsocket->ReceiveData(0, dummybuff, size);
}
}
if (subframes>0 && insubframe>=subframes && fMode==eFrame) {
while (mt->isBusy()) {;}//wait until all data are processed from the queues
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
cprintf(MAGENTA,"Get image!\n");
dout= new int32_t[nnx*nny];
doutf= new float[nnx*nny];
if (subframes>0 && insubframe!=subframes && insubframe>0)
subnorm=((double)subframes)/((double)insubframe);
else
subnorm=1.;
for (int ix=0; ix<nnx*nny; ix++) {
dout[ix]=detimage[ix]*subnorm;
if (dout[ix]<0) dout[ix]=0;
doutf[ix]=dout[ix];
}
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
cout << "Writing image to " << ofname << endl;
WriteToTiff(doutf,ofname ,nnx, nny);
nsubframes++;
insubframe=0;
nnsubframe++;
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,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);
zHeader.data = true;
zmqsocket2->SendHeader(0,zHeader);
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
cprintf(GREEN, "Sent subdata\n");
if (dout)
delete [] dout;
dout=NULL;
if (doutf)
delete [] doutf;
doutf=NULL;
mt->clearImage();
}
iframe++; iframe++;
} // exiting infinite loop } // exiting infinite loop

View File

@ -95,7 +95,7 @@ public:
virtual int *getImage() { virtual int *getImage() {
return det->getImage(); return det->getImage();
} }
virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);}; virtual int getImageSize(int &nnx, int &nny, int &ns, int &nsy) {return det->getImageSize(nnx, nny, ns, nsy);};
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;} virtual ~threadedAnalogDetector() {StopThread(); delete fifoFree; delete fifoData;}
@ -123,7 +123,7 @@ public:
return fifoFree->pop(ptr); return fifoFree->pop(ptr);
} }
virtual int isBusy() {return busy;} virtual int isBusy() {if (fifoData->isEmpty() && busy==0) return 0; else return 1;}
//protected: //protected:
/** Implement this method in your subclass with the code you want your thread to run. */ /** Implement this method in your subclass with the code you want your thread to run. */
@ -221,10 +221,10 @@ FILE *getFilePointer(){return det->getFilePointer();};
} }
virtual int setNSubPixels(int ns) { virtual int setNSubPixels(int ns, int nsy) {
slsInterpolation *interp=(det)->getInterpolation(); slsInterpolation *interp=(det)->getInterpolation();
if (interp) return interp->setNSubPixels(ns); if (interp) interp->setNSubPixels(ns, nsy);
else return 1;}; return 1;};
virtual slsInterpolation *setInterpolation(slsInterpolation *f){ virtual slsInterpolation *setInterpolation(slsInterpolation *f){
@ -249,7 +249,7 @@ protected:
} }
void * processData() { void * processData() {
busy=1; // busy=1;
while (!stop) { while (!stop) {
if (fifoData->isEmpty()) { if (fifoData->isEmpty()) {
busy=0; busy=0;
@ -259,6 +259,7 @@ protected:
fifoData->pop(data); //blocking! fifoData->pop(data); //blocking!
det->processData(data); det->processData(data);
fifoFree->push(data); fifoFree->push(data);
//busy=0;
} }
} }
return NULL; return NULL;
@ -313,13 +314,13 @@ public:
virtual void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();}; virtual void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
virtual int *getImage(int &nnx, int &nny, int &ns) { virtual int *getImage(int &nnx, int &nny, int &ns, int &nsy) {
int *img; int *img;
// int nnx, nny, ns; // int nnx, nny, ns;
// int nnx, nny, ns; // int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny,ns); int nn=dets[0]->getImageSize(nnx, nny,ns, nsy);
if (image) { if (image) {
delete image; delete [] image;
image=NULL; image=NULL;
} }
image=new int[nn]; image=new int[nn];
@ -362,10 +363,10 @@ public:
/* dets[ii]->writeImage(tit); */ /* dets[ii]->writeImage(tit); */
/* } */ /* } */
/* #endif */ /* #endif */
int nnx, nny, ns; int nnx, nny, ns, nsy;
getImage(nnx, nny, ns); getImage(nnx, nny, ns,nsy);
//int nnx, nny, ns; //int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny, ns); int nn=dets[0]->getImageSize(nnx, nny, ns, nsy);
float *gm=new float[nn]; float *gm=new float[nn];
if (gm) { if (gm) {
for (int ix=0; ix<nn; ix++) { for (int ix=0; ix<nn; ix++) {

View File

@ -46,7 +46,7 @@ public:
}; };
virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);}; /* virtual int setNSubPixels(int ns) { return (dets[0])->setNSubPixels(ns);}; */
virtual void resetFlatField() {(dets[0])->resetFlatField();}; virtual void resetFlatField() {(dets[0])->resetFlatField();};
@ -69,13 +69,13 @@ public:
virtual int *getImage(int &nnx, int &nny, int &ns) { virtual int *getImage(int &nnx, int &nny, int &nsx, int &nsy) {
if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,ns); if (getInterpolation()==NULL) return multiThreadedAnalogDetector::getImage(nnx,nny,nsx, nsy);
//if one interpolates, the whole image is stored in detector 0; //if one interpolates, the whole image is stored in detector 0;
int *img; int *img;
// int nnx, nny, ns; // int nnx, nny, ns;
// int nnx, nny, ns; // int nnx, nny, ns;
int nn=dets[0]->getImageSize(nnx, nny,ns); int nn=dets[0]->getImageSize(nnx, nny,nsx, nsy);
if (image) { if (image) {
delete image; delete image;
image=NULL; image=NULL;

View File

@ -10,7 +10,7 @@ class pedestalSubtraction {
\param nn number of samples to calculate the moving average (defaults to 1000) \param nn number of samples to calculate the moving average (defaults to 1000)
*/ */
pedestalSubtraction (int nn=1000) : stat(nn) {}; pedestalSubtraction (int nn=1000) : stat(nn) {};
/* void setPointers(double *me, double *va) {mean=me; var=va; stat.setPointers(mean, var);}; */
/** virtual destructorr /** virtual destructorr
*/ */
virtual ~pedestalSubtraction() {}; virtual ~pedestalSubtraction() {};

View File

@ -50,7 +50,6 @@ public analogDetector<uint16_t> {
*/ */
singlePhotonDetector(slsDetectorData<uint16_t> *d, singlePhotonDetector(slsDetectorData<uint16_t> *d,
int csize=3, int csize=3,
@ -58,7 +57,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), eMin(-1), eMax(-1), clusterSize(csize), clusterSizeY(csize), c2(1),c3(1), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
@ -66,13 +65,18 @@ public analogDetector<uint16_t> {
fm=new pthread_mutex_t ; fm=new pthread_mutex_t ;
eventMask=new eventType*[ny]; eventMask=new eventType*[ny];
// val=new double*[ny];
for (int i=0; i<ny; i++) { for (int i=0; i<ny; i++) {
eventMask[i]=new eventType[nx]; eventMask[i]=new eventType[nx];
// val[i]=new double[nx];
} }
if (ny==1) if (ny==1)
clusterSizeY=1; clusterSizeY=1;
c2=sqrt((clusterSizeY+1)/2* (clusterSize+1)/2);
c3=sqrt(clusterSizeY*clusterSize);
// cluster=new single_photon_hit(clusterSize,clusterSizeY); // cluster=new single_photon_hit(clusterSize,clusterSizeY);
clusters=new single_photon_hit[nx*ny]; clusters=new single_photon_hit[nx*ny];
@ -100,8 +104,10 @@ public analogDetector<uint16_t> {
myFile=orig->myFile; myFile=orig->myFile;
eventMask=new eventType*[ny]; eventMask=new eventType*[ny];
// val=new double*[ny];
for (int i=0; i<ny; i++) { for (int i=0; i<ny; i++) {
eventMask[i]=new eventType[nx]; eventMask[i]=new eventType[nx];
// val[i]=new double[nx];
} }
eMin=orig->eMin; eMin=orig->eMin;
eMax=orig->eMax; eMax=orig->eMax;
@ -111,6 +117,10 @@ public analogDetector<uint16_t> {
clusterSize=orig->clusterSize; clusterSize=orig->clusterSize;
clusterSizeY=orig->clusterSizeY; clusterSizeY=orig->clusterSizeY;
// cluster=new single_photon_hit(clusterSize,clusterSizeY); // cluster=new single_photon_hit(clusterSize,clusterSizeY);
c2=sqrt((clusterSizeY+1)/2* (clusterSize+1)/2);
c3=sqrt(clusterSizeY*clusterSize);
clusters=new single_photon_hit[nx*ny]; clusters=new single_photon_hit[nx*ny];
// cluster=clusters; // cluster=clusters;
@ -124,7 +134,9 @@ public analogDetector<uint16_t> {
gmap=orig->gmap; gmap=orig->gmap;
nphTot=0; nphTot=0;
nphFrame=0; nphFrame=0;
nphTot=0;
nphFrame=0;
} }
@ -196,7 +208,6 @@ public analogDetector<uint16_t> {
int nn=0; int nn=0;
double max=0, tl=0, tr=0, bl=0,br=0, v; double max=0, tl=0, tr=0, bl=0,br=0, v;
double rms=0; double rms=0;
int cm=0; int cm=0;
if (cmSub) cm=1; if (cmSub) cm=1;
@ -218,8 +229,8 @@ public analogDetector<uint16_t> {
cout << "add to common mode?"<< endl; cout << "add to common mode?"<< endl;
addToCommonMode(data); addToCommonMode(data);
} }
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)) { if (det->isGood(ix,iy)) {
val=subtractPedestal(data,ix,iy, cm); val=subtractPedestal(data,ix,iy, cm);
@ -236,8 +247,8 @@ public analogDetector<uint16_t> {
} }
} }
for (int iy=ymin; iy<ymax; iy++) { for (iy=ymin; iy<ymax; ++iy) {
for (int ix=xmin; ix<xmax; ix++) { for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)) { if (det->isGood(ix,iy)) {
eventMask[iy][ix]=PEDESTAL; eventMask[iy][ix]=PEDESTAL;
@ -346,18 +357,23 @@ int *getClusters(char *data, int *ph=NULL) {
int nph=0; int nph=0;
double val[ny][nx]; // const int cy=(clusterSizeY+1)/2;
int cy=(clusterSizeY+1)/2; //const int cs=(clusterSize+1)/2;
int cs=(clusterSize+1)/2;
//int ir, ic; //int ir, ic;
eventType ee;
double max=0, tl=0, tr=0, bl=0,br=0, *v; double max=0, tl=0, tr=0, bl=0,br=0, *v;
int cm=0; int cm=0;
int good=1; int good=1;
if (cmSub) cm=1; int ir, ic;
// double quadTot;
//quadrant quad;
double rms;
//if (cmSub) cm=1;
double val[ny][nx];
if (ph==NULL) if (ph==NULL)
ph=image; ph=image;
if (iframe<nDark) { if (iframe<nDark) {
addToPedestal(data); addToPedestal(data);
return 0; return 0;
@ -366,13 +382,15 @@ int *getClusters(char *data, int *ph=NULL) {
if (cm) if (cmSub) {
addToCommonMode(data); addToCommonMode(data);
cm=1;
}
for (iy=ymin; iy<ymax; ++iy) {
for (ix=xmin; ix<xmax; ++ix) {
if (det->isGood(ix,iy)==0) continue;
for (int iy=ymin; iy<ymax; iy++) {
for (int ix=xmin; ix<xmax; ix++) {
if (det->isGood(ix,iy)) {
max=0; max=0;
tl=0; tl=0;
tr=0; tr=0;
@ -384,97 +402,120 @@ int *getClusters(char *data, int *ph=NULL) {
eventMask[iy][ix]=PEDESTAL; //eventMask[iy][ix]
ee=PEDESTAL;
(clusters+nph)->rms=getPedestalRMS(ix,iy); rms=getPedestalRMS(ix,iy);
// cluster=clusters+nph; // cluster=clusters+nph;
// cout << ix << " " << iy << endl;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { for (ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { for (ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) { if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm); val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
v=&(val[iy+ir][ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
} }
v=&(val[iy+ir][ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
if (ir==0 && ic==0) {
if (*v<-nSigma*(clusters+nph)->rms)
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
else if (*v>nSigma*(clusters+nph)->rms)
eventMask[iy][ix]=PHOTON;
}
} }
} }
if (eventMask[iy][ix]==PHOTON && val[iy][ix]<max) /* if (ix==50 && iy==50) */
continue; /* cout << id << " " << ix << " " << iy << " " << det->getValue(data,ix,iy)<< " " << val[iy][ix] << " " << getPedestal(ix,iy) << " " << rms << endl; */
if (val[iy][ix]<-nSigma*rms){
if (bl>=br && bl>=tl && bl>=tr) { ee=NEGATIVE_PEDESTAL;
(clusters+nph)->quad=BOTTOM_LEFT; continue;
(clusters+nph)->quadTot=bl; }
} else if (br>=bl && br>=tl && br>=tr) { if (max>nSigma*rms){
(clusters+nph)->quad=BOTTOM_RIGHT; // cout << "ph1 " << max << " " << nSigma*rms << endl;
(clusters+nph)->quadTot=br; ee=PHOTON;
} else if (tl>=br && tl>=bl && tl>=tr) { if (val[iy][ix]<max)
(clusters+nph)->quad=TOP_LEFT; continue;
(clusters+nph)->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
(clusters+nph)->quad=TOP_RIGHT;
(clusters+nph)->quadTot=tr;
} }
else if (tot>c3*nSigma*rms) {
if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) { // cout << "ph3 " << tot << " " << c3*nSigma*rms << endl;
if (val[iy][ix]>=max) { ee=PHOTON;
eventMask[iy][ix]=PHOTON_MAX; }
(clusters+nph)->tot=tot; #ifndef WRITE_QUAD
(clusters+nph)->x=ix; else {
(clusters+nph)->y=iy; #endif
// (clusters+nph)->iframe=det->getFrameNumber(data); quad=BOTTOM_RIGHT;
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl; quadTot=br;
(clusters+nph)->ped=getPedestal(ix,iy,0); if (bl>=quadTot) {
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { quad=BOTTOM_LEFT;
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { quadTot=bl;
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir); }
if (tl>=quadTot) {
quad=TOP_LEFT;
quadTot=tl;
}
if (tr>=quadTot) {
quad=TOP_RIGHT;
quadTot=tr;
}
if (quadTot>c2*nSigma*rms) {
// cout << "ph2 " << quadTot << " " << c2*nSigma*rms << endl;
ee=PHOTON;
} }
}
good=1;
if (eMin>0 && tot<eMin) good=0;
if (eMax>0 && tot>eMax) good=0;
if (good) {
nph++;
image[iy*nx+ix]++;
}
#ifndef WRITE_QUAD
} else {
eventMask[iy][ix]=PHOTON;
}
} else if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy,cm);
} }
#endif
if (ee==PHOTON && val[iy][ix]==max) {
ee=PHOTON_MAX;
// cout << "**" <<id<< " " << iframe << " " << nDark << " " << ix << " " << iy << " " << rms << " " << max << " " << quadTot << " " << tot << endl;
(clusters+nph)->tot=tot;
(clusters+nph)->x=ix;
(clusters+nph)->y=iy;
(clusters+nph)->quad=quad;
(clusters+nph)->quadTot=quadTot;
//(clusters+nph)->rms=rms;
// (clusters+nph)->iframe=det->getFrameNumber(data);
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
// (clusters+nph)->ped=getPedestal(ix,iy,0);
for (ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx)
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
}
} }
} good=1;
if (eMin>0 && tot<eMin) good=0;
if (eMax>0 && tot>eMax) good=0;
if (good) {
nph++;
image[iy*nx+ix]++;
}
} else if (ee==PEDESTAL) {
addToPedestal(data,ix,iy,cm);
} /*else {
eventMask[iy][ix]=PHOTON;
}*/
//eventMask[iy][ix]=ee;
} }
}
nphFrame=nph; nphFrame=nph;
nphTot+=nph; nphTot+=nph;
//cout << nphFrame << endl; //cout << nphFrame << endl;
// cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl; //cout <<id << " **********************************"<< iframe << " " << det->getFrameNumber(data) << " " << nphFrame << endl;
writeClusters(det->getFrameNumber(data)); writeClusters(det->getFrameNumber(data));
return image; return image;
@ -561,13 +602,20 @@ int *getClusters(char *data, int *ph=NULL) {
*/ */
static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){ static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){
if (nph>0) {
/* #ifndef OLDFORMAT */ #ifndef OLDFORMAT
/* if (fwrite((void*)&fn, 1, sizeof(int), f)) */ if (fwrite((void*)&fn, 1, sizeof(int), f))
/* if (fwrite((void*)&nph, 1, sizeof(int), f)) */ if (fwrite((void*)&nph, 1, sizeof(int), f))
/* #endif */ #endif
for (int i=0; i<nph; i++) (cl+i)->write(f); for (int i=0; i<nph; i++) (cl+i)->write(f);
}; }
};
void writeClusters(FILE *f, int fn=0){ void writeClusters(FILE *f, int fn=0){
writeClusters(f,clusters,nphFrame, fn); writeClusters(f,clusters,nphFrame, fn);
//for (int i=0; i<nphFrame; i++) //for (int i=0; i<nphFrame; i++)
@ -623,6 +671,7 @@ int *getClusters(char *data, int *ph=NULL) {
double eMin, eMax; double eMin, eMax;
int clusterSize; /**< cluster size in the x direction */ int clusterSize; /**< cluster size in the x direction */
int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */ int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */
double c2, c3;
// single_photon_hit *cluster; /**< single photon hit data structure */ // single_photon_hit *cluster; /**< single photon hit data structure */
single_photon_hit *clusters; /**< single photon hit data structure */ single_photon_hit *clusters; /**< single photon hit data structure */
quadrant quad; /**< quadrant where the photon is located */ quadrant quad; /**< quadrant where the photon is located */
@ -631,6 +680,7 @@ int *getClusters(char *data, int *ph=NULL) {
int nphTot; int nphTot;
int nphFrame; int nphFrame;
// double **val;
pthread_mutex_t *fm; pthread_mutex_t *fm;
}; };

View File

@ -36,19 +36,17 @@ class single_photon_hit {
\param myFile file descriptor \param myFile file descriptor
*/ */
size_t write(FILE *myFile) { size_t write(FILE *myFile) {
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); //fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); // if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
#ifdef OLDFORMAT
// if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
//#ifdef OLDFORMAT
if (fwrite((void*)&iframe, 1, sizeof(int), myFile)) {}; if (fwrite((void*)&iframe, 1, sizeof(int), myFile)) {};
//#endif #endif
#ifndef WRITE_QUAD #ifndef WRITE_QUAD
//printf("no quad "); //printf("no quad ");
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile)) if (fwrite((void*)&x, sizeof(int16_t), 2, myFile))
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile); return fwrite((void*)data, sizeof(int), dx*dy, myFile);
#endif #endif
#ifdef WRITE_QUAD #ifdef WRITE_QUAD
// printf("quad "); // printf("quad ");
int qq[4]; int qq[4];
switch(quad) { switch(quad) {
case TOP_LEFT: case TOP_LEFT:
@ -91,8 +89,8 @@ class single_photon_hit {
default: default:
; ;
} }
if (fwrite((void*)&x, 2, sizeof(int16_t), myFile)) if (fwrite((void*)&x, sizeof(int16_t), 2, myFile))
return fwrite((void*)qq, 1, 4*sizeof(int), myFile); return fwrite((void*)qq, sizeof(int), 4, myFile);
#endif #endif
return 0; return 0;
}; };
@ -104,19 +102,19 @@ class single_photon_hit {
size_t read(FILE *myFile) { size_t read(FILE *myFile) {
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); //fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
//#ifdef OLDFORMAT #ifdef OLDFORMAT
if (fread((void*)&iframe, 1, sizeof(int), myFile)) {} if (fread((void*)&iframe, 1, sizeof(int), myFile)) {}
//#endif #endif
#ifndef WRITE_QUAD #ifndef WRITE_QUAD
// printf( "no quad \n"); // printf( "no quad \n");
if (fread((void*)&x, 2, sizeof(int16_t), myFile)) if (fread((void*)&x, sizeof(int16_t),2, myFile))
return fread((void*)data, 1, dx*dy*sizeof(int), myFile); return fread((void*)data, sizeof(int), dx*dy,myFile);
#endif #endif
#ifdef WRITE_QUAD #ifdef WRITE_QUAD
int qq[4]; int qq[4];
// printf( "quad \n"); printf( "quad \n");
if (fread((void*)&x, 2, sizeof(int16_t), myFile)) if (fread((void*)&x, sizeof(int16_t), 2, myFile))
if (fread((void*)qq, 1, 4*sizeof(int), myFile)) { if (fread((void*)qq, sizeof(int), 4, myFile)) {
quad=TOP_RIGHT; quad=TOP_RIGHT;
/* int mm=qq[0]; */ /* int mm=qq[0]; */
@ -216,7 +214,6 @@ class single_photon_hit {
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++) {
printf("%d \t",data[ix+iy*dx]); printf("%d \t",data[ix+iy*dx]);
} }
printf("\n"); printf("\n");
} }
@ -246,15 +243,15 @@ class single_photon_hit {
int *get_cluster() {return data;}; int *get_cluster() {return data;};
int iframe; /**< frame number */ int iframe; /**< frame number */
int16_t x; /**< x-coordinate of the center of hit */
int16_t y; /**< x-coordinate of the center of hit */
double rms; /**< noise of central pixel l -- at some point it can be removed*/ double rms; /**< noise of central pixel l -- at some point it can be removed*/
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/ double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
double tot; /**< sum of the 3x3 cluster */ double tot; /**< sum of the 3x3 cluster */
quadrant quad; /**< quadrant where the photon is located */ quadrant quad; /**< quadrant where the photon is located */
double quadTot; /**< sum of the maximum 2x2cluster */ double quadTot; /**< sum of the maximum 2x2cluster */
int dx; /**< size of data cluster in x */ int dx; /**< size of data cluster in x */
int dy; /**< size of data cluster in y */ int dy; /**< size of data cluster in y */
int16_t x; /**< x-coordinate of the center of hit */
int16_t y; /**< x-coordinate of the center of hit */
int *data; /**< pointer to data */ int *data; /**< pointer to data */
}; };

View File

@ -55,6 +55,149 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="lblCompleteImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Complete Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lblInCompleteImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Missing Packets</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>117</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QWidget" name="widgetStatistics" native="true"> <widget class="QWidget" name="widgetStatistics" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -241,7 +384,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>376</width> <width>376</width>
<height>28</height> <height>27</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuSave"> <widget class="QMenu" name="menuSave">

View File

@ -19,47 +19,8 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="layout"> <layout class="QGridLayout" name="gridLayout">
<property name="margin"> <item row="2" column="0" colspan="4">
<number>6</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QGroupBox" name="boxPlot">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Sample Plot</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="flat">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="plotLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QWidget" name="widgetStatistics" native="true"> <widget class="QWidget" name="widgetStatistics" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -86,73 +47,6 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="6">
<widget class="QLabel" name="lblSum">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Sum: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="lblMinDisp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lblMaxDisp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="0" column="3"> <item row="0" column="3">
<widget class="QLabel" name="lblMax"> <widget class="QLabel" name="lblMax">
<property name="sizePolicy"> <property name="sizePolicy">
@ -181,8 +75,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="7"> <item row="0" column="1">
<widget class="QLabel" name="lblSumDisp"> <widget class="QLabel" name="lblMinDisp">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -194,6 +88,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="lblMin"> <widget class="QLabel" name="lblMin">
<property name="sizePolicy"> <property name="sizePolicy">
@ -222,6 +129,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4">
<widget class="QLabel" name="lblMaxDisp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLabel" name="lblSumDisp">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item row="0" column="5"> <item row="0" column="5">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
@ -235,9 +168,213 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="6">
<widget class="QLabel" name="lblSum">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>Sum: </string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>419</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="4">
<widget class="QGroupBox" name="boxPlot">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
<pointsize>10</pointsize>
</font>
</property>
<property name="title">
<string>Sample Plot</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="plotLayout">
<property name="margin">
<number>9</number>
</property>
<property name="spacing">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lblInCompleteImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Missing Packets</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="lblCompleteImage">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>40</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>150</green>
<blue>110</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>139</red>
<green>142</green>
<blue>142</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Complete Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@ -14,7 +14,8 @@ class qCloneWidget : public QMainWindow, private Ui::ClonePlotObject {
qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2, qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title, SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
QString filePath, QString fileName, int64_t aIndex, QString filePath, QString fileName, int64_t aIndex,
bool displayStats, QString min, QString max, QString sum); bool displayStats, QString min, QString max, QString sum,
bool completeImage);
~qCloneWidget(); ~qCloneWidget();

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "ui_form_dac.h"
#include "Detector.h" #include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "ui_form_dac.h"
#include <string> #include <string>
class qDacWidget : public QWidget, private Ui::WidgetDacObject { class qDacWidget : public QWidget, private Ui::WidgetDacObject {

View File

@ -6,9 +6,9 @@
#include <QMessageBox> #include <QMessageBox>
#include <chrono> #include <chrono>
#include <cstdint>
#include <iostream> #include <iostream>
#include <ostream> #include <ostream>
#include <cstdint>
#include <string> #include <string>
using std::chrono::duration; using std::chrono::duration;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "ui_form_detectormain.h"
#include "qDefs.h"
#include "Detector.h" #include "Detector.h"
#include "qDefs.h"
#include "ui_form_detectormain.h"
#include <QTabWidget> #include <QTabWidget>
class qDrawPlot; class qDrawPlot;
@ -29,7 +29,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
Q_OBJECT Q_OBJECT
public: public:
qDetectorMain(int multiId, const std::string& fname, bool isDevel); qDetectorMain(int multiId, const std::string &fname, bool isDevel);
~qDetectorMain(); ~qDetectorMain();
private slots: private slots:
@ -51,9 +51,9 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
private: private:
void SetUpWidgetWindow(); void SetUpWidgetWindow();
void SetUpDetector(const std::string& config_file, int multiID); void SetUpDetector(const std::string &config_file, int multiID);
void Initialization(); void Initialization();
void LoadConfigFile(const std::string& config_file); void LoadConfigFile(const std::string &config_file);
/** enumeration of the tabs */ /** enumeration of the tabs */
enum { enum {
@ -70,7 +70,7 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
slsDetectorDefs::detectorType detType; slsDetectorDefs::detectorType detType;
std::unique_ptr<sls::Detector> det; std::unique_ptr<sls::Detector> det;
qDrawPlot *plot; qDrawPlot *plot;
MyTabWidget* tabs; MyTabWidget *tabs;
std::unique_ptr<QScrollArea> scroll[NumberOfTabs]; std::unique_ptr<QScrollArea> scroll[NumberOfTabs];
qTabMeasurement *tabMeasurement; qTabMeasurement *tabMeasurement;
qTabDataOutput *tabDataOutput; qTabDataOutput *tabDataOutput;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "ui_form_plot.h"
#include "qDefs.h"
#include "Detector.h" #include "Detector.h"
#include "qDefs.h"
#include "ui_form_plot.h"
#include <mutex> #include <mutex>
class SlsQt1DPlot; class SlsQt1DPlot;
@ -59,11 +59,9 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
private slots: private slots:
void SetSaveFileName(QString val); void SetSaveFileName(QString val);
void AcquireThread();
void UpdatePlot(); void UpdatePlot();
signals: signals:
void StartAcquireSignal();
void AcquireFinishedSignal(); void AcquireFinishedSignal();
void AbortSignal(); void AbortSignal();
void UpdateSignal(); void UpdateSignal();
@ -74,6 +72,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetupPlots(); void SetupPlots();
void GetStatistics(double &min, double &max, double &sum); void GetStatistics(double &min, double &max, double &sum);
void DetachHists(); void DetachHists();
void AcquireThread();
static void GetAcquisitionFinishedCallBack(double currentProgress, static void GetAcquisitionFinishedCallBack(double currentProgress,
int detectorStatus, int detectorStatus,
void *this_pointer); void *this_pointer);
@ -114,6 +113,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
QString zTitle2d{"Intensity"}; QString zTitle2d{"Intensity"};
QString plotTitle{""}; QString plotTitle{""};
QString indexTitle{""}; QString indexTitle{""};
bool completeImage{false};
bool xyRangeChanged{false}; bool xyRangeChanged{false};
double xyRange[4]{0, 0, 0, 0}; double xyRange[4]{0, 0, 0, 0};
bool isXYRange[4]{false, false, false, false}; bool isXYRange[4]{false, false, false, false};

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui_form_tab_advanced.h"
#include "Detector.h" #include "Detector.h"
#include "ui_form_tab_advanced.h"
class qDrawPlot; class qDrawPlot;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui_form_tab_dataoutput.h"
#include "Detector.h" #include "Detector.h"
#include "ui_form_tab_dataoutput.h"
class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject { class qTabDataOutput : public QWidget, private Ui::TabDataOutputObject {
Q_OBJECT Q_OBJECT

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui_form_tab_debugging.h"
#include "Detector.h" #include "Detector.h"
#include "ui_form_tab_debugging.h"
class QTreeWidget; class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "ui_form_tab_developer.h"
#include "Detector.h" #include "Detector.h"
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#include "ui_form_tab_developer.h"
#include <vector> #include <vector>
class qDacWidget; class qDacWidget;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui_form_tab_measurement.h"
#include "Detector.h" #include "Detector.h"
#include "ui_form_tab_measurement.h"
class qDrawPlot; class qDrawPlot;
class QStandardItemModel; class QStandardItemModel;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui_form_tab_plot.h"
#include "Detector.h" #include "Detector.h"
#include "ui_form_tab_plot.h"
class qDrawPlot; class qDrawPlot;
class QButtonGroup; class QButtonGroup;

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "ui_form_tab_settings.h"
#include "Detector.h" #include "Detector.h"
#include "ui_form_tab_settings.h"
class qTabSettings : public QWidget, private Ui::TabSettingsObject { class qTabSettings : public QWidget, private Ui::TabSettingsObject {
Q_OBJECT Q_OBJECT

View File

@ -1,8 +1,8 @@
#ifndef SLSQT1DPLOT_H #ifndef SLSQT1DPLOT_H
#define SLSQT1DPLOT_H #define SLSQT1DPLOT_H
#include "ansi.h"
#include "SlsQt1DZoomer.h" #include "SlsQt1DZoomer.h"
#include "ansi.h"
#include <qwt_plot.h> #include <qwt_plot.h>
#include <qwt_plot_curve.h> #include <qwt_plot_curve.h>
#include <qwt_plot_marker.h> #include <qwt_plot_marker.h>

View File

@ -1,9 +1,9 @@
#ifndef SLSQT2DZOOMER_H #ifndef SLSQT2DZOOMER_H
#define SLSQT2DZOOMER_H #define SLSQT2DZOOMER_H
#include "SlsQt2DHist.h" #include "SlsQt2DHist.h"
#include <cstdio>
#include <qwt_plot_panner.h> #include <qwt_plot_panner.h>
#include <qwt_plot_zoomer.h> #include <qwt_plot_zoomer.h>
#include <cstdio>
class SlsQt2DZoomer : public QwtPlotZoomer { class SlsQt2DZoomer : public QwtPlotZoomer {
private: private:

View File

@ -1,7 +1,7 @@
/* TODO! short description */ /* TODO! short description */
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include <qwt_symbol.h> #include <iostream>
#include <qwt_legend.h> #include <qwt_legend.h>
#include <qwt_math.h> #include <qwt_math.h>
#include <qwt_painter.h> #include <qwt_painter.h>
@ -10,8 +10,8 @@
#include <qwt_scale_draw.h> #include <qwt_scale_draw.h>
#include <qwt_scale_engine.h> #include <qwt_scale_engine.h>
#include <qwt_scale_widget.h> #include <qwt_scale_widget.h>
#include <qwt_symbol.h>
#include <stdlib.h> #include <stdlib.h>
#include <iostream>
#define QwtLog10ScaleEngine QwtLogScaleEngine // hmm #define QwtLog10ScaleEngine QwtLogScaleEngine // hmm
@ -314,7 +314,8 @@ void SlsQtH1DList::Remove(SlsQtH1D *hist) {
hl = hl->the_next; hl = hl->the_next;
else { // match else { // match
if (!hl->the_next) if (!hl->the_next)
hl->the_hist = nullptr; // first the_hist is zero when there's no next hl->the_hist =
nullptr; // first the_hist is zero when there's no next
else { else {
SlsQtH1DList *t = hl->the_next; SlsQtH1DList *t = hl->the_next;
hl->the_hist = t->the_hist; hl->the_hist = t->the_hist;

View File

@ -1,9 +1,9 @@
/* TODO! short description */ /* TODO! short description */
#include "SlsQt1DZoomer.h" #include "SlsQt1DZoomer.h"
#include "SlsQt1DPlot.h" #include "SlsQt1DPlot.h"
#include <iostream>
#include <qwt_plot.h> #include <qwt_plot.h>
#include <qwt_scale_div.h> #include <qwt_scale_div.h>
#include <iostream>
void SlsQt1DZoomer::ResetZoomBase() { void SlsQt1DZoomer::ResetZoomBase() {
SetZoomBase(x0, y0, x1 - x0, SetZoomBase(x0, y0, x1 - x0,

View File

@ -216,7 +216,7 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(QVector<double> colourStops) {
} }
QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) { QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
QVector<double> cs{0.0, 0.34, 0.61 ,0.84, 1.0}; QVector<double> cs{0.0, 0.34, 0.61, 0.84, 1.0};
if (log) { if (log) {
for (int i = 0; i < cs.size(); ++i) for (int i = 0; i < cs.size(); ++i)
cs[i] = (pow(10, 2 * cs[i]) - 1) / 99.0; cs[i] = (pow(10, 2 * cs[i]) - 1) / 99.0;
@ -224,7 +224,6 @@ QwtLinearColorMap *SlsQt2DPlot::myColourMap(int log) {
return myColourMap(cs); return myColourMap(cs);
} }
void SlsQt2DPlot::Update() { void SlsQt2DPlot::Update() {
if (isLog) if (isLog)
hist->SetMinimumToFirstGreaterThanZero(); hist->SetMinimumToFirstGreaterThanZero();

View File

@ -15,13 +15,20 @@ qCloneWidget::qCloneWidget(QWidget *parent, SlsQt1DPlot *p1, SlsQt2DPlot *p2,
SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title, SlsQt1DPlot *gp1, SlsQt2DPlot *gp, QString title,
QString fPath, QString fName, int64_t aIndex, QString fPath, QString fName, int64_t aIndex,
bool displayStats, QString min, QString max, bool displayStats, QString min, QString max,
QString sum) QString sum, bool completeImage)
: QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1), : QMainWindow(parent), plot1d(p1), plot2d(p2), gainplot1d(gp1),
gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) { gainplot2d(gp), filePath(fPath), fileName(fName), acqIndex(aIndex) {
setupUi(this); setupUi(this);
id = qCloneWidget::NumClones++; id = qCloneWidget::NumClones++;
SetupWidgetWindow(title); SetupWidgetWindow(title);
DisplayStats(displayStats, min, max, sum); DisplayStats(displayStats, min, max, sum);
lblCompleteImage->hide();
lblInCompleteImage->hide();
if (completeImage) {
lblCompleteImage->show();
} else {
lblInCompleteImage->show();
}
} }
qCloneWidget::~qCloneWidget() { qCloneWidget::~qCloneWidget() {

View File

@ -1,7 +1,6 @@
#include "qDacWidget.h" #include "qDacWidget.h"
#include "qDefs.h" #include "qDefs.h"
qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d, qDacWidget::qDacWidget(QWidget *parent, sls::Detector *detector, bool d,
std::string n, slsDetectorDefs::dacIndex i) std::string n, slsDetectorDefs::dacIndex i)
: QWidget(parent), det(detector), isDac(d), index(i) { : QWidget(parent), det(detector), isDac(d), index(i) {
@ -56,8 +55,8 @@ void qDacWidget::GetDac() {
void qDacWidget::SetDac() { void qDacWidget::SetDac() {
int val = (int)spinDac->value(); int val = (int)spinDac->value();
LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() LOG(logINFO) << "Setting dac:" << lblDac->text().toAscii().data() << " : "
<< " : " << val; << val;
try { try {
det->setDAC(index, val, 0, {detectorIndex}); det->setDAC(index, val, 0, {detectorIndex});

View File

@ -19,8 +19,8 @@
#include <QScrollArea> #include <QScrollArea>
#include <QSizePolicy> #include <QSizePolicy>
#include <string>
#include <getopt.h> #include <getopt.h>
#include <string>
#include <sys/stat.h> #include <sys/stat.h>
int main(int argc, char **argv) { int main(int argc, char **argv) {
@ -57,8 +57,7 @@ int main(int argc, char **argv) {
case 'f': case 'f':
fname = optarg; fname = optarg;
LOG(logDEBUG) LOG(logDEBUG) << long_options[option_index].name << " " << optarg;
<< long_options[option_index].name << " " << optarg;
break; break;
case 'd': case 'd':
@ -72,7 +71,7 @@ int main(int argc, char **argv) {
case 'v': case 'v':
tempval = APIGUI; tempval = APIGUI;
LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x" LOG(logINFO) << "SLS Detector GUI " << GITBRANCH << " (0x"
<< std::hex << tempval << ")"; << std::hex << tempval << ")";
return 0; return 0;
case 'h': case 'h':
@ -93,7 +92,7 @@ int main(int argc, char **argv) {
} }
QApplication app(argc, argv); QApplication app(argc, argv);
app.setStyle(new QPlastiqueStyle); //style is deleted by QApplication app.setStyle(new QPlastiqueStyle); // style is deleted by QApplication
try { try {
qDetectorMain det(multiId, fname, isDeveloper); qDetectorMain det(multiId, fname, isDeveloper);
det.show(); det.show();
@ -105,18 +104,18 @@ int main(int argc, char **argv) {
return 0; return 0;
} }
qDetectorMain::qDetectorMain(int multiId, const std::string& fname, bool isDevel) qDetectorMain::qDetectorMain(int multiId, const std::string &fname,
: QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC), isDeveloper(isDevel), bool isDevel)
heightPlotWindow(0), heightCentralWidget(0) { : QMainWindow(nullptr), detType(slsDetectorDefs::GENERIC),
isDeveloper(isDevel), heightPlotWindow(0), heightCentralWidget(0) {
setupUi(this); setupUi(this);
SetUpDetector(fname, multiId); SetUpDetector(fname, multiId);
SetUpWidgetWindow(); SetUpWidgetWindow();
} }
qDetectorMain::~qDetectorMain(){ qDetectorMain::~qDetectorMain() {
disconnect(tabs, SIGNAL(currentChanged(int)), this, disconnect(tabs, SIGNAL(currentChanged(int)), this, SLOT(Refresh(int)));
SLOT(Refresh(int)));
} }
void qDetectorMain::SetUpWidgetWindow() { void qDetectorMain::SetUpWidgetWindow() {
@ -132,8 +131,7 @@ void qDetectorMain::SetUpWidgetWindow() {
layoutTabs->addWidget(tabs); layoutTabs->addWidget(tabs);
// creating all the other tab widgets // creating all the other tab widgets
tabMeasurement = tabMeasurement = new qTabMeasurement(this, det.get(), plot);
new qTabMeasurement(this, det.get(), plot);
tabDataOutput = new qTabDataOutput(this, det.get()); tabDataOutput = new qTabDataOutput(this, det.get());
tabPlot = new qTabPlot(this, det.get(), plot); tabPlot = new qTabPlot(this, det.get(), plot);
tabSettings = new qTabSettings(this, det.get()); tabSettings = new qTabSettings(this, det.get());
@ -206,7 +204,7 @@ void qDetectorMain::SetUpWidgetWindow() {
Initialization(); Initialization();
} }
void qDetectorMain::SetUpDetector(const std::string& config_file, int multiID) { void qDetectorMain::SetUpDetector(const std::string &config_file, int multiID) {
// instantiate detector and set window title // instantiate detector and set window title
det = sls::make_unique<sls::Detector>(multiID); det = sls::make_unique<sls::Detector>(multiID);
@ -260,8 +258,8 @@ void qDetectorMain::Initialization() {
// Measurement tab // Measurement tab
connect(tabMeasurement, SIGNAL(EnableTabsSignal(bool)), this, connect(tabMeasurement, SIGNAL(EnableTabsSignal(bool)), this,
SLOT(EnableTabs(bool))); SLOT(EnableTabs(bool)));
connect(tabMeasurement, SIGNAL(FileNameChangedSignal(QString)), connect(tabMeasurement, SIGNAL(FileNameChangedSignal(QString)), plot,
plot, SLOT(SetSaveFileName(QString))); SLOT(SetSaveFileName(QString)));
// Plot tab // Plot tab
connect(tabPlot, SIGNAL(DisableZoomSignal(bool)), this, connect(tabPlot, SIGNAL(DisableZoomSignal(bool)), this,
SLOT(SetZoomToolTip(bool))); SLOT(SetZoomToolTip(bool)));
@ -269,8 +267,7 @@ void qDetectorMain::Initialization() {
// Plotting // Plotting
connect(plot, SIGNAL(AcquireFinishedSignal()), tabMeasurement, connect(plot, SIGNAL(AcquireFinishedSignal()), tabMeasurement,
SLOT(AcquireFinished())); SLOT(AcquireFinished()));
connect(plot, SIGNAL(AbortSignal()), tabMeasurement, connect(plot, SIGNAL(AbortSignal()), tabMeasurement, SLOT(AbortAcquire()));
SLOT(AbortAcquire()));
// menubar // menubar
// Modes Menu // Modes Menu
@ -284,7 +281,7 @@ void qDetectorMain::Initialization() {
SLOT(ExecuteHelp(QAction *))); SLOT(ExecuteHelp(QAction *)));
} }
void qDetectorMain::LoadConfigFile(const std::string& config_file) { void qDetectorMain::LoadConfigFile(const std::string &config_file) {
LOG(logINFO) << "Loading config file at start up:" << config_file; LOG(logINFO) << "Loading config file at start up:" << config_file;
@ -372,8 +369,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
"The Configuration Parameters have been " "The Configuration Parameters have been "
"configured successfully.", "configured successfully.",
"qDetectorMain::ExecuteUtilities"); "qDetectorMain::ExecuteUtilities");
LOG(logINFO) LOG(logINFO) << "Configuration Parameters loaded successfully";
<< "Configuration Parameters loaded successfully";
} }
} }
@ -438,7 +434,7 @@ void qDetectorMain::ExecuteUtilities(QAction *action) {
void qDetectorMain::ExecuteHelp(QAction *action) { void qDetectorMain::ExecuteHelp(QAction *action) {
if (action == actionAbout) { if (action == actionAbout) {
LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, " LOG(logINFO) << "About Common GUI for Jungfrau, Eiger, Mythen3, "
"Gotthard, Gotthard2 and Moench detectors"; "Gotthard, Gotthard2 and Moench detectors";
std::string guiVersion = std::to_string(APIGUI); std::string guiVersion = std::to_string(APIGUI);
std::string clientVersion = "unknown"; std::string clientVersion = "unknown";

View File

@ -51,16 +51,16 @@ void qDrawPlot::SetupWidgetWindow() {
gainMask = (3 << 14); gainMask = (3 << 14);
gainOffset = 14; gainOffset = 14;
LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Mask:" << gainMask
<< ", Gain Offset:" << std::dec << gainOffset; << ", Gain Offset:" << std::dec << gainOffset;
break; break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
pixelMask = ((1 << 12) - 1); pixelMask = ((1 << 12) - 1);
gainMask = (3 << 12); gainMask = (3 << 12);
gainOffset = 12; gainOffset = 12;
LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask LOG(logINFO) << "Pixel Mask: " << std::hex << pixelMask
<< ", Gain Mask:" << gainMask << ", Gain Mask:" << gainMask
<< ", Gain Offset:" << std::dec << gainOffset; << ", Gain Offset:" << std::dec << gainOffset;
break; break;
default: default:
break; break;
@ -87,7 +87,6 @@ void qDrawPlot::SetupWidgetWindow() {
void qDrawPlot::Initialization() { void qDrawPlot::Initialization() {
connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot())); connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot()));
connect(this, SIGNAL(StartAcquireSignal()), this, SLOT(AcquireThread()));
} }
void qDrawPlot::SetupPlots() { void qDrawPlot::SetupPlots() {
@ -97,27 +96,13 @@ void qDrawPlot::SetupPlots() {
slsDetectorDefs::xy res = det->getDetectorSize(); slsDetectorDefs::xy res = det->getDetectorSize();
nPixelsX = res.x; nPixelsX = res.x;
nPixelsY = res.y; nPixelsY = res.y;
switch (detType) {
case slsDetectorDefs::EIGER:
try {
if (det->getQuad().tsquash("Inconsistent values for quad type")) {
nPixelsX /= 2;
nPixelsY *= 2;
if (nPixelsX != nPixelsY) {
--nPixelsX;
}
}
}
CATCH_DISPLAY("Could not get quad.", "qDrawPlot::SetupPlots")
break;
default:
break;
}
LOG(logINFO) << "nPixelsX:" << nPixelsX; LOG(logINFO) << "nPixelsX:" << nPixelsX;
LOG(logINFO) << "nPixelsY:" << nPixelsY; LOG(logINFO) << "nPixelsY:" << nPixelsY;
boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal)); boxPlot->setFont(QFont("Sans Serif", qDefs::Q_FONT_SIZE, QFont::Normal));
widgetStatistics->hide(); widgetStatistics->hide();
lblCompleteImage->hide();
lblInCompleteImage->hide();
// setup 1d data // setup 1d data
@ -292,8 +277,7 @@ void qDrawPlot::SetPlotTitlePrefix(QString title) {
} }
void qDrawPlot::SetXAxisTitle(QString title) { void qDrawPlot::SetXAxisTitle(QString title) {
LOG(logINFO) << "Setting X Axis Title to " LOG(logINFO) << "Setting X Axis Title to " << title.toAscii().constData();
<< title.toAscii().constData();
if (is1d) { if (is1d) {
xTitle1d = title; xTitle1d = title;
} else { } else {
@ -302,8 +286,7 @@ void qDrawPlot::SetXAxisTitle(QString title) {
} }
void qDrawPlot::SetYAxisTitle(QString title) { void qDrawPlot::SetYAxisTitle(QString title) {
LOG(logINFO) << "Setting Y Axis Title to " LOG(logINFO) << "Setting Y Axis Title to " << title.toAscii().constData();
<< title.toAscii().constData();
if (is1d) { if (is1d) {
yTitle1d = title; yTitle1d = title;
} else { } else {
@ -312,8 +295,7 @@ void qDrawPlot::SetYAxisTitle(QString title) {
} }
void qDrawPlot::SetZAxisTitle(QString title) { void qDrawPlot::SetZAxisTitle(QString title) {
LOG(logINFO) << "Setting Z Axis Title to " LOG(logINFO) << "Setting Z Axis Title to " << title.toAscii().constData();
<< title.toAscii().constData();
zTitle2d = title; zTitle2d = title;
} }
@ -324,8 +306,8 @@ void qDrawPlot::SetXYRangeChanged(bool disable, double *xy, bool *isXY) {
std::copy(xy, xy + 4, xyRange); std::copy(xy, xy + 4, xyRange);
std::copy(isXY, isXY + 4, isXYRange); std::copy(isXY, isXY + 4, isXYRange);
LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha LOG(logDEBUG) << "Setting Disable zoom to " << std::boolalpha << disable
<< disable << std::noboolalpha; << std::noboolalpha;
disableZoom = disable; disableZoom = disable;
} }
@ -363,22 +345,26 @@ double qDrawPlot::GetYMaximum() {
} }
void qDrawPlot::SetDataCallBack(bool enable) { void qDrawPlot::SetDataCallBack(bool enable) {
LOG(logINFO) << "Setting data call back to " << std::boolalpha LOG(logINFO) << "Setting data call back to " << std::boolalpha << enable
<< enable << std::noboolalpha; << std::noboolalpha;
if (enable) { try {
isPlot = true; if (enable) {
det->setRxZmqDataStream(true); isPlot = true;
det->registerDataCallback(&(GetDataCallBack), this); det->registerDataCallback(&(GetDataCallBack), this);
} else { det->setRxZmqDataStream(true);
isPlot = false; } else {
det->setRxZmqDataStream(false); isPlot = false;
det->registerDataCallback(nullptr, this); det->registerDataCallback(nullptr, this);
det->setRxZmqDataStream(false);
}
} }
CATCH_DISPLAY("Could not get set rxr data streaming enable.",
"qDrawPlot::SetDataCallBack")
} }
void qDrawPlot::SetBinary(bool enable, int from, int to) { void qDrawPlot::SetBinary(bool enable, int from, int to) {
LOG(logINFO) << (enable ? "Enabling" : "Disabling") LOG(logINFO) << (enable ? "Enabling" : "Disabling")
<< " Binary output from " << from << " to " << to; << " Binary output from " << from << " to " << to;
binaryFrom = from; binaryFrom = from;
binaryTo = to; binaryTo = to;
isBinary = enable; isBinary = enable;
@ -392,7 +378,7 @@ void qDrawPlot::SetPersistency(int val) {
void qDrawPlot::SetLines(bool enable) { void qDrawPlot::SetLines(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable LOG(logINFO) << "Setting Lines to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
isLines = enable; isLines = enable;
for (int i = 0; i < nHists; ++i) { for (int i = 0; i < nHists; ++i) {
SlsQtH1D *h = hists1d.at(i); SlsQtH1D *h = hists1d.at(i);
@ -403,7 +389,7 @@ void qDrawPlot::SetLines(bool enable) {
void qDrawPlot::SetMarkers(bool enable) { void qDrawPlot::SetMarkers(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable LOG(logINFO) << "Setting Markers to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
isMarkers = enable; isMarkers = enable;
for (int i = 0; i < nHists; ++i) { for (int i = 0; i < nHists; ++i) {
SlsQtH1D *h = hists1d.at(i); SlsQtH1D *h = hists1d.at(i);
@ -414,28 +400,28 @@ void qDrawPlot::SetMarkers(bool enable) {
void qDrawPlot::Set1dLogY(bool enable) { void qDrawPlot::Set1dLogY(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable LOG(logINFO) << "Setting Log Y to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
plot1d->SetLogY(enable); plot1d->SetLogY(enable);
} }
void qDrawPlot::SetInterpolate(bool enable) { void qDrawPlot::SetInterpolate(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable LOG(logINFO) << "Setting Interpolate to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
plot2d->SetInterpolate(enable); plot2d->SetInterpolate(enable);
} }
void qDrawPlot::SetContour(bool enable) { void qDrawPlot::SetContour(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable LOG(logINFO) << "Setting Countour to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
plot2d->SetContour(enable); plot2d->SetContour(enable);
} }
void qDrawPlot::SetLogz(bool enable) { void qDrawPlot::SetLogz(bool enable) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable LOG(logINFO) << "Setting Log Z to " << std::boolalpha << enable
<< std::noboolalpha; << std::noboolalpha;
plot2d->SetLogz(enable, isZRange[0], isZRange[1], zRange[0], zRange[1]); plot2d->SetLogz(enable, isZRange[0], isZRange[1], zRange[0], zRange[1]);
} }
@ -467,7 +453,7 @@ void qDrawPlot::ResetAccumulate() {
void qDrawPlot::DisplayStatistics(bool enable) { void qDrawPlot::DisplayStatistics(bool enable) {
LOG(logINFO) << (enable ? "Enabling" : "Disabling") LOG(logINFO) << (enable ? "Enabling" : "Disabling")
<< " Statistics Display"; << " Statistics Display";
displayStatistics = enable; displayStatistics = enable;
} }
@ -483,7 +469,7 @@ void qDrawPlot::EnableGainPlot(bool enable) {
void qDrawPlot::SetSaveFileName(QString val) { void qDrawPlot::SetSaveFileName(QString val) {
LOG(logDEBUG) << "Setting Clone/Save File Name to " LOG(logDEBUG) << "Setting Clone/Save File Name to "
<< val.toAscii().constData(); << val.toAscii().constData();
fileSaveName = val; fileSaveName = val;
} }
@ -582,8 +568,8 @@ void qDrawPlot::ClonePlot() {
new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot1D, new qCloneWidget(this, cloneplot1D, cloneplot2D, clonegainplot1D,
clonegainplot2D, boxPlot->title(), fileSavePath, clonegainplot2D, boxPlot->title(), fileSavePath,
fileSaveName, currentAcqIndex, displayStatistics, fileSaveName, currentAcqIndex, displayStatistics,
lblMinDisp->text(), lblMaxDisp->text(), lblMinDisp->text(), lblMaxDisp->text(), lblSumDisp->text(),
lblSumDisp->text()); completeImage);
} }
void qDrawPlot::SavePlot() { void qDrawPlot::SavePlot() {
@ -668,7 +654,8 @@ void qDrawPlot::StartAcquisition() {
xyRangeChanged = true; xyRangeChanged = true;
} }
emit StartAcquireSignal(); QtConcurrent::run(this, &qDrawPlot::AcquireThread);
LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot"; LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot";
} }
@ -684,8 +671,7 @@ void qDrawPlot::AcquireThread() {
// exception in acquire will not call acquisition finished call back, so // exception in acquire will not call acquisition finished call back, so
// handle it // handle it
if (!mess.empty()) { if (!mess.empty()) {
LOG(logERROR) << "Acquisition Finished with an exception: " LOG(logERROR) << "Acquisition Finished with an exception: " << mess;
<< mess;
qDefs::ExceptionMessage("Acquire unsuccessful.", mess, qDefs::ExceptionMessage("Acquire unsuccessful.", mess,
"qDrawPlot::AcquireFinished"); "qDrawPlot::AcquireFinished");
try { try {
@ -731,7 +717,7 @@ void qDrawPlot::AcquisitionFinished(double currentProgress,
LOG(logERROR) << "Acquisition finished [Status: ERROR]"; LOG(logERROR) << "Acquisition finished [Status: ERROR]";
} else { } else {
LOG(logINFO) << "Acquisition finished [ Status:" << status LOG(logINFO) << "Acquisition finished [ Status:" << status
<< ", Progress: " << currentProgress << " ]"; << ", Progress: " << currentProgress << " ]";
} }
emit AcquireFinishedSignal(); emit AcquireFinishedSignal();
} }
@ -740,26 +726,26 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
uint32_t subFrameIndex) { uint32_t subFrameIndex) {
std::lock_guard<std::mutex> lock(mPlots); std::lock_guard<std::mutex> lock(mPlots);
LOG(logDEBUG) << "* GetData Callback *" << std::endl LOG(logDEBUG) << "* GetData Callback *" << std::endl
<< " frame index: " << frameIndex << std::endl << " frame index: " << frameIndex << std::endl
<< " sub frame index: " << " sub frame index: "
<< (((int)subFrameIndex == -1) ? (int)-1 : subFrameIndex) << (((int)subFrameIndex == -1) ? (int)-1 : subFrameIndex)
<< std::endl << std::endl
<< " Data [" << std::endl << " Data [" << std::endl
<< " \t progress: " << data->progressIndex << std::endl << " \t progress: " << data->progressIndex << std::endl
<< " \t file name: " << data->fileName << std::endl << " \t file name: " << data->fileName << std::endl
<< " \t nx: " << data->nx << std::endl << " \t nx: " << data->nx << std::endl
<< " \t ny: " << data->ny << std::endl << " \t ny: " << data->ny << std::endl
<< " \t data bytes: " << data->databytes << std::endl << " \t data bytes: " << data->databytes << std::endl
<< " \t dynamic range: " << data->dynamicRange << " \t dynamic range: " << data->dynamicRange << std::endl
<< std::endl << " \t file index: " << data->fileIndex << std::endl
<< " \t file index: " << data->fileIndex << std::endl << " \t complete image: " << data->completeImage << std::endl
<< " ]"; << " ]";
progress = (int)data->progressIndex; progress = (int)data->progressIndex;
currentAcqIndex = data->fileIndex; currentAcqIndex = data->fileIndex;
currentFrame = frameIndex; currentFrame = frameIndex;
LOG(logDEBUG) << "[ Progress:" << progress LOG(logDEBUG) << "[ Progress:" << progress << ", Frame:" << currentFrame
<< ", Frame:" << currentFrame << " ]"; << " ]";
// 2d (only image, not gain data, not pedestalvals), // 2d (only image, not gain data, not pedestalvals),
// check if npixelsX and npixelsY is the same (quad is different) // check if npixelsX and npixelsY is the same (quad is different)
@ -767,12 +753,17 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
static_cast<int>(nPixelsY) != data->ny)) { static_cast<int>(nPixelsY) != data->ny)) {
nPixelsX = data->nx; nPixelsX = data->nx;
nPixelsY = data->ny; nPixelsY = data->ny;
LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:" LOG(logINFO) << "Change in Detector Shape:\n\tnPixelsX:" << nPixelsX
<< nPixelsX << " nPixelsY:" << nPixelsY; << " nPixelsY:" << nPixelsY;
delete[] data2d; delete[] data2d;
data2d = new double[nPixelsY * nPixelsX]; data2d = new double[nPixelsY * nPixelsX];
std::fill(data2d, data2d + nPixelsX * nPixelsY, 0); std::fill(data2d, data2d + nPixelsX * nPixelsY, 0);
if (gainData) {
delete[] gainData;
gainData = new double[nPixelsY * nPixelsX];
std::fill(gainData, gainData + nPixelsX * nPixelsY, 0);
}
} }
// convert data to double // convert data to double
@ -795,6 +786,7 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
if ((int)subFrameIndex != -1) { if ((int)subFrameIndex != -1) {
indexTitle = QString("%1 %2").arg(frameIndex, subFrameIndex); indexTitle = QString("%1 %2").arg(frameIndex, subFrameIndex);
} }
completeImage = data->completeImage;
// reset pedestal // reset pedestal
if (resetPedestal) { if (resetPedestal) {
@ -819,8 +811,8 @@ void qDrawPlot::GetData(detectorData *data, uint64_t frameIndex,
} }
// calculate the pedestal value // calculate the pedestal value
if (pedestalCount == NUM_PEDESTAL_FRAMES) { if (pedestalCount == NUM_PEDESTAL_FRAMES) {
LOG(logINFO) << "Pedestal Calculated after " LOG(logINFO) << "Pedestal Calculated after " << NUM_PEDESTAL_FRAMES
<< NUM_PEDESTAL_FRAMES << " frames"; << " frames";
for (unsigned int px = 0; px < nPixels; ++px) for (unsigned int px = 0; px < nPixels; ++px)
tempPedestalVals[px] = tempPedestalVals[px] =
tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES; tempPedestalVals[px] / (double)NUM_PEDESTAL_FRAMES;
@ -1115,6 +1107,16 @@ void qDrawPlot::UpdatePlot() {
LOG(logDEBUG) << "Update Plot"; LOG(logDEBUG) << "Update Plot";
boxPlot->setTitle(plotTitle); boxPlot->setTitle(plotTitle);
// notify of incomplete images
lblCompleteImage->hide();
lblInCompleteImage->hide();
if (completeImage) {
lblCompleteImage->show();
} else {
lblInCompleteImage->show();
}
if (is1d) { if (is1d) {
Update1dPlot(); Update1dPlot();
} else { } else {

View File

@ -350,7 +350,7 @@ void qTabAdvanced::GetRxrZMQIP() {
void qTabAdvanced::SetDetector() { void qTabAdvanced::SetDetector() {
LOG(logDEBUG) << "Set Detector: " LOG(logDEBUG) << "Set Detector: "
<< comboDetector->currentText().toAscii().data(); << comboDetector->currentText().toAscii().data();
GetControlPort(); GetControlPort();
GetStopPort(); GetStopPort();
@ -531,8 +531,7 @@ void qTabAdvanced::SetROI() {
roi.xmax = spinXmax->value(); roi.xmax = spinXmax->value();
// set roi // set roi
LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax LOG(logINFO) << "Setting ROI: [" << roi.xmin << ", " << roi.xmax << "]";
<< "]";
try { try {
det->setROI(roi, {comboReadout->currentIndex()}); det->setROI(roi, {comboReadout->currentIndex()});
} }
@ -586,8 +585,7 @@ void qTabAdvanced::GetNumStoragecells() {
} }
void qTabAdvanced::SetNumStoragecells(int value) { void qTabAdvanced::SetNumStoragecells(int value) {
LOG(logINFO) << "Setting number of additional stoarge cells: " LOG(logINFO) << "Setting number of additional stoarge cells: " << value;
<< value;
try { try {
det->setNumberOfAdditionalStorageCells(value); det->setNumberOfAdditionalStorageCells(value);
} }
@ -621,11 +619,11 @@ void qTabAdvanced::SetSubExposureTime() {
auto timeNS = qDefs::getNSTime(std::make_pair( auto timeNS = qDefs::getNSTime(std::make_pair(
spinSubExpTime->value(), spinSubExpTime->value(),
static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex()))); static_cast<qDefs::timeUnit>(comboSubExpTimeUnit->currentIndex())));
LOG(logINFO) LOG(logINFO) << "Setting sub frame acquisition time to " << timeNS.count()
<< "Setting sub frame acquisition time to " << timeNS.count() << " ns" << " ns"
<< "/" << spinSubExpTime->value() << "/" << spinSubExpTime->value()
<< qDefs::getUnitString( << qDefs::getUnitString(
(qDefs::timeUnit)comboSubExpTimeUnit->currentIndex()); (qDefs::timeUnit)comboSubExpTimeUnit->currentIndex());
try { try {
det->setSubExptime(timeNS); det->setSubExptime(timeNS);
} }
@ -661,11 +659,10 @@ void qTabAdvanced::SetSubDeadTime() {
spinSubDeadTime->value(), spinSubDeadTime->value(),
static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex()))); static_cast<qDefs::timeUnit>(comboSubDeadTimeUnit->currentIndex())));
LOG(logINFO) LOG(logINFO) << "Setting sub frame dead time to " << timeNS.count() << " ns"
<< "Setting sub frame dead time to " << timeNS.count() << " ns" << "/" << spinSubDeadTime->value()
<< "/" << spinSubDeadTime->value() << qDefs::getUnitString(
<< qDefs::getUnitString( (qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
(qDefs::timeUnit)comboSubDeadTimeUnit->currentIndex());
try { try {
det->setSubDeadTime(timeNS); det->setSubDeadTime(timeNS);
} }

View File

@ -172,7 +172,7 @@ void qTabDataOutput::BrowseOutputDir() {
void qTabDataOutput::SetOutputDir() { void qTabDataOutput::SetOutputDir() {
QString path = dispOutputDir->text(); QString path = dispOutputDir->text();
LOG(logDEBUG) << "Setting output directory to " LOG(logDEBUG) << "Setting output directory to "
<< path.toAscii().constData(); << path.toAscii().constData();
// empty // empty
if (path.isEmpty()) { if (path.isEmpty()) {
@ -222,7 +222,7 @@ void qTabDataOutput::GetFileFormat() {
void qTabDataOutput::SetFileFormat(int format) { void qTabDataOutput::SetFileFormat(int format) {
LOG(logINFO) << "Setting File Format to " LOG(logINFO) << "Setting File Format to "
<< comboFileFormat->currentText().toAscii().data(); << comboFileFormat->currentText().toAscii().data();
try { try {
det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>( det->setFileFormat(static_cast<slsDetectorDefs::fileFormat>(
comboFileFormat->currentIndex())); comboFileFormat->currentIndex()));
@ -334,15 +334,13 @@ void qTabDataOutput::SetRateCorrection() {
// custom dead time // custom dead time
if (radioCustomDeadtime->isChecked()) { if (radioCustomDeadtime->isChecked()) {
int64_t deadtime = spinCustomDeadTime->value(); int64_t deadtime = spinCustomDeadTime->value();
LOG(logINFO) LOG(logINFO) << "Setting Rate Correction with custom dead time: "
<< "Setting Rate Correction with custom dead time: " << deadtime;
<< deadtime;
det->setRateCorrection(sls::ns(deadtime)); det->setRateCorrection(sls::ns(deadtime));
} }
// default dead time // default dead time
else { else {
LOG(logINFO) LOG(logINFO) << "Setting Rate Correction with default dead time";
<< "Setting Rate Correction with default dead time";
det->setDefaultRateCorrection(); det->setDefaultRateCorrection();
} }
} }
@ -367,7 +365,7 @@ void qTabDataOutput::GetSpeed() {
void qTabDataOutput::SetSpeed(int speed) { void qTabDataOutput::SetSpeed(int speed) {
LOG(logINFO) << "Setting Speed to " LOG(logINFO) << "Setting Speed to "
<< comboEigerClkDivider->currentText().toAscii().data(); << comboEigerClkDivider->currentText().toAscii().data();
; ;
try { try {
det->setSpeed(static_cast<slsDetectorDefs::speedLevel>(speed)); det->setSpeed(static_cast<slsDetectorDefs::speedLevel>(speed));
@ -398,9 +396,8 @@ void qTabDataOutput::SetFlags() {
auto mode = auto mode =
comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false; comboEigerParallelFlag->currentIndex() == PARALLEL ? true : false;
try { try {
LOG(logINFO) LOG(logINFO) << "Setting Readout Flags to "
<< "Setting Readout Flags to " << comboEigerParallelFlag->currentText().toAscii().data();
<< comboEigerParallelFlag->currentText().toAscii().data();
det->setParallelMode(mode); det->setParallelMode(mode);
} }
CATCH_HANDLE("Could not set readout flags.", "qTabDataOutput::SetFlags", CATCH_HANDLE("Could not set readout flags.", "qTabDataOutput::SetFlags",

View File

@ -1,6 +1,6 @@
#include "qTabDebugging.h" #include "qTabDebugging.h"
#include "qDefs.h"
#include "ToString.h" #include "ToString.h"
#include "qDefs.h"
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QGridLayout> #include <QGridLayout>
#include <QTreeWidget> #include <QTreeWidget>
@ -105,8 +105,9 @@ void qTabDebugging::GetInfo() {
treeDet->setHeaderLabel("Eiger Detector"); treeDet->setHeaderLabel("Eiger Detector");
// get num modules // get num modules
for (int i = 0; i < comboDetector->count() / 2; ++i) for (int i = 0; i < comboDetector->count() / 2; ++i)
items.append(new QTreeWidgetItem( items.append(
(QTreeWidget *)nullptr, QStringList(QString("Module %1").arg(i)))); new QTreeWidgetItem((QTreeWidget *)nullptr,
QStringList(QString("Module %1").arg(i))));
treeDet->insertTopLevelItems(0, items); treeDet->insertTopLevelItems(0, items);
// gets det names // gets det names
for (int i = 0; i < comboDetector->count(); ++i) { for (int i = 0; i < comboDetector->count(); ++i) {

View File

@ -297,7 +297,7 @@ void qTabMeasurement::GetTimingMode() {
void qTabMeasurement::SetTimingMode(int val) { void qTabMeasurement::SetTimingMode(int val) {
LOG(logINFO) << "Setting timing mode:" LOG(logINFO) << "Setting timing mode:"
<< comboTimingMode->currentText().toAscii().data(); << comboTimingMode->currentText().toAscii().data();
try { try {
det->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val)); det->setTimingMode(static_cast<slsDetectorDefs::timingMode>(val));
EnableWidgetsforTimingMode(); EnableWidgetsforTimingMode();
@ -438,7 +438,7 @@ void qTabMeasurement::SetExposureTime() {
auto val = spinExpTime->value(); auto val = spinExpTime->value();
auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboExpUnit->currentIndex());
LOG(logINFO) << "Setting exposure time to " << val << " " LOG(logINFO) << "Setting exposure time to " << val << " "
<< qDefs::getUnitString(unit); << qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setExptime(timeNS); det->setExptime(timeNS);
@ -476,7 +476,7 @@ void qTabMeasurement::SetAcquisitionPeriod() {
auto val = spinPeriod->value(); auto val = spinPeriod->value();
auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboPeriodUnit->currentIndex());
LOG(logINFO) << "Setting acquisition period to " << val << " " LOG(logINFO) << "Setting acquisition period to " << val << " "
<< qDefs::getUnitString(unit); << qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setPeriod(timeNS); det->setPeriod(timeNS);
@ -537,7 +537,7 @@ void qTabMeasurement::SetDelay() {
auto val = spinDelay->value(); auto val = spinDelay->value();
auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex()); auto unit = static_cast<qDefs::timeUnit>(comboDelayUnit->currentIndex());
LOG(logINFO) << "Setting delay to " << val << " " LOG(logINFO) << "Setting delay to " << val << " "
<< qDefs::getUnitString(unit); << qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setDelayAfterTrigger(timeNS); det->setDelayAfterTrigger(timeNS);
@ -573,7 +573,7 @@ void qTabMeasurement::SetBurstPeriod() {
auto unit = auto unit =
static_cast<qDefs::timeUnit>(comboBurstPeriodUnit->currentIndex()); static_cast<qDefs::timeUnit>(comboBurstPeriodUnit->currentIndex());
LOG(logINFO) << "Setting burst period to " << val << " " LOG(logINFO) << "Setting burst period to " << val << " "
<< qDefs::getUnitString(unit); << qDefs::getUnitString(unit);
try { try {
auto timeNS = qDefs::getNSTime(std::make_pair(val, unit)); auto timeNS = qDefs::getNSTime(std::make_pair(val, unit));
det->setBurstPeriod(timeNS); det->setBurstPeriod(timeNS);
@ -771,8 +771,7 @@ void qTabMeasurement::AcquireFinished() {
if (startingFnumImplemented) { if (startingFnumImplemented) {
GetStartingFrameNumber(); GetStartingFrameNumber();
} }
LOG(logDEBUG) << "Measurement " << currentMeasurement LOG(logDEBUG) << "Measurement " << currentMeasurement << " finished";
<< " finished";
// next measurement if acq is not stopped // next measurement if acq is not stopped
if (!isAcquisitionStopped && if (!isAcquisitionStopped &&
((currentMeasurement + 1) < numMeasurements)) { ((currentMeasurement + 1) < numMeasurements)) {
@ -801,8 +800,9 @@ void qTabMeasurement::Enable(bool enable) {
frameNotTimeResolved->setEnabled(enable); frameNotTimeResolved->setEnabled(enable);
// shortcut each time, else it doesnt work a second time // shortcut each time, else it doesnt work a second time
btnStart->setShortcut(QApplication::translate( btnStart->setShortcut(QApplication::translate("TabMeasurementObject",
"TabMeasurementObject", "Shift+Space", nullptr, QApplication::UnicodeUTF8)); "Shift+Space", nullptr,
QApplication::UnicodeUTF8));
} }
void qTabMeasurement::Refresh() { void qTabMeasurement::Refresh() {

View File

@ -75,8 +75,8 @@ void qTabMessages::ExecuteCommand() {
QString command = param.at(0); QString command = param.at(0);
param.removeFirst(); param.removeFirst();
LOG(logINFO) << "Executing Command:[" << command.toAscii().constData() LOG(logINFO) << "Executing Command:[" << command.toAscii().constData()
<< "] with Arguments:[" << "] with Arguments:["
<< param.join(" ").toAscii().constData() << "]"; << param.join(" ").toAscii().constData() << "]";
process->setProcessChannelMode(QProcess::MergedChannels); process->setProcessChannelMode(QProcess::MergedChannels);
process->start(command, param); process->start(command, param);
@ -121,7 +121,7 @@ void qTabMessages::SaveLog() {
LOG(logINFO) << mess; LOG(logINFO) << mess;
} else { } else {
LOG(logWARNING) << "Attempt to save log file failed: " LOG(logWARNING) << "Attempt to save log file failed: "
<< fName.toAscii().constData(); << fName.toAscii().constData();
qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.", qDefs::Message(qDefs::WARNING, "Attempt to save log file failed.",
"qTabMessages::SaveLog"); "qTabMessages::SaveLog");
} }

View File

@ -6,7 +6,6 @@
#include <QStackedLayout> #include <QStackedLayout>
#include <QStandardItemModel> #include <QStandardItemModel>
QString qTabPlot::defaultPlotTitle(""); QString qTabPlot::defaultPlotTitle("");
QString qTabPlot::defaultHistXAxisTitle("Channel Number"); QString qTabPlot::defaultHistXAxisTitle("Channel Number");
QString qTabPlot::defaultHistYAxisTitle("Counts"); QString qTabPlot::defaultHistYAxisTitle("Counts");
@ -64,6 +63,7 @@ void qTabPlot::SetupWidgetWindow() {
chkGapPixels->setEnabled(true); chkGapPixels->setEnabled(true);
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
chkGapPixels->setEnabled(true);
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
chkGainPlot->setChecked(true); chkGainPlot->setChecked(true);
plot->EnableGainPlot(true); plot->EnableGainPlot(true);
@ -289,16 +289,14 @@ void qTabPlot::SetBinary() {
bool binary1D = chkBinary->isChecked(); bool binary1D = chkBinary->isChecked();
bool binary2D = chkBinary_2->isChecked(); bool binary2D = chkBinary_2->isChecked();
if (is1d) { if (is1d) {
LOG(logINFO) << "Binary Plot " LOG(logINFO) << "Binary Plot " << (binary1D ? "enabled" : "disabled");
<< (binary1D ? "enabled" : "disabled");
lblFrom->setEnabled(binary1D); lblFrom->setEnabled(binary1D);
lblTo->setEnabled(binary1D); lblTo->setEnabled(binary1D);
spinFrom->setEnabled(binary1D); spinFrom->setEnabled(binary1D);
spinTo->setEnabled(binary1D); spinTo->setEnabled(binary1D);
plot->SetBinary(binary1D, spinFrom->value(), spinTo->value()); plot->SetBinary(binary1D, spinFrom->value(), spinTo->value());
} else { } else {
LOG(logINFO) << "Binary Plot " LOG(logINFO) << "Binary Plot " << (binary2D ? "enabled" : "disabled");
<< (binary2D ? "enabled" : "disabled");
lblFrom_2->setEnabled(binary2D); lblFrom_2->setEnabled(binary2D);
lblTo_2->setEnabled(binary2D); lblTo_2->setEnabled(binary2D);
spinFrom_2->setEnabled(binary2D); spinFrom_2->setEnabled(binary2D);
@ -312,8 +310,7 @@ void qTabPlot::GetGapPixels() {
disconnect(chkGapPixels, SIGNAL(toggled(bool)), this, disconnect(chkGapPixels, SIGNAL(toggled(bool)), this,
SLOT(SetGapPixels(bool))); SLOT(SetGapPixels(bool)));
try { try {
auto retval = det->getRxAddGapPixels().tsquash( auto retval = det->getGapPixelsinCallback();
"Inconsistent gap pixels enabled for all detectors.");
chkGapPixels->setChecked(retval); chkGapPixels->setChecked(retval);
} }
CATCH_DISPLAY("Could not get gap pixels enable.", "qTabPlot::GetGapPixels") CATCH_DISPLAY("Could not get gap pixels enable.", "qTabPlot::GetGapPixels")
@ -324,7 +321,7 @@ void qTabPlot::GetGapPixels() {
void qTabPlot::SetGapPixels(bool enable) { void qTabPlot::SetGapPixels(bool enable) {
LOG(logINFO) << "Setting Gap Pixels Enable to " << enable; LOG(logINFO) << "Setting Gap Pixels Enable to " << enable;
try { try {
det->setRxAddGapPixels(enable); det->setGapPixelsinCallback(enable);
} }
CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels", CATCH_HANDLE("Could not set gap pixels enable.", "qTabPlot::SetGapPixels",
this, &qTabPlot::GetGapPixels) this, &qTabPlot::GetGapPixels)
@ -434,10 +431,10 @@ void qTabPlot::SetXYRange() {
for (int i = 0; i < 4; ++i) { for (int i = 0; i < 4; ++i) {
if (chkVal[i] && !dispVal[i].isEmpty()) { if (chkVal[i] && !dispVal[i].isEmpty()) {
double val = dispVal[i].toDouble(); double val = dispVal[i].toDouble();
LOG(logDEBUG) LOG(logDEBUG) << "Setting "
<< "Setting " << qDefs::getRangeAsString(
<< qDefs::getRangeAsString(static_cast<qDefs::range>(i)) static_cast<qDefs::range>(i))
<< " to " << val; << " to " << val;
xyRange[i] = val; xyRange[i] = val;
isRange[i] = true; isRange[i] = true;
disablezoom = true; disablezoom = true;
@ -482,10 +479,10 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
ranges[qDefs::YMAX] = plot->GetYMaximum(); ranges[qDefs::YMAX] = plot->GetYMaximum();
double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / double idealAspectratio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]); (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio LOG(logDEBUG) << "Ideal Aspect ratio: " << idealAspectratio << " for x("
<< " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX]
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << "), y(" << ranges[qDefs::YMIN] << " - "
<< " - " << ranges[qDefs::YMAX] << ")"; << ranges[qDefs::YMAX] << ")";
// calculate current aspect ratio // calculate current aspect ratio
ranges[qDefs::XMIN] = dispXMin->text().toDouble(); ranges[qDefs::XMIN] = dispXMin->text().toDouble();
@ -494,10 +491,10 @@ void qTabPlot::MaintainAspectRatio(int dimension) {
ranges[qDefs::YMAX] = dispYMax->text().toDouble(); ranges[qDefs::YMAX] = dispYMax->text().toDouble();
double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) / double currentAspectRatio = (ranges[qDefs::XMAX] - ranges[qDefs::XMIN]) /
(ranges[qDefs::YMAX] - ranges[qDefs::YMIN]); (ranges[qDefs::YMAX] - ranges[qDefs::YMIN]);
LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio LOG(logDEBUG) << "Current Aspect ratio: " << currentAspectRatio << " for x("
<< " for x(" << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMIN] << " - " << ranges[qDefs::XMAX]
<< ranges[qDefs::XMAX] << "), y(" << ranges[qDefs::YMIN] << "), y(" << ranges[qDefs::YMIN] << " - "
<< " - " << ranges[qDefs::YMAX] << ")"; << ranges[qDefs::YMAX] << ")";
if (currentAspectRatio != idealAspectratio) { if (currentAspectRatio != idealAspectratio) {
// dimension: 1(x changed: y adjusted), 0(y changed: x adjusted), // dimension: 1(x changed: y adjusted), 0(y changed: x adjusted),
@ -643,7 +640,7 @@ void qTabPlot::SetStreamingFrequency() {
det->setRxZmqFrequency(freqVal); det->setRxZmqFrequency(freqVal);
} else { } else {
LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " " LOG(logINFO) << "Setting Streaming Timer to " << timeVal << " "
<< qDefs::getUnitString(timeUnit); << qDefs::getUnitString(timeUnit);
auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit)); auto timeMS = qDefs::getMSTime(std::make_pair(timeVal, timeUnit));
det->setRxZmqTimer(timeMS.count()); det->setRxZmqTimer(timeMS.count());
} }
@ -672,6 +669,8 @@ void qTabPlot::Refresh() {
break; break;
case slsDetectorDefs::JUNGFRAU: case slsDetectorDefs::JUNGFRAU:
chkGainPlot->setEnabled(true); chkGainPlot->setEnabled(true);
chkGapPixels->setEnabled(true);
GetGapPixels();
break; break;
case slsDetectorDefs::GOTTHARD2: case slsDetectorDefs::GOTTHARD2:
chkGainPlot1D->setEnabled(true); chkGainPlot1D->setEnabled(true);

View File

@ -1,6 +1,6 @@
#include "qTabSettings.h" #include "qTabSettings.h"
#include "qDefs.h"
#include "ToString.h" #include "ToString.h"
#include "qDefs.h"
#include <QStandardItemModel> #include <QStandardItemModel>
qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector) qTabSettings::qTabSettings(QWidget *parent, sls::Detector *detector)
@ -196,7 +196,7 @@ void qTabSettings::GetDynamicRange() {
void qTabSettings::SetDynamicRange(int index) { void qTabSettings::SetDynamicRange(int index) {
LOG(logINFO) << "Setting dynamic range to " LOG(logINFO) << "Setting dynamic range to "
<< comboDynamicRange->currentText().toAscii().data(); << comboDynamicRange->currentText().toAscii().data();
try { try {
switch (index) { switch (index) {
case DYNAMICRANGE_32: case DYNAMICRANGE_32:

View File

@ -16,6 +16,7 @@ add_executable(ctbDetectorServer_virtual
../slsDetectorServer/src/LTC2620.c ../slsDetectorServer/src/LTC2620.c
../slsDetectorServer/src/MAX1932.c ../slsDetectorServer/src/MAX1932.c
../slsDetectorServer/src/programFpgaBlackfin.c ../slsDetectorServer/src/programFpgaBlackfin.c
../slsDetectorServer/src/communication_virtual.c
) )
include_directories( include_directories(
@ -33,6 +34,7 @@ target_compile_definitions(ctbDetectorServer_virtual
target_link_libraries(ctbDetectorServer_virtual target_link_libraries(ctbDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings PUBLIC pthread rt slsProjectCWarnings
m
) )
set_target_properties(ctbDetectorServer_virtual PROPERTIES set_target_properties(ctbDetectorServer_virtual PROPERTIES

730
slsDetectorServers/ctbDetectorServer/RegisterDefs.h Executable file → Normal file
View File

@ -4,552 +4,580 @@
#define MEM_MAP_SHIFT 1 #define MEM_MAP_SHIFT 1
/* FPGA Version RO register */ /* FPGA Version RO register */
#define FPGA_VERSION_REG (0x00 << MEM_MAP_SHIFT) #define FPGA_VERSION_REG (0x00 << MEM_MAP_SHIFT)
#define FPGA_VERSION_BRD_RVSN_OFST (0) #define FPGA_VERSION_BRD_RVSN_OFST (0)
#define FPGA_VERSION_BRD_RVSN_MSK (0x00FFFFFF << FPGA_VERSION_BRD_RVSN_OFST) #define FPGA_VERSION_BRD_RVSN_MSK (0x00FFFFFF << FPGA_VERSION_BRD_RVSN_OFST)
#define FPGA_VERSION_DTCTR_TYP_OFST (24) #define FPGA_VERSION_DTCTR_TYP_OFST (24)
#define FPGA_VERSION_DTCTR_TYP_MSK (0x000000FF << FPGA_VERSION_DTCTR_TYP_OFST) #define FPGA_VERSION_DTCTR_TYP_MSK (0x000000FF << FPGA_VERSION_DTCTR_TYP_OFST)
#define FPGA_VERSION_DTCTR_TYP_CTB_VAL ((0x4 << FPGA_VERSION_DTCTR_TYP_OFST) & FPGA_VERSION_DTCTR_TYP_MSK) #define FPGA_VERSION_DTCTR_TYP_CTB_VAL \
((0x4 << FPGA_VERSION_DTCTR_TYP_OFST) & FPGA_VERSION_DTCTR_TYP_MSK)
/* Fix pattern RO register */ /* Fix pattern RO register */
#define FIX_PATT_REG (0x01 << MEM_MAP_SHIFT) #define FIX_PATT_REG (0x01 << MEM_MAP_SHIFT)
#define FIX_PATT_VAL (0xACDC2016) #define FIX_PATT_VAL (0xACDC2016)
/* Status RO register */ /* Status RO register */
#define STATUS_REG (0x02 << MEM_MAP_SHIFT) #define STATUS_REG (0x02 << MEM_MAP_SHIFT)
#define STATUS_RN_BSY_OFST (0) #define STATUS_RN_BSY_OFST (0)
#define STATUS_RN_BSY_MSK (0x00000001 << STATUS_RN_BSY_OFST) #define STATUS_RN_BSY_MSK (0x00000001 << STATUS_RN_BSY_OFST)
#define STATUS_RDT_BSY_OFST (1) #define STATUS_RDT_BSY_OFST (1)
#define STATUS_RDT_BSY_MSK (0x00000001 << STATUS_RDT_BSY_OFST) #define STATUS_RDT_BSY_MSK (0x00000001 << STATUS_RDT_BSY_OFST)
#define STATUS_ANY_FF_FLL_OFST (2) #define STATUS_ANY_FF_FLL_OFST (2)
#define STATUS_ANY_FF_FLL_MSK (0x00000001 << STATUS_ANY_FF_FLL_OFST) #define STATUS_ANY_FF_FLL_MSK (0x00000001 << STATUS_ANY_FF_FLL_OFST)
#define STATUS_WTNG_FR_TRGGR_OFST (3) #define STATUS_WTNG_FR_TRGGR_OFST (3)
#define STATUS_WTNG_FR_TRGGR_MSK (0x00000001 << STATUS_WTNG_FR_TRGGR_OFST) #define STATUS_WTNG_FR_TRGGR_MSK (0x00000001 << STATUS_WTNG_FR_TRGGR_OFST)
#define STATUS_DLY_BFR_OFST (4) #define STATUS_DLY_BFR_OFST (4)
#define STATUS_DLY_BFR_MSK (0x00000001 << STATUS_DLY_BFR_OFST) #define STATUS_DLY_BFR_MSK (0x00000001 << STATUS_DLY_BFR_OFST)
#define STATUS_DLY_AFTR_OFST (5) #define STATUS_DLY_AFTR_OFST (5)
#define STATUS_DLY_AFTR_MSK (0x00000001 << STATUS_DLY_AFTR_OFST) #define STATUS_DLY_AFTR_MSK (0x00000001 << STATUS_DLY_AFTR_OFST)
#define STATUS_EXPSNG_OFST (6) #define STATUS_EXPSNG_OFST (6)
#define STATUS_EXPSNG_MSK (0x00000001 << STATUS_EXPSNG_OFST) #define STATUS_EXPSNG_MSK (0x00000001 << STATUS_EXPSNG_OFST)
#define STATUS_CNT_ENBL_OFST (7) #define STATUS_CNT_ENBL_OFST (7)
#define STATUS_CNT_ENBL_MSK (0x00000001 << STATUS_CNT_ENBL_OFST) #define STATUS_CNT_ENBL_MSK (0x00000001 << STATUS_CNT_ENBL_OFST)
#define STATUS_SM_FF_FLL_OFST (11) #define STATUS_SM_FF_FLL_OFST (11)
#define STATUS_SM_FF_FLL_MSK (0x00000001 << STATUS_SM_FF_FLL_OFST) #define STATUS_SM_FF_FLL_MSK (0x00000001 << STATUS_SM_FF_FLL_OFST)
#define STATUS_STPPD_OFST (15) #define STATUS_STPPD_OFST (15)
#define STATUS_STPPD_MSK (0x00000001 << STATUS_STPPD_OFST) #define STATUS_STPPD_MSK (0x00000001 << STATUS_STPPD_OFST)
#define STATUS_ALL_FF_EMPTY_OFST (16) #define STATUS_ALL_FF_EMPTY_OFST (16)
#define STATUS_ALL_FF_EMPTY_MSK (0x00000001 << STATUS_ALL_FF_EMPTY_OFST) #define STATUS_ALL_FF_EMPTY_MSK (0x00000001 << STATUS_ALL_FF_EMPTY_OFST)
#define STATUS_CYCL_RN_BSY_OFST (17) #define STATUS_CYCL_RN_BSY_OFST (17)
#define STATUS_CYCL_RN_BSY_MSK (0x00000001 << STATUS_CYCL_RN_BSY_OFST) #define STATUS_CYCL_RN_BSY_MSK (0x00000001 << STATUS_CYCL_RN_BSY_OFST)
#define STATUS_FRM_RN_BSY_OFST (18) #define STATUS_FRM_RN_BSY_OFST (18)
#define STATUS_FRM_RN_BSY_MSK (0x00000001 << STATUS_FRM_RN_BSY_OFST) #define STATUS_FRM_RN_BSY_MSK (0x00000001 << STATUS_FRM_RN_BSY_OFST)
#define STATUS_ADC_DESERON_OFST (19) #define STATUS_ADC_DESERON_OFST (19)
#define STATUS_ADC_DESERON_MSK (0x00000001 << STATUS_ADC_DESERON_OFST) #define STATUS_ADC_DESERON_MSK (0x00000001 << STATUS_ADC_DESERON_OFST)
#define STATUS_PLL_RCNFG_BSY_OFST (20) #define STATUS_PLL_RCNFG_BSY_OFST (20)
#define STATUS_PLL_RCNFG_BSY_MSK (0x00000001 << STATUS_PLL_RCNFG_BSY_OFST) #define STATUS_PLL_RCNFG_BSY_MSK (0x00000001 << STATUS_PLL_RCNFG_BSY_OFST)
#define STATUS_DT_STRMNG_BSY_OFST (21) #define STATUS_DT_STRMNG_BSY_OFST (21)
#define STATUS_DT_STRMNG_BSY_MSK (0x00000001 << STATUS_DT_STRMNG_BSY_OFST) #define STATUS_DT_STRMNG_BSY_MSK (0x00000001 << STATUS_DT_STRMNG_BSY_OFST)
#define STATUS_FRM_PCKR_BSY_OFST (22) #define STATUS_FRM_PCKR_BSY_OFST (22)
#define STATUS_FRM_PCKR_BSY_MSK (0x00000001 << STATUS_FRM_PCKR_BSY_OFST) #define STATUS_FRM_PCKR_BSY_MSK (0x00000001 << STATUS_FRM_PCKR_BSY_OFST)
#define STATUS_PLL_PHS_DN_OFST (23) #define STATUS_PLL_PHS_DN_OFST (23)
#define STATUS_PLL_PHS_DN_MSK (0x00000001 << STATUS_PLL_PHS_DN_OFST) #define STATUS_PLL_PHS_DN_MSK (0x00000001 << STATUS_PLL_PHS_DN_OFST)
#define STATUS_PT_CNTRL_STTS_OFF_OFST (24) #define STATUS_PT_CNTRL_STTS_OFF_OFST (24)
#define STATUS_PT_CNTRL_STTS_OFF_MSK (0x000000FF << STATUS_PT_CNTRL_STTS_OFF_OFST) #define STATUS_PT_CNTRL_STTS_OFF_MSK \
#define STATUS_IDLE_MSK (0x677FF) (0x000000FF << STATUS_PT_CNTRL_STTS_OFF_OFST)
#define STATUS_IDLE_MSK (0x677FF)
/* Look at me RO register TODO */ /* Look at me RO register TODO */
#define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT) #define LOOK_AT_ME_REG (0x03 << MEM_MAP_SHIFT)
/* System Status RO register */ /* System Status RO register */
#define SYSTEM_STATUS_REG (0x04 << MEM_MAP_SHIFT) #define SYSTEM_STATUS_REG (0x04 << MEM_MAP_SHIFT)
#define SYSTEM_STATUS_DDR3_CLBRTN_OK_OFST (0) #define SYSTEM_STATUS_DDR3_CLBRTN_OK_OFST (0)
#define SYSTEM_STATUS_DDR3_CLBRTN_OK_MSK (0x00000001 << SYSTEM_STATUS_DDR3_CLBRTN_OK_OFST) #define SYSTEM_STATUS_DDR3_CLBRTN_OK_MSK \
#define SYSTEM_STATUS_DDR3_CLBRTN_FL_OFST (1) (0x00000001 << SYSTEM_STATUS_DDR3_CLBRTN_OK_OFST)
#define SYSTEM_STATUS_DDR3_CLBRTN_FL_MSK (0x00000001 << SYSTEM_STATUS_DDR3_CLBRTN_FL_OFST) #define SYSTEM_STATUS_DDR3_CLBRTN_FL_OFST (1)
#define SYSTEM_STATUS_DDR3_INT_DN_OFST (2) #define SYSTEM_STATUS_DDR3_CLBRTN_FL_MSK \
#define SYSTEM_STATUS_DDR3_INT_DN_MSK (0x00000001 << SYSTEM_STATUS_DDR3_INT_DN_OFST) (0x00000001 << SYSTEM_STATUS_DDR3_CLBRTN_FL_OFST)
#define SYSTEM_STATUS_RCNFG_PLL_LCK_OFST (3) #define SYSTEM_STATUS_DDR3_INT_DN_OFST (2)
#define SYSTEM_STATUS_RCNFG_PLL_LCK_MSK (0x00000001 << SYSTEM_STATUS_RCNFG_PLL_LCK_OFST) #define SYSTEM_STATUS_DDR3_INT_DN_MSK \
#define SYSTEM_STATUS_PLL_A_LCK_OFST (4) (0x00000001 << SYSTEM_STATUS_DDR3_INT_DN_OFST)
#define SYSTEM_STATUS_PLL_A_LCK_MSK (0x00000001 << SYSTEM_STATUS_PLL_A_LCK_OFST) #define SYSTEM_STATUS_RCNFG_PLL_LCK_OFST (3)
#define SYSTEM_STATUS_RCNFG_PLL_LCK_MSK \
(0x00000001 << SYSTEM_STATUS_RCNFG_PLL_LCK_OFST)
#define SYSTEM_STATUS_PLL_A_LCK_OFST (4)
#define SYSTEM_STATUS_PLL_A_LCK_MSK (0x00000001 << SYSTEM_STATUS_PLL_A_LCK_OFST)
/* PLL Param (Reconfiguratble PLL Parameter) RO register TODO FIXME: Same as PLL_PARAM_REG 0x50 */ /* PLL Param (Reconfiguratble PLL Parameter) RO register TODO FIXME: Same as
* PLL_PARAM_REG 0x50 */
//#define PLL_PARAM_REG (0x05 << MEM_MAP_SHIFT) //#define PLL_PARAM_REG (0x05 << MEM_MAP_SHIFT)
/* FIFO Data RO register TODO */ /* FIFO Data RO register TODO */
#define FIFO_DATA_REG (0x06 << MEM_MAP_SHIFT) #define FIFO_DATA_REG (0x06 << MEM_MAP_SHIFT)
#define FIFO_DATA_HRDWR_SRL_NMBR_OFST (0) #define FIFO_DATA_HRDWR_SRL_NMBR_OFST (0)
#define FIFO_DATA_HRDWR_SRL_NMBR_MSK (0x0000FFFF << FIFO_DATA_HRDWR_SRL_NMBR_OFST) #define FIFO_DATA_HRDWR_SRL_NMBR_MSK \
(0x0000FFFF << FIFO_DATA_HRDWR_SRL_NMBR_OFST)
//#define FIFO_DATA_WRD_OFST (16) //#define FIFO_DATA_WRD_OFST (16)
//#define FIFO_DATA_WRD_MSK (0x0000FFFF << FIFO_DATA_WRD_OFST) //#define FIFO_DATA_WRD_MSK (0x0000FFFF << FIFO_DATA_WRD_OFST)
/* FIFO Status RO register TODO */ /* FIFO Status RO register TODO */
#define FIFO_STATUS_REG (0x07 << MEM_MAP_SHIFT) #define FIFO_STATUS_REG (0x07 << MEM_MAP_SHIFT)
/* FIFO Empty RO register TODO */ /* FIFO Empty RO register TODO */
#define FIFO_EMPTY_REG (0x08 << MEM_MAP_SHIFT) #define FIFO_EMPTY_REG (0x08 << MEM_MAP_SHIFT)
#define FIFO_EMPTY_ALL_EMPTY_MSK (0xFFFFFFFF) #define FIFO_EMPTY_ALL_EMPTY_MSK (0xFFFFFFFF)
/* FIFO Full RO register TODO */ /* FIFO Full RO register TODO */
#define FIFO_FULL_REG (0x09 << MEM_MAP_SHIFT) #define FIFO_FULL_REG (0x09 << MEM_MAP_SHIFT)
/* MCB Serial Number RO register */ /* MCB Serial Number RO register */
#define MOD_SERIAL_NUMBER_REG (0x0A << MEM_MAP_SHIFT) #define MOD_SERIAL_NUMBER_REG (0x0A << MEM_MAP_SHIFT)
#define MOD_SERIAL_NUMBER_OFST (0) #define MOD_SERIAL_NUMBER_OFST (0)
#define MOD_SERIAL_NUMBER_MSK (0x000000FF << MOD_SERIAL_NUMBER_OFST) #define MOD_SERIAL_NUMBER_MSK (0x000000FF << MOD_SERIAL_NUMBER_OFST)
#define MOD_SERIAL_NUMBER_VRSN_OFST (16) #define MOD_SERIAL_NUMBER_VRSN_OFST (16)
#define MOD_SERIAL_NUMBER_VRSN_MSK (0x0000003F << MOD_SERIAL_NUMBER_VRSN_OFST) #define MOD_SERIAL_NUMBER_VRSN_MSK (0x0000003F << MOD_SERIAL_NUMBER_VRSN_OFST)
/* API Version RO register */ /* API Version RO register */
#define API_VERSION_REG (0x0F << MEM_MAP_SHIFT) #define API_VERSION_REG (0x0F << MEM_MAP_SHIFT)
#define API_VERSION_OFST (0) #define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST) #define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DTCTR_TYP_OFST (24) #define API_VERSION_DTCTR_TYP_OFST (24)
#define API_VERSION_DTCTR_TYP_MSK (0x000000FF << API_VERSION_DTCTR_TYP_OFST) #define API_VERSION_DTCTR_TYP_MSK (0x000000FF << API_VERSION_DTCTR_TYP_OFST)
/* Time from Start 64 bit RO register. t = GCLK x 50 ns. Reset using CONTROL_CRST. TODO */ /* Time from Start 64 bit RO register. t = GCLK x 50 ns. Reset using
#define TIME_FROM_START_LSB_REG (0x10 << MEM_MAP_SHIFT) * CONTROL_CRST. TODO */
#define TIME_FROM_START_MSB_REG (0x11 << MEM_MAP_SHIFT) #define TIME_FROM_START_LSB_REG (0x10 << MEM_MAP_SHIFT)
#define TIME_FROM_START_MSB_REG (0x11 << MEM_MAP_SHIFT)
/* Delay Left 64 bit RO register. t = DLY x 50 ns. TODO */ /* Delay Left 64 bit RO register. t = DLY x 50 ns. TODO */
#define DELAY_LEFT_LSB_REG (0x12 << MEM_MAP_SHIFT) #define DELAY_LEFT_LSB_REG (0x12 << MEM_MAP_SHIFT)
#define DELAY_LEFT_MSB_REG (0x13 << MEM_MAP_SHIFT) #define DELAY_LEFT_MSB_REG (0x13 << MEM_MAP_SHIFT)
/* Triggers Left 64 bit RO register TODO */ /* Triggers Left 64 bit RO register TODO */
#define CYCLES_LEFT_LSB_REG (0x14 << MEM_MAP_SHIFT) #define CYCLES_LEFT_LSB_REG (0x14 << MEM_MAP_SHIFT)
#define CYCLES_LEFT_MSB_REG (0x15 << MEM_MAP_SHIFT) #define CYCLES_LEFT_MSB_REG (0x15 << MEM_MAP_SHIFT)
/* Frames Left 64 bit RO register TODO */ /* Frames Left 64 bit RO register TODO */
#define FRAMES_LEFT_LSB_REG (0x16 << MEM_MAP_SHIFT) #define FRAMES_LEFT_LSB_REG (0x16 << MEM_MAP_SHIFT)
#define FRAMES_LEFT_MSB_REG (0x17 << MEM_MAP_SHIFT) #define FRAMES_LEFT_MSB_REG (0x17 << MEM_MAP_SHIFT)
/* Period Left 64 bit RO register. t = T x 50 ns. TODO */ /* Period Left 64 bit RO register. t = T x 50 ns. TODO */
#define PERIOD_LEFT_LSB_REG (0x18 << MEM_MAP_SHIFT) #define PERIOD_LEFT_LSB_REG (0x18 << MEM_MAP_SHIFT)
#define PERIOD_LEFT_MSB_REG (0x19 << MEM_MAP_SHIFT) #define PERIOD_LEFT_MSB_REG (0x19 << MEM_MAP_SHIFT)
/* Exposure Time Left 64 bit RO register */ /* Exposure Time Left 64 bit RO register */
//#define EXPTIME_LEFT_LSB_REG (0x1A << MEM_MAP_SHIFT) // Not used in FW //#define EXPTIME_LEFT_LSB_REG (0x1A << MEM_MAP_SHIFT) // Not
//#define EXPTIME_LEFT_MSB_REG (0x1B << MEM_MAP_SHIFT) // Not used in FW // used in FW #define EXPTIME_LEFT_MSB_REG (0x1B <<
// MEM_MAP_SHIFT)
//// Not used in FW
/* Gates Left 64 bit RO register */ /* Gates Left 64 bit RO register */
//#define GATES_LEFT_LSB_REG (0x1C << MEM_MAP_SHIFT) // Not used in FW //#define GATES_LEFT_LSB_REG (0x1C << MEM_MAP_SHIFT) // Not
//#define GATES_LEFT_MSB_REG (0x1D << MEM_MAP_SHIFT) // Not used in FW // used in FW #define GATES_LEFT_MSB_REG (0x1D <<
// MEM_MAP_SHIFT)
//// Not used in FW
/* Data In 64 bit RO register TODO */ /* Data In 64 bit RO register TODO */
#define DATA_IN_LSB_REG (0x1E << MEM_MAP_SHIFT) #define DATA_IN_LSB_REG (0x1E << MEM_MAP_SHIFT)
#define DATA_IN_MSB_REG (0x1F << MEM_MAP_SHIFT) #define DATA_IN_MSB_REG (0x1F << MEM_MAP_SHIFT)
/* Pattern Out 64 bit RO register */ /* Pattern Out 64 bit RO register */
#define PATTERN_OUT_LSB_REG (0x20 << MEM_MAP_SHIFT) #define PATTERN_OUT_LSB_REG (0x20 << MEM_MAP_SHIFT)
#define PATTERN_OUT_MSB_REG (0x21 << MEM_MAP_SHIFT) #define PATTERN_OUT_MSB_REG (0x21 << MEM_MAP_SHIFT)
/* Frames From Start 64 bit RO register TODO */ /* Frames From Start 64 bit RO register TODO */
//#define FRAMES_FROM_START_LSB_REG (0x22 << MEM_MAP_SHIFT) // Not used in FW //#define FRAMES_FROM_START_LSB_REG (0x22 << MEM_MAP_SHIFT) // Not
//#define FRAMES_FROM_START_MSB_REG (0x23 << MEM_MAP_SHIFT) // Not used in FW // used in FW #define FRAMES_FROM_START_MSB_REG (0x23 <<
// MEM_MAP_SHIFT)
//// Not used in FW
/* Frames From Start PG 64 bit RO register. Reset using CONTROL_CRST. TODO */ /* Frames From Start PG 64 bit RO register. Reset using CONTROL_CRST. TODO */
#define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT) #define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT)
#define FRAMES_FROM_START_PG_MSB_REG (0x25 << MEM_MAP_SHIFT) #define FRAMES_FROM_START_PG_MSB_REG (0x25 << MEM_MAP_SHIFT)
/* Start Frame Time (Measurement Time) 64 bit register (timestamp at a frame start until reset) TODO */ /* Start Frame Time (Measurement Time) 64 bit register (timestamp at a frame
#define START_FRAME_TIME_LSB_REG (0x26 << MEM_MAP_SHIFT) * start until reset) TODO */
#define START_FRAME_TIME_MSB_REG (0x27 << MEM_MAP_SHIFT) #define START_FRAME_TIME_LSB_REG (0x26 << MEM_MAP_SHIFT)
#define START_FRAME_TIME_MSB_REG (0x27 << MEM_MAP_SHIFT)
/* Power Status RO register */ /* Power Status RO register */
#define POWER_STATUS_REG (0x29 << MEM_MAP_SHIFT) #define POWER_STATUS_REG (0x29 << MEM_MAP_SHIFT)
#define POWER_STATUS_ALRT_OFST (27) #define POWER_STATUS_ALRT_OFST (27)
#define POWER_STATUS_ALRT_MSK (0x0000001F << POWER_STATUS_ALRT_OFST) #define POWER_STATUS_ALRT_MSK (0x0000001F << POWER_STATUS_ALRT_OFST)
/* DAC Value Out RO register */ /* DAC Value Out RO register */
//#define DAC_VAL_OUT_REG (0x2A << MEM_MAP_SHIFT) //#define DAC_VAL_OUT_REG (0x2A << MEM_MAP_SHIFT)
/* Slow ADC SPI Value RO register */ /* Slow ADC SPI Value RO register */
#define ADC_SPI_SLOW_VAL_REG (0x2B << MEM_MAP_SHIFT) #define ADC_SPI_SLOW_VAL_REG (0x2B << MEM_MAP_SHIFT)
/* FIFO Digital In Status RO register */ /* FIFO Digital In Status RO register */
#define FIFO_DIN_STATUS_REG (0x3B << MEM_MAP_SHIFT) #define FIFO_DIN_STATUS_REG (0x3B << MEM_MAP_SHIFT)
#define FIFO_DIN_STATUS_FIFO_FULL_OFST (30) #define FIFO_DIN_STATUS_FIFO_FULL_OFST (30)
#define FIFO_DIN_STATUS_FIFO_FULL_MSK (0x00000001 << FIFO_DIN_STATUS_FIFO_FULL_OFST) #define FIFO_DIN_STATUS_FIFO_FULL_MSK \
#define FIFO_DIN_STATUS_FIFO_EMPTY_OFST (31) (0x00000001 << FIFO_DIN_STATUS_FIFO_FULL_OFST)
#define FIFO_DIN_STATUS_FIFO_EMPTY_MSK (0x00000001 << FIFO_DIN_STATUS_FIFO_EMPTY_OFST) #define FIFO_DIN_STATUS_FIFO_EMPTY_OFST (31)
#define FIFO_DIN_STATUS_FIFO_EMPTY_MSK \
(0x00000001 << FIFO_DIN_STATUS_FIFO_EMPTY_OFST)
/* FIFO Digital In 64 bit RO register */ /* FIFO Digital In 64 bit RO register */
#define FIFO_DIN_LSB_REG (0x3C << MEM_MAP_SHIFT) #define FIFO_DIN_LSB_REG (0x3C << MEM_MAP_SHIFT)
#define FIFO_DIN_MSB_REG (0x3D << MEM_MAP_SHIFT) #define FIFO_DIN_MSB_REG (0x3D << MEM_MAP_SHIFT)
/* SPI (Serial Peripheral Interface) DAC, HV RW register */ /* SPI (Serial Peripheral Interface) DAC, HV RW register */
#define SPI_REG (0x40 << MEM_MAP_SHIFT) #define SPI_REG (0x40 << MEM_MAP_SHIFT)
#define SPI_DAC_SRL_DGTL_OTPT_OFST (0) #define SPI_DAC_SRL_DGTL_OTPT_OFST (0)
#define SPI_DAC_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_DAC_SRL_DGTL_OTPT_OFST) #define SPI_DAC_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_DAC_SRL_DGTL_OTPT_OFST)
#define SPI_DAC_SRL_CLK_OTPT_OFST (1) #define SPI_DAC_SRL_CLK_OTPT_OFST (1)
#define SPI_DAC_SRL_CLK_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CLK_OTPT_OFST) #define SPI_DAC_SRL_CLK_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CLK_OTPT_OFST)
#define SPI_DAC_SRL_CS_OTPT_OFST (2) #define SPI_DAC_SRL_CS_OTPT_OFST (2)
#define SPI_DAC_SRL_CS_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CS_OTPT_OFST) #define SPI_DAC_SRL_CS_OTPT_MSK (0x00000001 << SPI_DAC_SRL_CS_OTPT_OFST)
#define SPI_HV_SRL_DGTL_OTPT_OFST (8) #define SPI_HV_SRL_DGTL_OTPT_OFST (8)
#define SPI_HV_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_HV_SRL_DGTL_OTPT_OFST) #define SPI_HV_SRL_DGTL_OTPT_MSK (0x00000001 << SPI_HV_SRL_DGTL_OTPT_OFST)
#define SPI_HV_SRL_CLK_OTPT_OFST (9) #define SPI_HV_SRL_CLK_OTPT_OFST (9)
#define SPI_HV_SRL_CLK_OTPT_MSK (0x00000001 << SPI_HV_SRL_CLK_OTPT_OFST) #define SPI_HV_SRL_CLK_OTPT_MSK (0x00000001 << SPI_HV_SRL_CLK_OTPT_OFST)
#define SPI_HV_SRL_CS_OTPT_OFST (10) #define SPI_HV_SRL_CS_OTPT_OFST (10)
#define SPI_HV_SRL_CS_OTPT_MSK (0x00000001 << SPI_HV_SRL_CS_OTPT_OFST) #define SPI_HV_SRL_CS_OTPT_MSK (0x00000001 << SPI_HV_SRL_CS_OTPT_OFST)
/* ADC SPI (Serial Peripheral Interface) RW register */ /* ADC SPI (Serial Peripheral Interface) RW register */
#define ADC_SPI_REG (0x41 << MEM_MAP_SHIFT) #define ADC_SPI_REG (0x41 << MEM_MAP_SHIFT)
#define ADC_SPI_SRL_CLK_OTPT_OFST (0) #define ADC_SPI_SRL_CLK_OTPT_OFST (0)
#define ADC_SPI_SRL_CLK_OTPT_MSK (0x00000001 << ADC_SPI_SRL_CLK_OTPT_OFST) #define ADC_SPI_SRL_CLK_OTPT_MSK (0x00000001 << ADC_SPI_SRL_CLK_OTPT_OFST)
#define ADC_SPI_SRL_DT_OTPT_OFST (1) #define ADC_SPI_SRL_DT_OTPT_OFST (1)
#define ADC_SPI_SRL_DT_OTPT_MSK (0x00000001 << ADC_SPI_SRL_DT_OTPT_OFST) #define ADC_SPI_SRL_DT_OTPT_MSK (0x00000001 << ADC_SPI_SRL_DT_OTPT_OFST)
#define ADC_SPI_SRL_CS_OTPT_OFST (2) #define ADC_SPI_SRL_CS_OTPT_OFST (2)
#define ADC_SPI_SRL_CS_OTPT_MSK (0x0000000F << ADC_SPI_SRL_CS_OTPT_OFST) #define ADC_SPI_SRL_CS_OTPT_MSK (0x0000000F << ADC_SPI_SRL_CS_OTPT_OFST)
#define ADC_SPI_SLOW_SRL_DT_OFST (8) #define ADC_SPI_SLOW_SRL_DT_OFST (8)
#define ADC_SPI_SLOW_SRL_DT_MSK (0x00000001 << ADC_SPI_SLOW_SRL_DT_OFST) #define ADC_SPI_SLOW_SRL_DT_MSK (0x00000001 << ADC_SPI_SLOW_SRL_DT_OFST)
#define ADC_SPI_SLOW_SRL_CLK_OFST (9) #define ADC_SPI_SLOW_SRL_CLK_OFST (9)
#define ADC_SPI_SLOW_SRL_CLK_MSK (0x00000001 << ADC_SPI_SLOW_SRL_CLK_OFST) #define ADC_SPI_SLOW_SRL_CLK_MSK (0x00000001 << ADC_SPI_SLOW_SRL_CLK_OFST)
#define ADC_SPI_SLOW_SRL_CNV_OFST (10) #define ADC_SPI_SLOW_SRL_CNV_OFST (10)
#define ADC_SPI_SLOW_SRL_CNV_MSK (0x00000001 << ADC_SPI_SLOW_SRL_CNV_OFST) #define ADC_SPI_SLOW_SRL_CNV_MSK (0x00000001 << ADC_SPI_SLOW_SRL_CNV_OFST)
/* ADC Offset RW register */ /* ADC Offset RW register */
#define ADC_OFFSET_REG (0x42 << MEM_MAP_SHIFT) #define ADC_OFFSET_REG (0x42 << MEM_MAP_SHIFT)
#define ADC_OFFSET_ADC_PPLN_OFST (0) #define ADC_OFFSET_ADC_PPLN_OFST (0)
#define ADC_OFFSET_ADC_PPLN_MSK (0x000000FF << ADC_OFFSET_ADC_PPLN_OFST) #define ADC_OFFSET_ADC_PPLN_MSK (0x000000FF << ADC_OFFSET_ADC_PPLN_OFST)
#define ADC_OFFSET_DBT_PPLN_OFST (16) #define ADC_OFFSET_DBT_PPLN_OFST (16)
#define ADC_OFFSET_DBT_PPLN_MSK (0x000000FF << ADC_OFFSET_DBT_PPLN_OFST) #define ADC_OFFSET_DBT_PPLN_MSK (0x000000FF << ADC_OFFSET_DBT_PPLN_OFST)
/* ADC Port Invert RW register */ /* ADC Port Invert RW register */
#define ADC_PORT_INVERT_REG (0x43 << MEM_MAP_SHIFT) #define ADC_PORT_INVERT_REG (0x43 << MEM_MAP_SHIFT)
#define ADC_PORT_INVERT_0_INPT_OFST (0) #define ADC_PORT_INVERT_0_INPT_OFST (0)
#define ADC_PORT_INVERT_0_INPT_MSK (0x000000FF << ADC_PORT_INVERT_0_INPT_OFST) #define ADC_PORT_INVERT_0_INPT_MSK (0x000000FF << ADC_PORT_INVERT_0_INPT_OFST)
#define ADC_PORT_INVERT_1_INPT_OFST (8) #define ADC_PORT_INVERT_1_INPT_OFST (8)
#define ADC_PORT_INVERT_1_INPT_MSK (0x000000FF << ADC_PORT_INVERT_1_INPT_OFST) #define ADC_PORT_INVERT_1_INPT_MSK (0x000000FF << ADC_PORT_INVERT_1_INPT_OFST)
#define ADC_PORT_INVERT_2_INPT_OFST (16) #define ADC_PORT_INVERT_2_INPT_OFST (16)
#define ADC_PORT_INVERT_2_INPT_MSK (0x000000FF << ADC_PORT_INVERT_2_INPT_OFST) #define ADC_PORT_INVERT_2_INPT_MSK (0x000000FF << ADC_PORT_INVERT_2_INPT_OFST)
#define ADC_PORT_INVERT_3_INPT_OFST (24) #define ADC_PORT_INVERT_3_INPT_OFST (24)
#define ADC_PORT_INVERT_3_INPT_MSK (0x000000FF << ADC_PORT_INVERT_3_INPT_OFST) #define ADC_PORT_INVERT_3_INPT_MSK (0x000000FF << ADC_PORT_INVERT_3_INPT_OFST)
/* Dummy RW register */ /* Dummy RW register */
#define DUMMY_REG (0x44 << MEM_MAP_SHIFT) #define DUMMY_REG (0x44 << MEM_MAP_SHIFT)
#define DUMMY_FIFO_CHNNL_SLCT_OFST (0) #define DUMMY_FIFO_CHNNL_SLCT_OFST (0)
#define DUMMY_FIFO_CHNNL_SLCT_MSK (0x0000003F << DUMMY_FIFO_CHNNL_SLCT_OFST) #define DUMMY_FIFO_CHNNL_SLCT_MSK (0x0000003F << DUMMY_FIFO_CHNNL_SLCT_OFST)
#define DUMMY_ANLG_FIFO_RD_STRBE_OFST (8) #define DUMMY_ANLG_FIFO_RD_STRBE_OFST (8)
#define DUMMY_ANLG_FIFO_RD_STRBE_MSK (0x00000001 << DUMMY_ANLG_FIFO_RD_STRBE_OFST) #define DUMMY_ANLG_FIFO_RD_STRBE_MSK \
#define DUMMY_DGTL_FIFO_RD_STRBE_OFST (9) (0x00000001 << DUMMY_ANLG_FIFO_RD_STRBE_OFST)
#define DUMMY_DGTL_FIFO_RD_STRBE_MSK (0x00000001 << DUMMY_DGTL_FIFO_RD_STRBE_OFST) #define DUMMY_DGTL_FIFO_RD_STRBE_OFST (9)
#define DUMMY_DGTL_FIFO_RD_STRBE_MSK \
(0x00000001 << DUMMY_DGTL_FIFO_RD_STRBE_OFST)
/* Receiver IP Address RW register */ /* Receiver IP Address RW register */
#define RX_IP_REG (0x45 << MEM_MAP_SHIFT) #define RX_IP_REG (0x45 << MEM_MAP_SHIFT)
/* UDP Port RW register */ /* UDP Port RW register */
#define UDP_PORT_REG (0x46 << MEM_MAP_SHIFT) #define UDP_PORT_REG (0x46 << MEM_MAP_SHIFT)
#define UDP_PORT_RX_OFST (0) #define UDP_PORT_RX_OFST (0)
#define UDP_PORT_RX_MSK (0x0000FFFF << UDP_PORT_RX_OFST) #define UDP_PORT_RX_MSK (0x0000FFFF << UDP_PORT_RX_OFST)
#define UDP_PORT_TX_OFST (16) #define UDP_PORT_TX_OFST (16)
#define UDP_PORT_TX_MSK (0x0000FFFF << UDP_PORT_TX_OFST) #define UDP_PORT_TX_MSK (0x0000FFFF << UDP_PORT_TX_OFST)
/* Receiver Mac Address 64 bit RW register */ /* Receiver Mac Address 64 bit RW register */
#define RX_MAC_LSB_REG (0x47 << MEM_MAP_SHIFT) #define RX_MAC_LSB_REG (0x47 << MEM_MAP_SHIFT)
#define RX_MAC_MSB_REG (0x48 << MEM_MAP_SHIFT) #define RX_MAC_MSB_REG (0x48 << MEM_MAP_SHIFT)
#define RX_MAC_LSB_OFST (0) #define RX_MAC_LSB_OFST (0)
#define RX_MAC_LSB_MSK (0xFFFFFFFF << RX_MAC_LSB_OFST) #define RX_MAC_LSB_MSK (0xFFFFFFFF << RX_MAC_LSB_OFST)
#define RX_MAC_MSB_OFST (0) #define RX_MAC_MSB_OFST (0)
#define RX_MAC_MSB_MSK (0x0000FFFF << RX_MAC_MSB_OFST) #define RX_MAC_MSB_MSK (0x0000FFFF << RX_MAC_MSB_OFST)
/* Detector/ Transmitter Mac Address 64 bit RW register */ /* Detector/ Transmitter Mac Address 64 bit RW register */
#define TX_MAC_LSB_REG (0x49 << MEM_MAP_SHIFT) #define TX_MAC_LSB_REG (0x49 << MEM_MAP_SHIFT)
#define TX_MAC_MSB_REG (0x4A << MEM_MAP_SHIFT) #define TX_MAC_MSB_REG (0x4A << MEM_MAP_SHIFT)
#define TX_MAC_LSB_OFST (0) #define TX_MAC_LSB_OFST (0)
#define TX_MAC_LSB_MSK (0xFFFFFFFF << TX_MAC_LSB_OFST) #define TX_MAC_LSB_MSK (0xFFFFFFFF << TX_MAC_LSB_OFST)
#define TX_MAC_MSB_OFST (0) #define TX_MAC_MSB_OFST (0)
#define TX_MAC_MSB_MSK (0x0000FFFF << TX_MAC_MSB_OFST) #define TX_MAC_MSB_MSK (0x0000FFFF << TX_MAC_MSB_OFST)
/* Detector/ Transmitter IP Address RW register */ /* Detector/ Transmitter IP Address RW register */
#define TX_IP_REG (0x4B << MEM_MAP_SHIFT) #define TX_IP_REG (0x4B << MEM_MAP_SHIFT)
/* Detector/ Transmitter IP Checksum RW register */ /* Detector/ Transmitter IP Checksum RW register */
#define TX_IP_CHECKSUM_REG (0x4C << MEM_MAP_SHIFT) #define TX_IP_CHECKSUM_REG (0x4C << MEM_MAP_SHIFT)
#define TX_IP_CHECKSUM_OFST (0) #define TX_IP_CHECKSUM_OFST (0)
#define TX_IP_CHECKSUM_MSK (0x0000FFFF << TX_IP_CHECKSUM_OFST) #define TX_IP_CHECKSUM_MSK (0x0000FFFF << TX_IP_CHECKSUM_OFST)
/* Configuration RW register */ /* Configuration RW register */
#define CONFIG_REG (0x4D << MEM_MAP_SHIFT) #define CONFIG_REG (0x4D << MEM_MAP_SHIFT)
#define CONFIG_LED_DSBL_OFST (0) #define CONFIG_LED_DSBL_OFST (0)
#define CONFIG_LED_DSBL_MSK (0x00000001 << CONFIG_LED_DSBL_OFST) #define CONFIG_LED_DSBL_MSK (0x00000001 << CONFIG_LED_DSBL_OFST)
#define CONFIG_DSBL_ANLG_OTPT_OFST (8) #define CONFIG_DSBL_ANLG_OTPT_OFST (8)
#define CONFIG_DSBL_ANLG_OTPT_MSK (0x00000001 << CONFIG_DSBL_ANLG_OTPT_OFST) #define CONFIG_DSBL_ANLG_OTPT_MSK (0x00000001 << CONFIG_DSBL_ANLG_OTPT_OFST)
#define CONFIG_ENBLE_DGTL_OTPT_OFST (9) #define CONFIG_ENBLE_DGTL_OTPT_OFST (9)
#define CONFIG_ENBLE_DGTL_OTPT_MSK (0x00000001 << CONFIG_ENBLE_DGTL_OTPT_OFST) #define CONFIG_ENBLE_DGTL_OTPT_MSK (0x00000001 << CONFIG_ENBLE_DGTL_OTPT_OFST)
#define CONFIG_GB10_SND_UDP_OFST (12) #define CONFIG_GB10_SND_UDP_OFST (12)
#define CONFIG_GB10_SND_UDP_MSK (0x00000001 << CONFIG_GB10_SND_UDP_OFST) #define CONFIG_GB10_SND_UDP_MSK (0x00000001 << CONFIG_GB10_SND_UDP_OFST)
/* External Signal RW register */ /* External Signal RW register */
#define EXT_SIGNAL_REG (0x4E << MEM_MAP_SHIFT) #define EXT_SIGNAL_REG (0x4E << MEM_MAP_SHIFT)
#define EXT_SIGNAL_OFST (0) #define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST) #define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
#define EXT_SIGNAL_AUTO_VAL ((0x0 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK) #define EXT_SIGNAL_AUTO_VAL ((0x0 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK)
#define EXT_SIGNAL_TRGGR_VAL ((0x1 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK) #define EXT_SIGNAL_TRGGR_VAL ((0x1 << EXT_SIGNAL_OFST) & EXT_SIGNAL_MSK)
/* Control RW register */ /* Control RW register */
#define CONTROL_REG (0x4F << MEM_MAP_SHIFT) #define CONTROL_REG (0x4F << MEM_MAP_SHIFT)
#define CONTROL_STRT_ACQSTN_OFST (0) #define CONTROL_STRT_ACQSTN_OFST (0)
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST) #define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
#define CONTROL_STP_ACQSTN_OFST (1) #define CONTROL_STP_ACQSTN_OFST (1)
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST) #define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
//#define CONTROL_STRT_FF_TST_OFST (2) //#define CONTROL_STRT_FF_TST_OFST (2)
//#define CONTROL_STRT_FF_TST_MSK (0x00000001 << CONTROL_STRT_FF_TST_OFST) //#define CONTROL_STRT_FF_TST_MSK (0x00000001 <<
//#define CONTROL_STP_FF_TST_OFST (3) // CONTROL_STRT_FF_TST_OFST) #define CONTROL_STP_FF_TST_OFST (3)
//#define CONTROL_STP_FF_TST_MSK (0x00000001 << CONTROL_STP_FF_TST_OFST) //#define CONTROL_STP_FF_TST_MSK (0x00000001 <<
//#define CONTROL_STRT_RDT_OFST (4) // CONTROL_STP_FF_TST_OFST) #define CONTROL_STRT_RDT_OFST (4)
//#define CONTROL_STRT_RDT_MSK (0x00000001 << CONTROL_STRT_RDT_OFST) //#define CONTROL_STRT_RDT_MSK (0x00000001 <<
//#define CONTROL_STP_RDT_OFST (5) // CONTROL_STRT_RDT_OFST) #define CONTROL_STP_RDT_OFST (5)
//#define CONTROL_STP_RDT_MSK (0x00000001 << CONTROL_STP_RDT_OFST) // #define CONTROL_STP_RDT_MSK (0x00000001 <<
#define CONTROL_STRT_EXPSR_OFST (6) // CONTROL_STP_RDT_OFST)
#define CONTROL_STRT_EXPSR_MSK (0x00000001 << CONTROL_STRT_EXPSR_OFST) #define CONTROL_STRT_EXPSR_OFST (6)
#define CONTROL_STRT_EXPSR_MSK (0x00000001 << CONTROL_STRT_EXPSR_OFST)
//#define CONTROL_STP_EXPSR_OFST (7) //#define CONTROL_STP_EXPSR_OFST (7)
//#define CONTROL_STP_EXPSR_MSK (0x00000001 << CONTROL_STP_RDT_OFST) //#define CONTROL_STP_EXPSR_MSK (0x00000001 <<
//#define CONTROL_STRT_TRN_OFST (8) // CONTROL_STP_RDT_OFST) #define CONTROL_STRT_TRN_OFST (8) #define
//#define CONTROL_STRT_TRN_MSK (0x00000001 << CONTROL_STRT_RDT_OFST) // CONTROL_STRT_TRN_MSK (0x00000001 << CONTROL_STRT_RDT_OFST)
//#define CONTROL_STP_TRN_OFST (9) //#define CONTROL_STP_TRN_OFST (9)
//#define CONTROL_STP_TRN_MSK (0x00000001 << CONTROL_STP_RDT_OFST) //#define CONTROL_STP_TRN_MSK (0x00000001 <<
#define CONTROL_CRE_RST_OFST (10) // CONTROL_STP_RDT_OFST)
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST) #define CONTROL_CRE_RST_OFST (10)
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10? #define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) #define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
#define CONTROL_MMRY_RST_OFST (12) #define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_MMRY_RST_MSK (0x00000001 << CONTROL_MMRY_RST_OFST) #define CONTROL_MMRY_RST_OFST (12)
#define CONTROL_MMRY_RST_MSK (0x00000001 << CONTROL_MMRY_RST_OFST)
//#define CONTROL_PLL_RCNFG_WR_OFST (13) //#define CONTROL_PLL_RCNFG_WR_OFST (13)
//#define CONTROL_PLL_RCNFG_WR_MSK (0x00000001 << CONTROL_PLL_RCNFG_WR_OFST) //#define CONTROL_PLL_RCNFG_WR_MSK (0x00000001 <<
#define CONTROL_SND_10GB_PCKT_OFST (14) // CONTROL_PLL_RCNFG_WR_OFST)
#define CONTROL_SND_10GB_PCKT_MSK (0x00000001 << CONTROL_SND_10GB_PCKT_OFST) #define CONTROL_SND_10GB_PCKT_OFST (14)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15) #define CONTROL_SND_10GB_PCKT_MSK (0x00000001 << CONTROL_SND_10GB_PCKT_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) #define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
/* Reconfiguratble PLL Paramater RW register */ /* Reconfiguratble PLL Paramater RW register */
#define PLL_PARAM_REG (0x50 << MEM_MAP_SHIFT) #define PLL_PARAM_REG (0x50 << MEM_MAP_SHIFT)
/* Reconfiguratble PLL Control RW regiser */ /* Reconfiguratble PLL Control RW regiser */
#define PLL_CNTRL_REG (0x51 << MEM_MAP_SHIFT) #define PLL_CNTRL_REG (0x51 << MEM_MAP_SHIFT)
#define PLL_CNTRL_RCNFG_PRMTR_RST_OFST (0) #define PLL_CNTRL_RCNFG_PRMTR_RST_OFST (0)
#define PLL_CNTRL_RCNFG_PRMTR_RST_MSK (0x00000001 << PLL_CNTRL_RCNFG_PRMTR_RST_OFST) #define PLL_CNTRL_RCNFG_PRMTR_RST_MSK \
#define PLL_CNTRL_WR_PRMTR_OFST (2) (0x00000001 << PLL_CNTRL_RCNFG_PRMTR_RST_OFST)
#define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST) #define PLL_CNTRL_WR_PRMTR_OFST (2)
#define PLL_CNTRL_PLL_RST_OFST (3) #define PLL_CNTRL_WR_PRMTR_MSK (0x00000001 << PLL_CNTRL_WR_PRMTR_OFST)
#define PLL_CNTRL_PLL_RST_MSK (0x00000001 << PLL_CNTRL_PLL_RST_OFST) #define PLL_CNTRL_PLL_RST_OFST (3)
#define PLL_CNTRL_ADDR_OFST (16) #define PLL_CNTRL_PLL_RST_MSK (0x00000001 << PLL_CNTRL_PLL_RST_OFST)
#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST) #define PLL_CNTRL_ADDR_OFST (16)
#define PLL_CNTRL_ADDR_MSK (0x0000003F << PLL_CNTRL_ADDR_OFST)
/* Pattern Control RW register */ /* Pattern Control RW register */
#define PATTERN_CNTRL_REG (0x52 << MEM_MAP_SHIFT) #define PATTERN_CNTRL_REG (0x52 << MEM_MAP_SHIFT)
#define PATTERN_CNTRL_WR_OFST (0) #define PATTERN_CNTRL_WR_OFST (0)
#define PATTERN_CNTRL_WR_MSK (0x00000001 << PATTERN_CNTRL_WR_OFST) #define PATTERN_CNTRL_WR_MSK (0x00000001 << PATTERN_CNTRL_WR_OFST)
#define PATTERN_CNTRL_RD_OFST (1) #define PATTERN_CNTRL_RD_OFST (1)
#define PATTERN_CNTRL_RD_MSK (0x00000001 << PATTERN_CNTRL_RD_OFST) #define PATTERN_CNTRL_RD_MSK (0x00000001 << PATTERN_CNTRL_RD_OFST)
#define PATTERN_CNTRL_ADDR_OFST (16) #define PATTERN_CNTRL_ADDR_OFST (16)
#define PATTERN_CNTRL_ADDR_MSK (0x00001FFF << PATTERN_CNTRL_ADDR_OFST) #define PATTERN_CNTRL_ADDR_MSK (0x00001FFF << PATTERN_CNTRL_ADDR_OFST)
/* Pattern Limit RW regiser */ /* Pattern Limit RW regiser */
#define PATTERN_LIMIT_REG (0x53 << MEM_MAP_SHIFT) #define PATTERN_LIMIT_REG (0x53 << MEM_MAP_SHIFT)
#define PATTERN_LIMIT_STRT_OFST (0) #define PATTERN_LIMIT_STRT_OFST (0)
#define PATTERN_LIMIT_STRT_MSK (0x00001FFF << PATTERN_LIMIT_STRT_OFST) #define PATTERN_LIMIT_STRT_MSK (0x00001FFF << PATTERN_LIMIT_STRT_OFST)
#define PATTERN_LIMIT_STP_OFST (16) #define PATTERN_LIMIT_STP_OFST (16)
#define PATTERN_LIMIT_STP_MSK (0x00001FFF << PATTERN_LIMIT_STP_OFST) #define PATTERN_LIMIT_STP_MSK (0x00001FFF << PATTERN_LIMIT_STP_OFST)
/* Pattern Loop 0 Address RW regiser */ /* Pattern Loop 0 Address RW regiser */
#define PATTERN_LOOP_0_ADDR_REG (0x54 << MEM_MAP_SHIFT) #define PATTERN_LOOP_0_ADDR_REG (0x54 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_0_ADDR_STRT_OFST (0) #define PATTERN_LOOP_0_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_0_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STRT_OFST) #define PATTERN_LOOP_0_ADDR_STRT_MSK \
#define PATTERN_LOOP_0_ADDR_STP_OFST (16) (0x00001FFF << PATTERN_LOOP_0_ADDR_STRT_OFST)
#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STP_OFST) #define PATTERN_LOOP_0_ADDR_STP_OFST (16)
#define PATTERN_LOOP_0_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_0_ADDR_STP_OFST)
/* Pattern Loop 0 Iteration RW regiser */ /* Pattern Loop 0 Iteration RW regiser */
#define PATTERN_LOOP_0_ITERATION_REG (0x55 << MEM_MAP_SHIFT) #define PATTERN_LOOP_0_ITERATION_REG (0x55 << MEM_MAP_SHIFT)
/* Pattern Loop 1 Address RW regiser */ /* Pattern Loop 1 Address RW regiser */
#define PATTERN_LOOP_1_ADDR_REG (0x56 << MEM_MAP_SHIFT) #define PATTERN_LOOP_1_ADDR_REG (0x56 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_1_ADDR_STRT_OFST (0) #define PATTERN_LOOP_1_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_1_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STRT_OFST) #define PATTERN_LOOP_1_ADDR_STRT_MSK \
#define PATTERN_LOOP_1_ADDR_STP_OFST (16) (0x00001FFF << PATTERN_LOOP_1_ADDR_STRT_OFST)
#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STP_OFST) #define PATTERN_LOOP_1_ADDR_STP_OFST (16)
#define PATTERN_LOOP_1_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_1_ADDR_STP_OFST)
/* Pattern Loop 1 Iteration RW regiser */ /* Pattern Loop 1 Iteration RW regiser */
#define PATTERN_LOOP_1_ITERATION_REG (0x57 << MEM_MAP_SHIFT) #define PATTERN_LOOP_1_ITERATION_REG (0x57 << MEM_MAP_SHIFT)
/* Pattern Loop 2 Address RW regiser */ /* Pattern Loop 2 Address RW regiser */
#define PATTERN_LOOP_2_ADDR_REG (0x58 << MEM_MAP_SHIFT) #define PATTERN_LOOP_2_ADDR_REG (0x58 << MEM_MAP_SHIFT)
#define PATTERN_LOOP_2_ADDR_STRT_OFST (0) #define PATTERN_LOOP_2_ADDR_STRT_OFST (0)
#define PATTERN_LOOP_2_ADDR_STRT_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STRT_OFST) #define PATTERN_LOOP_2_ADDR_STRT_MSK \
#define PATTERN_LOOP_2_ADDR_STP_OFST (16) (0x00001FFF << PATTERN_LOOP_2_ADDR_STRT_OFST)
#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STP_OFST) #define PATTERN_LOOP_2_ADDR_STP_OFST (16)
#define PATTERN_LOOP_2_ADDR_STP_MSK (0x00001FFF << PATTERN_LOOP_2_ADDR_STP_OFST)
/* Pattern Loop 2 Iteration RW regiser */ /* Pattern Loop 2 Iteration RW regiser */
#define PATTERN_LOOP_2_ITERATION_REG (0x59 << MEM_MAP_SHIFT) #define PATTERN_LOOP_2_ITERATION_REG (0x59 << MEM_MAP_SHIFT)
/* Pattern Wait 0 RW regiser */ /* Pattern Wait 0 RW regiser */
#define PATTERN_WAIT_0_ADDR_REG (0x5A << MEM_MAP_SHIFT) #define PATTERN_WAIT_0_ADDR_REG (0x5A << MEM_MAP_SHIFT)
#define PATTERN_WAIT_0_ADDR_OFST (0) #define PATTERN_WAIT_0_ADDR_OFST (0)
#define PATTERN_WAIT_0_ADDR_MSK (0x00001FFF << PATTERN_WAIT_0_ADDR_OFST) #define PATTERN_WAIT_0_ADDR_MSK (0x00001FFF << PATTERN_WAIT_0_ADDR_OFST)
//FIXME: is mask 3FF // FIXME: is mask 3FF
/* Pattern Wait 1 RW regiser */ /* Pattern Wait 1 RW regiser */
#define PATTERN_WAIT_1_ADDR_REG (0x5B << MEM_MAP_SHIFT) #define PATTERN_WAIT_1_ADDR_REG (0x5B << MEM_MAP_SHIFT)
#define PATTERN_WAIT_1_ADDR_OFST (0) #define PATTERN_WAIT_1_ADDR_OFST (0)
#define PATTERN_WAIT_1_ADDR_MSK (0x00001FFF << PATTERN_WAIT_1_ADDR_OFST) #define PATTERN_WAIT_1_ADDR_MSK (0x00001FFF << PATTERN_WAIT_1_ADDR_OFST)
/* Pattern Wait 2 RW regiser */ /* Pattern Wait 2 RW regiser */
#define PATTERN_WAIT_2_ADDR_REG (0x5C << MEM_MAP_SHIFT) #define PATTERN_WAIT_2_ADDR_REG (0x5C << MEM_MAP_SHIFT)
#define PATTERN_WAIT_2_ADDR_OFST (0) #define PATTERN_WAIT_2_ADDR_OFST (0)
#define PATTERN_WAIT_2_ADDR_MSK (0x00001FFF << PATTERN_WAIT_2_ADDR_OFST) #define PATTERN_WAIT_2_ADDR_MSK (0x00001FFF << PATTERN_WAIT_2_ADDR_OFST)
/* Samples RW register */ /* Samples RW register */
#define SAMPLES_REG (0x5D << MEM_MAP_SHIFT) #define SAMPLES_REG (0x5D << MEM_MAP_SHIFT)
#define SAMPLES_DIGITAL_OFST (0) #define SAMPLES_DIGITAL_OFST (0)
#define SAMPLES_DIGITAL_MSK (0x0000FFFF << SAMPLES_DIGITAL_OFST) #define SAMPLES_DIGITAL_MSK (0x0000FFFF << SAMPLES_DIGITAL_OFST)
#define SAMPLES_ANALOG_OFST (16) #define SAMPLES_ANALOG_OFST (16)
#define SAMPLES_ANALOG_MSK (0x0000FFFF << SAMPLES_ANALOG_OFST) #define SAMPLES_ANALOG_MSK (0x0000FFFF << SAMPLES_ANALOG_OFST)
/** Power RW register */ /** Power RW register */
#define POWER_REG (0x5E << MEM_MAP_SHIFT) #define POWER_REG (0x5E << MEM_MAP_SHIFT)
#define POWER_ENBL_VLTG_RGLTR_OFST (16) #define POWER_ENBL_VLTG_RGLTR_OFST (16)
#define POWER_ENBL_VLTG_RGLTR_MSK (0x0000001F << POWER_ENBL_VLTG_RGLTR_OFST) #define POWER_ENBL_VLTG_RGLTR_MSK (0x0000001F << POWER_ENBL_VLTG_RGLTR_OFST)
#define POWER_HV_INTERNAL_SLCT_OFST (31) #define POWER_HV_INTERNAL_SLCT_OFST (31)
#define POWER_HV_INTERNAL_SLCT_MSK (0x00000001 << POWER_HV_INTERNAL_SLCT_OFST) #define POWER_HV_INTERNAL_SLCT_MSK (0x00000001 << POWER_HV_INTERNAL_SLCT_OFST)
/* Number of Words RW register TODO */ /* Number of Words RW register TODO */
#define NUMBER_OF_WORDS_REG (0x5F << MEM_MAP_SHIFT) #define NUMBER_OF_WORDS_REG (0x5F << MEM_MAP_SHIFT)
/* Delay 64 bit RW register. t = DLY x 50 ns. */ /* Delay 64 bit RW register. t = DLY x 50 ns. */
#define DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT) #define DELAY_LSB_REG (0x60 << MEM_MAP_SHIFT)
#define DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT) #define DELAY_MSB_REG (0x61 << MEM_MAP_SHIFT)
/* Triggers 64 bit RW register */ /* Triggers 64 bit RW register */
#define CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT) #define CYCLES_LSB_REG (0x62 << MEM_MAP_SHIFT)
#define CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT) #define CYCLES_MSB_REG (0x63 << MEM_MAP_SHIFT)
/* Frames 64 bit RW register */ /* Frames 64 bit RW register */
#define FRAMES_LSB_REG (0x64 << MEM_MAP_SHIFT) #define FRAMES_LSB_REG (0x64 << MEM_MAP_SHIFT)
#define FRAMES_MSB_REG (0x65 << MEM_MAP_SHIFT) #define FRAMES_MSB_REG (0x65 << MEM_MAP_SHIFT)
/* Period 64 bit RW register */ /* Period 64 bit RW register */
#define PERIOD_LSB_REG (0x66 << MEM_MAP_SHIFT) #define PERIOD_LSB_REG (0x66 << MEM_MAP_SHIFT)
#define PERIOD_MSB_REG (0x67 << MEM_MAP_SHIFT) #define PERIOD_MSB_REG (0x67 << MEM_MAP_SHIFT)
/* Period 64 bit RW register */ /* Period 64 bit RW register */
//#define EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT) // Not used in FW //#define EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT) //
//#define EXPTIME_MSB_REG (0x69 << MEM_MAP_SHIFT) // Not used in FW // Not used in FW #define EXPTIME_MSB_REG (0x69 <<
// MEM_MAP_SHIFT) // Not used in FW
/* Gates 64 bit RW register */ /* Gates 64 bit RW register */
//#define GATES_LSB_REG (0x6A << MEM_MAP_SHIFT) // Not used in FW //#define GATES_LSB_REG (0x6A << MEM_MAP_SHIFT) // Not used
//#define GATES_MSB_REG (0x6B << MEM_MAP_SHIFT) // Not used in FW // in FW #define GATES_MSB_REG (0x6B << MEM_MAP_SHIFT) //
// Not used in FW
/* Pattern IO Control 64 bit RW regiser /* Pattern IO Control 64 bit RW regiser
* Each bit configured as output(1)/ input(0) */ * Each bit configured as output(1)/ input(0) */
#define PATTERN_IO_CNTRL_LSB_REG (0x6C << MEM_MAP_SHIFT) #define PATTERN_IO_CNTRL_LSB_REG (0x6C << MEM_MAP_SHIFT)
#define PATTERN_IO_CNTRL_MSB_REG (0x6D << MEM_MAP_SHIFT) #define PATTERN_IO_CNTRL_MSB_REG (0x6D << MEM_MAP_SHIFT)
/* Pattern IO Clock Control 64 bit RW regiser /* Pattern IO Clock Control 64 bit RW regiser
* When bit n enabled (1), clocked output for DIO[n] (T run clock) * When bit n enabled (1), clocked output for DIO[n] (T run clock)
* When bit n disabled (0), Dio[n] driven by its pattern output */ * When bit n disabled (0), Dio[n] driven by its pattern output */
#define PATTERN_IO_CLK_CNTRL_LSB_REG (0x6E << MEM_MAP_SHIFT) #define PATTERN_IO_CLK_CNTRL_LSB_REG (0x6E << MEM_MAP_SHIFT)
#define PATTERN_IO_CLK_CNTRL_MSB_REG (0x6F << MEM_MAP_SHIFT) #define PATTERN_IO_CLK_CNTRL_MSB_REG (0x6F << MEM_MAP_SHIFT)
/* Pattern In 64 bit RW register */ /* Pattern In 64 bit RW register */
#define PATTERN_IN_LSB_REG (0x70 << MEM_MAP_SHIFT) #define PATTERN_IN_LSB_REG (0x70 << MEM_MAP_SHIFT)
#define PATTERN_IN_MSB_REG (0x71 << MEM_MAP_SHIFT) #define PATTERN_IN_MSB_REG (0x71 << MEM_MAP_SHIFT)
/* Pattern Wait Timer 0 64 bit RW register. t = PWT1 x T run clock */ /* Pattern Wait Timer 0 64 bit RW register. t = PWT1 x T run clock */
#define PATTERN_WAIT_TIMER_0_LSB_REG (0x72 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_0_LSB_REG (0x72 << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_0_MSB_REG (0x73 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_0_MSB_REG (0x73 << MEM_MAP_SHIFT)
/* Pattern Wait Timer 1 64 bit RW register. t = PWT2 x T run clock */ /* Pattern Wait Timer 1 64 bit RW register. t = PWT2 x T run clock */
#define PATTERN_WAIT_TIMER_1_LSB_REG (0x74 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_1_LSB_REG (0x74 << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_1_MSB_REG (0x75 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_1_MSB_REG (0x75 << MEM_MAP_SHIFT)
/* Pattern Wait Timer 2 64 bit RW register. t = PWT3 x T run clock */ /* Pattern Wait Timer 2 64 bit RW register. t = PWT3 x T run clock */
#define PATTERN_WAIT_TIMER_2_LSB_REG (0x76 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_2_LSB_REG (0x76 << MEM_MAP_SHIFT)
#define PATTERN_WAIT_TIMER_2_MSB_REG (0x77 << MEM_MAP_SHIFT) #define PATTERN_WAIT_TIMER_2_MSB_REG (0x77 << MEM_MAP_SHIFT)
/* Readout enable RW register */ /* Readout enable RW register */
#define READOUT_10G_ENABLE_REG (0x79 << MEM_MAP_SHIFT) #define READOUT_10G_ENABLE_REG (0x79 << MEM_MAP_SHIFT)
#define READOUT_10G_ENABLE_ANLG_OFST (0)
#define READOUT_10G_ENABLE_ANLG_MSK (0x000000FF << READOUT_10G_ENABLE_ANLG_OFST)
#define READOUT_10G_ENABLE_DGTL_OFST (8)
#define READOUT_10G_ENABLE_DGTL_MSK (0x00000001 << READOUT_10G_ENABLE_DGTL_OFST)
#define READOUT_10G_ENABLE_ANLG_OFST (0)
#define READOUT_10G_ENABLE_ANLG_MSK (0x000000FF << READOUT_10G_ENABLE_ANLG_OFST)
#define READOUT_10G_ENABLE_DGTL_OFST (8)
#define READOUT_10G_ENABLE_DGTL_MSK (0x00000001 << READOUT_10G_ENABLE_DGTL_OFST)
/* Digital Bit External Trigger RW register */ /* Digital Bit External Trigger RW register */
#define DBIT_EXT_TRG_REG (0x7B << MEM_MAP_SHIFT) #define DBIT_EXT_TRG_REG (0x7B << MEM_MAP_SHIFT)
#define DBIT_EXT_TRG_SRC_OFST (0) #define DBIT_EXT_TRG_SRC_OFST (0)
#define DBIT_EXT_TRG_SRC_MSK (0x0000003F << DBIT_EXT_TRG_SRC_OFST) #define DBIT_EXT_TRG_SRC_MSK (0x0000003F << DBIT_EXT_TRG_SRC_OFST)
#define DBIT_EXT_TRG_OPRTN_MD_OFST (16) #define DBIT_EXT_TRG_OPRTN_MD_OFST (16)
#define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST) #define DBIT_EXT_TRG_OPRTN_MD_MSK (0x00000001 << DBIT_EXT_TRG_OPRTN_MD_OFST)
/* Pin Delay 0 RW register */ /* Pin Delay 0 RW register */
#define OUTPUT_DELAY_0_REG (0x7C << MEM_MAP_SHIFT) #define OUTPUT_DELAY_0_REG (0x7C << MEM_MAP_SHIFT)
#define OUTPUT_DELAY_0_OTPT_STTNG_STEPS (25) #define OUTPUT_DELAY_0_OTPT_STTNG_STEPS (25)
#define OUTPUT_DELAY_0_OTPT_STTNG_OFST (0) //t = OTPT_STTNG * 25 ps, max for Cyclone V = 775 ps #define OUTPUT_DELAY_0_OTPT_STTNG_OFST \
#define OUTPUT_DELAY_0_OTPT_STTNG_MSK (0x0000001F << OUTPUT_DELAY_0_OTPT_STTNG_OFST) (0) // t = OTPT_STTNG * 25 ps, max for Cyclone V = 775 ps
// 1: load dynamic output settings, 0: trigger start of dynamic output delay configuration pn falling edge of ODT (output delay trigger) bit #define OUTPUT_DELAY_0_OTPT_STTNG_MSK \
#define OUTPUT_DELAY_0_OTPT_TRGGR_OFST (31) (0x0000001F << OUTPUT_DELAY_0_OTPT_STTNG_OFST)
#define OUTPUT_DELAY_0_OTPT_TRGGR_MSK (0x00000001 << OUTPUT_DELAY_0_OTPT_TRGGR_OFST) // 1: load dynamic output settings, 0: trigger start of dynamic output delay
#define OUTPUT_DELAY_0_OTPT_TRGGR_LD_VAL (1) // configuration pn falling edge of ODT (output delay trigger) bit
#define OUTPUT_DELAY_0_OTPT_TRGGR_STRT_VAL (0) #define OUTPUT_DELAY_0_OTPT_TRGGR_OFST (31)
#define OUTPUT_DELAY_0_OTPT_TRGGR_MSK \
(0x00000001 << OUTPUT_DELAY_0_OTPT_TRGGR_OFST)
#define OUTPUT_DELAY_0_OTPT_TRGGR_LD_VAL (1)
#define OUTPUT_DELAY_0_OTPT_TRGGR_STRT_VAL (0)
/* Pin Delay 1 RW register /* Pin Delay 1 RW register
* Each bit configured as enable for dynamic output delay configuration */ * Each bit configured as enable for dynamic output delay configuration */
#define PIN_DELAY_1_REG (0x7D << MEM_MAP_SHIFT) #define PIN_DELAY_1_REG (0x7D << MEM_MAP_SHIFT)
/** Pattern Mask 64 bit RW regiser */ /** Pattern Mask 64 bit RW regiser */
#define PATTERN_MASK_LSB_REG (0x80 << MEM_MAP_SHIFT) #define PATTERN_MASK_LSB_REG (0x80 << MEM_MAP_SHIFT)
#define PATTERN_MASK_MSB_REG (0x81 << MEM_MAP_SHIFT) #define PATTERN_MASK_MSB_REG (0x81 << MEM_MAP_SHIFT)
/** Pattern Set 64 bit RW regiser */ /** Pattern Set 64 bit RW regiser */
#define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT) #define PATTERN_SET_LSB_REG (0x82 << MEM_MAP_SHIFT)
#define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT) #define PATTERN_SET_MSB_REG (0x83 << MEM_MAP_SHIFT)
/** I2C Control register */ /** I2C Control register */
#define I2C_TRANSFER_COMMAND_FIFO_REG (0x100 << MEM_MAP_SHIFT) #define I2C_TRANSFER_COMMAND_FIFO_REG (0x100 << MEM_MAP_SHIFT)
#define I2C_RX_DATA_FIFO_REG (0x101 << MEM_MAP_SHIFT) #define I2C_RX_DATA_FIFO_REG (0x101 << MEM_MAP_SHIFT)
#define I2C_CONTROL_REG (0x102 << MEM_MAP_SHIFT) #define I2C_CONTROL_REG (0x102 << MEM_MAP_SHIFT)
#define I2C_STATUS_REG (0x105 << MEM_MAP_SHIFT) #define I2C_STATUS_REG (0x105 << MEM_MAP_SHIFT)
#define I2C_RX_DATA_FIFO_LEVEL_REG (0x107 << MEM_MAP_SHIFT) #define I2C_RX_DATA_FIFO_LEVEL_REG (0x107 << MEM_MAP_SHIFT)
#define I2C_SCL_LOW_COUNT_REG (0x108 << MEM_MAP_SHIFT) #define I2C_SCL_LOW_COUNT_REG (0x108 << MEM_MAP_SHIFT)
#define I2C_SCL_HIGH_COUNT_REG (0x109 << MEM_MAP_SHIFT) #define I2C_SCL_HIGH_COUNT_REG (0x109 << MEM_MAP_SHIFT)
#define I2C_SDA_HOLD_REG (0x10A << MEM_MAP_SHIFT) #define I2C_SDA_HOLD_REG (0x10A << MEM_MAP_SHIFT)
//fixme: upto 0x10f // fixme: upto 0x10f
/* Round Robin */ /* Round Robin */
#define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT) #define RXR_ENDPOINT_START_REG (0x1000 << MEM_MAP_SHIFT)

File diff suppressed because it is too large Load Diff

View File

@ -1,112 +1,158 @@
#pragma once #pragma once
#include "sls_detector_defs.h"
#include "RegisterDefs.h" #include "RegisterDefs.h"
#include "sls_detector_defs.h"
#define MIN_REQRD_VRSN_T_RD_API 0x181130
#define REQRD_FRMWR_VRSN 0x191127
#define MIN_REQRD_VRSN_T_RD_API 0x181130 #define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
#define REQRD_FRMWR_VRSN 0x191127
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
/* Struct Definitions */ /* Struct Definitions */
typedef struct udp_header_struct { typedef struct udp_header_struct {
uint32_t udp_destmac_msb; uint32_t udp_destmac_msb;
uint16_t udp_srcmac_msb; uint16_t udp_srcmac_msb;
uint16_t udp_destmac_lsb; uint16_t udp_destmac_lsb;
uint32_t udp_srcmac_lsb; uint32_t udp_srcmac_lsb;
uint8_t ip_tos; uint8_t ip_tos;
uint8_t ip_ihl: 4, ip_ver: 4; uint8_t ip_ihl : 4, ip_ver : 4;
uint16_t udp_ethertype; uint16_t udp_ethertype;
uint16_t ip_identification; uint16_t ip_identification;
uint16_t ip_totallength; uint16_t ip_totallength;
uint8_t ip_protocol; uint8_t ip_protocol;
uint8_t ip_ttl; uint8_t ip_ttl;
uint16_t ip_fragmentoffset: 13, ip_flags: 3; uint16_t ip_fragmentoffset : 13, ip_flags : 3;
uint16_t ip_srcip_msb; uint16_t ip_srcip_msb;
uint16_t ip_checksum; uint16_t ip_checksum;
uint16_t ip_destip_msb; uint16_t ip_destip_msb;
uint16_t ip_srcip_lsb; uint16_t ip_srcip_lsb;
uint16_t udp_srcport; uint16_t udp_srcport;
uint16_t ip_destip_lsb; uint16_t ip_destip_lsb;
uint16_t udp_checksum; uint16_t udp_checksum;
uint16_t udp_destport; uint16_t udp_destport;
} udp_header; } udp_header;
#define IP_HEADER_SIZE (20) #define IP_HEADER_SIZE (20)
#define UDP_IP_HEADER_LENGTH_BYTES (28) #define UDP_IP_HEADER_LENGTH_BYTES (28)
/* Enums */ /* Enums */
enum ADCINDEX {V_PWR_IO, V_PWR_A, V_PWR_B, V_PWR_C, V_PWR_D, I_PWR_IO, I_PWR_A, I_PWR_B, I_PWR_C, I_PWR_D, S_ADC0, S_ADC1, S_ADC2, S_ADC3, S_ADC4, S_ADC5, S_ADC6, S_ADC7, S_TMP}; enum ADCINDEX {
enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, V_PWR_IO,
D10, D11, D12, D13, D14, D15, D16, D17, V_PWR_A,
D_PWR_D, D_PWR_CHIP, D_PWR_C, D_PWR_B, D_PWR_A, D_PWR_IO}; V_PWR_B,
enum CLKINDEX {RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS}; V_PWR_C,
#define CLK_NAMES "run", "adc", "sync", "dbit" V_PWR_D,
I_PWR_IO,
I_PWR_A,
I_PWR_B,
I_PWR_C,
I_PWR_D,
S_ADC0,
S_ADC1,
S_ADC2,
S_ADC3,
S_ADC4,
S_ADC5,
S_ADC6,
S_ADC7,
S_TMP
};
enum DACINDEX {
D0,
D1,
D2,
D3,
D4,
D5,
D6,
D7,
D8,
D9,
D10,
D11,
D12,
D13,
D14,
D15,
D16,
D17,
D_PWR_D,
D_PWR_CHIP,
D_PWR_C,
D_PWR_B,
D_PWR_A,
D_PWR_IO
};
enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
#define CLK_NAMES "run", "adc", "sync", "dbit"
/* Hardware Definitions */ /* Hardware Definitions */
#define NCHAN (36) #define NCHAN (36)
#define NCHAN_ANALOG (32) #define NCHAN_ANALOG (32)
#define NCHAN_DIGITAL (64) #define NCHAN_DIGITAL (64)
#define NCHIP (1) #define NCHIP (1)
#define NDAC (24) #define NDAC (24)
#define NPWR (6) #define NPWR (6)
#define NDAC_ONLY (NDAC - NPWR) #define NDAC_ONLY (NDAC - NPWR)
#define DYNAMIC_RANGE (16) #define DYNAMIC_RANGE (16)
#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8) #define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8)
#define CLK_FREQ (156.25) /* MHz */ #define CLK_FREQ (156.25) /* MHz */
#define I2C_POWER_VIO_DEVICE_ID (0x40) #define I2C_POWER_VIO_DEVICE_ID (0x40)
#define I2C_POWER_VA_DEVICE_ID (0x41) #define I2C_POWER_VA_DEVICE_ID (0x41)
#define I2C_POWER_VB_DEVICE_ID (0x42) #define I2C_POWER_VB_DEVICE_ID (0x42)
#define I2C_POWER_VC_DEVICE_ID (0x43) #define I2C_POWER_VC_DEVICE_ID (0x43)
#define I2C_POWER_VD_DEVICE_ID (0x44) #define I2C_POWER_VD_DEVICE_ID (0x44)
#define I2C_SHUNT_RESISTER_OHMS (0.005) #define I2C_SHUNT_RESISTER_OHMS (0.005)
/** Default Parameters */ /** Default Parameters */
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL) #define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_NUM_SAMPLES (1) #define DEFAULT_NUM_SAMPLES (1)
#define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_EXPTIME (0) #define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_CYCLES (1) #define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) //ns #define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0) #define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100) #define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a) #define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_RUN_CLK (200) // 40 #define DEFAULT_RUN_CLK (200) // 40
#define DEFAULT_ADC_CLK (40) // 20 #define DEFAULT_ADC_CLK (40) // 20
#define DEFAULT_SYNC_CLK (40) // 20 #define DEFAULT_SYNC_CLK (40) // 20
#define DEFAULT_DBIT_CLK (200) #define DEFAULT_DBIT_CLK (200)
#define HIGHVOLTAGE_MIN (60) #define HIGHVOLTAGE_MIN (60)
#define HIGHVOLTAGE_MAX (200) // min dac val #define HIGHVOLTAGE_MAX (200) // min dac val
#define DAC_MIN_MV (0) #define DAC_MIN_MV (0)
#define DAC_MAX_MV (2500) #define DAC_MAX_MV (2500)
#define VCHIP_MIN_MV (1673) #define VCHIP_MIN_MV (1673)
#define VCHIP_MAX_MV (2668) // min dac val #define VCHIP_MAX_MV (2668) // min dac val
#define POWER_RGLTR_MIN (636) #define POWER_RGLTR_MIN (636)
#define POWER_RGLTR_MAX (2638) // min dac val (not vchip-max) because of dac conversions #define POWER_RGLTR_MAX \
#define VCHIP_POWER_INCRMNT (200) (2638) // min dac val (not vchip-max) because of dac conversions
#define VIO_MIN_MV (1200) // for fpga to function #define VCHIP_POWER_INCRMNT (200)
#define VIO_MIN_MV (1200) // for fpga to function
/* Defines in the Firmware */ /* Defines in the Firmware */
#define MAX_PATTERN_LENGTH (0x2000) #define MAX_PATTERN_LENGTH (0x2000)
#define DIGITAL_IO_DELAY_MAXIMUM_PS ((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * OUTPUT_DELAY_0_OTPT_STTNG_STEPS) #define DIGITAL_IO_DELAY_MAXIMUM_PS \
#define MAX_PHASE_SHIFTS_STEPS (8) ((OUTPUT_DELAY_0_OTPT_STTNG_MSK >> OUTPUT_DELAY_0_OTPT_STTNG_OFST) * \
OUTPUT_DELAY_0_OTPT_STTNG_STEPS)
#define MAX_PHASE_SHIFTS_STEPS (8)
#define WAIT_TME_US_FR_ACQDONE_REG (100) // wait time in us after acquisition done to ensure there is no data in fifo #define WAIT_TME_US_FR_ACQDONE_REG \
#define WAIT_TIME_US_PLL (10 * 1000) (100) // wait time in us after acquisition done to ensure there is no data
#define WAIT_TIME_US_STP_ACQ (100) // in fifo
#define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000) #define WAIT_TIME_US_PLL (10 * 1000)
#define WAIT_TIME_PATTERN_READ (10) #define WAIT_TIME_US_STP_ACQ (100)
#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin #define WAIT_TIME_CONFIGURE_MAC (2 * 1000 * 1000)
#define WAIT_TIME_PATTERN_READ (10)
#define WAIT_TIME_1US_FOR_LOOP_CNT (50) // around 30 is 1 us in blackfin
/* MSB & LSB DEFINES */ /* MSB & LSB DEFINES */
#define MSB_OF_64_BIT_REG_OFST (32) #define MSB_OF_64_BIT_REG_OFST (32)
#define LSB_OF_64_BIT_REG_OFST (0) #define LSB_OF_64_BIT_REG_OFST (0)
#define BIT32_MSK (0xFFFFFFFF) #define BIT32_MSK (0xFFFFFFFF)
#define BIT16_MASK (0xFFFF) #define BIT16_MASK (0xFFFF)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)
#define MAXIMUM_ADC_CLK (65)
#define PLL_VCO_FREQ_MHZ (800)

339
slsDetectorServers/eigerDetectorServer/9mhvserial_bf.c Executable file → Normal file
View File

@ -1,202 +1,197 @@
#include "ansi.h" #include "ansi.h"
#include <termios.h> /* POSIX terminal control definitions */
#include <stdio.h>
#include <stdlib.h> // atoi
#include <fcntl.h> // File control definitions
#include <sys/ioctl.h> // ioctl
#include <unistd.h> // read, close
#include <string.h> // memset
#include <linux/i2c-dev.h> // I2C_SLAVE, __u8 reg
#include <errno.h> #include <errno.h>
#include <fcntl.h> // File control definitions
#include <linux/i2c-dev.h> // I2C_SLAVE, __u8 reg
#include <stdio.h>
#include <stdlib.h> // atoi
#include <string.h> // memset
#include <sys/ioctl.h> // ioctl
#include <termios.h> /* POSIX terminal control definitions */
#include <unistd.h> // read, close
#define PORTNAME "/dev/ttyBF1" #define PORTNAME "/dev/ttyBF1"
#define GOODBYE 200 #define GOODBYE 200
#define BUFFERSIZE 16 #define BUFFERSIZE 16
#define I2C_DEVICE_FILE "/dev/i2c-0" #define I2C_DEVICE_FILE "/dev/i2c-0"
#define I2C_DEVICE_ADDRESS 0x4C #define I2C_DEVICE_ADDRESS 0x4C
//#define I2C_DEVICE_ADDRESS 0x48 //#define I2C_DEVICE_ADDRESS 0x48
#define I2C_REGISTER_ADDRESS 0x40 #define I2C_REGISTER_ADDRESS 0x40
int i2c_open(const char *file, unsigned int addr) {
// device file
int fd = open(file, O_RDWR);
if (fd < 0) {
LOG(logERROR, ("Warning: Unable to open file %s\n", file));
return -1;
}
int i2c_open(const char* file,unsigned int addr){ // device address
if (ioctl(fd, I2C_SLAVE, addr & 0x7F) < 0) {
//device file LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n", addr));
int fd = open( file, O_RDWR ); return -2;
if (fd < 0) { }
LOG(logERROR, ("Warning: Unable to open file %s\n",file)); return fd;
return -1;
}
//device address
if( ioctl( fd, I2C_SLAVE, addr&0x7F ) < 0 ) {
LOG(logERROR, ("Warning: Unable to set slave address:0x%x \n",addr));
return -2;
}
return fd;
} }
int i2c_read() {
int i2c_read(){ int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS);
__u8 reg = I2C_REGISTER_ADDRESS & 0xff;
int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS); unsigned char buf = reg;
__u8 reg = I2C_REGISTER_ADDRESS & 0xff; if (write(fd, &buf, 1) != 1) {
LOG(logERROR,
unsigned char buf = reg; ("Warning: Unable to write read request to register %d\n", reg));
if (write(fd, &buf, 1)!= 1){ return -1;
LOG(logERROR, ("Warning: Unable to write read request to register %d\n", reg)); }
return -1; // read and update value (but old value read out)
} if (read(fd, &buf, 1) != 1) {
//read and update value (but old value read out) LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
if(read(fd, &buf, 1) != 1){ return -2;
LOG(logERROR, ("Warning: Unable to read register %d\n", reg)); }
return -2; // read again to read the updated value
} if (read(fd, &buf, 1) != 1) {
//read again to read the updated value LOG(logERROR, ("Warning: Unable to read register %d\n", reg));
if(read(fd, &buf, 1) != 1){ return -2;
LOG(logERROR, ("Warning: Unable to read register %d\n", reg)); }
return -2; close(fd);
} return buf;
close(fd);
return buf;
} }
int i2c_write(unsigned int value) {
int i2c_write(unsigned int value){ __u8 val = value & 0xff;
__u8 val = value & 0xff; int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS);
if (fd < 0)
return fd;
int fd = i2c_open(I2C_DEVICE_FILE, I2C_DEVICE_ADDRESS); __u8 reg = I2C_REGISTER_ADDRESS & 0xff;
if(fd < 0) char buf[3];
return fd; buf[0] = reg;
buf[1] = val;
if (write(fd, buf, 2) != 2) {
LOG(logERROR,
("Warning: Unable to write %d to register %d\n", val, reg));
return -1;
}
__u8 reg = I2C_REGISTER_ADDRESS & 0xff; close(fd);
char buf[3]; return 0;
buf[0] = reg;
buf[1] = val;
if (write(fd, buf, 2) != 2) {
LOG(logERROR, ("Warning: Unable to write %d to register %d\n",val, reg));
return -1;
}
close(fd);
return 0;
} }
int main(int argc, char *argv[]) {
int fd = open(PORTNAME, O_RDWR | O_NOCTTY | O_SYNC);
if (fd < 0) {
LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME));
return -1;
}
LOG(logINFO, ("opened port at %s\n", PORTNAME));
struct termios serial_conf;
// reset structure
memset(&serial_conf, 0, sizeof(serial_conf));
// control options
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL;
// input options
serial_conf.c_iflag = IGNPAR;
// output options
serial_conf.c_oflag = 0;
// line options
serial_conf.c_lflag = ICANON;
// flush input
if (tcflush(fd, TCIOFLUSH) < 0) {
LOG(logERROR, ("Warning: error form tcflush %d\n", errno));
return 0;
}
// set new options for the port, TCSANOW:changes occur immediately without
// waiting for data to complete
if (tcsetattr(fd, TCSANOW, &serial_conf) < 0) {
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
return 0;
}
if (tcsetattr(fd, TCSAFLUSH, &serial_conf) < 0) {
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno));
return 0;
}
int main(int argc, char* argv[]) { int ret = 0;
int n = 0;
int ival = 0;
char buffer[BUFFERSIZE];
memset(buffer, 0, BUFFERSIZE);
buffer[BUFFERSIZE - 1] = '\n';
LOG(logINFO, ("Ready...\n"));
int fd = open(PORTNAME, O_RDWR | O_NOCTTY | O_SYNC); while (ret != GOODBYE) {
if(fd < 0){ memset(buffer, 0, BUFFERSIZE);
LOG(logERROR, ("Warning: Unable to open port %s\n", PORTNAME)); n = read(fd, buffer, BUFFERSIZE);
return -1; LOG(logDEBUG1, ("Received %d Bytes\n", n));
} LOG(logINFO, ("Got message: '%s'\n", buffer));
LOG(logINFO, ("opened port at %s\n",PORTNAME));
struct termios serial_conf; switch (buffer[0]) {
// reset structure case '\0':
memset(&serial_conf,0,sizeof(serial_conf)); LOG(logINFO, ("Got Start (Detector restart)\n"));
// control options break;
serial_conf.c_cflag = B2400 | CS8 | CREAD | CLOCAL; case 's':
// input options LOG(logINFO, ("Got Start \n"));
serial_conf.c_iflag = IGNPAR; break;
// output options case 'p':
serial_conf.c_oflag = 0; if (!sscanf(&buffer[1], "%d", &ival)) {
// line options LOG(logERROR, ("Warning: cannot scan voltage value\n"));
serial_conf.c_lflag = ICANON; break;
// flush input }
if(tcflush(fd, TCIOFLUSH) < 0){ // ok/ fail
LOG(logERROR, ("Warning: error form tcflush %d\n", errno)); memset(buffer, 0, BUFFERSIZE);
return 0; buffer[BUFFERSIZE - 1] = '\n';
} if (i2c_write(ival) < 0)
// set new options for the port, TCSANOW:changes occur immediately without waiting for data to complete strcpy(buffer, "fail ");
if(tcsetattr(fd, TCSANOW, &serial_conf) < 0){ else
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno)); strcpy(buffer, "success ");
return 0; LOG(logINFO, ("Sending: '%s'\n", buffer));
} n = write(fd, buffer, BUFFERSIZE);
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
break;
if(tcsetattr(fd, TCSAFLUSH, &serial_conf) < 0){ case 'g':
LOG(logERROR, ("Warning: error form tcsetattr %d\n", errno)); ival = i2c_read();
return 0; // ok/ fail
} memset(buffer, 0, BUFFERSIZE);
buffer[BUFFERSIZE - 1] = '\n';
if (ival < 0)
strcpy(buffer, "fail ");
else
strcpy(buffer, "success ");
n = write(fd, buffer, BUFFERSIZE);
LOG(logINFO, ("Sending: '%s'\n", buffer));
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
// value
memset(buffer, 0, BUFFERSIZE);
buffer[BUFFERSIZE - 1] = '\n';
if (ival >= 0) {
LOG(logINFO, ("Sending: '%d'\n", ival));
sprintf(buffer, "%d ", ival);
n = write(fd, buffer, BUFFERSIZE);
LOG(logINFO, ("Sent %d Bytes\n", n));
} else
LOG(logERROR, ("%s\n", buffer));
break;
int ret = 0; case 'e':
int n = 0; printf("Exiting Program\n");
int ival= 0; ret = GOODBYE;
char buffer[BUFFERSIZE]; break;
memset(buffer,0,BUFFERSIZE); default:
buffer[BUFFERSIZE-1] = '\n'; LOG(logERROR, ("Unknown Command. buffer:'%s'\n", buffer));
LOG(logINFO, ("Ready...\n")); break;
}
}
close(fd);
while(ret != GOODBYE){ printf("Goodbye Serial Communication for HV(9M)\n");
memset(buffer,0,BUFFERSIZE); return 0;
n = read(fd,buffer,BUFFERSIZE);
LOG(logDEBUG1, ("Received %d Bytes\n", n));
LOG(logINFO, ("Got message: '%s'\n",buffer));
switch(buffer[0]){
case '\0':
LOG(logINFO, ("Got Start (Detector restart)\n"));
break;
case 's':
LOG(logINFO, ("Got Start \n"));
break;
case 'p':
if (!sscanf(&buffer[1],"%d",&ival)){
LOG(logERROR, ("Warning: cannot scan voltage value\n"));
break;
}
// ok/ fail
memset(buffer,0,BUFFERSIZE);
buffer[BUFFERSIZE-1] = '\n';
if(i2c_write(ival)<0)
strcpy(buffer,"fail ");
else
strcpy(buffer,"success ");
LOG(logINFO, ("Sending: '%s'\n",buffer));
n = write(fd, buffer, BUFFERSIZE);
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
break;
case 'g':
ival = i2c_read();
//ok/ fail
memset(buffer,0,BUFFERSIZE);
buffer[BUFFERSIZE-1] = '\n';
if(ival < 0)
strcpy(buffer,"fail ");
else
strcpy(buffer,"success ");
n = write(fd, buffer, BUFFERSIZE);
LOG(logINFO, ("Sending: '%s'\n",buffer));
LOG(logDEBUG1, ("Sent %d Bytes\n", n));
//value
memset(buffer,0,BUFFERSIZE);
buffer[BUFFERSIZE-1] = '\n';
if(ival >= 0){
LOG(logINFO, ("Sending: '%d'\n",ival));
sprintf(buffer,"%d ",ival);
n = write(fd, buffer, BUFFERSIZE);
LOG(logINFO, ("Sent %d Bytes\n", n));
}else LOG(logERROR, ("%s\n",buffer));
break;
case 'e':
printf("Exiting Program\n");
ret = GOODBYE;
break;
default:
LOG(logERROR, ("Unknown Command. buffer:'%s'\n",buffer));
break;
}
}
close(fd);
printf("Goodbye Serial Communication for HV(9M)\n");
return 0;
} }

2552
slsDetectorServers/eigerDetectorServer/Beb.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

104
slsDetectorServers/eigerDetectorServer/Beb.h Executable file → Normal file
View File

@ -1,40 +1,40 @@
#pragma once #pragma once
#include <stdlib.h>
#include "LocalLinkInterface.h" #include "LocalLinkInterface.h"
#include "slsDetectorServer_defs.h" #include "slsDetectorServer_defs.h"
struct BebInfo {
struct BebInfo{ unsigned int beb_number;
unsigned int beb_number; unsigned int serial_address;
unsigned int serial_address; char src_mac_1GbE[50];
char src_mac_1GbE[50]; char src_mac_10GbE[50];
char src_mac_10GbE[50]; char src_ip_1GbE[50];
char src_ip_1GbE[50]; char src_ip_10GbE[50];
char src_ip_10GbE[50]; unsigned int src_port_1GbE;
unsigned int src_port_1GbE; unsigned int src_port_10GbE;
unsigned int src_port_10GbE;
}; };
void BebInfo_BebInfo(struct BebInfo *bebInfo, unsigned int beb_num);
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num); void BebInfo_BebDstInfo(struct BebInfo *bebInfo, unsigned int beb_num);
void BebInfo_BebDstInfo(struct BebInfo* bebInfo, unsigned int beb_num); int BebInfo_SetSerialAddress(struct BebInfo *bebInfo, unsigned int add);
int BebInfo_SetSerialAddress(struct BebInfo* bebInfo, unsigned int add); int BebInfo_SetHeaderInfo(
int BebInfo_SetHeaderInfo(struct BebInfo* bebInfo, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port);//src_port fixed 42000+beb_number or 52000 + beb_number); struct BebInfo *bebInfo, int ten_gig, char *src_mac, char *src_ip,
unsigned int BebInfo_GetBebNumber(struct BebInfo* bebInfo); unsigned int
unsigned int BebInfo_GetSerialAddress(struct BebInfo* bebInfo); src_port); // src_port fixed 42000+beb_number or 52000 + beb_number);
char* BebInfo_GetSrcMAC(struct BebInfo* bebInfo, int ten_gig); unsigned int BebInfo_GetBebNumber(struct BebInfo *bebInfo);
char* BebInfo_GetSrcIP(struct BebInfo* bebInfo, int ten_gig); unsigned int BebInfo_GetSerialAddress(struct BebInfo *bebInfo);
unsigned int BebInfo_GetSrcPort(struct BebInfo* bebInfo, int ten_gig); char *BebInfo_GetSrcMAC(struct BebInfo *bebInfo, int ten_gig);
void BebInfo_Print(struct BebInfo* bebInfo); char *BebInfo_GetSrcIP(struct BebInfo *bebInfo, int ten_gig);
unsigned int BebInfo_GetSrcPort(struct BebInfo *bebInfo, int ten_gig);
void BebInfo_Print(struct BebInfo *bebInfo);
void Beb_ClearBebInfos(); void Beb_ClearBebInfos();
int Beb_InitBebInfos(); int Beb_InitBebInfos();
int Beb_CheckSourceStuffBebInfo(); int Beb_CheckSourceStuffBebInfo();
unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb); unsigned int Beb_GetBebInfoIndex(unsigned int beb_numb);
void Beb_GetModuleConfiguration(int *master, int *top, int *normal);
void Beb_GetModuleConfiguration(int* master, int* top, int* normal); int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay);
void Beb_EndofDataSend(int tengiga);
int Beb_SetMasterViaSoftware(); int Beb_SetMasterViaSoftware();
int Beb_SetSlaveViaSoftware(); int Beb_SetSlaveViaSoftware();
@ -56,27 +56,43 @@ u_int32_t Beb_GetFirmwareRevision();
u_int32_t Beb_GetFirmwareSoftwareAPIVersion(); u_int32_t Beb_GetFirmwareSoftwareAPIVersion();
void Beb_ResetFrameNumber(); void Beb_ResetFrameNumber();
int Beb_WriteTo(unsigned int index); int Beb_WriteTo(unsigned int index);
int Beb_SetMAC(char* mac, uint8_t* dst_ptr); int Beb_SetMAC(char *mac, uint8_t *dst_ptr);
int Beb_SetIP(char* ip, uint8_t* dst_ptr); int Beb_SetIP(char *ip, uint8_t *dst_ptr);
int Beb_SetPortNumber(unsigned int port_number, uint8_t* dst_ptr); int Beb_SetPortNumber(unsigned int port_number, uint8_t *dst_ptr);
void Beb_AdjustIPChecksum(struct udp_header_type *ip); void Beb_AdjustIPChecksum(struct udp_header_type *ip);
int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char* dst_mac, char* dst_ip, unsigned int dst_port); int Beb_SetHeaderData(unsigned int beb_number, int ten_gig, char *dst_mac,
int Beb_SetHeaderData1(char* src_mac, char* src_ip, unsigned int src_port, char* dst_mac, char* dst_ip, unsigned int dst_port); char *dst_ip, unsigned int dst_port);
int Beb_SetHeaderData1(char *src_mac, char *src_ip, unsigned int src_port,
char *dst_mac, char *dst_ip, unsigned int dst_port);
void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d); void Beb_SwapDataFun(int little_endian, unsigned int n, unsigned int *d);
int Beb_SetByteOrder(); int Beb_SetByteOrder();
void Beb_Beb(); void Beb_Beb();
int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig, char* src_mac, char* src_ip, unsigned int src_port); int Beb_SetBebSrcHeaderInfos(unsigned int beb_number, int ten_gig,
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig, unsigned int header_number, char* dst_mac, char* dst_ip, unsigned int dst_port); char *src_mac, char *src_ip,
unsigned int src_port);
int Beb_SetUpUDPHeader(unsigned int beb_number, int ten_gig,
unsigned int header_number, char *dst_mac, char *dst_ip,
unsigned int dst_port);
/*int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty=1);*/ /*int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int
int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int npackets, unsigned int packet_size, int stop_read_when_fifo_empty); * left_right, int ten_gig, unsigned int dst_number, unsigned int npackets,
* unsigned int packet_size, int stop_read_when_fifo_empty=1);*/
int Beb_SendMultiReadRequest(unsigned int beb_number, unsigned int left_right,
int ten_gig, unsigned int dst_number,
unsigned int npackets, unsigned int packet_size,
int stop_read_when_fifo_empty);
int Beb_StopAcquisition(); int Beb_StopAcquisition();
int Beb_SetUpTransferParameters(short the_bit_mode); int Beb_SetUpTransferParameters(short the_bit_mode);
/*int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait=0); //all images go to the same destination!*/ /*int Beb_RequestNImages(unsigned int beb_number, unsigned int left_right, int
int Beb_RequestNImages(unsigned int beb_number, int ten_gig, unsigned int dst_number, unsigned int nimages, int test_just_send_out_packets_no_wait); * ten_gig, unsigned int dst_number, unsigned int nimages, int
* test_just_send_out_packets_no_wait=0); //all images go to the same
* destination!*/
int Beb_RequestNImages(unsigned int beb_number, int ten_gig,
unsigned int dst_number, unsigned int nimages,
int test_just_send_out_packets_no_wait);
int Beb_Test(unsigned int beb_number); int Beb_Test(unsigned int beb_number);
@ -85,17 +101,15 @@ int Beb_GetBebFPGATemp();
void Beb_SetDetectorNumber(uint32_t detid); void Beb_SetDetectorNumber(uint32_t detid);
int Beb_SetQuad(int value); int Beb_SetQuad(int value);
int Beb_GetQuad(); int Beb_GetQuad();
int* Beb_GetDetectorPosition(); int *Beb_GetDetectorPosition();
int Beb_SetDetectorPosition(int pos[]); int Beb_SetDetectorPosition(int pos[]);
int Beb_SetStartingFrameNumber(uint64_t value); int Beb_SetStartingFrameNumber(uint64_t value);
int Beb_GetStartingFrameNumber(uint64_t* retval, int tengigaEnable); int Beb_GetStartingFrameNumber(uint64_t *retval, int tengigaEnable);
void Beb_SetReadNLines(int value); void Beb_SetReadNLines(int value);
uint16_t Beb_swap_uint16( uint16_t val); uint16_t Beb_swap_uint16(uint16_t val);
int Beb_open(u_int32_t** csp0base, u_int32_t offset); int Beb_open(u_int32_t **csp0base, u_int32_t offset);
u_int32_t Beb_Read32 (u_int32_t* baseaddr, u_int32_t offset); u_int32_t Beb_Read32(u_int32_t *baseaddr, u_int32_t offset);
u_int32_t Beb_Write32 (u_int32_t* baseaddr, u_int32_t offset, u_int32_t data); u_int32_t Beb_Write32(u_int32_t *baseaddr, u_int32_t offset, u_int32_t data);
void Beb_close(int fd,u_int32_t* csp0base); void Beb_close(int fd, u_int32_t *csp0base);

View File

@ -5,6 +5,7 @@ set(src
../slsDetectorServer/src/communication_funcs.c ../slsDetectorServer/src/communication_funcs.c
../slsDetectorServer/src/communication_funcs_UDP.c ../slsDetectorServer/src/communication_funcs_UDP.c
../slsDetectorServer/src/common.c ../slsDetectorServer/src/common.c
../slsDetectorServer/src/communication_virtual.c
) )
include_directories( include_directories(
@ -22,7 +23,7 @@ target_include_directories(eigerDetectorServerMaster_virtual
target_compile_definitions(eigerDetectorServerMaster_virtual target_compile_definitions(eigerDetectorServerMaster_virtual
PUBLIC EIGERD PCCOMPILE STOP_SERVER PUBLIC EIGERD PCCOMPILE STOP_SERVER
PUBLIC VIRTUAL DVIRTUAL_9M PUBLIC VIRTUAL #VIRTUAL_9M
PUBLIC VIRTUAL_MASTER PUBLIC VIRTUAL_MASTER
) )
@ -38,27 +39,60 @@ install(TARGETS eigerDetectorServerMaster_virtual
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
add_executable(eigerDetectorServerSlave_virtual
add_executable(eigerDetectorServerSlaveTop_virtual
${src} ${src}
) )
target_include_directories(eigerDetectorServerSlave_virtual target_include_directories(eigerDetectorServerSlaveTop_virtual
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
) )
target_compile_definitions(eigerDetectorServerSlave_virtual target_compile_definitions(eigerDetectorServerSlaveTop_virtual
PUBLIC EIGERD PCCOMPILE STOP_SERVER PUBLIC EIGERD PCCOMPILE STOP_SERVER
PUBLIC VIRTUAL DVIRTUAL_9M PUBLIC VIRTUAL #VIRTUAL_9M
PUBLIC VIRTUAL_TOP
) )
target_link_libraries(eigerDetectorServerSlave_virtual target_link_libraries(eigerDetectorServerSlaveTop_virtual
PUBLIC pthread rt PUBLIC pthread rt
) )
set_target_properties(eigerDetectorServerSlave_virtual PROPERTIES set_target_properties(eigerDetectorServerSlaveTop_virtual PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
) )
install(TARGETS eigerDetectorServerSlave_virtual install(TARGETS eigerDetectorServerSlaveTop_virtual
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
add_executable(eigerDetectorServerSlaveBottom_virtual
${src}
)
target_include_directories(eigerDetectorServerSlaveBottom_virtual
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(eigerDetectorServerSlaveBottom_virtual
PUBLIC EIGERD PCCOMPILE STOP_SERVER
PUBLIC VIRTUAL #VIRTUAL_9M
)
target_link_libraries(eigerDetectorServerSlaveBottom_virtual
PUBLIC pthread rt
)
set_target_properties(eigerDetectorServerSlaveBottom_virtual PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
install(TARGETS eigerDetectorServerSlaveBottom_virtual
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )

3863
slsDetectorServers/eigerDetectorServer/FebControl.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

152
slsDetectorServers/eigerDetectorServer/FebControl.h Executable file → Normal file
View File

@ -2,49 +2,51 @@
#include "FebInterface.h" #include "FebInterface.h"
#include <netinet/in.h> #include <netinet/in.h>
struct Module {
unsigned int module_number;
int top_address_valid;
unsigned int top_left_address;
unsigned int top_right_address;
int bottom_address_valid;
unsigned int bottom_left_address;
unsigned int bottom_right_address;
struct Module{ unsigned int idelay_top[4]; // ll,lr,rl,ll
unsigned int module_number; unsigned int idelay_bottom[4]; // ll,lr,rl,ll
int top_address_valid; float high_voltage;
unsigned int top_left_address; int *top_dac;
unsigned int top_right_address; int *bottom_dac;
int bottom_address_valid;
unsigned int bottom_left_address;
unsigned int bottom_right_address;
unsigned int idelay_top[4]; //ll,lr,rl,ll
unsigned int idelay_bottom[4]; //ll,lr,rl,ll
float high_voltage;
int* top_dac;
int* bottom_dac;
}; };
void Module_Module(struct Module *mod, unsigned int number,
unsigned int address_top);
void Module_ModuleBottom(struct Module *mod, unsigned int number,
unsigned int address_bottom);
void Module_Module1(struct Module *mod, unsigned int number,
unsigned int address_top, unsigned int address_bottom);
unsigned int Module_GetModuleNumber(struct Module *mod);
int Module_TopAddressIsValid(struct Module *mod);
unsigned int Module_GetTopBaseAddress(struct Module *mod);
unsigned int Module_GetTopLeftAddress(struct Module *mod);
unsigned int Module_GetTopRightAddress(struct Module *mod);
unsigned int Module_GetBottomBaseAddress(struct Module *mod);
int Module_BottomAddressIsValid(struct Module *mod);
unsigned int Module_GetBottomLeftAddress(struct Module *mod);
unsigned int Module_GetBottomRightAddress(struct Module *mod);
unsigned int Module_SetTopIDelay(struct Module *mod, unsigned int chip,
unsigned int value);
unsigned int Module_GetTopIDelay(struct Module *mod, unsigned int chip);
unsigned int Module_SetBottomIDelay(struct Module *mod, unsigned int chip,
unsigned int value);
unsigned int Module_GetBottomIDelay(struct Module *mod, unsigned int chip);
void Module_Module(struct Module* mod,unsigned int number, unsigned int address_top); float Module_SetHighVoltage(struct Module *mod, float value);
void Module_ModuleBottom(struct Module* mod,unsigned int number, unsigned int address_bottom); float Module_GetHighVoltage(struct Module *mod);
void Module_Module1(struct Module* mod,unsigned int number, unsigned int address_top, unsigned int address_bottom);
unsigned int Module_GetModuleNumber(struct Module* mod);
int Module_TopAddressIsValid(struct Module* mod);
unsigned int Module_GetTopBaseAddress(struct Module* mod);
unsigned int Module_GetTopLeftAddress(struct Module* mod) ;
unsigned int Module_GetTopRightAddress(struct Module* mod);
unsigned int Module_GetBottomBaseAddress(struct Module* mod);
int Module_BottomAddressIsValid(struct Module* mod);
unsigned int Module_GetBottomLeftAddress(struct Module* mod);
unsigned int Module_GetBottomRightAddress(struct Module* mod);
unsigned int Module_SetTopIDelay(struct Module* mod,unsigned int chip,unsigned int value);
unsigned int Module_GetTopIDelay(struct Module* mod,unsigned int chip) ;
unsigned int Module_SetBottomIDelay(struct Module* mod,unsigned int chip,unsigned int value);
unsigned int Module_GetBottomIDelay(struct Module* mod,unsigned int chip);
float Module_SetHighVoltage(struct Module* mod,float value);
float Module_GetHighVoltage(struct Module* mod);
int Module_SetTopDACValue(struct Module* mod,unsigned int i, int value);
int Module_GetTopDACValue(struct Module* mod,unsigned int i);
int Module_SetBottomDACValue(struct Module* mod,unsigned int i, int value);
int Module_GetBottomDACValue(struct Module* mod,unsigned int i);
int Module_SetTopDACValue(struct Module *mod, unsigned int i, int value);
int Module_GetTopDACValue(struct Module *mod, unsigned int i);
int Module_SetBottomDACValue(struct Module *mod, unsigned int i, int value);
int Module_GetBottomDACValue(struct Module *mod, unsigned int i);
void Feb_Control_activate(int activate); void Feb_Control_activate(int activate);
@ -52,22 +54,30 @@ int Feb_Control_IsBottomModule();
int Feb_Control_GetModuleNumber(); int Feb_Control_GetModuleNumber();
void Feb_Control_PrintModuleList(); void Feb_Control_PrintModuleList();
int Feb_Control_GetModuleIndex(unsigned int module_number, unsigned int* module_index); int Feb_Control_GetModuleIndex(unsigned int module_number,
int Feb_Control_CheckModuleAddresses(struct Module* m); unsigned int *module_index);
int Feb_Control_CheckModuleAddresses(struct Module *m);
int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address); int Feb_Control_AddModule(unsigned int module_number, unsigned int top_address);
int Feb_Control_AddModule1(unsigned int module_number, int top_enable, unsigned int top_address, unsigned int bottom_address, int half_module); int Feb_Control_AddModule1(unsigned int module_number, int top_enable,
int Feb_Control_GetDACNumber(char* s, unsigned int* n); unsigned int top_address,
int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch, unsigned int* value); unsigned int bottom_address, int half_module);
int Feb_Control_VoltageToDAC(float value, unsigned int* digital, unsigned int nsteps, float vmin, float vmax); int Feb_Control_GetDACNumber(char *s, unsigned int *n);
float Feb_Control_DACToVoltage(unsigned int digital,unsigned int nsteps,float vmin,float vmax); int Feb_Control_SendDACValue(unsigned int dst_num, unsigned int ch,
int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr, unsigned int channels, unsigned int ndelay_units); unsigned int *value);
int Feb_Control_VoltageToDAC(float value, unsigned int *digital,
unsigned int nsteps, float vmin, float vmax);
float Feb_Control_DACToVoltage(unsigned int digital, unsigned int nsteps,
float vmin, float vmax);
int Feb_Control_SendIDelays(unsigned int dst_num, int chip_lr,
unsigned int channels, unsigned int ndelay_units);
int Feb_Control_SetStaticBits(); int Feb_Control_SetStaticBits();
int Feb_Control_SetStaticBits1(unsigned int the_static_bits); int Feb_Control_SetStaticBits1(unsigned int the_static_bits);
int Feb_Control_SendBitModeToBebServer(); int Feb_Control_SendBitModeToBebServer();
unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec); unsigned int Feb_Control_ConvertTimeToRegister(float time_in_sec);
unsigned int Feb_Control_AddressToAll(); unsigned int Feb_Control_AddressToAll();
int Feb_Control_SetCommandRegister(unsigned int cmd); int Feb_Control_SetCommandRegister(unsigned int cmd);
int Feb_Control_GetDAQStatusRegister(unsigned int dst_address, unsigned int* ret_status); int Feb_Control_GetDAQStatusRegister(unsigned int dst_address,
unsigned int *ret_status);
int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us); int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us);
int Feb_Control_ResetChipCompletely(); int Feb_Control_ResetChipCompletely();
int Feb_Control_ResetChipPartially(); int Feb_Control_ResetChipPartially();
@ -80,22 +90,25 @@ unsigned int Feb_Control_GetNModules();
unsigned int Feb_Control_GetNHalfModules(); unsigned int Feb_Control_GetNHalfModules();
int Feb_Control_SetHighVoltage(int value); int Feb_Control_SetHighVoltage(int value);
int Feb_Control_GetHighVoltage(int* value); int Feb_Control_GetHighVoltage(int *value);
int Feb_Control_SendHighVoltage(int dacvalue); int Feb_Control_SendHighVoltage(int dacvalue);
int Feb_Control_ReceiveHighVoltage(unsigned int* value); int Feb_Control_ReceiveHighVoltage(unsigned int *value);
int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units); int Feb_Control_SetIDelays(unsigned int module_num, unsigned int ndelay_units);
int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos, unsigned int ndelay_units); int Feb_Control_SetIDelays1(unsigned int module_num, unsigned int chip_pos,
unsigned int ndelay_units);
int Feb_Control_DecodeDACString(char* dac_str, unsigned int* module_index, int* top, int* bottom, unsigned int* dac_ch); int Feb_Control_DecodeDACString(char *dac_str, unsigned int *module_index,
int Feb_Control_SetDAC(char* s, int value, int is_a_voltage_mv); int *top, int *bottom, unsigned int *dac_ch);
int Feb_Control_GetDAC(char* s, int* ret_value, int voltage_mv); int Feb_Control_SetDAC(char *s, int value, int is_a_voltage_mv);
int Feb_Control_GetDACName(unsigned int dac_num,char* s); int Feb_Control_GetDAC(char *s, int *ret_value, int voltage_mv);
int Feb_Control_GetDACName(unsigned int dac_num, char *s);
int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int* trimbits); int Feb_Control_SetTrimbits(unsigned int module_num, unsigned int *trimbits,
unsigned int* Feb_Control_GetTrimbits(); int top);
int Feb_Control_SaveAllTrimbitsTo(int value); unsigned int *Feb_Control_GetTrimbits();
int Feb_Control_SaveAllTrimbitsTo(int value, int top);
int Feb_Control_Reset(); int Feb_Control_Reset();
int Feb_Control_PrepareForAcquisition(); int Feb_Control_PrepareForAcquisition();
@ -111,7 +124,8 @@ unsigned int Feb_Control_GetNExposures();
int Feb_Control_SetExposureTime(double the_exposure_time_in_sec); int Feb_Control_SetExposureTime(double the_exposure_time_in_sec);
double Feb_Control_GetExposureTime(); double Feb_Control_GetExposureTime();
int64_t Feb_Control_GetExposureTime_in_nsec(); int64_t Feb_Control_GetExposureTime_in_nsec();
int Feb_Control_SetSubFrameExposureTime(int64_t the_subframe_exposure_time_in_10nsec); int Feb_Control_SetSubFrameExposureTime(
int64_t the_subframe_exposure_time_in_10nsec);
int64_t Feb_Control_GetSubFrameExposureTime(); int64_t Feb_Control_GetSubFrameExposureTime();
int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec); int Feb_Control_SetSubFramePeriod(int64_t the_subframe_period_in_10nsec);
int64_t Feb_Control_GetSubFramePeriod(); int64_t Feb_Control_GetSubFramePeriod();
@ -119,17 +133,24 @@ int Feb_Control_SetExposurePeriod(double the_exposure_period_in_sec);
double Feb_Control_GetExposurePeriod(); double Feb_Control_GetExposurePeriod();
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo); int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);
unsigned int Feb_Control_GetDynamicRange(); unsigned int Feb_Control_GetDynamicRange();
int Feb_Control_SetReadoutSpeed(unsigned int readout_speed); //0 was default, 0->full,1->half,2->quarter or 3->super_slow int Feb_Control_SetReadoutSpeed(
int Feb_Control_SetReadoutMode(unsigned int readout_mode); ///0 was default,0->parallel,1->non-parallel,2-> safe_mode unsigned int readout_speed); // 0 was default, 0->full,1->half,2->quarter or
int Feb_Control_SetTriggerMode(unsigned int trigger_mode, int polarity);//0 and 1 was default, // 3->super_slow
int Feb_Control_SetExternalEnableMode(int use_external_enable, int polarity);//0 and 1 was default, int Feb_Control_SetReadoutMode(
unsigned int readout_mode); /// 0 was
/// default,0->parallel,1->non-parallel,2->
/// safe_mode
int Feb_Control_SetTriggerMode(unsigned int trigger_mode,
int polarity); // 0 and 1 was default,
int Feb_Control_SetExternalEnableMode(int use_external_enable,
int polarity); // 0 and 1 was default,
int Feb_Control_SetInTestModeVariable(int on); int Feb_Control_SetInTestModeVariable(int on);
int Feb_Control_GetTestModeVariable(); int Feb_Control_GetTestModeVariable();
void Feb_Control_Set_Counter_Bit(int value); void Feb_Control_Set_Counter_Bit(int value);
int Feb_Control_Get_Counter_Bit(); int Feb_Control_Get_Counter_Bit();
int Feb_Control_Pulse_Pixel(int npulses,int x, int y); int Feb_Control_Pulse_Pixel(int npulses, int x, int y);
int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos); int Feb_Control_PulsePixelNMove(int npulses, int inc_x_pos, int inc_y_pos);
int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in); int Feb_Control_Shift32InSerialIn(unsigned int value_to_shift_in);
int Feb_Control_SendTokenIn(); int Feb_Control_SendTokenIn();
@ -158,5 +179,4 @@ int Feb_Control_SetReadNLines(int value);
int Feb_Control_GetReadNLines(); int Feb_Control_GetReadNLines();
int Feb_Control_WriteRegister(uint32_t offset, uint32_t data); int Feb_Control_WriteRegister(uint32_t offset, uint32_t data);
int Feb_Control_ReadRegister(uint32_t offset, uint32_t* retval); int Feb_Control_ReadRegister(uint32_t offset, uint32_t *retval);

315
slsDetectorServers/eigerDetectorServer/FebInterface.c Executable file → Normal file
View File

@ -1,195 +1,236 @@
#include "FebInterface.h" #include "FebInterface.h"
#include "LocalLinkInterface.h" #include "LocalLinkInterface.h"
#include "xparameters.h"
#include "clogger.h" #include "clogger.h"
#include "xparameters.h"
#include <unistd.h> #include <unistd.h>
struct LocalLinkInterface ll_local, *ll;
unsigned int Feb_Interface_nfebs;
unsigned int *Feb_Interface_feb_numb;
struct LocalLinkInterface ll_local,* ll; int Feb_Interface_send_ndata;
unsigned int Feb_Interface_send_buffer_size;
unsigned int Feb_Interface_nfebs; unsigned int *Feb_Interface_send_data_raw;
unsigned int* Feb_Interface_feb_numb; unsigned int *Feb_Interface_send_data;
int Feb_Interface_send_ndata;
unsigned int Feb_Interface_send_buffer_size;
unsigned int* Feb_Interface_send_data_raw;
unsigned int* Feb_Interface_send_data;
int Feb_Interface_recv_ndata;
unsigned int Feb_Interface_recv_buffer_size;
unsigned int* Feb_Interface_recv_data_raw;
unsigned int* Feb_Interface_recv_data;
int Feb_Interface_recv_ndata;
unsigned int Feb_Interface_recv_buffer_size;
unsigned int *Feb_Interface_recv_data_raw;
unsigned int *Feb_Interface_recv_data;
void Feb_Interface_FebInterface() { void Feb_Interface_FebInterface() {
ll = &ll_local; ll = &ll_local;
Feb_Interface_nfebs = 0; Feb_Interface_nfebs = 0;
Feb_Interface_feb_numb = 0; Feb_Interface_feb_numb = 0;
Feb_Interface_send_ndata = 0; Feb_Interface_send_ndata = 0;
Feb_Interface_send_buffer_size = 1026; Feb_Interface_send_buffer_size = 1026;
Feb_Interface_send_data_raw = malloc((Feb_Interface_send_buffer_size+1) * sizeof(unsigned int)); Feb_Interface_send_data_raw =
Feb_Interface_send_data = &Feb_Interface_send_data_raw[1]; malloc((Feb_Interface_send_buffer_size + 1) * sizeof(unsigned int));
Feb_Interface_send_data = &Feb_Interface_send_data_raw[1];
Feb_Interface_recv_ndata = 0; Feb_Interface_recv_ndata = 0;
Feb_Interface_recv_buffer_size = 1026; Feb_Interface_recv_buffer_size = 1026;
Feb_Interface_recv_data_raw = malloc((Feb_Interface_recv_buffer_size+1) * sizeof(unsigned int)); Feb_Interface_recv_data_raw =
Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1]; malloc((Feb_Interface_recv_buffer_size + 1) * sizeof(unsigned int));
Feb_Interface_recv_data = &Feb_Interface_recv_data_raw[1];
Local_LocalLinkInterface1(ll,XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
Local_LocalLinkInterface1(
ll, XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR);
} }
void Feb_Interface_SendCompleteList(unsigned int n, unsigned int *list) {
unsigned int i;
void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list) { if (Feb_Interface_feb_numb)
unsigned int i; free(Feb_Interface_feb_numb);
if (Feb_Interface_feb_numb) free(Feb_Interface_feb_numb); Feb_Interface_nfebs = n;
Feb_Interface_nfebs = n; Feb_Interface_feb_numb = malloc(n * sizeof(unsigned int));
Feb_Interface_feb_numb = malloc(n * sizeof(unsigned int)); for (i = 0; i < n; i++)
for(i=0;i<n;i++) Feb_Interface_feb_numb[i] = list[i]; Feb_Interface_feb_numb[i] = list[i];
} }
int Feb_Interface_WriteTo(unsigned int ch) { int Feb_Interface_WriteTo(unsigned int ch) {
if (ch>0xfff) return 0; if (ch > 0xfff)
return 0;
LOG(logDEBUG1, ("FIW ch %d\n", ch)); LOG(logDEBUG1, ("FIW ch %d\n", ch));
Feb_Interface_send_data_raw[0] = 0x8fff0000; Feb_Interface_send_data_raw[0] = 0x8fff0000;
if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; if (Local_Write(ll, 4, Feb_Interface_send_data_raw) != 4)
return 0;
Feb_Interface_send_data_raw[0] = 0x90000000 | (ch<<16); Feb_Interface_send_data_raw[0] = 0x90000000 | (ch << 16);
if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; if (Local_Write(ll, 4, Feb_Interface_send_data_raw) != 4)
return 0;
Feb_Interface_send_data_raw[0] = 0xc0000000; Feb_Interface_send_data_raw[0] = 0xc0000000;
return ((Feb_Interface_send_ndata+1)*4==Local_Write(ll,(Feb_Interface_send_ndata+1)*4,Feb_Interface_send_data_raw)); return ((Feb_Interface_send_ndata + 1) * 4 ==
Local_Write(ll, (Feb_Interface_send_ndata + 1) * 4,
Feb_Interface_send_data_raw));
} }
int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) { int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys) {
unsigned int t; unsigned int t;
if (ch>=0xfff) return 0; if (ch >= 0xfff)
return 0;
Feb_Interface_recv_data_raw[0] = 0xa0000000 | (ch<<16); Feb_Interface_recv_data_raw[0] = 0xa0000000 | (ch << 16);
Local_Write(ll,4,Feb_Interface_recv_data_raw); Local_Write(ll, 4, Feb_Interface_recv_data_raw);
usleep(20); usleep(20);
Feb_Interface_recv_ndata=-1; Feb_Interface_recv_ndata = -1;
for(t=0;t<ntrys;t++) { for (t = 0; t < ntrys; t++) {
if ((Feb_Interface_recv_ndata=Local_Read(ll,Feb_Interface_recv_buffer_size*4,Feb_Interface_recv_data_raw)/4)>0) { if ((Feb_Interface_recv_ndata =
Feb_Interface_recv_ndata--; Local_Read(ll, Feb_Interface_recv_buffer_size * 4,
break; Feb_Interface_recv_data_raw) /
} 4) > 0) {
usleep(1000); Feb_Interface_recv_ndata--;
} break;
}
usleep(1000);
}
return (Feb_Interface_recv_ndata>=0); return (Feb_Interface_recv_ndata >= 0);
} }
int Feb_Interface_SetByteOrder() { int Feb_Interface_SetByteOrder() {
Feb_Interface_send_data_raw[0] = 0x8fff0000; Feb_Interface_send_data_raw[0] = 0x8fff0000;
if (Local_Write(ll,4,Feb_Interface_send_data_raw)!=4) return 0; if (Local_Write(ll, 4, Feb_Interface_send_data_raw) != 4)
Feb_Interface_send_ndata = 2; return 0;
Feb_Interface_send_data[0] = 0; Feb_Interface_send_ndata = 2;
Feb_Interface_send_data[1] = 0; Feb_Interface_send_data[0] = 0;
unsigned int i; Feb_Interface_send_data[1] = 0;
unsigned int dst = 0xff; unsigned int i;
for(i=0;i<Feb_Interface_nfebs;i++) dst = (dst | Feb_Interface_feb_numb[i]); unsigned int dst = 0xff;
int passed = Feb_Interface_WriteTo(dst); for (i = 0; i < Feb_Interface_nfebs; i++)
dst = (dst | Feb_Interface_feb_numb[i]);
int passed = Feb_Interface_WriteTo(dst);
return passed; return passed;
} }
int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,
int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int* value_read) { unsigned int *value_read) {
return Feb_Interface_ReadRegisters(sub_num,1,&reg_num,value_read); return Feb_Interface_ReadRegisters(sub_num, 1, &reg_num, value_read);
} }
int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
unsigned int *reg_nums,
unsigned int *values_read) {
// here cout<<"Reading Register ...."<<endl;
unsigned int i;
nreads &= 0x3ff;
if (!nreads || nreads > Feb_Interface_send_buffer_size - 2)
return 0;
int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read) { Feb_Interface_send_ndata = nreads + 2;
//here cout<<"Reading Register ...."<<endl; Feb_Interface_send_data[0] = 0x20000000 | nreads << 14;
unsigned int i;
nreads &= 0x3ff;
if (!nreads||nreads>Feb_Interface_send_buffer_size-2) return 0;
Feb_Interface_send_ndata = nreads+2; for (i = 0; i < nreads; i++)
Feb_Interface_send_data[0] = 0x20000000 | nreads << 14; Feb_Interface_send_data[i + 1] = reg_nums[i];
Feb_Interface_send_data[nreads + 1] = 0;
for(i=0;i<nreads;i++) Feb_Interface_send_data[i+1]=reg_nums[i]; if (!Feb_Interface_WriteTo(sub_num) ||
Feb_Interface_send_data[nreads+1] = 0; !Feb_Interface_ReadFrom(sub_num, 20) ||
Feb_Interface_recv_ndata != (int)(nreads + 2))
return 0;
if (!Feb_Interface_WriteTo(sub_num)||!Feb_Interface_ReadFrom(sub_num,20)||Feb_Interface_recv_ndata!=(int)(nreads+2)) return 0; for (i = 0; i < nreads; i++)
values_read[i] = Feb_Interface_recv_data[i + 1];
for(i=0;i<nreads;i++) values_read[i] = Feb_Interface_recv_data[i+1]; return 1;
return 1;
} }
int Feb_Interface_WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, int wait_on, unsigned int wait_on_address) { int Feb_Interface_WriteRegister(unsigned int sub_num, unsigned int reg_num,
return Feb_Interface_WriteRegisters(sub_num,1,&reg_num,&value,&wait_on,&wait_on_address); unsigned int value, int wait_on,
unsigned int wait_on_address) {
return Feb_Interface_WriteRegisters(sub_num, 1, &reg_num, &value, &wait_on,
&wait_on_address);
} }
int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, int* wait_ons, unsigned int* wait_on_addresses) { int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites,
unsigned int i; unsigned int *reg_nums, unsigned int *values,
nwrites &= 0x3ff; //10 bits int *wait_ons,
if (!nwrites||2*nwrites>Feb_Interface_send_buffer_size-2) return 0; unsigned int *wait_on_addresses) {
unsigned int i;
nwrites &= 0x3ff; // 10 bits
if (!nwrites || 2 * nwrites > Feb_Interface_send_buffer_size - 2)
return 0;
//cout<<"Write register : "<<this<<" "<<s_num<<" "<<nwrites<<" "<<reg_nums<<" "<<values<<" "<<wait_ons<<" "<<wait_on_addresses<<endl; // cout<<"Write register : "<<this<<" "<<s_num<<" "<<nwrites<<"
Feb_Interface_send_ndata = 2*nwrites+2; // "<<reg_nums<<" "<<values<<" "<<wait_ons<<" "<<wait_on_addresses<<endl;
Feb_Interface_send_data[0] = 0x80000000 | nwrites << 14; Feb_Interface_send_ndata = 2 * nwrites + 2;
Feb_Interface_send_data[2*nwrites+1] = 0; Feb_Interface_send_data[0] = 0x80000000 | nwrites << 14;
Feb_Interface_send_data[2 * nwrites + 1] = 0;
for(i=0;i<nwrites;i++) Feb_Interface_send_data[2*i+1] = 0x3fff&reg_nums[i]; for (i = 0; i < nwrites; i++)
for(i=0;i<nwrites;i++) Feb_Interface_send_data[2*i+2] = values[i]; Feb_Interface_send_data[2 * i + 1] = 0x3fff & reg_nums[i];
// wait on busy data(28), address of busy flag data(27 downto 14) for (i = 0; i < nwrites; i++)
if (wait_ons&&wait_on_addresses) for(i=0;i<nwrites;i++) Feb_Interface_send_data[2*i+1] |= (wait_ons[i]<<28 | (0x3fff&wait_on_addresses[i])<<14); Feb_Interface_send_data[2 * i + 2] = values[i];
// wait on busy data(28), address of busy flag data(27 downto 14)
if (wait_ons && wait_on_addresses)
for (i = 0; i < nwrites; i++)
Feb_Interface_send_data[2 * i + 1] |=
(wait_ons[i] << 28 | (0x3fff & wait_on_addresses[i]) << 14);
if (!Feb_Interface_WriteTo(sub_num)) return 0; if (!Feb_Interface_WriteTo(sub_num))
return 0;
return 1; return 1;
} }
int Feb_Interface_WriteMemoryInLoops(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values) { int Feb_Interface_WriteMemoryInLoops(unsigned int sub_num, unsigned int mem_num,
unsigned int max_single_packet_size = 352; unsigned int start_address,
int passed=1; unsigned int nwrites,
unsigned int n_to_send = max_single_packet_size; unsigned int *values) {
unsigned int ndata_sent = 0; unsigned int max_single_packet_size = 352;
unsigned int ndata_countdown = nwrites; int passed = 1;
while(ndata_countdown>0) { unsigned int n_to_send = max_single_packet_size;
n_to_send = ndata_countdown<max_single_packet_size ? ndata_countdown:max_single_packet_size; unsigned int ndata_sent = 0;
if (!Feb_Interface_WriteMemory(sub_num,mem_num,start_address,n_to_send,&(values[ndata_sent]))) {passed=0; break;} unsigned int ndata_countdown = nwrites;
ndata_countdown-=n_to_send; while (ndata_countdown > 0) {
ndata_sent +=n_to_send; n_to_send = ndata_countdown < max_single_packet_size
start_address +=n_to_send; ? ndata_countdown
usleep(500);//500 works : max_single_packet_size;
} if (!Feb_Interface_WriteMemory(sub_num, mem_num, start_address,
return passed; n_to_send, &(values[ndata_sent]))) {
passed = 0;
break;
}
ndata_countdown -= n_to_send;
ndata_sent += n_to_send;
start_address += n_to_send;
usleep(500); // 500 works
}
return passed;
} }
int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values) { int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num,
// -1 means write to all unsigned int start_address, unsigned int nwrites,
unsigned int i; unsigned int *values) {
mem_num &= 0x3f; // -1 means write to all
start_address &= 0x3fff; unsigned int i;
nwrites &= 0x3ff; mem_num &= 0x3f;
if (!nwrites||nwrites>Feb_Interface_send_buffer_size-2) { start_address &= 0x3fff;
LOG(logERROR, ("invalid nwrites:%d\n",nwrites)); nwrites &= 0x3ff;
return 0; if (!nwrites || nwrites > Feb_Interface_send_buffer_size - 2) {
}//*d-1026 LOG(logERROR, ("invalid nwrites:%d\n", nwrites));
return 0;
} //*d-1026
Feb_Interface_send_ndata = nwrites+2;//*d-1026 Feb_Interface_send_ndata = nwrites + 2; //*d-1026
Feb_Interface_send_data[0] = 0xc0000000 | mem_num << 24 | nwrites << 14 | start_address; //cmd -> write to memory, nwrites, mem number, start address Feb_Interface_send_data[0] =
Feb_Interface_send_data[nwrites+1] = 0; 0xc0000000 | mem_num << 24 | nwrites << 14 |
for(i=0;i<nwrites;i++) Feb_Interface_send_data[i+1] = values[i]; start_address; // cmd -> write to memory, nwrites, mem number, start
// address
Feb_Interface_send_data[nwrites + 1] = 0;
for (i = 0; i < nwrites; i++)
Feb_Interface_send_data[i + 1] = values[i];
if (!Feb_Interface_WriteTo(sub_num))
return 0;
if (!Feb_Interface_WriteTo(sub_num)) return 0; return 1;
return 1;
} }

28
slsDetectorServers/eigerDetectorServer/FebInterface.h Executable file → Normal file
View File

@ -3,12 +3,24 @@
int Feb_Interface_WriteTo(unsigned int ch); int Feb_Interface_WriteTo(unsigned int ch);
int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys); int Feb_Interface_ReadFrom(unsigned int ch, unsigned int ntrys);
void Feb_Interface_FebInterface(); void Feb_Interface_FebInterface();
void Feb_Interface_SendCompleteList(unsigned int n,unsigned int* list); void Feb_Interface_SendCompleteList(unsigned int n, unsigned int *list);
int Feb_Interface_SetByteOrder(); int Feb_Interface_SetByteOrder();
int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,unsigned int* value_read); int Feb_Interface_ReadRegister(unsigned int sub_num, unsigned int reg_num,
int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads, unsigned int* reg_nums,unsigned int* values_read); unsigned int *value_read);
int Feb_Interface_WriteRegister(unsigned int sub_num, unsigned int reg_num,unsigned int value, int wait_on, unsigned int wait_on_address); int Feb_Interface_ReadRegisters(unsigned int sub_num, unsigned int nreads,
int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites, unsigned int* reg_nums, unsigned int* values, int* wait_ons, unsigned int* wait_on_addresses); unsigned int *reg_nums,
int Feb_Interface_WriteMemoryInLoops(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values); unsigned int *values_read);
int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num, unsigned int start_address, unsigned int nwrites, unsigned int *values); int Feb_Interface_WriteRegister(unsigned int sub_num, unsigned int reg_num,
unsigned int value, int wait_on,
unsigned int wait_on_address);
int Feb_Interface_WriteRegisters(unsigned int sub_num, unsigned int nwrites,
unsigned int *reg_nums, unsigned int *values,
int *wait_ons,
unsigned int *wait_on_addresses);
int Feb_Interface_WriteMemoryInLoops(unsigned int sub_num, unsigned int mem_num,
unsigned int start_address,
unsigned int nwrites,
unsigned int *values);
int Feb_Interface_WriteMemory(unsigned int sub_num, unsigned int mem_num,
unsigned int start_address, unsigned int nwrites,
unsigned int *values);

336
slsDetectorServers/eigerDetectorServer/FebRegisterDefs.h Executable file → Normal file
View File

@ -1,228 +1,224 @@
//daq register definitions // daq register definitions
#define DAQ_REG_CTRL 1 #define DAQ_REG_CTRL 1
#define DAQ_REG_CHIP_CMDS 2 #define DAQ_REG_CHIP_CMDS 2
#define DAQ_REG_STATIC_BITS 3 #define DAQ_REG_STATIC_BITS 3
#define DAQ_REG_CLK_ROW_CLK_NTIMES 3 #define DAQ_REG_CLK_ROW_CLK_NTIMES 3
#define DAQ_REG_SHIFT_IN_32 3 #define DAQ_REG_SHIFT_IN_32 3
#define DAQ_REG_READOUT_NROWS 3 #define DAQ_REG_READOUT_NROWS 3
#define DAQ_REG_SEND_N_TESTPULSES 3 #define DAQ_REG_SEND_N_TESTPULSES 3
#define DAQ_REG_NEXPOSURES 3 #define DAQ_REG_NEXPOSURES 3
#define DAQ_REG_EXPOSURE_TIMER 4 // == (31 downto 3) * 10^(2 downto 0) #define DAQ_REG_EXPOSURE_TIMER 4 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0) #define DAQ_REG_EXPOSURE_REPEAT_TIMER 5 // == (31 downto 3) * 10^(2 downto 0)
#define DAQ_REG_SUBFRAME_EXPOSURES 6 #define DAQ_REG_SUBFRAME_EXPOSURES 6
#define DAQ_REG_SUBFRAME_PERIOD 7 //also pg and fifo status register #define DAQ_REG_SUBFRAME_PERIOD 7 // also pg and fifo status register
#define DAQ_REG_PARTIAL_READOUT 8 #define DAQ_REG_PARTIAL_READOUT 8
#define DAQ_REG_HRDWRE 12 #define DAQ_REG_HRDWRE 12
#define DAQ_REG_HRDWRE_OW_OFST (0) #define DAQ_REG_HRDWRE_OW_OFST (0)
#define DAQ_REG_HRDWRE_OW_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_OFST) #define DAQ_REG_HRDWRE_OW_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_OFST)
#define DAQ_REG_HRDWRE_TOP_OFST (1) #define DAQ_REG_HRDWRE_TOP_OFST (1)
#define DAQ_REG_HRDWRE_TOP_MSK (0x00000001 << DAQ_REG_HRDWRE_TOP_OFST) #define DAQ_REG_HRDWRE_TOP_MSK (0x00000001 << DAQ_REG_HRDWRE_TOP_OFST)
#define DAQ_REG_HRDWRE_INTRRPT_SF_OFST (2) #define DAQ_REG_HRDWRE_INTRRPT_SF_OFST (2)
#define DAQ_REG_HRDWRE_INTRRPT_SF_MSK (0x00000001 << DAQ_REG_HRDWRE_INTRRPT_SF_OFST) #define DAQ_REG_HRDWRE_INTRRPT_SF_MSK \
(0x00000001 << DAQ_REG_HRDWRE_INTRRPT_SF_OFST)
#define DAQ_REG_RO_OFFSET 20 #define DAQ_REG_RO_OFFSET 20
#define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) //also pg and fifo status register #define DAQ_REG_STATUS \
#define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3) (DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register
#define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4) #define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3)
#define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5) #define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4)
#define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5)
#define DAQ_CTRL_RESET 0x80000000
#define DAQ_CTRL_START 0x40000000
#define ACQ_CTRL_START 0x50000000 // this is 0x10000000 (acq) | 0x40000000 (daq)
#define DAQ_CTRL_STOP 0x00000000
// direct chip commands to the DAQ_REG_CHIP_CMDS register
#define DAQ_SET_STATIC_BIT 0x00000001
#define DAQ_RESET_COMPLETELY 0x0000000E
#define DAQ_RESET_PERIPHERY 0x00000002
#define DAQ_RESET_PIXEL_COUNTERS 0x00000004
#define DAQ_RESET_COLUMN_SELECT 0x00000008
#define DAQ_CTRL_RESET 0x80000000 #define DAQ_STORE_IMAGE 0x00000010
#define DAQ_CTRL_START 0x40000000 #define DAQ_RELEASE_IMAGE_STORE 0x00000020
#define ACQ_CTRL_START 0x50000000 //this is 0x10000000 (acq) | 0x40000000 (daq)
#define DAQ_CTRL_STOP 0x00000000
//direct chip commands to the DAQ_REG_CHIP_CMDS register
#define DAQ_SET_STATIC_BIT 0x00000001
#define DAQ_RESET_COMPLETELY 0x0000000E
#define DAQ_RESET_PERIPHERY 0x00000002
#define DAQ_RESET_PIXEL_COUNTERS 0x00000004
#define DAQ_RESET_COLUMN_SELECT 0x00000008
#define DAQ_STORE_IMAGE 0x00000010
#define DAQ_RELEASE_IMAGE_STORE 0x00000020
#define DAQ_SEND_A_TOKEN_IN 0x00000040 #define DAQ_SEND_A_TOKEN_IN 0x00000040
#define DAQ_CLK_ROW_CLK_NTIMES 0x00000080 #define DAQ_CLK_ROW_CLK_NTIMES 0x00000080
#define DAQ_SERIALIN_SHIFT_IN_32 0x00000100 #define DAQ_SERIALIN_SHIFT_IN_32 0x00000100
#define DAQ_LOAD_16ROWS_OF_TRIMBITS 0x00000200 #define DAQ_LOAD_16ROWS_OF_TRIMBITS 0x00000200
#define DAQ_IGNORE_INITIAL_CRAP 0x00000400 //crap before readout #define DAQ_IGNORE_INITIAL_CRAP 0x00000400 // crap before readout
#define DAQ_READOUT_NROWS 0x00000800 #define DAQ_READOUT_NROWS 0x00000800
#define DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START 0x00001000 //last 4 bit of data in the last frame #define DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START \
0x00001000 // last 4 bit of data in the last frame
#define DAQ_RELEASE_IMAGE_STORE_AFTER_READOUT 0x00002000 #define DAQ_RELEASE_IMAGE_STORE_AFTER_READOUT 0x00002000
#define DAQ_RESET_PIXEL_COUNTERS_AFTER_READOUT 0x00004000 #define DAQ_RESET_PIXEL_COUNTERS_AFTER_READOUT 0x00004000
#define DAQ_CLK_ROW_CLK_TO_SELECT_NEXT_ROW 0x00008000 #define DAQ_CLK_ROW_CLK_TO_SELECT_NEXT_ROW 0x00008000
#define DAQ_CLK_MAIN_CLK_TO_SELECT_NEXT_PIXEL 0x00010000 #define DAQ_CLK_MAIN_CLK_TO_SELECT_NEXT_PIXEL 0x00010000
#define DAQ_SEND_N_TEST_PULSES 0x00020000 #define DAQ_SEND_N_TEST_PULSES 0x00020000
#define DAQ_CHIP_CONTROLLER_HALF_SPEED 0x00040000 //everything at 100 MHz (50MHz ddr readout) #define DAQ_CHIP_CONTROLLER_HALF_SPEED \
#define DAQ_CHIP_CONTROLLER_QUARTER_SPEED 0x00080000 //everything at 50 MHz (25MHz ddr readout) 0x00040000 // everything at 100 MHz (50MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED 0x000c0000 //everything at ~200 kHz (200 kHz MHz ddr readout) #define DAQ_CHIP_CONTROLLER_QUARTER_SPEED \
0x00080000 // everything at 50 MHz (25MHz ddr readout)
#define DAQ_CHIP_CONTROLLER_SUPER_SLOW_SPEED \
0x000c0000 // everything at ~200 kHz (200 kHz MHz ddr readout)
//#define DAQ_FIFO_ENABLE 0x00100000 commented out as it is not used anywhere //#define DAQ_FIFO_ENABLE 0x00100000 commented out as it
#define DAQ_REG_CHIP_CMDS_INT_TRIGGER 0x00100000 // is not used anywhere
#define DAQ_REG_CHIP_CMDS_INT_TRIGGER 0x00100000
//direct chip commands to the DAQ_REG_CHIP_CMDS register // direct chip commands to the DAQ_REG_CHIP_CMDS register
#define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE 0x00200000 //row clk is before main clk readout sequence #define DAQ_NEXPOSURERS_SAFEST_MODE_ROW_CLK_BEFORE_MODE \
#define DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE 0x00400000 //expose ->readout ->expose -> ..., with store is always closed 0x00200000 // row clk is before main clk readout sequence
#define DAQ_NEXPOSURERS_PARALLEL_MODE 0x00600000 //parallel acquire/read mode #define DAQ_NEXPOSURERS_NORMAL_NONPARALLEL_MODE \
0x00400000 // expose ->readout ->expose -> ..., with store is always closed
#define DAQ_NEXPOSURERS_PARALLEL_MODE 0x00600000 // parallel acquire/read mode
//DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES is old now hard-wired in the firmware that every image comes with a header // DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES is old now hard-wired in the firmware
//#define DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES 0x00800000 //DAQ_IGNORE_INITIAL_CRAP and DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START // that every image comes with a header #define
// DAQ_NEXPOSURERS_READOUT_COMPLETE_IMAGES 0x00800000
////DAQ_IGNORE_INITIAL_CRAP and DAQ_CLKOUT_LAST_4_BITS_AND_RETURN_TO_START
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING 0x01000000 #define DAQ_NEXPOSURERS_EXTERNAL_ENABLING 0x01000000
#define DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY 0x02000000 #define DAQ_NEXPOSURERS_EXTERNAL_ENABLING_POLARITY 0x02000000
#define DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY 0x04000000 #define DAQ_NEXPOSURERS_EXTERNAL_TRIGGER_POLARITY 0x04000000
#define DAQ_NEXPOSURERS_INTERNAL_ACQUISITION 0x00000000 //internally controlled #define DAQ_NEXPOSURERS_INTERNAL_ACQUISITION 0x00000000 // internally controlled
#define DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START 0x08000000 //external acquisition start #define DAQ_NEXPOSURERS_EXTERNAL_ACQUISITION_START \
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START 0x10000000 //external image start 0x08000000 // external acquisition start
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP 0x18000000 //externally controlly, external image start and stop #define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START 0x10000000 // external image start
#define DAQ_NEXPOSURERS_EXTERNAL_IMAGE_START_AND_STOP \
0x18000000 // externally controlly, external image start and stop
#define DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING 0x20000000 #define DAQ_NEXPOSURERS_ACTIVATE_AUTO_SUBIMAGING 0x20000000
#define DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION 0x40000000 #define DAQ_NEXPOSURERS_ACTIVATE_RATE_CORRECTION 0x40000000
//#define DAQ_MASTER_HALF_MODULE 0x80000000 currently not used //#define DAQ_MASTER_HALF_MODULE 0x80000000 currently not
// used
// chips static bits
#define DAQ_STATIC_BIT_PROGRAM 0x00000001
#define DAQ_STATIC_BIT_M4 0x00000002 // these are the status bits, not bit mode
#define DAQ_STATIC_BIT_M8 0x00000004 // these are the status bits, not bit mode
#define DAQ_STATIC_BIT_M12 \
0x00000000 // these are the status bits, not bit mode, ie. "00" is 12 bit
// mode
#define DAQ_STATIC_BIT_CHIP_TEST 0x00000008
#define DAQ_STATIC_BIT_ROTEST 0x00000010
#define DAQ_CS_BAR_LEFT 0x00000020
#define DAQ_CS_BAR_RIGHT 0x00000040
//chips static bits // status flags
#define DAQ_STATIC_BIT_PROGRAM 0x00000001 #define DAQ_STATUS_DAQ_RUNNING 0x01
#define DAQ_STATIC_BIT_M4 0x00000002 //these are the status bits, not bit mode #define DAQ_DATA_COLLISION_ERROR 0x02
#define DAQ_STATIC_BIT_M8 0x00000004 //these are the status bits, not bit mode
#define DAQ_STATIC_BIT_M12 0x00000000 //these are the status bits, not bit mode, ie. "00" is 12 bit mode
#define DAQ_STATIC_BIT_CHIP_TEST 0x00000008
#define DAQ_STATIC_BIT_ROTEST 0x00000010
#define DAQ_CS_BAR_LEFT 0x00000020
#define DAQ_CS_BAR_RIGHT 0x00000040
#define DAQ_STATUS_CURRENT_M4 0x04
//status flags
#define DAQ_STATUS_DAQ_RUNNING 0x01
#define DAQ_DATA_COLLISION_ERROR 0x02
#define DAQ_STATUS_CURRENT_M4 0x04
#define DAQ_STATUS_CURRENT_M8 0x08 #define DAQ_STATUS_CURRENT_M8 0x08
#define DAQ_STATUS_CURRENT_M12 0x00 //in 12 bit mode both are cleared #define DAQ_STATUS_CURRENT_M12 0x00 // in 12 bit mode both are cleared
#define DAQ_STATUS_CURRENT_TESTMODE 0x10 #define DAQ_STATUS_CURRENT_TESTMODE 0x10
#define DAQ_STATUS_TOKEN_OUT 0x20 #define DAQ_STATUS_TOKEN_OUT 0x20
#define DAQ_STATUS_SERIAL_OUT 0x40 #define DAQ_STATUS_SERIAL_OUT 0x40
#define DAQ_STATUS_PIXELS_ARE_ENABLED 0x80 #define DAQ_STATUS_PIXELS_ARE_ENABLED 0x80
#define DAQ_STATUS_DAQ_RUN_TOGGLE 0x200 #define DAQ_STATUS_DAQ_RUN_TOGGLE 0x200
//data delay registers // data delay registers
#define CHIP_DATA_OUT_DELAY_REG_CTRL 1 #define CHIP_DATA_OUT_DELAY_REG_CTRL 1
#define CHIP_DATA_OUT_DELAY_REG2 2 #define CHIP_DATA_OUT_DELAY_REG2 2
#define CHIP_DATA_OUT_DELAY_REG3 3 #define CHIP_DATA_OUT_DELAY_REG3 3
#define CHIP_DATA_OUT_DELAY_REG4 4 #define CHIP_DATA_OUT_DELAY_REG4 4
#define CHIP_DATA_OUT_DELAY_SET 0x20000000 #define CHIP_DATA_OUT_DELAY_SET 0x20000000
//module configuration // module configuration
#define TOP_BIT_MASK 0x00f #define TOP_BIT_MASK 0x00f
#define MASTER_BIT_MASK 0x200 #define MASTER_BIT_MASK 0x200
#define NORMAL_MODULE_BIT_MASK 0x400 #define NORMAL_MODULE_BIT_MASK 0x400
// Master Slave Top Bottom Definition // Master Slave Top Bottom Definition
#define MODULE_CONFIGURATION_MASK 0x84 #define MODULE_CONFIGURATION_MASK 0x84
//Software Configuration // Software Configuration
#define MASTERCONFIG_OFFSET 0x160 //0x20 * 11 (P11) #define MASTERCONFIG_OFFSET 0x160 // 0x20 * 11 (P11)
#define MASTER_BIT 0x1 #define MASTER_BIT 0x1
#define OVERWRITE_HARDWARE_BIT 0x2 #define OVERWRITE_HARDWARE_BIT 0x2
#define DEACTIVATE_BIT 0x4 #define DEACTIVATE_BIT 0x4
#define FPGA_TEMP_OFFSET 0x200 #define FPGA_TEMP_OFFSET 0x200
#define TXM_DELAY_LEFT_OFFSET 0x180 #define TXM_DELAY_LEFT_OFFSET 0x180
#define TXM_DELAY_RIGHT_OFFSET 0x1A0 #define TXM_DELAY_RIGHT_OFFSET 0x1A0
#define TXM_DELAY_FRAME_OFFSET 0x1C0 #define TXM_DELAY_FRAME_OFFSET 0x1C0
#define FLOW_REG_OFFSET 0x140 #define FLOW_REG_OFFSET 0x140
#define FLOW_REG_TXM_FLOW_CNTRL_10G_OFST (0) #define FLOW_REG_TXM_FLOW_CNTRL_10G_OFST (0)
#define FLOW_REG_TXM_FLOW_CNTRL_10G_MSK (0x1 << FLOW_REG_TXM_FLOW_CNTRL_10G_OFST) #define FLOW_REG_TXM_FLOW_CNTRL_10G_MSK \
#define FLOW_REG_OVERFLOW_32_BIT_OFST (2) (0x1 << FLOW_REG_TXM_FLOW_CNTRL_10G_OFST)
#define FLOW_REG_OVERFLOW_32_BIT_MSK (0x1 << FLOW_REG_OVERFLOW_32_BIT_OFST) #define FLOW_REG_OVERFLOW_32_BIT_OFST (2)
#define FLOW_REG_OVERFLOW_32_BIT_MSK (0x1 << FLOW_REG_OVERFLOW_32_BIT_OFST)
//command memory // command memory
#define LEFT_OFFSET 0x0 #define LEFT_OFFSET 0x0
#define RIGHT_OFFSET 0x100 #define RIGHT_OFFSET 0x100
#define FIRST_CMD_PART1_OFFSET 0x8 #define FIRST_CMD_PART1_OFFSET 0x8
#define FIRST_CMD_PART2_OFFSET 0xc #define FIRST_CMD_PART2_OFFSET 0xc
#define SECOND_CMD_PART1_OFFSET 0x10 #define SECOND_CMD_PART1_OFFSET 0x10
#define SECOND_CMD_PART2_OFFSET 0x14 #define SECOND_CMD_PART2_OFFSET 0x14
#define COMMAND_COUNTER_OFFSET 0x18 #define COMMAND_COUNTER_OFFSET 0x18
#define STOP_ACQ_OFFSET 0x1c #define STOP_ACQ_OFFSET 0x1c
#define STOP_ACQ_BIT 0x40000000 #define STOP_ACQ_BIT 0x40000000
#define TWO_REQUESTS_OFFSET 0x1c #define TWO_REQUESTS_OFFSET 0x1c
#define TWO_REQUESTS_BIT 0x80000000 #define TWO_REQUESTS_BIT 0x80000000
//version // version
#define FIRMWARE_VERSION_OFFSET 0x4 #define FIRMWARE_VERSION_OFFSET 0x4
#define FIRMWARESOFTWARE_API_OFFSET 0x0 #define FIRMWARESOFTWARE_API_OFFSET 0x0
#define FRAME_NUM_RESET_OFFSET 0xA0 #define FRAME_NUM_RESET_OFFSET 0xA0
//1g counters // 1g counters
#define ONE_GIGA_LEFT_INDEX_LSB_COUNTER 0x04 #define ONE_GIGA_LEFT_INDEX_LSB_COUNTER 0x04
#define ONE_GIGA_LEFT_INDEX_MSB_COUNTER 0x24 #define ONE_GIGA_LEFT_INDEX_MSB_COUNTER 0x24
#define ONE_GIGA_LEFT_TXN_DELAY_COUNTER 0x104 #define ONE_GIGA_LEFT_TXN_DELAY_COUNTER 0x104
#define ONE_GIGA_LEFT_FRAME_DELAY_COUNTER 0x124 #define ONE_GIGA_LEFT_FRAME_DELAY_COUNTER 0x124
#define ONE_GIGA_RIGHT_INDEX_LSB_COUNTER 0x44 #define ONE_GIGA_RIGHT_INDEX_LSB_COUNTER 0x44
#define ONE_GIGA_RIGHT_INDEX_MSB_COUNTER 0x64 #define ONE_GIGA_RIGHT_INDEX_MSB_COUNTER 0x64
#define ONE_GIGA_RIGHT_TXN_DELAY_COUNTER 0x144 #define ONE_GIGA_RIGHT_TXN_DELAY_COUNTER 0x144
#define ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x164 #define ONE_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x164
//10g counters // 10g counters
#define TEN_GIGA_LEFT_INDEX_LSB_COUNTER 0x84 #define TEN_GIGA_LEFT_INDEX_LSB_COUNTER 0x84
#define TEN_GIGA_LEFT_INDEX_MSB_COUNTER 0xa4 #define TEN_GIGA_LEFT_INDEX_MSB_COUNTER 0xa4
#define TEN_GIGA_LEFT_TXN_DELAY_COUNTER 0x184 #define TEN_GIGA_LEFT_TXN_DELAY_COUNTER 0x184
#define TEN_GIGA_LEFT_FRAME_DELAY_COUNTER 0x1a4 #define TEN_GIGA_LEFT_FRAME_DELAY_COUNTER 0x1a4
#define TEN_GIGA_RIGHT_INDEX_LSB_COUNTER 0xc4 #define TEN_GIGA_RIGHT_INDEX_LSB_COUNTER 0xc4
#define TEN_GIGA_RIGHT_INDEX_MSB_COUNTER 0xe4 #define TEN_GIGA_RIGHT_INDEX_MSB_COUNTER 0xe4
#define TEN_GIGA_RIGHT_TXN_DELAY_COUNTER 0x1c4 #define TEN_GIGA_RIGHT_TXN_DELAY_COUNTER 0x1c4
#define TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x1e4 #define TEN_GIGA_RIGHT_FRAME_DELAY_COUNTER 0x1e4
// udp header (position, id) // udp header (position, id)
#define UDP_HEADER_A_LEFT_OFST 0x00C0 #define UDP_HEADER_A_LEFT_OFST 0x00C0
#define UDP_HEADER_B_LEFT_OFST 0x00E0 #define UDP_HEADER_B_LEFT_OFST 0x00E0
#define UDP_HEADER_A_RIGHT_OFST 0x0100 #define UDP_HEADER_A_RIGHT_OFST 0x0100
#define UDP_HEADER_B_RIGHT_OFST 0x0120 #define UDP_HEADER_B_RIGHT_OFST 0x0120
#define UDP_HEADER_X_OFST (0)
#define UDP_HEADER_X_MSK (0xFFFF << UDP_HEADER_X_OFST)
#define UDP_HEADER_ID_OFST (16)
#define UDP_HEADER_ID_MSK (0xFFFF << UDP_HEADER_ID_OFST)
#define UDP_HEADER_Z_OFST (0)
#define UDP_HEADER_Z_MSK (0xFFFF << UDP_HEADER_Z_OFST)
#define UDP_HEADER_Y_OFST (16)
#define UDP_HEADER_Y_MSK (0xFFFF << UDP_HEADER_Y_OFST)
#define UDP_HEADER_X_OFST (0)
#define UDP_HEADER_X_MSK (0xFFFF << UDP_HEADER_X_OFST)
#define UDP_HEADER_ID_OFST (16)
#define UDP_HEADER_ID_MSK (0xFFFF << UDP_HEADER_ID_OFST)
#define UDP_HEADER_Z_OFST (0)
#define UDP_HEADER_Z_MSK (0xFFFF << UDP_HEADER_Z_OFST)
#define UDP_HEADER_Y_OFST (16)
#define UDP_HEADER_Y_MSK (0xFFFF << UDP_HEADER_Y_OFST)

36
slsDetectorServers/eigerDetectorServer/HardwareIO.c Executable file → Normal file
View File

@ -1,76 +1,64 @@
#include "HardwareIO.h" #include "HardwareIO.h"
xfs_u8 HWIO_xfs_in8(xfs_u32 InAddress) xfs_u8 HWIO_xfs_in8(xfs_u32 InAddress) {
{
/* read the contents of the I/O location and then synchronize the I/O /* read the contents of the I/O location and then synchronize the I/O
* such that the I/O operation completes before proceeding on * such that the I/O operation completes before proceeding on
*/ */
xfs_u8 IoContents; xfs_u8 IoContents;
__asm__ volatile ("eieio; lbz %0,0(%1)":"=r" (IoContents):"b" __asm__ volatile("eieio; lbz %0,0(%1)" : "=r"(IoContents) : "b"(InAddress));
(InAddress));
return IoContents; return IoContents;
} }
/*****************************************************************************/ /*****************************************************************************/
xfs_u16 HWIO_xfs_in16(xfs_u32 InAddress) xfs_u16 HWIO_xfs_in16(xfs_u32 InAddress) {
{
/* read the contents of the I/O location and then synchronize the I/O /* read the contents of the I/O location and then synchronize the I/O
* such that the I/O operation completes before proceeding on * such that the I/O operation completes before proceeding on
*/ */
xfs_u16 IoContents; xfs_u16 IoContents;
__asm__ volatile ("eieio; lhz %0,0(%1)":"=r" (IoContents):"b" __asm__ volatile("eieio; lhz %0,0(%1)" : "=r"(IoContents) : "b"(InAddress));
(InAddress));
return IoContents; return IoContents;
} }
/*****************************************************************************/ /*****************************************************************************/
xfs_u32 HWIO_xfs_in32(xfs_u32 InAddress) xfs_u32 HWIO_xfs_in32(xfs_u32 InAddress) {
{
/* read the contents of the I/O location and then synchronize the I/O /* read the contents of the I/O location and then synchronize the I/O
* such that the I/O operation completes before proceeding on * such that the I/O operation completes before proceeding on
*/ */
xfs_u32 IoContents; xfs_u32 IoContents;
__asm__ volatile ("eieio; lwz %0,0(%1)":"=r" (IoContents):"b" __asm__ volatile("eieio; lwz %0,0(%1)" : "=r"(IoContents) : "b"(InAddress));
(InAddress));
return IoContents; return IoContents;
} }
/*****************************************************************************/ /*****************************************************************************/
void HWIO_xfs_out8(xfs_u32 OutAddress, xfs_u8 Value) void HWIO_xfs_out8(xfs_u32 OutAddress, xfs_u8 Value) {
{
/* write the contents of the I/O location and then synchronize the I/O /* write the contents of the I/O location and then synchronize the I/O
* such that the I/O operation completes before proceeding on * such that the I/O operation completes before proceeding on
*/ */
__asm__ volatile ("stb %0,0(%1); eieio"::"r" (Value), "b"(OutAddress)); __asm__ volatile("stb %0,0(%1); eieio" ::"r"(Value), "b"(OutAddress));
} }
/*****************************************************************************/ /*****************************************************************************/
void HWIO_xfs_out16(xfs_u32 OutAddress, xfs_u16 Value) void HWIO_xfs_out16(xfs_u32 OutAddress, xfs_u16 Value) {
{
/* write the contents of the I/O location and then synchronize the I/O /* write the contents of the I/O location and then synchronize the I/O
* such that the I/O operation completes before proceeding on * such that the I/O operation completes before proceeding on
*/ */
__asm__ volatile ("sth %0,0(%1); eieio"::"r" (Value), "b"(OutAddress)); __asm__ volatile("sth %0,0(%1); eieio" ::"r"(Value), "b"(OutAddress));
} }
/*****************************************************************************/ /*****************************************************************************/
void HWIO_xfs_out32(xfs_u32 OutAddress, xfs_u32 Value) void HWIO_xfs_out32(xfs_u32 OutAddress, xfs_u32 Value) {
{
/* write the contents of the I/O location and then synchronize the I/O /* write the contents of the I/O location and then synchronize the I/O
* such that the I/O operation completes before proceeding on * such that the I/O operation completes before proceeding on
*/ */
__asm__ volatile ("stw %0,0(%1); eieio"::"r" (Value), "b"(OutAddress)); __asm__ volatile("stw %0,0(%1); eieio" ::"r"(Value), "b"(OutAddress));
} }

17
slsDetectorServers/eigerDetectorServer/HardwareIO.h Executable file → Normal file
View File

@ -1,16 +1,13 @@
//Class initially from Gerd and was called mmap_test.c // Class initially from Gerd and was called mmap_test.c
#pragma once #pragma once
#include "xfs_types.h" #include "xfs_types.h"
xfs_u8 HWIO_xfs_in8(xfs_u32 InAddress);
xfs_u16 HWIO_xfs_in16(xfs_u32 InAddress);
xfs_u32 HWIO_xfs_in32(xfs_u32 InAddress);
void HWIO_xfs_out8(xfs_u32 OutAddress, xfs_u8 Value);
xfs_u8 HWIO_xfs_in8(xfs_u32 InAddress); void HWIO_xfs_out16(xfs_u32 OutAddress, xfs_u16 Value);
xfs_u16 HWIO_xfs_in16(xfs_u32 InAddress); void HWIO_xfs_out32(xfs_u32 OutAddress, xfs_u32 Value);
xfs_u32 HWIO_xfs_in32(xfs_u32 InAddress);
void HWIO_xfs_out8(xfs_u32 OutAddress, xfs_u8 Value);
void HWIO_xfs_out16(xfs_u32 OutAddress, xfs_u16 Value);
void HWIO_xfs_out32(xfs_u32 OutAddress, xfs_u32 Value);

View File

@ -1,11 +1,10 @@
//from Gerd and was called mmap_test.h // from Gerd and was called mmap_test.h
#ifndef __PLB_LL_FIFO_H__ #ifndef __PLB_LL_FIFO_H__
#define __PLB_LL_FIFO_H__ #define __PLB_LL_FIFO_H__
/******************************************************************************/ /******************************************************************************/
/* definitions */ /* definitions */
/******************************************************************************/ /******************************************************************************/
@ -14,49 +13,43 @@
#define PLB_LL_FIFO_REG_STATUS 1 #define PLB_LL_FIFO_REG_STATUS 1
#define PLB_LL_FIFO_REG_FIFO 2 #define PLB_LL_FIFO_REG_FIFO 2
#define PLB_LL_FIFO_CTRL_LL_REM_SHIFT 30 #define PLB_LL_FIFO_CTRL_LL_REM_SHIFT 30
#define PLB_LL_FIFO_CTRL_LL_REM 0xC0000000 #define PLB_LL_FIFO_CTRL_LL_REM 0xC0000000
#define PLB_LL_FIFO_CTRL_LL_EOF 0x20000000 #define PLB_LL_FIFO_CTRL_LL_EOF 0x20000000
#define PLB_LL_FIFO_CTRL_LL_SOF 0x10000000 #define PLB_LL_FIFO_CTRL_LL_SOF 0x10000000
#define PLB_LL_FIFO_CTRL_LL_MASK 0xF0000000 #define PLB_LL_FIFO_CTRL_LL_MASK 0xF0000000
#define PLB_LL_FIFO_CTRL_TX_RESET 0x08000000
#define PLB_LL_FIFO_CTRL_RX_RESET 0x04000000
#define PLB_LL_FIFO_CTRL_TX_RESET 0x08000000 #define PLB_LL_FIFO_CTRL_RESET_STATUS 0x00800000
#define PLB_LL_FIFO_CTRL_RX_RESET 0x04000000 #define PLB_LL_FIFO_CTRL_RESET_USER 0x00400000
#define PLB_LL_FIFO_CTRL_RESET_LINK 0x00200000
#define PLB_LL_FIFO_CTRL_RESET_GT 0x00100000
#define PLB_LL_FIFO_CTRL_RESET_STATUS 0x00800000 #define PLB_LL_FIFO_CTRL_RESET_ALL 0x0CF00000
#define PLB_LL_FIFO_CTRL_RESET_USER 0x00400000
#define PLB_LL_FIFO_CTRL_RESET_LINK 0x00200000
#define PLB_LL_FIFO_CTRL_RESET_GT 0x00100000
#define PLB_LL_FIFO_CTRL_RESET_ALL 0x0CF00000
// do not reset complete gtx dual in std. case // do not reset complete gtx dual in std. case
// cause this would reset PLL and stop LL clk // cause this would reset PLL and stop LL clk
#define PLB_LL_FIFO_CTRL_RESET_STD 0x0CE00000 #define PLB_LL_FIFO_CTRL_RESET_STD 0x0CE00000
// reset Rx and Tx Fifo and set User Reset // reset Rx and Tx Fifo and set User Reset
#define PLB_LL_FIFO_CTRL_RESET_FIFO 0x0C400000 #define PLB_LL_FIFO_CTRL_RESET_FIFO 0x0C400000
#define PLB_LL_FIFO_CTRL_CONFIG_VECTOR 0x000FFFFF
#define PLB_LL_FIFO_CTRL_CONFIG_VECTOR 0x000FFFFF #define PLB_LL_FIFO_STATUS_LL_REM_SHIFT 30
#define PLB_LL_FIFO_STATUS_LL_REM 0xC0000000
#define PLB_LL_FIFO_STATUS_LL_EOF 0x20000000
#define PLB_LL_FIFO_STATUS_LL_SOF 0x10000000
#define PLB_LL_FIFO_STATUS_EMPTY 0x08000000
#define PLB_LL_FIFO_STATUS_ALMOSTEMPTY 0x04000000
#define PLB_LL_FIFO_STATUS_FULL 0x02000000
#define PLB_LL_FIFO_STATUS_ALMOSTFULL 0x01000000
#define PLB_LL_FIFO_STATUS_LL_REM_SHIFT 30 #define PLB_LL_FIFO_STATUS_VECTOR 0x000FFFFF
#define PLB_LL_FIFO_STATUS_LL_REM 0xC0000000
#define PLB_LL_FIFO_STATUS_LL_EOF 0x20000000
#define PLB_LL_FIFO_STATUS_LL_SOF 0x10000000
#define PLB_LL_FIFO_STATUS_EMPTY 0x08000000
#define PLB_LL_FIFO_STATUS_ALMOSTEMPTY 0x04000000
#define PLB_LL_FIFO_STATUS_FULL 0x02000000
#define PLB_LL_FIFO_STATUS_ALMOSTFULL 0x01000000
#define PLB_LL_FIFO_STATUS_VECTOR 0x000FFFFF
#define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
#define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
#endif // __PLB_LL_FIFO_H__ #endif // __PLB_LL_FIFO_H__

View File

@ -2,219 +2,221 @@
#include "HardwareMMappingDefs.h" #include "HardwareMMappingDefs.h"
#include "clogger.h" #include "clogger.h"
#include <unistd.h>
#include <sys/mman.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/mman.h>
#include <unistd.h>
void Local_LocalLinkInterface1(struct LocalLinkInterface *ll,
void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) { unsigned int ll_fifo_badr) {
LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n")); LOG(logDEBUG1, ("Initialize PLB LL FIFOs\n"));
ll->ll_fifo_base=0; ll->ll_fifo_base = 0;
ll->ll_fifo_ctrl_reg=0; ll->ll_fifo_ctrl_reg = 0;
if (Local_Init(ll,ll_fifo_badr)) { if (Local_Init(ll, ll_fifo_badr)) {
Local_Reset(ll); Local_Reset(ll);
LOG(logDEBUG1, ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll))); LOG(logDEBUG1,
} else LOG(logERROR, ("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr)); ("\tFIFO Status : 0x%08x\n\n\n", Local_StatusVector(ll)));
} else
LOG(logERROR,
("\tCould not map LocalLink : 0x%08x\n\n\n", ll_fifo_badr));
} }
void Local_LocalLinkInterface(struct LocalLinkInterface *ll) {
void Local_LocalLinkInterface(struct LocalLinkInterface* ll) { LOG(logDEBUG1, ("Initializing new memory\n"));
LOG(logDEBUG1, ("Initializing new memory\n"));
} }
int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr) {
int fd;
void *plb_ll_fifo_ptr;
if ((fd = open("/dev/mem", O_RDWR)) < 0) {
fprintf(stderr, "Could not open /dev/mem\n");
return 0;
}
int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr) { plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE,
int fd; MAP_FILE | MAP_SHARED, fd, ll_fifo_badr);
void *plb_ll_fifo_ptr; close(fd);
if ((fd=open("/dev/mem", O_RDWR)) < 0) { if (plb_ll_fifo_ptr == MAP_FAILED) {
fprintf(stderr, "Could not open /dev/mem\n"); perror("mmap");
return 0; return 0;
} }
plb_ll_fifo_ptr = mmap(0, getpagesize(), PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, ll_fifo_badr); ll->ll_fifo_base = (xfs_u32)plb_ll_fifo_ptr;
close(fd); ll->ll_fifo_ctrl_reg = 0;
if (plb_ll_fifo_ptr == MAP_FAILED) { return 1;
perror ("mmap");
return 0;
}
ll->ll_fifo_base = (xfs_u32) plb_ll_fifo_ptr;
ll->ll_fifo_ctrl_reg = 0;
return 1;
} }
int Local_Reset(struct LocalLinkInterface *ll) {
return Local_Reset1(ll, PLB_LL_FIFO_CTRL_RESET_STD);
int Local_Reset(struct LocalLinkInterface* ll) {
return Local_Reset1(ll,PLB_LL_FIFO_CTRL_RESET_STD);
} }
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask) { int Local_Reset1(struct LocalLinkInterface *ll, unsigned int rst_mask) {
ll->ll_fifo_ctrl_reg |= rst_mask; ll->ll_fifo_ctrl_reg |= rst_mask;
LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n",ll->ll_fifo_ctrl_reg)); LOG(logDEBUG1, ("\tCTRL Register bits: 0x%08x\n", ll->ll_fifo_ctrl_reg));
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_CTRL,
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_CTRL,
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_CTRL,
ll->ll_fifo_ctrl_reg);
HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_CTRL,
ll->ll_fifo_ctrl_reg);
ll->ll_fifo_ctrl_reg &= (~rst_mask); ll->ll_fifo_ctrl_reg &= (~rst_mask);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_CTRL,
return 1; ll->ll_fifo_ctrl_reg);
return 1;
} }
unsigned int Local_StatusVector(struct LocalLinkInterface *ll) {
return HWIO_xfs_in32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_STATUS);
unsigned int Local_StatusVector(struct LocalLinkInterface* ll) {
return HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS);
} }
int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer) { int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
// note: buffer must be word (4 byte) aligned void *buffer) {
// frame_len in byte // note: buffer must be word (4 byte) aligned
int vacancy=0; // frame_len in byte
int i; int vacancy = 0;
int words_send = 0; int i;
int last_word; int words_send = 0;
unsigned int *word_ptr; int last_word;
unsigned int fifo_ctrl; unsigned int *word_ptr;
xfs_u32 status; unsigned int fifo_ctrl;
xfs_u32 status;
if (buffer_len < 1) return -1; if (buffer_len < 1)
return -1;
last_word = (buffer_len-1)/4; last_word = (buffer_len - 1) / 4;
word_ptr = (unsigned int *)buffer; word_ptr = (unsigned int *)buffer;
LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ",buffer_len, ll->ll_fifo_base)); LOG(logDEBUG1, ("LL Write - Len: %2d - If: %X - Data: ", buffer_len,
for (i=0; i < buffer_len/4; i++) ll->ll_fifo_base));
LOG(logDEBUG1, ("%.8X ",*(((unsigned *) buffer)+i))); for (i = 0; i < buffer_len / 4; i++)
LOG(logDEBUG1, ("%.8X ", *(((unsigned *)buffer) + i)));
while (words_send <= last_word) while (words_send <= last_word) {
{ while (!vacancy) // wait for Fifo to be empty again
while (!vacancy)//wait for Fifo to be empty again {
{ status =
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS); HWIO_xfs_in32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_STATUS);
if ((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0) vacancy = 1; if ((status & PLB_LL_FIFO_STATUS_ALMOSTFULL) == 0)
if (vacancy == 0) { vacancy = 1;
LOG(logERROR, ("Fifo full!\n")); if (vacancy == 0) {
} LOG(logERROR, ("Fifo full!\n"));
} }
}
//Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100 // Just to know: #define PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS 100
for (i=0; ((i<PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) && (words_send <= last_word)); i++) for (i = 0; ((i < PLB_LL_FIFO_ALMOST_FULL_THRESHOLD_WORDS) &&
{ (words_send <= last_word));
fifo_ctrl = 0; i++) {
if (words_send == 0) fifo_ctrl = 0;
{ if (words_send == 0) {
fifo_ctrl = PLB_LL_FIFO_CTRL_LL_SOF;//announce the start of file fifo_ctrl =
} PLB_LL_FIFO_CTRL_LL_SOF; // announce the start of file
}
if (words_send == last_word) if (words_send == last_word) {
{ fifo_ctrl |=
fifo_ctrl |= (PLB_LL_FIFO_CTRL_LL_EOF | (( (buffer_len-1)<<PLB_LL_FIFO_CTRL_LL_REM_SHIFT) & PLB_LL_FIFO_CTRL_LL_REM) ); (PLB_LL_FIFO_CTRL_LL_EOF |
} (((buffer_len - 1) << PLB_LL_FIFO_CTRL_LL_REM_SHIFT) &
Local_ctrl_reg_write_mask(ll,PLB_LL_FIFO_CTRL_LL_MASK,fifo_ctrl); PLB_LL_FIFO_CTRL_LL_REM));
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO,word_ptr[words_send++]); }
} Local_ctrl_reg_write_mask(ll, PLB_LL_FIFO_CTRL_LL_MASK, fifo_ctrl);
} HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_FIFO,
return buffer_len; word_ptr[words_send++]);
}
}
return buffer_len;
} }
int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer) {
static unsigned int buffer_ptr = 0;
// note: buffer must be word (4 byte) aligned
// frame_len in byte
int len;
unsigned int *word_ptr;
unsigned int status;
volatile unsigned int fifo_val;
int sof = 0;
int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer) { LOG(logDEBUG1, ("LL Read - If: %X - Data: ", ll->ll_fifo_base));
static unsigned int buffer_ptr = 0;
// note: buffer must be word (4 byte) aligned
// frame_len in byte
int len;
unsigned int *word_ptr;
unsigned int status;
volatile unsigned int fifo_val;
int sof = 0;
LOG(logDEBUG1, ("LL Read - If: %X - Data: ",ll->ll_fifo_base)); word_ptr = (unsigned int *)buffer;
do {
status = HWIO_xfs_in32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_STATUS);
word_ptr = (unsigned int *)buffer; if (!(status & PLB_LL_FIFO_STATUS_EMPTY)) {
do if (status & PLB_LL_FIFO_STATUS_LL_SOF) {
{ if (buffer_ptr) {
status = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_STATUS); buffer_ptr = 0;
return -1; // buffer overflow
}
buffer_ptr = 0;
sof = 1;
}
if (!(status & PLB_LL_FIFO_STATUS_EMPTY)) fifo_val = HWIO_xfs_in32(
{ ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_FIFO); // read from fifo
if (status & PLB_LL_FIFO_STATUS_LL_SOF)
{
if (buffer_ptr)
{
buffer_ptr = 0;
return -1; // buffer overflow
}
buffer_ptr = 0;
sof = 1;
}
fifo_val = HWIO_xfs_in32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_FIFO); //read from fifo if ((buffer_ptr > 0) || sof) {
if ((buffer_len >> 2) > buffer_ptr) {
LOG(logDEBUG1, ("%.8X ", fifo_val));
word_ptr[buffer_ptr++] = fifo_val; // write to buffer
} else {
buffer_ptr = 0;
return -2; // buffer overflow
}
if ((buffer_ptr > 0) || sof) if (status & PLB_LL_FIFO_STATUS_LL_EOF) {
{ len = (buffer_ptr << 2) - 3 +
if ( (buffer_len >> 2) > buffer_ptr) ((status & PLB_LL_FIFO_STATUS_LL_REM) >>
{ PLB_LL_FIFO_STATUS_LL_REM_SHIFT);
LOG(logDEBUG1, ("%.8X ", fifo_val)); LOG(logDEBUG1, ("Len: %d\n", len));
word_ptr[buffer_ptr++] = fifo_val; //write to buffer buffer_ptr = 0;
} return len;
else }
{ }
buffer_ptr = 0; }
return -2; // buffer overflow } while (!(status & PLB_LL_FIFO_STATUS_EMPTY));
}
if (status & PLB_LL_FIFO_STATUS_LL_EOF) return 0;
{
len = (buffer_ptr << 2) -3 + ( (status & PLB_LL_FIFO_STATUS_LL_REM)>>PLB_LL_FIFO_STATUS_LL_REM_SHIFT );
LOG(logDEBUG1, ("Len: %d\n",len));
buffer_ptr = 0;
return len;
}
}
}
}
while(!(status & PLB_LL_FIFO_STATUS_EMPTY));
return 0;
} }
int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val) { int Local_ctrl_reg_write_mask(struct LocalLinkInterface *ll, unsigned int mask,
ll->ll_fifo_ctrl_reg &= (~mask); unsigned int val) {
ll->ll_fifo_ctrl_reg |= ( mask & val); ll->ll_fifo_ctrl_reg &= (~mask);
HWIO_xfs_out32(ll->ll_fifo_base+4*PLB_LL_FIFO_REG_CTRL,ll->ll_fifo_ctrl_reg); ll->ll_fifo_ctrl_reg |= (mask & val);
return 1; HWIO_xfs_out32(ll->ll_fifo_base + 4 * PLB_LL_FIFO_REG_CTRL,
ll->ll_fifo_ctrl_reg);
return 1;
} }
int Local_Test(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer) {
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer) { int len;
unsigned int rec_buff_len = 4096;
unsigned int rec_buffer[4097];
int len; Local_Write(ll, buffer_len, buffer);
unsigned int rec_buff_len = 4096; usleep(10000);
unsigned int rec_buffer[4097];
do {
len = Local_Read(ll, rec_buff_len, rec_buffer);
LOG(logDEBUG1, ("receive length: %i\n", len));
Local_Write(ll,buffer_len,buffer); if (len > 0) {
usleep(10000); rec_buffer[len] = 0;
LOG(logINFO, ("%s\n", (char *)rec_buffer));
}
} while (len > 0);
do{ return 1;
len = Local_Read(ll,rec_buff_len,rec_buffer);
LOG(logDEBUG1, ("receive length: %i\n",len));
if (len > 0) {
rec_buffer[len]=0;
LOG(logINFO, ("%s\n", (char*) rec_buffer));
}
} while(len > 0);
return 1;
} }

View File

@ -2,20 +2,23 @@
#include "HardwareIO.h" #include "HardwareIO.h"
struct LocalLinkInterface {
struct LocalLinkInterface{ xfs_u32 ll_fifo_base;
xfs_u32 ll_fifo_base; unsigned int ll_fifo_ctrl_reg;
unsigned int ll_fifo_ctrl_reg;
}; };
int Local_Init(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr); int Local_Init(struct LocalLinkInterface *ll, unsigned int ll_fifo_badr);
int Local_Reset1(struct LocalLinkInterface* ll,unsigned int rst_mask); int Local_Reset1(struct LocalLinkInterface *ll, unsigned int rst_mask);
int Local_ctrl_reg_write_mask(struct LocalLinkInterface* ll,unsigned int mask, unsigned int val); int Local_ctrl_reg_write_mask(struct LocalLinkInterface *ll, unsigned int mask,
void Local_LocalLinkInterface1(struct LocalLinkInterface* ll,unsigned int ll_fifo_badr); unsigned int val);
unsigned int Local_StatusVector(struct LocalLinkInterface* ll); void Local_LocalLinkInterface1(struct LocalLinkInterface *ll,
int Local_Reset(struct LocalLinkInterface* ll); unsigned int ll_fifo_badr);
int Local_Write(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); unsigned int Local_StatusVector(struct LocalLinkInterface *ll);
int Local_Read(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); int Local_Reset(struct LocalLinkInterface *ll);
int Local_Test(struct LocalLinkInterface* ll,unsigned int buffer_len, void *buffer); int Local_Write(struct LocalLinkInterface *ll, unsigned int buffer_len,
void Local_LocalLinkInterface(struct LocalLinkInterface* ll); void *buffer);
int Local_Read(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer);
int Local_Test(struct LocalLinkInterface *ll, unsigned int buffer_len,
void *buffer);
void Local_LocalLinkInterface(struct LocalLinkInterface *ll);

File diff suppressed because it is too large Load Diff

View File

@ -1,96 +1,127 @@
#pragma once #pragma once
#include "sls_detector_defs.h" #include "sls_detector_defs.h"
#define REQUIRED_FIRMWARE_VERSION (24) #define REQUIRED_FIRMWARE_VERSION (24)
#define IDFILECOMMAND "more /home/root/executables/detid.txt" #define IDFILECOMMAND "more /home/root/executables/detid.txt"
#define FIRMWARE_VERSION_SAME_TOP_BOT_ADDR (26)
#define STATUS_IDLE 0 #define STATUS_IDLE 0
#define STATUS_RUNNING 1 #define STATUS_RUNNING 1
#define STATUS_ERROR 2 #define STATUS_ERROR 2
/* Enums */ /* Enums */
enum DACINDEX {E_SVP,E_VTR,E_VRF,E_VRS,E_SVN,E_VTGSTV,E_VCMP_LL,E_VCMP_LR,E_CAL,E_VCMP_RL,E_RXB_RB,E_RXB_LB,E_VCMP_RR,E_VCP,E_VCN,E_VIS,E_VTHRESHOLD}; enum DACINDEX {
#define DEFAULT_DAC_VALS { \ E_SVP,
0, /* SvP */ \ E_VTR,
2480, /* Vtr */ \ E_VRF,
3300, /* Vrf */ \ E_VRS,
1400, /* Vrs */ \ E_SVN,
4000, /* SvN */ \ E_VTGSTV,
2556, /* Vtgstv */ \ E_VCMP_LL,
1000, /* Vcmp_ll */ \ E_VCMP_LR,
1000, /* Vcmp_lr */ \ E_CAL,
0, /* cal */ \ E_VCMP_RL,
1000, /* Vcmp_rl */ \ E_RXB_RB,
1100, /* rxb_rb */ \ E_RXB_LB,
1100, /* rxb_lb */ \ E_VCMP_RR,
1000, /* Vcmp_rr */ \ E_VCP,
1000, /* Vcp */ \ E_VCN,
2000, /* Vcn */ \ E_VIS,
1550 /* Vis */ \ E_VTHRESHOLD
}; };
enum ADCINDEX {TEMP_FPGAEXT, TEMP_10GE, TEMP_DCDC, TEMP_SODL, TEMP_SODR, TEMP_FPGA, TEMP_FPGAFEBL, TEMP_FPGAFEBR}; #define DEFAULT_DAC_VALS \
enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G}; { \
enum ROINDEX {E_PARALLEL, E_NON_PARALLEL}; 0, /* SvP */ \
enum CLKINDEX {RUN_CLK, NUM_CLOCKS}; 2480, /* Vtr */ \
#define CLK_NAMES "run" 3300, /* Vrf */ \
1400, /* Vrs */ \
4000, /* SvN */ \
2556, /* Vtgstv */ \
1000, /* Vcmp_ll */ \
1000, /* Vcmp_lr */ \
0, /* cal */ \
1000, /* Vcmp_rl */ \
1100, /* rxb_rb */ \
1100, /* rxb_lb */ \
1000, /* Vcmp_rr */ \
1000, /* Vcp */ \
2000, /* Vcn */ \
1550 /* Vis */ \
};
enum ADCINDEX {
TEMP_FPGAEXT,
TEMP_10GE,
TEMP_DCDC,
TEMP_SODL,
TEMP_SODR,
TEMP_FPGA,
TEMP_FPGAFEBL,
TEMP_FPGAFEBR
};
enum NETWORKINDEX { TXN_LEFT, TXN_RIGHT, TXN_FRAME, FLOWCTRL_10G };
enum ROINDEX { E_PARALLEL, E_NON_PARALLEL };
enum CLKINDEX { RUN_CLK, NUM_CLOCKS };
#define CLK_NAMES "run"
/* Hardware Definitions */ /* Hardware Definitions */
#define NCHAN (256 * 256) #define NCHAN (256 * 256)
#define NCHIP (4) #define NCHIP (4)
#define NDAC (16) #define NDAC (16)
#define TEN_GIGA_BUFFER_SIZE (4112)
#define TEN_GIGA_BUFFER_SIZE (4112) #define ONE_GIGA_BUFFER_SIZE (1040)
#define ONE_GIGA_BUFFER_SIZE (1040) #define TEN_GIGA_CONSTANT (4)
#define TEN_GIGA_CONSTANT (4) #define ONE_GIGA_CONSTANT (16)
#define ONE_GIGA_CONSTANT (16) #define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input"
#define NORMAL_HIGHVOLTAGE_INPUTPORT "/sys/class/hwmon/hwmon5/device/in0_input" #define NORMAL_HIGHVOLTAGE_OUTPUTPORT \
#define NORMAL_HIGHVOLTAGE_OUTPUTPORT "/sys/class/hwmon/hwmon5/device/out0_output" "/sys/class/hwmon/hwmon5/device/out0_output"
#define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1" #define SPECIAL9M_HIGHVOLTAGE_PORT "/dev/ttyS1"
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE (16) #define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE (16)
#define DEFAULT_UDP_SOURCE_PORT (0xE185) #define DEFAULT_UDP_SOURCE_PORT (0xE185)
/** Default Parameters */ /** Default Parameters */
#define DEFAULT_NUM_FRAMES (1) #define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_STARTING_FRAME_NUMBER (1) #define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_NUM_CYCLES (1) #define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (1E9) //ns #define DEFAULT_EXPTIME (1E9) // ns
#define DEFAULT_PERIOD (1E9) //ns #define DEFAULT_PERIOD (1E9) // ns
#define DEFAULT_DELAY (0) #define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_SETTINGS (DYNAMICGAIN) #define DEFAULT_SETTINGS (DYNAMICGAIN)
#define DEFAULT_SUBFRAME_EXPOSURE (2621440) // 2.6ms #define DEFAULT_SUBFRAME_EXPOSURE (2621440) // 2.6ms
#define DEFAULT_SUBFRAME_DEADTIME (0) #define DEFAULT_SUBFRAME_DEADTIME (0)
#define DEFAULT_DYNAMIC_RANGE (16) #define DEFAULT_DYNAMIC_RANGE (16)
#define DEFAULT_PARALLEL_MODE (0) #define DEFAULT_PARALLEL_MODE (1)
#define DEFAULT_READOUT_STOREINRAM_MODE (0) #define DEFAULT_READOUT_STOREINRAM_MODE (0)
#define DEFAULT_READOUT_OVERFLOW32_MODE (0) #define DEFAULT_READOUT_OVERFLOW32_MODE (0)
#define DEFAULT_CLK_SPEED (HALF_SPEED) #define DEFAULT_CLK_SPEED (FULL_SPEED)
#define DEFAULT_IO_DELAY (650) #define DEFAULT_IO_DELAY (650)
#define DEFAULT_TIMING_MODE (AUTO_TIMING) #define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_PHOTON_ENERGY (-1) #define DEFAULT_PHOTON_ENERGY (-1)
#define DEFAULT_RATE_CORRECTION (0) #define DEFAULT_RATE_CORRECTION (0)
#define DEFAULT_EXT_GATING_ENABLE (0) #define DEFAULT_EXT_GATING_ENABLE (0)
#define DEFAULT_EXT_GATING_POLARITY (1) //positive #define DEFAULT_EXT_GATING_POLARITY (1) // positive
#define DEFAULT_TEST_MODE (0) #define DEFAULT_TEST_MODE (0)
#define DEFAULT_HIGH_VOLTAGE (0) #define DEFAULT_HIGH_VOLTAGE (0)
#define MAX_TRIMBITS_VALUE (63) #define MAX_TRIMBITS_VALUE (63)
#define MAX_ROWS_PER_READOUT (256) #define MAX_ROWS_PER_READOUT (256)
#define MAX_PACKETS_PER_REQUEST (256) #define MAX_PACKETS_PER_REQUEST (256)
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF) #define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
#define DAC_MIN_MV (0) #define DAC_MIN_MV (0)
#define DAC_MAX_MV (2048) #define DAC_MAX_MV (2048)
#define LTC2620_MIN_VAL (0) // including LTC defines instead of LTC262.h (includes bit banging and blackfin read and write) #define LTC2620_MIN_VAL \
#define LTC2620_MAX_VAL (4095) // 12 bits (0) // including LTC defines instead of LTC262.h (includes bit banging and
#define DAC_MAX_STEPS (4096) // blackfin read and write)
#define LTC2620_MAX_VAL (4095) // 12 bits
#define DAC_MAX_STEPS (4096)
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */ #define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS \
(0x1FFFFFFF) /** 29 bit register for max subframe exposure value */
#define SLAVE_HIGH_VOLTAGE_READ_VAL (-999)
#define HIGH_VOLTAGE_TOLERANCE (5)
#define SLAVE_HIGH_VOLTAGE_READ_VAL (-999)
#define HIGH_VOLTAGE_TOLERANCE (5)

50
slsDetectorServers/eigerDetectorServer/xfs_types.h Executable file → Normal file
View File

@ -14,35 +14,29 @@ typedef signed int xfs_i32;
typedef signed short xfs_i16; typedef signed short xfs_i16;
typedef signed char xfs_i8; typedef signed char xfs_i8;
// UDP Header // UDP Header
struct udp_header_type struct udp_header_type {
{ // ethternet frame (14 byte)
// ethternet frame (14 byte) uint8_t dst_mac[6];
uint8_t dst_mac[6]; uint8_t src_mac[6];
uint8_t src_mac[6]; uint8_t len_type[2];
uint8_t len_type[2];
// ip header (20 byte)
uint8_t ver_headerlen[1];
uint8_t service_type[1];
uint8_t total_length[2];
uint8_t identification[2];
uint8_t flags[1];
uint8_t frag_offset[1];
uint8_t time_to_live[1];
uint8_t protocol[1];
uint8_t ip_header_checksum[2];
uint8_t src_ip[4];
uint8_t dst_ip[4];
// udp header (8 byte) // ip header (20 byte)
uint8_t src_port[2]; uint8_t ver_headerlen[1];
uint8_t dst_port[2]; uint8_t service_type[1];
uint8_t udp_message_len[2]; uint8_t total_length[2];
uint8_t udp_checksum[2]; uint8_t identification[2];
uint8_t flags[1];
uint8_t frag_offset[1];
uint8_t time_to_live[1];
uint8_t protocol[1];
uint8_t ip_header_checksum[2];
uint8_t src_ip[4];
uint8_t dst_ip[4];
// udp header (8 byte)
uint8_t src_port[2];
uint8_t dst_port[2];
uint8_t udp_message_len[2];
uint8_t udp_checksum[2];
}; };

572
slsDetectorServers/eigerDetectorServer/xparameters.h Executable file → Normal file
View File

@ -1,4 +1,5 @@
/* ONLY THOSE ARE USED IN THIS SOFTWARE. If one of those is modified in xilinx compilation, this file should be replaced with updated values /* ONLY THOSE ARE USED IN THIS SOFTWARE. If one of those is modified in xilinx
compilation, this file should be replaced with updated values
XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR
XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR
@ -14,37 +15,32 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
* *
* Copyright (c) 1995-2010 Xilinx, Inc. All rights reserved. * Copyright (c) 1995-2010 Xilinx, Inc. All rights reserved.
* *
* Description: Driver parameters * Description: Driver parameters
* *
*******************************************************************/ *******************************************************************/
#define STDIN_BASEADDRESS 0xC0000000 #define STDIN_BASEADDRESS 0xC0000000
#define STDOUT_BASEADDRESS 0xC0000000 #define STDOUT_BASEADDRESS 0xC0000000
/******************************************************************/ /******************************************************************/
/* Definitions for peripheral BB_IO_SHIFT_REG_PPC440 */ /* Definitions for peripheral BB_IO_SHIFT_REG_PPC440 */
#define XPAR_BB_IO_SHIFT_REG_PPC440_BASEADDR 0xD3000000 #define XPAR_BB_IO_SHIFT_REG_PPC440_BASEADDR 0xD3000000
#define XPAR_BB_IO_SHIFT_REG_PPC440_HIGHADDR 0xD300FFFF #define XPAR_BB_IO_SHIFT_REG_PPC440_HIGHADDR 0xD300FFFF
/* Definitions for peripheral EIGER_BEB_SYNCH_IO_PPC440 */ /* Definitions for peripheral EIGER_BEB_SYNCH_IO_PPC440 */
#define XPAR_EIGER_BEB_SYNCH_IO_PPC440_BASEADDR 0xD3100000 #define XPAR_EIGER_BEB_SYNCH_IO_PPC440_BASEADDR 0xD3100000
#define XPAR_EIGER_BEB_SYNCH_IO_PPC440_HIGHADDR 0xD310FFFF #define XPAR_EIGER_BEB_SYNCH_IO_PPC440_HIGHADDR 0xD310FFFF
/* Definitions for peripheral PLB_BRAM_10G */ /* Definitions for peripheral PLB_BRAM_10G */
#define XPAR_PLB_BRAM_10G_MEM0_BASEADDR 0xD4100000 #define XPAR_PLB_BRAM_10G_MEM0_BASEADDR 0xD4100000
#define XPAR_PLB_BRAM_10G_MEM0_HIGHADDR 0xD410FFFF #define XPAR_PLB_BRAM_10G_MEM0_HIGHADDR 0xD410FFFF
/* Definitions for peripheral PLB_BRAM_TEMAC */ /* Definitions for peripheral PLB_BRAM_TEMAC */
#define XPAR_PLB_BRAM_TEMAC_MEM0_BASEADDR 0xD4000000 #define XPAR_PLB_BRAM_TEMAC_MEM0_BASEADDR 0xD4000000
#define XPAR_PLB_BRAM_TEMAC_MEM0_HIGHADDR 0xD400FFFF #define XPAR_PLB_BRAM_TEMAC_MEM0_HIGHADDR 0xD400FFFF
/* Definitions for peripheral PLB_GPIO_SYS */ /* Definitions for peripheral PLB_GPIO_SYS */
#define XPAR_PLB_GPIO_SYS_BASEADDR 0xD1000000 #define XPAR_PLB_GPIO_SYS_BASEADDR 0xD1000000
#define XPAR_PLB_GPIO_SYS_HIGHADDR 0xD100FFFF #define XPAR_PLB_GPIO_SYS_HIGHADDR 0xD100FFFF
@ -52,38 +48,30 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
/** Command Generator */ /** Command Generator */
#define XPAR_CMD_GENERATOR 0xC5000000 #define XPAR_CMD_GENERATOR 0xC5000000
/** Version Numbers */ /** Version Numbers */
#define XPAR_VERSION 0xc6000000 #define XPAR_VERSION 0xc6000000
/* Definitions for peripheral PLB_GPIO_TEST */ /* Definitions for peripheral PLB_GPIO_TEST */
#define XPAR_PLB_GPIO_TEST_BASEADDR 0xD1010000 #define XPAR_PLB_GPIO_TEST_BASEADDR 0xD1010000
#define XPAR_PLB_GPIO_TEST_HIGHADDR 0xD101FFFF #define XPAR_PLB_GPIO_TEST_HIGHADDR 0xD101FFFF
// udp header (set frame number) // udp header (set frame number)
#define UDP_HEADER_FRAME_NUMBER_LSB_OFST (0x0140) #define UDP_HEADER_FRAME_NUMBER_LSB_OFST (0x0140)
#define UDP_HEADER_FRAME_NUMBER_MSB_OFST (0x0160) #define UDP_HEADER_FRAME_NUMBER_MSB_OFST (0x0160)
/* Definitions for packet, frame and delay down counters */ /* Definitions for packet, frame and delay down counters */
#define XPAR_COUNTER_BASEADDR 0xD1020000 #define XPAR_COUNTER_BASEADDR 0xD1020000
#define XPAR_COUNTER_HIGHADDR 0xD102FFFF #define XPAR_COUNTER_HIGHADDR 0xD102FFFF
// udp header (get frame number) // udp header (get frame number)
#define UDP_HEADER_GET_FNUM_1G_LEFT_LSB_OFST (0x0004) #define UDP_HEADER_GET_FNUM_1G_LEFT_LSB_OFST (0x0004)
#define UDP_HEADER_GET_FNUM_1G_LEFT_MSB_OFST (0x0024) #define UDP_HEADER_GET_FNUM_1G_LEFT_MSB_OFST (0x0024)
#define UDP_HEADER_GET_FNUM_1G_RIGHT_LSB_OFST (0x0044) #define UDP_HEADER_GET_FNUM_1G_RIGHT_LSB_OFST (0x0044)
#define UDP_HEADER_GET_FNUM_1G_RIGHT_MSB_OFST (0x0064) #define UDP_HEADER_GET_FNUM_1G_RIGHT_MSB_OFST (0x0064)
#define UDP_HEADER_GET_FNUM_10G_LEFT_LSB_OFST (0x0084) #define UDP_HEADER_GET_FNUM_10G_LEFT_LSB_OFST (0x0084)
#define UDP_HEADER_GET_FNUM_10G_LEFT_MSB_OFST (0x00A4) #define UDP_HEADER_GET_FNUM_10G_LEFT_MSB_OFST (0x00A4)
#define UDP_HEADER_GET_FNUM_10G_RIGHT_LSB_OFST (0x00C4) #define UDP_HEADER_GET_FNUM_10G_RIGHT_LSB_OFST (0x00C4)
#define UDP_HEADER_GET_FNUM_10G_RIGHT_MSB_OFST (0x00E4) #define UDP_HEADER_GET_FNUM_10G_RIGHT_MSB_OFST (0x00E4)
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT */ /* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT */
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR 0xC4100000 #define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR 0xC4100000
@ -92,46 +80,37 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
/* Definitions for a new memory */ /* Definitions for a new memory */
//#define XPAR_PLB_LL_NEW_MEMORY 0xD1000000//0xD1000084//0xC4200000 //#define XPAR_PLB_LL_NEW_MEMORY 0xD1000000//0xD1000084//0xC4200000
/* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT */ /* Definitions for peripheral PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT */
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR 0xC4110000 #define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_BASEADDR 0xC4110000
#define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_HIGHADDR 0xC411FFFF #define XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_RIGHT_HIGHADDR 0xC411FFFF
/* Definitions for peripheral PLB_LL_FIFO_AURORA_RX4_TX1_LEFT */ /* Definitions for peripheral PLB_LL_FIFO_AURORA_RX4_TX1_LEFT */
#define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR 0xC4120000 #define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_BASEADDR 0xC4120000
#define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_HIGHADDR 0xC412FFFF #define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_LEFT_HIGHADDR 0xC412FFFF
/* Definitions for peripheral PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT */ /* Definitions for peripheral PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT */
#define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR 0xC4130000 #define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_BASEADDR 0xC4130000
#define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_HIGHADDR 0xC413FFFF #define XPAR_PLB_LL_FIFO_AURORA_RX4_TX1_RIGHT_HIGHADDR 0xC413FFFF
/* Definitions for peripheral PLB_LL_FIFO_XAUI_10G */ /* Definitions for peripheral PLB_LL_FIFO_XAUI_10G */
#define XPAR_PLB_LL_FIFO_XAUI_10G_BASEADDR 0xC4140000 #define XPAR_PLB_LL_FIFO_XAUI_10G_BASEADDR 0xC4140000
#define XPAR_PLB_LL_FIFO_XAUI_10G_HIGHADDR 0xC414FFFF #define XPAR_PLB_LL_FIFO_XAUI_10G_HIGHADDR 0xC414FFFF
/* Definitions for peripheral PLB_V46_CPU_TO_PLB_V46_BRIDGED */ /* Definitions for peripheral PLB_V46_CPU_TO_PLB_V46_BRIDGED */
#define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_BRIDGE_BASEADDR 0xCFFF0000 #define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_BRIDGE_BASEADDR 0xCFFF0000
#define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_BRIDGE_HIGHADDR 0xCFFFFFFF #define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_BRIDGE_HIGHADDR 0xCFFFFFFF
#define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_RNG0_BASEADDR 0xD0000000 #define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_RNG0_BASEADDR 0xD0000000
#define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_RNG0_HIGHADDR 0xDFFFFFFF #define XPAR_PLB_V46_CPU_TO_PLB_V46_BRIDGED_RNG0_HIGHADDR 0xDFFFFFFF
/* Definitions for peripheral PPC_SRAM */ /* Definitions for peripheral PPC_SRAM */
#define XPAR_PPC_SRAM_BASEADDR 0x00000000 #define XPAR_PPC_SRAM_BASEADDR 0x00000000
#define XPAR_PPC_SRAM_HIGHADDR 0x01FFFFFF #define XPAR_PPC_SRAM_HIGHADDR 0x01FFFFFF
/******************************************************************/ /******************************************************************/
/* Definitions for peripheral PFLASH */ /* Definitions for peripheral PFLASH */
#define XPAR_PFLASH_NUM_BANKS_MEM 1 #define XPAR_PFLASH_NUM_BANKS_MEM 1
/******************************************************************/ /******************************************************************/
/* Definitions for peripheral PFLASH */ /* Definitions for peripheral PFLASH */
@ -152,15 +131,13 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
/* Definitions for peripheral PLB_SHT1X_IF_CH1 */ /* Definitions for peripheral PLB_SHT1X_IF_CH1 */
#define XPAR_PLB_SHT1X_IF_CH1_DEVICE_ID 0 #define XPAR_PLB_SHT1X_IF_CH1_DEVICE_ID 0
#define XPAR_PLB_SHT1X_IF_CH1_BASEADDR 0xD2200000 #define XPAR_PLB_SHT1X_IF_CH1_BASEADDR 0xD2200000
#define XPAR_PLB_SHT1X_IF_CH1_HIGHADDR 0xD220FFFF #define XPAR_PLB_SHT1X_IF_CH1_HIGHADDR 0xD220FFFF
/* Definitions for peripheral PLB_SHT1X_IF_CH2 */ /* Definitions for peripheral PLB_SHT1X_IF_CH2 */
#define XPAR_PLB_SHT1X_IF_CH2_DEVICE_ID 1 #define XPAR_PLB_SHT1X_IF_CH2_DEVICE_ID 1
#define XPAR_PLB_SHT1X_IF_CH2_BASEADDR 0xD2210000 #define XPAR_PLB_SHT1X_IF_CH2_BASEADDR 0xD2210000
#define XPAR_PLB_SHT1X_IF_CH2_HIGHADDR 0xD221FFFF #define XPAR_PLB_SHT1X_IF_CH2_HIGHADDR 0xD221FFFF
/******************************************************************/ /******************************************************************/
@ -168,28 +145,25 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
#define XPAR_XUARTLITE_NUM_INSTANCES 1 #define XPAR_XUARTLITE_NUM_INSTANCES 1
/* Definitions for peripheral RS232 */ /* Definitions for peripheral RS232 */
#define XPAR_RS232_BASEADDR 0xC0000000 #define XPAR_RS232_BASEADDR 0xC0000000
#define XPAR_RS232_HIGHADDR 0xC000FFFF #define XPAR_RS232_HIGHADDR 0xC000FFFF
#define XPAR_RS232_DEVICE_ID 0 #define XPAR_RS232_DEVICE_ID 0
#define XPAR_RS232_BAUDRATE 115200 #define XPAR_RS232_BAUDRATE 115200
#define XPAR_RS232_USE_PARITY 0 #define XPAR_RS232_USE_PARITY 0
#define XPAR_RS232_ODD_PARITY 0 #define XPAR_RS232_ODD_PARITY 0
#define XPAR_RS232_DATA_BITS 8 #define XPAR_RS232_DATA_BITS 8
/******************************************************************/ /******************************************************************/
/* Canonical definitions for peripheral RS232 */ /* Canonical definitions for peripheral RS232 */
#define XPAR_UARTLITE_0_DEVICE_ID XPAR_RS232_DEVICE_ID #define XPAR_UARTLITE_0_DEVICE_ID XPAR_RS232_DEVICE_ID
#define XPAR_UARTLITE_0_BASEADDR 0xC0000000 #define XPAR_UARTLITE_0_BASEADDR 0xC0000000
#define XPAR_UARTLITE_0_HIGHADDR 0xC000FFFF #define XPAR_UARTLITE_0_HIGHADDR 0xC000FFFF
#define XPAR_UARTLITE_0_BAUDRATE 115200 #define XPAR_UARTLITE_0_BAUDRATE 115200
#define XPAR_UARTLITE_0_USE_PARITY 0 #define XPAR_UARTLITE_0_USE_PARITY 0
#define XPAR_UARTLITE_0_ODD_PARITY 0 #define XPAR_UARTLITE_0_ODD_PARITY 0
#define XPAR_UARTLITE_0_DATA_BITS 8 #define XPAR_UARTLITE_0_DATA_BITS 8
#define XPAR_UARTLITE_0_SIO_CHAN 1 #define XPAR_UARTLITE_0_SIO_CHAN 1
/******************************************************************/ /******************************************************************/
@ -197,144 +171,137 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
#define XPAR_XSPI_NUM_INSTANCES 2 #define XPAR_XSPI_NUM_INSTANCES 2
/* Definitions for peripheral SPI_FLASH */ /* Definitions for peripheral SPI_FLASH */
#define XPAR_SPI_FLASH_DEVICE_ID 0 #define XPAR_SPI_FLASH_DEVICE_ID 0
#define XPAR_SPI_FLASH_BASEADDR 0xD2000000 #define XPAR_SPI_FLASH_BASEADDR 0xD2000000
#define XPAR_SPI_FLASH_HIGHADDR 0xD200FFFF #define XPAR_SPI_FLASH_HIGHADDR 0xD200FFFF
#define XPAR_SPI_FLASH_FIFO_EXIST 1 #define XPAR_SPI_FLASH_FIFO_EXIST 1
#define XPAR_SPI_FLASH_SPI_SLAVE_ONLY 0 #define XPAR_SPI_FLASH_SPI_SLAVE_ONLY 0
#define XPAR_SPI_FLASH_NUM_SS_BITS 1 #define XPAR_SPI_FLASH_NUM_SS_BITS 1
#define XPAR_SPI_FLASH_NUM_TRANSFER_BITS 8 #define XPAR_SPI_FLASH_NUM_TRANSFER_BITS 8
/* Definitions for peripheral XPS_SPI_FEB_CFG */ /* Definitions for peripheral XPS_SPI_FEB_CFG */
#define XPAR_XPS_SPI_FEB_CFG_DEVICE_ID 1 #define XPAR_XPS_SPI_FEB_CFG_DEVICE_ID 1
#define XPAR_XPS_SPI_FEB_CFG_BASEADDR 0xD2010000 #define XPAR_XPS_SPI_FEB_CFG_BASEADDR 0xD2010000
#define XPAR_XPS_SPI_FEB_CFG_HIGHADDR 0xD201FFFF #define XPAR_XPS_SPI_FEB_CFG_HIGHADDR 0xD201FFFF
#define XPAR_XPS_SPI_FEB_CFG_FIFO_EXIST 1 #define XPAR_XPS_SPI_FEB_CFG_FIFO_EXIST 1
#define XPAR_XPS_SPI_FEB_CFG_SPI_SLAVE_ONLY 0 #define XPAR_XPS_SPI_FEB_CFG_SPI_SLAVE_ONLY 0
#define XPAR_XPS_SPI_FEB_CFG_NUM_SS_BITS 2 #define XPAR_XPS_SPI_FEB_CFG_NUM_SS_BITS 2
#define XPAR_XPS_SPI_FEB_CFG_NUM_TRANSFER_BITS 8 #define XPAR_XPS_SPI_FEB_CFG_NUM_TRANSFER_BITS 8
/******************************************************************/ /******************************************************************/
/* Canonical definitions for peripheral SPI_FLASH */ /* Canonical definitions for peripheral SPI_FLASH */
#define XPAR_SPI_0_DEVICE_ID XPAR_SPI_FLASH_DEVICE_ID #define XPAR_SPI_0_DEVICE_ID XPAR_SPI_FLASH_DEVICE_ID
#define XPAR_SPI_0_BASEADDR 0xD2000000 #define XPAR_SPI_0_BASEADDR 0xD2000000
#define XPAR_SPI_0_HIGHADDR 0xD200FFFF #define XPAR_SPI_0_HIGHADDR 0xD200FFFF
#define XPAR_SPI_0_FIFO_EXIST 1 #define XPAR_SPI_0_FIFO_EXIST 1
#define XPAR_SPI_0_SPI_SLAVE_ONLY 0 #define XPAR_SPI_0_SPI_SLAVE_ONLY 0
#define XPAR_SPI_0_NUM_SS_BITS 1 #define XPAR_SPI_0_NUM_SS_BITS 1
#define XPAR_SPI_0_NUM_TRANSFER_BITS 8 #define XPAR_SPI_0_NUM_TRANSFER_BITS 8
/* Canonical definitions for peripheral XPS_SPI_FEB_CFG */ /* Canonical definitions for peripheral XPS_SPI_FEB_CFG */
#define XPAR_SPI_1_DEVICE_ID XPAR_XPS_SPI_FEB_CFG_DEVICE_ID #define XPAR_SPI_1_DEVICE_ID XPAR_XPS_SPI_FEB_CFG_DEVICE_ID
#define XPAR_SPI_1_BASEADDR 0xD2010000 #define XPAR_SPI_1_BASEADDR 0xD2010000
#define XPAR_SPI_1_HIGHADDR 0xD201FFFF #define XPAR_SPI_1_HIGHADDR 0xD201FFFF
#define XPAR_SPI_1_FIFO_EXIST 1 #define XPAR_SPI_1_FIFO_EXIST 1
#define XPAR_SPI_1_SPI_SLAVE_ONLY 0 #define XPAR_SPI_1_SPI_SLAVE_ONLY 0
#define XPAR_SPI_1_NUM_SS_BITS 2 #define XPAR_SPI_1_NUM_SS_BITS 2
#define XPAR_SPI_1_NUM_TRANSFER_BITS 8 #define XPAR_SPI_1_NUM_TRANSFER_BITS 8
/******************************************************************/ /******************************************************************/
/* Definitions for driver LLTEMAC */ /* Definitions for driver LLTEMAC */
#define XPAR_XLLTEMAC_NUM_INSTANCES 1 #define XPAR_XLLTEMAC_NUM_INSTANCES 1
/* Definitions for peripheral TEMAC_INST Channel 0 */ /* Definitions for peripheral TEMAC_INST Channel 0 */
#define XPAR_TEMAC_INST_CHAN_0_DEVICE_ID 0 #define XPAR_TEMAC_INST_CHAN_0_DEVICE_ID 0
#define XPAR_TEMAC_INST_CHAN_0_BASEADDR 0xC3000000 #define XPAR_TEMAC_INST_CHAN_0_BASEADDR 0xC3000000
#define XPAR_TEMAC_INST_CHAN_0_HIGHADDR 0xC30FFFFF #define XPAR_TEMAC_INST_CHAN_0_HIGHADDR 0xC30FFFFF
#define XPAR_TEMAC_INST_CHAN_0_TXCSUM 0 #define XPAR_TEMAC_INST_CHAN_0_TXCSUM 0
#define XPAR_TEMAC_INST_CHAN_0_RXCSUM 0 #define XPAR_TEMAC_INST_CHAN_0_RXCSUM 0
#define XPAR_TEMAC_INST_CHAN_0_PHY_TYPE 4 #define XPAR_TEMAC_INST_CHAN_0_PHY_TYPE 4
#define XPAR_TEMAC_INST_CHAN_0_TXVLAN_TRAN 0 #define XPAR_TEMAC_INST_CHAN_0_TXVLAN_TRAN 0
#define XPAR_TEMAC_INST_CHAN_0_RXVLAN_TRAN 0 #define XPAR_TEMAC_INST_CHAN_0_RXVLAN_TRAN 0
#define XPAR_TEMAC_INST_CHAN_0_TXVLAN_TAG 0 #define XPAR_TEMAC_INST_CHAN_0_TXVLAN_TAG 0
#define XPAR_TEMAC_INST_CHAN_0_RXVLAN_TAG 0 #define XPAR_TEMAC_INST_CHAN_0_RXVLAN_TAG 0
#define XPAR_TEMAC_INST_CHAN_0_TXVLAN_STRP 0 #define XPAR_TEMAC_INST_CHAN_0_TXVLAN_STRP 0
#define XPAR_TEMAC_INST_CHAN_0_RXVLAN_STRP 0 #define XPAR_TEMAC_INST_CHAN_0_RXVLAN_STRP 0
#define XPAR_TEMAC_INST_CHAN_0_MCAST_EXTEND 0 #define XPAR_TEMAC_INST_CHAN_0_MCAST_EXTEND 0
/* Canonical definitions for peripheral TEMAC_INST Channel 0 */ /* Canonical definitions for peripheral TEMAC_INST Channel 0 */
#define XPAR_LLTEMAC_0_DEVICE_ID 0 #define XPAR_LLTEMAC_0_DEVICE_ID 0
#define XPAR_LLTEMAC_0_BASEADDR 0xC3000000 #define XPAR_LLTEMAC_0_BASEADDR 0xC3000000
#define XPAR_LLTEMAC_0_HIGHADDR 0xC30FFFFF #define XPAR_LLTEMAC_0_HIGHADDR 0xC30FFFFF
#define XPAR_LLTEMAC_0_TXCSUM 0 #define XPAR_LLTEMAC_0_TXCSUM 0
#define XPAR_LLTEMAC_0_RXCSUM 0 #define XPAR_LLTEMAC_0_RXCSUM 0
#define XPAR_LLTEMAC_0_PHY_TYPE 4 #define XPAR_LLTEMAC_0_PHY_TYPE 4
#define XPAR_LLTEMAC_0_TXVLAN_TRAN 0 #define XPAR_LLTEMAC_0_TXVLAN_TRAN 0
#define XPAR_LLTEMAC_0_RXVLAN_TRAN 0 #define XPAR_LLTEMAC_0_RXVLAN_TRAN 0
#define XPAR_LLTEMAC_0_TXVLAN_TAG 0 #define XPAR_LLTEMAC_0_TXVLAN_TAG 0
#define XPAR_LLTEMAC_0_RXVLAN_TAG 0 #define XPAR_LLTEMAC_0_RXVLAN_TAG 0
#define XPAR_LLTEMAC_0_TXVLAN_STRP 0 #define XPAR_LLTEMAC_0_TXVLAN_STRP 0
#define XPAR_LLTEMAC_0_RXVLAN_STRP 0 #define XPAR_LLTEMAC_0_RXVLAN_STRP 0
#define XPAR_LLTEMAC_0_MCAST_EXTEND 0 #define XPAR_LLTEMAC_0_MCAST_EXTEND 0
#define XPAR_LLTEMAC_0_INTR 1 #define XPAR_LLTEMAC_0_INTR 1
/* LocalLink TYPE Enumerations */ /* LocalLink TYPE Enumerations */
#define XPAR_LL_FIFO 1 #define XPAR_LL_FIFO 1
#define XPAR_LL_DMA 2 #define XPAR_LL_DMA 2
/* Canonical LocalLink parameters for TEMAC_INST */ /* Canonical LocalLink parameters for TEMAC_INST */
/******************************************************************/ /******************************************************************/
/* Definitions for peripheral XPS_BRAM_IF_CNTLR_PPC440 */ /* Definitions for peripheral XPS_BRAM_IF_CNTLR_PPC440 */
#define XPAR_XPS_BRAM_IF_CNTLR_PPC440_BASEADDR 0xFFFC0000 #define XPAR_XPS_BRAM_IF_CNTLR_PPC440_BASEADDR 0xFFFC0000
#define XPAR_XPS_BRAM_IF_CNTLR_PPC440_HIGHADDR 0xFFFFFFFF #define XPAR_XPS_BRAM_IF_CNTLR_PPC440_HIGHADDR 0xFFFFFFFF
/******************************************************************/ /******************************************************************/
#define XPAR_INTC_MAX_NUM_INTR_INPUTS 5 #define XPAR_INTC_MAX_NUM_INTR_INPUTS 5
#define XPAR_XINTC_HAS_IPR 1 #define XPAR_XINTC_HAS_IPR 1
#define XPAR_XINTC_USE_DCR 0 #define XPAR_XINTC_USE_DCR 0
/* Definitions for driver INTC */ /* Definitions for driver INTC */
#define XPAR_XINTC_NUM_INSTANCES 1 #define XPAR_XINTC_NUM_INSTANCES 1
/* Definitions for peripheral XPS_INTC_PPC440 */ /* Definitions for peripheral XPS_INTC_PPC440 */
#define XPAR_XPS_INTC_PPC440_DEVICE_ID 0 #define XPAR_XPS_INTC_PPC440_DEVICE_ID 0
#define XPAR_XPS_INTC_PPC440_BASEADDR 0xC1000000 #define XPAR_XPS_INTC_PPC440_BASEADDR 0xC1000000
#define XPAR_XPS_INTC_PPC440_HIGHADDR 0xC100FFFF #define XPAR_XPS_INTC_PPC440_HIGHADDR 0xC100FFFF
#define XPAR_XPS_INTC_PPC440_KIND_OF_INTR 0xFFFFFFF4 #define XPAR_XPS_INTC_PPC440_KIND_OF_INTR 0xFFFFFFF4
/******************************************************************/ /******************************************************************/
#define XPAR_INTC_SINGLE_BASEADDR 0xC1000000 #define XPAR_INTC_SINGLE_BASEADDR 0xC1000000
#define XPAR_INTC_SINGLE_HIGHADDR 0xC100FFFF #define XPAR_INTC_SINGLE_HIGHADDR 0xC100FFFF
#define XPAR_INTC_SINGLE_DEVICE_ID XPAR_XPS_INTC_PPC440_DEVICE_ID #define XPAR_INTC_SINGLE_DEVICE_ID XPAR_XPS_INTC_PPC440_DEVICE_ID
#define XPAR_XPS_LL_FIFO_TEMAC_IP2INTC_IRPT_MASK 0X000001 #define XPAR_XPS_LL_FIFO_TEMAC_IP2INTC_IRPT_MASK 0X000001
#define XPAR_XPS_INTC_PPC440_XPS_LL_FIFO_TEMAC_IP2INTC_IRPT_INTR 0 #define XPAR_XPS_INTC_PPC440_XPS_LL_FIFO_TEMAC_IP2INTC_IRPT_INTR 0
#define XPAR_TEMAC_INST_TEMACINTC0_IRPT_MASK 0X000002 #define XPAR_TEMAC_INST_TEMACINTC0_IRPT_MASK 0X000002
#define XPAR_XPS_INTC_PPC440_TEMAC_INST_TEMACINTC0_IRPT_INTR 1 #define XPAR_XPS_INTC_PPC440_TEMAC_INST_TEMACINTC0_IRPT_INTR 1
#define XPAR_XPS_TIMER_PPC440_INTERRUPT_MASK 0X000004 #define XPAR_XPS_TIMER_PPC440_INTERRUPT_MASK 0X000004
#define XPAR_XPS_INTC_PPC440_XPS_TIMER_PPC440_INTERRUPT_INTR 2 #define XPAR_XPS_INTC_PPC440_XPS_TIMER_PPC440_INTERRUPT_INTR 2
#define XPAR_SPI_FLASH_IP2INTC_IRPT_MASK 0X000008 #define XPAR_SPI_FLASH_IP2INTC_IRPT_MASK 0X000008
#define XPAR_XPS_INTC_PPC440_SPI_FLASH_IP2INTC_IRPT_INTR 3 #define XPAR_XPS_INTC_PPC440_SPI_FLASH_IP2INTC_IRPT_INTR 3
#define XPAR_RS232_INTERRUPT_MASK 0X000010 #define XPAR_RS232_INTERRUPT_MASK 0X000010
#define XPAR_XPS_INTC_PPC440_RS232_INTERRUPT_INTR 4 #define XPAR_XPS_INTC_PPC440_RS232_INTERRUPT_INTR 4
/******************************************************************/ /******************************************************************/
/* Canonical definitions for peripheral XPS_INTC_PPC440 */ /* Canonical definitions for peripheral XPS_INTC_PPC440 */
#define XPAR_INTC_0_DEVICE_ID XPAR_XPS_INTC_PPC440_DEVICE_ID #define XPAR_INTC_0_DEVICE_ID XPAR_XPS_INTC_PPC440_DEVICE_ID
#define XPAR_INTC_0_BASEADDR 0xC1000000 #define XPAR_INTC_0_BASEADDR 0xC1000000
#define XPAR_INTC_0_HIGHADDR 0xC100FFFF #define XPAR_INTC_0_HIGHADDR 0xC100FFFF
#define XPAR_INTC_0_KIND_OF_INTR 0xFFFFFFF4 #define XPAR_INTC_0_KIND_OF_INTR 0xFFFFFFF4
#define XPAR_INTC_0_LLFIFO_0_VEC_ID XPAR_XPS_INTC_PPC440_XPS_LL_FIFO_TEMAC_IP2INTC_IRPT_INTR #define XPAR_INTC_0_LLFIFO_0_VEC_ID \
#define XPAR_INTC_0_LLTEMAC_0_VEC_ID XPAR_XPS_INTC_PPC440_TEMAC_INST_TEMACINTC0_IRPT_INTR XPAR_XPS_INTC_PPC440_XPS_LL_FIFO_TEMAC_IP2INTC_IRPT_INTR
#define XPAR_INTC_0_TMRCTR_0_VEC_ID XPAR_XPS_INTC_PPC440_XPS_TIMER_PPC440_INTERRUPT_INTR #define XPAR_INTC_0_LLTEMAC_0_VEC_ID \
#define XPAR_INTC_0_SPI_0_VEC_ID XPAR_XPS_INTC_PPC440_SPI_FLASH_IP2INTC_IRPT_INTR XPAR_XPS_INTC_PPC440_TEMAC_INST_TEMACINTC0_IRPT_INTR
#define XPAR_INTC_0_TMRCTR_0_VEC_ID \
XPAR_XPS_INTC_PPC440_XPS_TIMER_PPC440_INTERRUPT_INTR
#define XPAR_INTC_0_SPI_0_VEC_ID \
XPAR_XPS_INTC_PPC440_SPI_FLASH_IP2INTC_IRPT_INTR
#define XPAR_INTC_0_UARTLITE_0_VEC_ID XPAR_XPS_INTC_PPC440_RS232_INTERRUPT_INTR #define XPAR_INTC_0_UARTLITE_0_VEC_ID XPAR_XPS_INTC_PPC440_RS232_INTERRUPT_INTR
/******************************************************************/ /******************************************************************/
@ -344,17 +311,15 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
/* Definitions for peripheral XPS_LL_FIFO_TEMAC */ /* Definitions for peripheral XPS_LL_FIFO_TEMAC */
#define XPAR_XPS_LL_FIFO_TEMAC_DEVICE_ID 0 #define XPAR_XPS_LL_FIFO_TEMAC_DEVICE_ID 0
#define XPAR_XPS_LL_FIFO_TEMAC_BASEADDR 0xC4000000 #define XPAR_XPS_LL_FIFO_TEMAC_BASEADDR 0xC4000000
#define XPAR_XPS_LL_FIFO_TEMAC_HIGHADDR 0xC400FFFF #define XPAR_XPS_LL_FIFO_TEMAC_HIGHADDR 0xC400FFFF
/******************************************************************/ /******************************************************************/
/* Canonical definitions for peripheral XPS_LL_FIFO_TEMAC */ /* Canonical definitions for peripheral XPS_LL_FIFO_TEMAC */
#define XPAR_LLFIFO_0_DEVICE_ID XPAR_XPS_LL_FIFO_TEMAC_DEVICE_ID #define XPAR_LLFIFO_0_DEVICE_ID XPAR_XPS_LL_FIFO_TEMAC_DEVICE_ID
#define XPAR_LLFIFO_0_BASEADDR 0xC4000000 #define XPAR_LLFIFO_0_BASEADDR 0xC4000000
#define XPAR_LLFIFO_0_HIGHADDR 0xC400FFFF #define XPAR_LLFIFO_0_HIGHADDR 0xC400FFFF
/******************************************************************/ /******************************************************************/
@ -362,22 +327,19 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
#define XPAR_XSYSMON_NUM_INSTANCES 1 #define XPAR_XSYSMON_NUM_INSTANCES 1
/* Definitions for peripheral XPS_SYSMON_ADC_PPC440 */ /* Definitions for peripheral XPS_SYSMON_ADC_PPC440 */
#define XPAR_XPS_SYSMON_ADC_PPC440_DEVICE_ID 0 #define XPAR_XPS_SYSMON_ADC_PPC440_DEVICE_ID 0
#define XPAR_XPS_SYSMON_ADC_PPC440_BASEADDR 0xD0010000 #define XPAR_XPS_SYSMON_ADC_PPC440_BASEADDR 0xD0010000
#define XPAR_XPS_SYSMON_ADC_PPC440_HIGHADDR 0xD001FFFF #define XPAR_XPS_SYSMON_ADC_PPC440_HIGHADDR 0xD001FFFF
#define XPAR_XPS_SYSMON_ADC_PPC440_INCLUDE_INTR 1 #define XPAR_XPS_SYSMON_ADC_PPC440_INCLUDE_INTR 1
/******************************************************************/ /******************************************************************/
/* Canonical definitions for peripheral XPS_SYSMON_ADC_PPC440 */ /* Canonical definitions for peripheral XPS_SYSMON_ADC_PPC440 */
#define XPAR_SYSMON_0_DEVICE_ID XPAR_XPS_SYSMON_ADC_PPC440_DEVICE_ID #define XPAR_SYSMON_0_DEVICE_ID XPAR_XPS_SYSMON_ADC_PPC440_DEVICE_ID
#define XPAR_SYSMON_0_BASEADDR 0xD0010000 #define XPAR_SYSMON_0_BASEADDR 0xD0010000
#define XPAR_SYSMON_0_HIGHADDR 0xD001FFFF #define XPAR_SYSMON_0_HIGHADDR 0xD001FFFF
#define XPAR_SYSMON_0_INCLUDE_INTR 1 #define XPAR_SYSMON_0_INCLUDE_INTR 1
/******************************************************************/ /******************************************************************/
/* Definitions for driver TMRCTR */ /* Definitions for driver TMRCTR */
@ -385,18 +347,15 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
/* Definitions for peripheral XPS_TIMER_PPC440 */ /* Definitions for peripheral XPS_TIMER_PPC440 */
#define XPAR_XPS_TIMER_PPC440_DEVICE_ID 0 #define XPAR_XPS_TIMER_PPC440_DEVICE_ID 0
#define XPAR_XPS_TIMER_PPC440_BASEADDR 0xC2000000 #define XPAR_XPS_TIMER_PPC440_BASEADDR 0xC2000000
#define XPAR_XPS_TIMER_PPC440_HIGHADDR 0xC200FFFF #define XPAR_XPS_TIMER_PPC440_HIGHADDR 0xC200FFFF
/******************************************************************/ /******************************************************************/
/* Canonical definitions for peripheral XPS_TIMER_PPC440 */ /* Canonical definitions for peripheral XPS_TIMER_PPC440 */
#define XPAR_TMRCTR_0_DEVICE_ID XPAR_XPS_TIMER_PPC440_DEVICE_ID #define XPAR_TMRCTR_0_DEVICE_ID XPAR_XPS_TIMER_PPC440_DEVICE_ID
#define XPAR_TMRCTR_0_BASEADDR 0xC2000000 #define XPAR_TMRCTR_0_BASEADDR 0xC2000000
#define XPAR_TMRCTR_0_HIGHADDR 0xC200FFFF #define XPAR_TMRCTR_0_HIGHADDR 0xC200FFFF
/******************************************************************/ /******************************************************************/
@ -408,149 +367,148 @@ XPAR_PLB_LL_FIFO_AURORA_DUAL_CTRL_FEB_LEFT_BASEADDR
#define XPAR_PROC_BUS_0_FREQ_HZ 100000000 #define XPAR_PROC_BUS_0_FREQ_HZ 100000000
/******************************************************************/ /******************************************************************/
#define XPAR_CPU_PPC440_CORE_CLOCK_FREQ_HZ 400000000 #define XPAR_CPU_PPC440_CORE_CLOCK_FREQ_HZ 400000000
#define XPAR_PPC440_VIRTEX5_CORE_CLOCK_FREQ_HZ 400000000 #define XPAR_PPC440_VIRTEX5_CORE_CLOCK_FREQ_HZ 400000000
#define XPAR_CPU_PPC440_IDCR_BASEADDR 0x00000000 #define XPAR_CPU_PPC440_IDCR_BASEADDR 0x00000000
/******************************************************************/ /******************************************************************/
#define XPAR_CPU_ID 0 #define XPAR_CPU_ID 0
#define XPAR_PPC440_VIRTEX5_ID 0 #define XPAR_PPC440_VIRTEX5_ID 0
#define XPAR_PPC440_VIRTEX5_PIR 0b1111 #define XPAR_PPC440_VIRTEX5_PIR 0b1111
#define XPAR_PPC440_VIRTEX5_ENDIAN_RESET 0 #define XPAR_PPC440_VIRTEX5_ENDIAN_RESET 0
#define XPAR_PPC440_VIRTEX5_USER_RESET 0b0000 #define XPAR_PPC440_VIRTEX5_USER_RESET 0b0000
#define XPAR_PPC440_VIRTEX5_INTERCONNECT_IMASK 0xffffffff #define XPAR_PPC440_VIRTEX5_INTERCONNECT_IMASK 0xffffffff
#define XPAR_PPC440_VIRTEX5_ICU_RD_FETCH_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_ICU_RD_FETCH_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_ICU_RD_SPEC_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_ICU_RD_SPEC_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_ICU_RD_TOUCH_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_ICU_RD_TOUCH_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_RD_LD_CACHE_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_RD_LD_CACHE_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_RD_NONCACHE_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_RD_NONCACHE_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_RD_TOUCH_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_RD_TOUCH_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_RD_URGENT_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_RD_URGENT_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_WR_FLUSH_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_WR_FLUSH_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_WR_STORE_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_WR_STORE_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DCU_WR_URGENT_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DCU_WR_URGENT_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DMA0_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DMA0_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DMA1_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DMA1_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DMA2_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DMA2_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_DMA3_PLB_PRIO 0b00 #define XPAR_PPC440_VIRTEX5_DMA3_PLB_PRIO 0b00
#define XPAR_PPC440_VIRTEX5_IDCR_BASEADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_IDCR_BASEADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_IDCR_HIGHADDR 0x000000FF #define XPAR_PPC440_VIRTEX5_IDCR_HIGHADDR 0x000000FF
#define XPAR_PPC440_VIRTEX5_APU_CONTROL 0b00010000000000000 #define XPAR_PPC440_VIRTEX5_APU_CONTROL 0b00010000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_0 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_0 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_1 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_1 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_2 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_2 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_3 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_3 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_4 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_4 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_5 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_5 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_6 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_6 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_7 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_7 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_8 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_8 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_9 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_9 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_10 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_10 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_11 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_11 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_12 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_12 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_13 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_13 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_14 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_14 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_APU_UDI_15 0b000000000000000000000000 #define XPAR_PPC440_VIRTEX5_APU_UDI_15 0b000000000000000000000000
#define XPAR_PPC440_VIRTEX5_PPC440MC_ADDR_BASE 0x00000000 #define XPAR_PPC440_VIRTEX5_PPC440MC_ADDR_BASE 0x00000000
#define XPAR_PPC440_VIRTEX5_PPC440MC_ADDR_HIGH 0X01FFFFFF #define XPAR_PPC440_VIRTEX5_PPC440MC_ADDR_HIGH 0X01FFFFFF
#define XPAR_PPC440_VIRTEX5_PPC440MC_ROW_CONFLICT_MASK 0x00000000 #define XPAR_PPC440_VIRTEX5_PPC440MC_ROW_CONFLICT_MASK 0x00000000
#define XPAR_PPC440_VIRTEX5_PPC440MC_BANK_CONFLICT_MASK 0x00000000 #define XPAR_PPC440_VIRTEX5_PPC440MC_BANK_CONFLICT_MASK 0x00000000
#define XPAR_PPC440_VIRTEX5_PPC440MC_CONTROL 0X8140008F #define XPAR_PPC440_VIRTEX5_PPC440MC_CONTROL 0X8140008F
#define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_ICU 4 #define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_ICU 4
#define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_DCUW 3 #define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_DCUW 3
#define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_DCUR 2 #define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_DCUR 2
#define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_SPLB1 0 #define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_SPLB1 0
#define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_SPLB0 1 #define XPAR_PPC440_VIRTEX5_PPC440MC_PRIO_SPLB0 1
#define XPAR_PPC440_VIRTEX5_PPC440MC_ARB_MODE 0 #define XPAR_PPC440_VIRTEX5_PPC440MC_ARB_MODE 0
#define XPAR_PPC440_VIRTEX5_PPC440MC_MAX_BURST 8 #define XPAR_PPC440_VIRTEX5_PPC440MC_MAX_BURST 8
#define XPAR_PPC440_VIRTEX5_MPLB_AWIDTH 32 #define XPAR_PPC440_VIRTEX5_MPLB_AWIDTH 32
#define XPAR_PPC440_VIRTEX5_MPLB_DWIDTH 128 #define XPAR_PPC440_VIRTEX5_MPLB_DWIDTH 128
#define XPAR_PPC440_VIRTEX5_MPLB_NATIVE_DWIDTH 128 #define XPAR_PPC440_VIRTEX5_MPLB_NATIVE_DWIDTH 128
#define XPAR_PPC440_VIRTEX5_MPLB_COUNTER 0x00000500 #define XPAR_PPC440_VIRTEX5_MPLB_COUNTER 0x00000500
#define XPAR_PPC440_VIRTEX5_MPLB_PRIO_ICU 4 #define XPAR_PPC440_VIRTEX5_MPLB_PRIO_ICU 4
#define XPAR_PPC440_VIRTEX5_MPLB_PRIO_DCUW 3 #define XPAR_PPC440_VIRTEX5_MPLB_PRIO_DCUW 3
#define XPAR_PPC440_VIRTEX5_MPLB_PRIO_DCUR 2 #define XPAR_PPC440_VIRTEX5_MPLB_PRIO_DCUR 2
#define XPAR_PPC440_VIRTEX5_MPLB_PRIO_SPLB1 0 #define XPAR_PPC440_VIRTEX5_MPLB_PRIO_SPLB1 0
#define XPAR_PPC440_VIRTEX5_MPLB_PRIO_SPLB0 1 #define XPAR_PPC440_VIRTEX5_MPLB_PRIO_SPLB0 1
#define XPAR_PPC440_VIRTEX5_MPLB_ARB_MODE 0 #define XPAR_PPC440_VIRTEX5_MPLB_ARB_MODE 0
#define XPAR_PPC440_VIRTEX5_MPLB_SYNC_TATTRIBUTE 0 #define XPAR_PPC440_VIRTEX5_MPLB_SYNC_TATTRIBUTE 0
#define XPAR_PPC440_VIRTEX5_MPLB_MAX_BURST 8 #define XPAR_PPC440_VIRTEX5_MPLB_MAX_BURST 8
#define XPAR_PPC440_VIRTEX5_MPLB_ALLOW_LOCK_XFER 1 #define XPAR_PPC440_VIRTEX5_MPLB_ALLOW_LOCK_XFER 1
#define XPAR_PPC440_VIRTEX5_MPLB_READ_PIPE_ENABLE 1 #define XPAR_PPC440_VIRTEX5_MPLB_READ_PIPE_ENABLE 1
#define XPAR_PPC440_VIRTEX5_MPLB_WRITE_PIPE_ENABLE 1 #define XPAR_PPC440_VIRTEX5_MPLB_WRITE_PIPE_ENABLE 1
#define XPAR_PPC440_VIRTEX5_MPLB_WRITE_POST_ENABLE 1 #define XPAR_PPC440_VIRTEX5_MPLB_WRITE_POST_ENABLE 1
#define XPAR_PPC440_VIRTEX5_MPLB_P2P 0 #define XPAR_PPC440_VIRTEX5_MPLB_P2P 0
#define XPAR_PPC440_VIRTEX5_MPLB_WDOG_ENABLE 1 #define XPAR_PPC440_VIRTEX5_MPLB_WDOG_ENABLE 1
#define XPAR_PPC440_VIRTEX5_SPLB0_AWIDTH 32 #define XPAR_PPC440_VIRTEX5_SPLB0_AWIDTH 32
#define XPAR_PPC440_VIRTEX5_SPLB0_DWIDTH 128 #define XPAR_PPC440_VIRTEX5_SPLB0_DWIDTH 128
#define XPAR_PPC440_VIRTEX5_SPLB0_NATIVE_DWIDTH 128 #define XPAR_PPC440_VIRTEX5_SPLB0_NATIVE_DWIDTH 128
#define XPAR_PPC440_VIRTEX5_SPLB0_SUPPORT_BURSTS 1 #define XPAR_PPC440_VIRTEX5_SPLB0_SUPPORT_BURSTS 1
#define XPAR_PPC440_VIRTEX5_SPLB0_USE_MPLB_ADDR 0 #define XPAR_PPC440_VIRTEX5_SPLB0_USE_MPLB_ADDR 0
#define XPAR_PPC440_VIRTEX5_SPLB0_NUM_MPLB_ADDR_RNG 0 #define XPAR_PPC440_VIRTEX5_SPLB0_NUM_MPLB_ADDR_RNG 0
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG_MC_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB0_RNG_MC_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG_MC_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB0_RNG_MC_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG0_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB0_RNG0_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG0_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB0_RNG0_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG1_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB0_RNG1_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG1_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB0_RNG1_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG2_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB0_RNG2_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG2_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB0_RNG2_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG3_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB0_RNG3_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB0_RNG3_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB0_RNG3_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB0_NUM_MASTERS 1 #define XPAR_PPC440_VIRTEX5_SPLB0_NUM_MASTERS 1
#define XPAR_PPC440_VIRTEX5_SPLB0_MID_WIDTH 1 #define XPAR_PPC440_VIRTEX5_SPLB0_MID_WIDTH 1
#define XPAR_PPC440_VIRTEX5_SPLB0_ALLOW_LOCK_XFER 1 #define XPAR_PPC440_VIRTEX5_SPLB0_ALLOW_LOCK_XFER 1
#define XPAR_PPC440_VIRTEX5_SPLB0_READ_PIPE_ENABLE 1 #define XPAR_PPC440_VIRTEX5_SPLB0_READ_PIPE_ENABLE 1
#define XPAR_PPC440_VIRTEX5_SPLB0_PROPAGATE_MIRQ 0 #define XPAR_PPC440_VIRTEX5_SPLB0_PROPAGATE_MIRQ 0
#define XPAR_PPC440_VIRTEX5_SPLB0_P2P -1 #define XPAR_PPC440_VIRTEX5_SPLB0_P2P -1
#define XPAR_PPC440_VIRTEX5_SPLB1_AWIDTH 32 #define XPAR_PPC440_VIRTEX5_SPLB1_AWIDTH 32
#define XPAR_PPC440_VIRTEX5_SPLB1_DWIDTH 128 #define XPAR_PPC440_VIRTEX5_SPLB1_DWIDTH 128
#define XPAR_PPC440_VIRTEX5_SPLB1_NATIVE_DWIDTH 128 #define XPAR_PPC440_VIRTEX5_SPLB1_NATIVE_DWIDTH 128
#define XPAR_PPC440_VIRTEX5_SPLB1_SUPPORT_BURSTS 1 #define XPAR_PPC440_VIRTEX5_SPLB1_SUPPORT_BURSTS 1
#define XPAR_PPC440_VIRTEX5_SPLB1_USE_MPLB_ADDR 0 #define XPAR_PPC440_VIRTEX5_SPLB1_USE_MPLB_ADDR 0
#define XPAR_PPC440_VIRTEX5_SPLB1_NUM_MPLB_ADDR_RNG 0 #define XPAR_PPC440_VIRTEX5_SPLB1_NUM_MPLB_ADDR_RNG 0
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG_MC_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB1_RNG_MC_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG_MC_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB1_RNG_MC_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG0_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB1_RNG0_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG0_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB1_RNG0_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG1_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB1_RNG1_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG1_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB1_RNG1_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG2_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB1_RNG2_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG2_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB1_RNG2_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG3_MPLB_BASEADDR 0xFFFFFFFF #define XPAR_PPC440_VIRTEX5_SPLB1_RNG3_MPLB_BASEADDR 0xFFFFFFFF
#define XPAR_PPC440_VIRTEX5_SPLB1_RNG3_MPLB_HIGHADDR 0x00000000 #define XPAR_PPC440_VIRTEX5_SPLB1_RNG3_MPLB_HIGHADDR 0x00000000
#define XPAR_PPC440_VIRTEX5_SPLB1_NUM_MASTERS 1 #define XPAR_PPC440_VIRTEX5_SPLB1_NUM_MASTERS 1
#define XPAR_PPC440_VIRTEX5_SPLB1_MID_WIDTH 1 #define XPAR_PPC440_VIRTEX5_SPLB1_MID_WIDTH 1
#define XPAR_PPC440_VIRTEX5_SPLB1_ALLOW_LOCK_XFER 1 #define XPAR_PPC440_VIRTEX5_SPLB1_ALLOW_LOCK_XFER 1
#define XPAR_PPC440_VIRTEX5_SPLB1_READ_PIPE_ENABLE 1 #define XPAR_PPC440_VIRTEX5_SPLB1_READ_PIPE_ENABLE 1
#define XPAR_PPC440_VIRTEX5_SPLB1_PROPAGATE_MIRQ 0 #define XPAR_PPC440_VIRTEX5_SPLB1_PROPAGATE_MIRQ 0
#define XPAR_PPC440_VIRTEX5_SPLB1_P2P -1 #define XPAR_PPC440_VIRTEX5_SPLB1_P2P -1
#define XPAR_PPC440_VIRTEX5_NUM_DMA 0 #define XPAR_PPC440_VIRTEX5_NUM_DMA 0
#define XPAR_PPC440_VIRTEX5_DMA0_TXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA0_TXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA0_RXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA0_RXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA0_CONTROL 0b00000000 #define XPAR_PPC440_VIRTEX5_DMA0_CONTROL 0b00000000
#define XPAR_PPC440_VIRTEX5_DMA0_TXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA0_TXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA0_RXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA0_RXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA1_TXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA1_TXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA1_RXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA1_RXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA1_CONTROL 0b00000000 #define XPAR_PPC440_VIRTEX5_DMA1_CONTROL 0b00000000
#define XPAR_PPC440_VIRTEX5_DMA1_TXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA1_TXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA1_RXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA1_RXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA2_TXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA2_TXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA2_RXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA2_RXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA2_CONTROL 0b00000000 #define XPAR_PPC440_VIRTEX5_DMA2_CONTROL 0b00000000
#define XPAR_PPC440_VIRTEX5_DMA2_TXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA2_TXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA2_RXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA2_RXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA3_TXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA3_TXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA3_RXCHANNELCTRL 0x01010000 #define XPAR_PPC440_VIRTEX5_DMA3_RXCHANNELCTRL 0x01010000
#define XPAR_PPC440_VIRTEX5_DMA3_CONTROL 0b00000000 #define XPAR_PPC440_VIRTEX5_DMA3_CONTROL 0b00000000
#define XPAR_PPC440_VIRTEX5_DMA3_TXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA3_TXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DMA3_RXIRQTIMER 0b1111111111 #define XPAR_PPC440_VIRTEX5_DMA3_RXIRQTIMER 0b1111111111
#define XPAR_PPC440_VIRTEX5_DCR_AUTOLOCK_ENABLE 1 #define XPAR_PPC440_VIRTEX5_DCR_AUTOLOCK_ENABLE 1
#define XPAR_PPC440_VIRTEX5_PPCDM_ASYNCMODE 0 #define XPAR_PPC440_VIRTEX5_PPCDM_ASYNCMODE 0
#define XPAR_PPC440_VIRTEX5_PPCDS_ASYNCMODE 0 #define XPAR_PPC440_VIRTEX5_PPCDS_ASYNCMODE 0
#define XPAR_PPC440_VIRTEX5_GENERATE_PLB_TIMESPECS 1 #define XPAR_PPC440_VIRTEX5_GENERATE_PLB_TIMESPECS 1
#define XPAR_PPC440_VIRTEX5_HW_VER "1.01.a" #define XPAR_PPC440_VIRTEX5_HW_VER "1.01.a"
/******************************************************************/ /******************************************************************/

View File

@ -11,6 +11,7 @@ add_executable(gotthard2DetectorServer_virtual
../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c ../slsDetectorServer/src/ALTERA_PLL_CYCLONE10.c
../slsDetectorServer/src/ASIC_Driver.c ../slsDetectorServer/src/ASIC_Driver.c
../slsDetectorServer/src/programFpgaNios.c ../slsDetectorServer/src/programFpgaNios.c
../slsDetectorServer/src/communication_virtual.c
) )
include_directories( include_directories(

View File

@ -1,251 +1,256 @@
#pragma once #pragma once
#define REG_OFFSET (4)
#define REG_OFFSET (4)
/* Base addresses 0x1804 0000 ---------------------------------------------*/ /* Base addresses 0x1804 0000 ---------------------------------------------*/
/* Reconfiguration core for readout pll */ /* Reconfiguration core for readout pll */
#define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF #define BASE_READOUT_PLL (0x0000) // 0x1804_0000 - 0x1804_07FF
/* Reconfiguration core for system pll */ /* Reconfiguration core for system pll */
#define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF #define BASE_SYSTEM_PLL (0x0800) // 0x1804_0800 - 0x1804_0FFF
/* Clock Generation */ /* Clock Generation */
#define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO #define BASE_CLK_GENERATION (0x1000) // 0x1804_1000 - 0x1804_XXXX //TODO
/* Base addresses 0x1806 0000 ---------------------------------------------*/ /* Base addresses 0x1806 0000 ---------------------------------------------*/
/* General purpose control and status registers */ /* General purpose control and status registers */
#define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF #define BASE_CONTROL (0x0000) // 0x1806_0000 - 0x1806_00FF
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/ctrl/ctrl.vhd // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/ctrl/ctrl.vhd
/* ASIC Control */ /* ASIC Control */
#define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F #define BASE_ASIC (0x0100) // 0x1806_0100 - 0x1806_011F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/asic/asic_ctrl.vhd // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/asic/asic_ctrl.vhd
/* ASIC Digital Interface. Data recovery core */ /* ASIC Digital Interface. Data recovery core */
#define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F #define BASE_ADIF (0x0120) // 0x1806_0120 - 0x1806_012F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/adif/adif_ctrl.vhd // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/adif/adif_ctrl.vhd
/* Formatting of data core */ /* Formatting of data core */
#define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F #define BASE_FMT (0x0130) // 0x1806_0130 - 0x1806_013F
/* Packetizer */ /* Packetizer */
#define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F #define BASE_PKT (0x0140) // 0x1806_0140 - 0x1806_014F
// https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd // https://git.psi.ch/sls_detectors_firmware/gotthard_II_mcb/blob/master/code/hdl/pkt/pkt_ctrl.vhd
/* Flow control and status registers */ /* Flow control and status registers */
#define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF #define BASE_FLOW_CONTROL (0x00200) // 0x1806_0200 - 0x1806_02FF
// https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/f37608230b4721661f29aacc20124555705ee705/flow/flow_ctrl.vhd // https://git.psi.ch/sls_detectors_firmware/vhdl_library/blob/f37608230b4721661f29aacc20124555705ee705/flow/flow_ctrl.vhd
/* UDP datagram generator */ /* UDP datagram generator */
#define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF #define BASE_UDP_RAM (0x01000) // 0x1806_1000 - 0x1806_1FFF
/* Clock Generation registers ------------------------------------------------------*/
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
#define PLL_RESET_READOUT_OFST (0)
#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST)
#define PLL_RESET_SYSTEM_OFST (1)
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
/* Clock Generation registers
* ------------------------------------------------------*/
#define PLL_RESET_REG (0x00 * REG_OFFSET + BASE_CLK_GENERATION)
#define PLL_RESET_READOUT_OFST (0)
#define PLL_RESET_READOUT_MSK (0x00000001 << PLL_RESET_READOUT_OFST)
#define PLL_RESET_SYSTEM_OFST (1)
#define PLL_RESET_SYSTEM_MSK (0x00000001 << PLL_RESET_SYSTEM_OFST)
/* Control registers --------------------------------------------------*/ /* Control registers --------------------------------------------------*/
/* Module Control Board Serial Number register */ /* Module Control Board Serial Number register */
#define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL) #define MCB_SERIAL_NO_REG (0x00 * REG_OFFSET + BASE_CONTROL)
#define MCB_SERIAL_NO_VRSN_OFST (16) #define MCB_SERIAL_NO_VRSN_OFST (16)
#define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST) #define MCB_SERIAL_NO_VRSN_MSK (0x0000001F << MCB_SERIAL_NO_VRSN_OFST)
/* FPGA Version register */ /* FPGA Version register */
#define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL) #define FPGA_VERSION_REG (0x01 * REG_OFFSET + BASE_CONTROL)
#define FPGA_COMPILATION_DATE_OFST (0) #define FPGA_COMPILATION_DATE_OFST (0)
#define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST) #define FPGA_COMPILATION_DATE_MSK (0x00FFFFFF << FPGA_COMPILATION_DATE_OFST)
#define DETECTOR_TYPE_OFST (24) #define DETECTOR_TYPE_OFST (24)
#define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST) #define DETECTOR_TYPE_MSK (0x000000FF << DETECTOR_TYPE_OFST)
/* API Version register */ /* API Version register */
#define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL) #define API_VERSION_REG (0x02 * REG_OFFSET + BASE_CONTROL)
#define API_VERSION_OFST (0) #define API_VERSION_OFST (0)
#define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST) #define API_VERSION_MSK (0x00FFFFFF << API_VERSION_OFST)
#define API_VERSION_DETECTOR_TYPE_OFST (24) //Not used in software #define API_VERSION_DETECTOR_TYPE_OFST (24) // Not used in software
#define API_VERSION_DETECTOR_TYPE_MSK (0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) //Not used in software #define API_VERSION_DETECTOR_TYPE_MSK \
(0x000000FF << API_VERSION_DETECTOR_TYPE_OFST) // Not used in software
/* Fix pattern register */ /* Fix pattern register */
#define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL) #define FIX_PATT_REG (0x03 * REG_OFFSET + BASE_CONTROL)
#define FIX_PATT_VAL (0xACDC2019) #define FIX_PATT_VAL (0xACDC2019)
/* Status register */ /* Status register */
#define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL) #define STATUS_REG (0x04 * REG_OFFSET + BASE_CONTROL)
/* Look at me read only register */ /* Look at me read only register */
#define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL) #define LOOK_AT_ME_REG (0x05 * REG_OFFSET + BASE_CONTROL)
/* System status register */ /* System status register */
#define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL) #define SYSTEM_STATUS_REG (0x06 * REG_OFFSET + BASE_CONTROL)
/* Config RW regiseter */ /* Config RW regiseter */
#define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) #define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL)
/* Control RW register */ /* Control RW register */
#define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL) #define CONTROL_REG (0x21 * REG_OFFSET + BASE_CONTROL)
#define CONTROL_STRT_ACQSTN_OFST (0) #define CONTROL_STRT_ACQSTN_OFST (0)
#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST) #define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST)
#define CONTROL_STP_ACQSTN_OFST (1) #define CONTROL_STP_ACQSTN_OFST (1)
#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST) #define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST)
#define CONTROL_CRE_RST_OFST (10) #define CONTROL_CRE_RST_OFST (10)
#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST) #define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST)
#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10? #define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10?
#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) #define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST)
#define CONTROL_CLR_ACQSTN_FIFO_OFST (15) #define CONTROL_CLR_ACQSTN_FIFO_OFST (15)
#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) #define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST)
#define CONTROL_TIMING_SOURCE_EXT_OFST (17) #define CONTROL_TIMING_SOURCE_EXT_OFST (17)
#define CONTROL_TIMING_SOURCE_EXT_MSK (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST) #define CONTROL_TIMING_SOURCE_EXT_MSK \
#define CONTROL_PWR_CHIP_OFST (31) (0x00000001 << CONTROL_TIMING_SOURCE_EXT_OFST)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST) #define CONTROL_PWR_CHIP_OFST (31)
#define CONTROL_PWR_CHIP_MSK (0x00000001 << CONTROL_PWR_CHIP_OFST)
/** DTA Offset Register */ /** DTA Offset Register */
#define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL) #define DTA_OFFSET_REG (0x24 * REG_OFFSET + BASE_CONTROL)
/* ASIC registers --------------------------------------------------*/ /* ASIC registers --------------------------------------------------*/
/* ASIC Config register */ /* ASIC Config register */
#define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC) #define ASIC_CONFIG_REG (0x00 * REG_OFFSET + BASE_ASIC)
#define ASIC_CONFIG_RUN_MODE_OFST (0) #define ASIC_CONFIG_RUN_MODE_OFST (0)
#define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST) #define ASIC_CONFIG_RUN_MODE_MSK (0x00000003 << ASIC_CONFIG_RUN_MODE_OFST)
#define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL ((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) #define ASIC_CONFIG_RUN_MODE_INT_BURST_VAL \
#define ASIC_CONFIG_RUN_MODE_CONT_VAL ((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) ((0x1 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL ((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK) #define ASIC_CONFIG_RUN_MODE_CONT_VAL \
#define ASIC_CONFIG_GAIN_OFST (4) ((0x2 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST) #define ASIC_CONFIG_RUN_MODE_EXT_BURST_VAL \
#define ASIC_CONFIG_DYNAMIC_GAIN_VAL ((0x0 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) ((0x3 << ASIC_CONFIG_RUN_MODE_OFST) & ASIC_CONFIG_RUN_MODE_MSK)
#define ASIC_CONFIG_FIX_GAIN_1_VAL ((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_GAIN_OFST (4)
#define ASIC_CONFIG_FIX_GAIN_2_VAL ((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_GAIN_MSK (0x00000003 << ASIC_CONFIG_GAIN_OFST)
#define ASIC_CONFIG_RESERVED_VAL ((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK) #define ASIC_CONFIG_DYNAMIC_GAIN_VAL \
((0x0 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_1_VAL \
((0x1 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_FIX_GAIN_2_VAL \
((0x2 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_RESERVED_VAL \
((0x3 << ASIC_CONFIG_GAIN_OFST) & ASIC_CONFIG_GAIN_MSK)
#define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7) #define ASIC_CONFIG_CURRENT_SRC_EN_OFST (7)
#define ASIC_CONFIG_CURRENT_SRC_EN_MSK (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST) #define ASIC_CONFIG_CURRENT_SRC_EN_MSK \
#define ASIC_CONFIG_RST_DAC_OFST (15) (0x00000001 << ASIC_CONFIG_CURRENT_SRC_EN_OFST)
#define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST) #define ASIC_CONFIG_RST_DAC_OFST (15)
#define ASIC_CONFIG_DONE_OFST (31) #define ASIC_CONFIG_RST_DAC_MSK (0x00000001 << ASIC_CONFIG_RST_DAC_OFST)
#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST) #define ASIC_CONFIG_DONE_OFST (31)
#define ASIC_CONFIG_DONE_MSK (0x00000001 << ASIC_CONFIG_DONE_OFST)
/* ASIC Internal Frames Register */ /* ASIC Internal Frames Register */
#define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_FRAMES_REG (0x01 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_FRAMES_OFST (0) #define ASIC_INT_FRAMES_OFST (0)
#define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST) #define ASIC_INT_FRAMES_MSK (0x00000FFF << ASIC_INT_FRAMES_OFST)
/* ASIC Period 64bit Register */ /* ASIC Period 64bit Register */
#define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_PERIOD_LSB_REG (0x02 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_PERIOD_MSB_REG (0x03 * REG_OFFSET + BASE_ASIC)
/* ASIC Exptime 64bit Register */ /* ASIC Exptime 64bit Register */
#define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_EXPTIME_LSB_REG (0x04 * REG_OFFSET + BASE_ASIC)
#define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC) #define ASIC_INT_EXPTIME_MSB_REG (0x05 * REG_OFFSET + BASE_ASIC)
/* Packetizer -------------------------------------------------------------*/ /* Packetizer -------------------------------------------------------------*/
/* Packetizer Config Register */ /* Packetizer Config Register */
#define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT) #define PKT_CONFIG_REG (0x00 * REG_OFFSET + BASE_PKT)
#define PKT_CONFIG_NRXR_MAX_OFST (0) #define PKT_CONFIG_NRXR_MAX_OFST (0)
#define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST) #define PKT_CONFIG_NRXR_MAX_MSK (0x0000003F << PKT_CONFIG_NRXR_MAX_OFST)
#define PKT_CONFIG_RXR_START_ID_OFST (8) #define PKT_CONFIG_RXR_START_ID_OFST (8)
#define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST) #define PKT_CONFIG_RXR_START_ID_MSK (0x0000003F << PKT_CONFIG_RXR_START_ID_OFST)
/* Module Coordinates Register */ /* Module Coordinates Register */
#define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT) #define COORD_0_REG (0x02 * REG_OFFSET + BASE_PKT)
#define COORD_ROW_OFST (0) #define COORD_ROW_OFST (0)
#define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST) #define COORD_ROW_MSK (0x0000FFFF << COORD_ROW_OFST)
#define COORD_COL_OFST (16) #define COORD_COL_OFST (16)
#define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST) #define COORD_COL_MSK (0x0000FFFF << COORD_COL_OFST)
/* Module ID Register */ /* Module ID Register */
#define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT) #define COORD_1_REG (0x03 * REG_OFFSET + BASE_PKT)
#define COORD_RESERVED_OFST (0) #define COORD_RESERVED_OFST (0)
#define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST) #define COORD_RESERVED_MSK (0x0000FFFF << COORD_RESERVED_OFST)
#define COORD_ID_OFST (16) // Not connected in firmware TODO #define COORD_ID_OFST (16) // Not connected in firmware TODO
#define COORD_ID_MSK (0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO #define COORD_ID_MSK \
(0x0000FFFF << COORD_ID_OFST) // Not connected in firmware TODO
/* Flow control registers --------------------------------------------------*/ /* Flow control registers --------------------------------------------------*/
/* Flow status Register*/ /* Flow status Register*/
#define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL) #define FLOW_STATUS_REG (0x00 * REG_OFFSET + BASE_FLOW_CONTROL)
#define FLOW_STATUS_RUN_BUSY_OFST (0) #define FLOW_STATUS_RUN_BUSY_OFST (0)
#define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST) #define FLOW_STATUS_RUN_BUSY_MSK (0x00000001 << FLOW_STATUS_RUN_BUSY_OFST)
#define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3) #define FLOW_STATUS_WAIT_FOR_TRGGR_OFST (3)
#define FLOW_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST) #define FLOW_STATUS_WAIT_FOR_TRGGR_MSK \
(0x00000001 << FLOW_STATUS_WAIT_FOR_TRGGR_OFST)
#define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4) #define FLOW_STATUS_DLY_BFRE_TRGGR_OFST (4)
#define FLOW_STATUS_DLY_BFRE_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST) #define FLOW_STATUS_DLY_BFRE_TRGGR_MSK \
(0x00000001 << FLOW_STATUS_DLY_BFRE_TRGGR_OFST)
#define FLOW_STATUS_FIFO_FULL_OFST (5) #define FLOW_STATUS_FIFO_FULL_OFST (5)
#define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST) #define FLOW_STATUS_FIFO_FULL_MSK (0x00000001 << FLOW_STATUS_FIFO_FULL_OFST)
#define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15) #define FLOW_STATUS_DLY_AFTR_TRGGR_OFST (15)
#define FLOW_STATUS_DLY_AFTR_TRGGR_MSK (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST) #define FLOW_STATUS_DLY_AFTR_TRGGR_MSK \
#define FLOW_STATUS_CSM_BUSY_OFST (17) (0x00000001 << FLOW_STATUS_DLY_AFTR_TRGGR_OFST)
#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST) #define FLOW_STATUS_CSM_BUSY_OFST (17)
#define FLOW_STATUS_CSM_BUSY_MSK (0x00000001 << FLOW_STATUS_CSM_BUSY_OFST)
/* Delay left 64bit Register */ /* Delay left 64bit Register */
#define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_DELAY_LSB_REG (0x02 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_DELAY_MSB_REG (0x03 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Triggers left 64bit Register */ /* Triggers left 64bit Register */
#define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_CYCLES_LSB_REG (0x04 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_CYCLES_MSB_REG (0x05 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames left 64bit Register */ /* Frames left 64bit Register */
#define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_FRAMES_LSB_REG (0x06 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_FRAMES_MSB_REG (0x07 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period left 64bit Register */ /* Period left 64bit Register */
#define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_PERIOD_LSB_REG (0x08 * REG_OFFSET + BASE_FLOW_CONTROL)
#define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL) #define GET_PERIOD_MSB_REG (0x09 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Time from Start 64 bit register */ /* Time from Start 64 bit register */
#define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL) #define TIME_FROM_START_LSB_REG (0x0A * REG_OFFSET + BASE_FLOW_CONTROL)
#define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL) #define TIME_FROM_START_MSB_REG (0x0B * REG_OFFSET + BASE_FLOW_CONTROL)
/* Get Frames from Start 64 bit register (frames from last reset using CONTROL_CRST) */ /* Get Frames from Start 64 bit register (frames from last reset using
#define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL) * CONTROL_CRST) */
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL) #define FRAMES_FROM_START_LSB_REG (0x0C * REG_OFFSET + BASE_FLOW_CONTROL)
#define FRAMES_FROM_START_MSB_REG (0x0D * REG_OFFSET + BASE_FLOW_CONTROL)
/* Measurement Time 64 bit register (timestamp at a frame start until reset)*/ /* Measurement Time 64 bit register (timestamp at a frame start until reset)*/
#define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL) #define START_FRAME_TIME_LSB_REG (0x0E * REG_OFFSET + BASE_FLOW_CONTROL)
#define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL) #define START_FRAME_TIME_MSB_REG (0x0F * REG_OFFSET + BASE_FLOW_CONTROL)
/* Delay 64bit Write-register */ /* Delay 64bit Write-register */
#define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_DELAY_LSB_REG (0x22 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_DELAY_MSB_REG (0x23 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Cylces (also #bursts) 64bit Write-register */ /* Cylces (also #bursts) 64bit Write-register */
#define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_CYCLES_LSB_REG (0x24 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_CYCLES_MSB_REG (0x25 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Frames 64bit Write-register */ /* Frames 64bit Write-register */
#define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_FRAMES_LSB_REG (0x26 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_FRAMES_MSB_REG (0x27 * REG_OFFSET + BASE_FLOW_CONTROL)
/* Period (also burst period) 64bit Write-register */ /* Period (also burst period) 64bit Write-register */
#define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_PERIOD_LSB_REG (0x28 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_PERIOD_MSB_REG (0x29 * REG_OFFSET + BASE_FLOW_CONTROL)
/* External Signal register */ /* External Signal register */
#define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL) #define EXT_SIGNAL_REG (0x30 * REG_OFFSET + BASE_FLOW_CONTROL)
#define EXT_SIGNAL_OFST (0) #define EXT_SIGNAL_OFST (0)
#define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST) #define EXT_SIGNAL_MSK (0x00000001 << EXT_SIGNAL_OFST)
/* Trigger Delay 64 bit register */ /* Trigger Delay 64 bit register */
#define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_TRIGGER_DELAY_LSB_REG (0x32 * REG_OFFSET + BASE_FLOW_CONTROL)
#define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL) #define SET_TRIGGER_DELAY_MSB_REG (0x33 * REG_OFFSET + BASE_FLOW_CONTROL)

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