mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
b7d81b1e87
@ -1,10 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.9)
|
||||
project(slsDetectorPackage)
|
||||
|
||||
set(PROJECT_VERSION 5.0.0)
|
||||
include(cmake/project_version.cmake)
|
||||
|
||||
include(CheckIPOSupported)
|
||||
|
||||
|
||||
|
||||
|
||||
include(cmake/project_version.cmake)
|
||||
|
||||
# Include additional modules that are used unconditionally
|
||||
include(GNUInstallDirs)
|
||||
|
||||
@ -34,6 +38,7 @@ option (SLS_USE_HDF5 "HDF5 File format" OFF)
|
||||
option (SLS_USE_TEXTCLIENT "Text Client" ON)
|
||||
option (SLS_USE_RECEIVER "Receiver" ON)
|
||||
option (SLS_USE_GUI "GUI" OFF)
|
||||
option (SLS_USE_SIMULATOR "Simulator" OFF)
|
||||
option (SLS_USE_TESTS "TESTS" OFF)
|
||||
option (SLS_USE_INTEGRATION_TESTS "Integration Tests" OFF)
|
||||
option(SLS_USE_SANITIZER "Sanitizers for debugging" OFF)
|
||||
@ -87,10 +92,12 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
-Wno-misleading-indentation # mostly in rapidjson remove using clang format
|
||||
-Wduplicated-cond
|
||||
-Wnull-dereference )
|
||||
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
|
||||
target_compile_options(slsProjectWarnings INTERFACE
|
||||
-Wno-class-memaccess )
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -115,6 +122,8 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_INSTALL_RPATH "$ORIGIN")
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||
|
||||
|
||||
|
||||
find_package(Doxygen)
|
||||
find_package(ZeroMQ 4 REQUIRED)
|
||||
|
||||
@ -130,6 +139,7 @@ if (SLS_USE_TEXTCLIENT)
|
||||
add_subdirectory(slsDetectorSoftware)
|
||||
endif (SLS_USE_TEXTCLIENT)
|
||||
|
||||
|
||||
if (SLS_USE_RECEIVER)
|
||||
if (SLS_USE_HDF5)
|
||||
find_package(HDF5 1.10 COMPONENTS CXX REQUIRED)
|
||||
@ -146,6 +156,10 @@ if (SLS_USE_GUI)
|
||||
endif()
|
||||
endif (SLS_USE_GUI)
|
||||
|
||||
if (SLS_USE_SIMULATOR)
|
||||
add_subdirectory(slsDetectorServers)
|
||||
endif (SLS_USE_SIMULATOR)
|
||||
|
||||
if (SLS_USE_INTEGRATION_TESTS)
|
||||
add_subdirectory(integrationTests)
|
||||
endif (SLS_USE_INTEGRATION_TESTS)
|
||||
@ -160,9 +174,13 @@ configure_file( .clang-tidy
|
||||
|
||||
|
||||
if (DOXYGEN_FOUND)
|
||||
# set input and output files
|
||||
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen/Doxyfile.in)
|
||||
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
|
||||
|
||||
# request to configure the file
|
||||
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
|
||||
message("Doxygen build started")
|
||||
|
||||
# note the option ALL which allows to build the docs together with the application
|
||||
add_custom_target( docs
|
||||
|
45
cmk.sh
45
cmk.sh
@ -8,6 +8,8 @@ RECEIVER=0
|
||||
GUI=0
|
||||
DEBUG=0
|
||||
PYTHON=0
|
||||
TESTS=0
|
||||
SIMULATOR=0
|
||||
|
||||
|
||||
CLEAN=0
|
||||
@ -16,7 +18,7 @@ CMAKE_PRE=""
|
||||
CMAKE_POST=""
|
||||
|
||||
usage() { echo -e "
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
|
||||
Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [s] [i] [-h] [-d <HDF5 directory>] [-j] <Number of threads>
|
||||
-[no option]: only make
|
||||
-c: Clean
|
||||
-b: Builds/Rebuilds CMake files normal mode
|
||||
@ -26,8 +28,10 @@ Usage: $0 [-c] [-b] [-p] [e] [t] [r] [g] [-h] [-d <HDF5 directory>] [-j] <Number
|
||||
-t: Build/Rebuilds only text client
|
||||
-r: Build/Rebuilds only receiver
|
||||
-g: Build/Rebuilds only gui
|
||||
-s: Simulator
|
||||
-j: Number of threads to compile through
|
||||
-e: Debug mode
|
||||
-i: Builds tests
|
||||
|
||||
Rebuild when you switch to a new build and compile in parallel:
|
||||
./cmk.sh -bj5
|
||||
@ -63,7 +67,7 @@ For rebuilding only certain sections
|
||||
|
||||
" ; exit 1; }
|
||||
|
||||
while getopts ":bpchd:j:trges:" opt ; do
|
||||
while getopts ":bpchd:j:trgeis" opt ; do
|
||||
case $opt in
|
||||
b)
|
||||
echo "Building of CMake files Required"
|
||||
@ -110,16 +114,24 @@ while getopts ":bpchd:j:trges:" opt ; do
|
||||
echo "Compiling Options: Debug"
|
||||
DEBUG=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
i)
|
||||
echo "Compiling Options: Tests"
|
||||
TESTS=1
|
||||
;;
|
||||
s)
|
||||
echo "Compiling Options: Simulator"
|
||||
SIMULATOR=1
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument."
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument."
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
@ -173,6 +185,19 @@ if [ $DEBUG -eq 1 ]; then
|
||||
echo "Debug Option enabled"
|
||||
fi
|
||||
|
||||
#Simulator
|
||||
if [ $SIMULATOR -eq 1 ]; then
|
||||
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_SIMULATOR=ON "
|
||||
echo "Simulator Option enabled"
|
||||
fi
|
||||
|
||||
|
||||
#Tests
|
||||
if [ $TESTS -eq 1 ]; then
|
||||
CMAKE_POST+=" -DCMAKE_BUILD_TYPE=Debug -DSLS_USE_TESTS=ON -DSLS_USE_INTEGRATION_TESTS=ON"
|
||||
echo "Tests Option enabled"
|
||||
fi
|
||||
|
||||
|
||||
#hdf5 rebuild
|
||||
if [ $HDF5 -eq 1 ]; then
|
||||
|
@ -1,15 +1,15 @@
|
||||
hostname bchip038+
|
||||
hostname localhost
|
||||
|
||||
0:rx_udpport 50004
|
||||
0:rx_udpip 10.1.1.100
|
||||
0:detectorip 10.1.1.10
|
||||
rx_hostname pcmoench01
|
||||
0:rx_udpip 172.24.8.84
|
||||
0:detectorip 172.24.8.254
|
||||
rx_hostname localhost
|
||||
|
||||
powerchip 1
|
||||
#powerchip 1
|
||||
|
||||
#extsig:0 trigger_in_rising_edge
|
||||
#timing trigger
|
||||
|
||||
outdir /external_pool/jungfrau_data/softwaretest
|
||||
outdir /tmp/slsdetector
|
||||
|
||||
|
||||
|
@ -479,4 +479,42 @@ TEST_CASE("Chiptestboard Dbit offset, list, sampling, advinvert", "[.ctbintegrat
|
||||
CHECK(m.getExternalSampling() == 1);
|
||||
CHECK(m.readRegister(0x7b) == 0x1003E);
|
||||
|
||||
}
|
||||
|
||||
TEST_CASE("Eiger or Jungfrau startingfnum", "[.eigerintegration][.jungfrauintegration][startingfnum]") {
|
||||
SingleDetectorConfig c;
|
||||
|
||||
// pick up multi detector from shm id 0
|
||||
multiSlsDetector m(0);
|
||||
|
||||
// ensure ctb detector type, hostname and online
|
||||
REQUIRE(((m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::EIGER) || (m.getDetectorTypeAsEnum() == slsDetectorDefs::detectorType::JUNGFRAU)));
|
||||
REQUIRE(m.getHostname() == c.hostname);
|
||||
REQUIRE(m.setOnline(true) == slsDetectorDefs::ONLINE_FLAG);
|
||||
|
||||
CHECK(m.setTimer(slsDetectorDefs::FRAME_NUMBER, 1) == 1);
|
||||
|
||||
// starting fnum
|
||||
uint64_t val = 8;
|
||||
|
||||
m.setStartingFrameNumber(val);
|
||||
CHECK(m.getStartingFrameNumber() == val);
|
||||
CHECK(m.acquire() == slsDetectorDefs::OK);
|
||||
CHECK(m.getReceiverCurrentFrameIndex() == val);
|
||||
|
||||
++val;
|
||||
CHECK(m.acquire() == slsDetectorDefs::OK);
|
||||
CHECK(m.getReceiverCurrentFrameIndex() == val);
|
||||
|
||||
CHECK_THROWS_AS(m.setStartingFrameNumber(0), sls::RuntimeError);
|
||||
|
||||
if (m.getDetectorTypeAsString() == "Eiger") {
|
||||
val = 281474976710655;
|
||||
} else if (m.getDetectorTypeAsString() == "Jungfrau") {
|
||||
val = 18446744073709551615;
|
||||
}
|
||||
m.setStartingFrameNumber(val);
|
||||
CHECK(m.getStartingFrameNumber() == val);
|
||||
CHECK(m.acquire() == slsDetectorDefs::OK);
|
||||
CHECK(m.getReceiverCurrentFrameIndex() == val);
|
||||
}
|
@ -107,4 +107,4 @@ TEST_CASE("Set and read timers", "[.integration][.multi]") {
|
||||
// MAX_TIMERS
|
||||
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
}
|
||||
|
2
slsDetectorServers/CMakeLists.txt
Normal file
2
slsDetectorServers/CMakeLists.txt
Normal file
@ -0,0 +1,2 @@
|
||||
add_subdirectory(eigerDetectorServer)
|
||||
add_subdirectory(jungfrauDetectorServer)
|
Binary file not shown.
@ -1523,7 +1523,7 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||
if (setUDPDestinationDetails(cDestIp, udpport) == FAIL) {
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp 1G destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
@ -2146,7 +2146,7 @@ int startStateMachine(){
|
||||
// 1 giga udp
|
||||
if (!enableTenGigabitEthernet(-1)) {
|
||||
// create udp socket
|
||||
if(createUDPSocket() != OK) {
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
// update header with modId, detType and version. Reset offset and fnum
|
||||
@ -2265,9 +2265,9 @@ void readandSendUDPFrames(int *ret, char *mess) {
|
||||
FILE_LOG(logDEBUG1, ("Reading from 1G UDP\n"));
|
||||
|
||||
// validate udp socket
|
||||
if (getUdPSocketDescriptor() <= 0) {
|
||||
if (getUdPSocketDescriptor(0) <= 0) {
|
||||
*ret = FAIL;
|
||||
sprintf(mess,"UDP Socket not created. sockfd:%d\n", getUdPSocketDescriptor());
|
||||
sprintf(mess,"UDP Socket not created. sockfd:%d\n", getUdPSocketDescriptor(0));
|
||||
FILE_LOG(logERROR, (mess));
|
||||
return;
|
||||
}
|
||||
@ -2276,14 +2276,14 @@ void readandSendUDPFrames(int *ret, char *mess) {
|
||||
while(readFrameFromFifo() == OK) {
|
||||
int bytesToSend = 0, n = 0;
|
||||
while((bytesToSend = fillUDPPacket(udpPacketData))) {
|
||||
n += sendUDPPacket(udpPacketData, bytesToSend);
|
||||
n += sendUDPPacket(0, udpPacketData, bytesToSend);
|
||||
}
|
||||
if (n >= dataBytes) {
|
||||
FILE_LOG(logINFO, (" Frame %lld sent (%d packets, %d databytes, n:%d bytes sent)\n",
|
||||
udpFrameNumber, udpPacketNumber + 1, dataBytes, n));
|
||||
}
|
||||
}
|
||||
closeUDPSocket();
|
||||
closeUDPSocket(0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define MIN_REQRD_VRSN_T_RD_API 0x181130
|
||||
#define REQRD_FRMWR_VRSN 0x190402
|
||||
|
||||
#define CTRL_SRVR_INIT_TIME_US (1 * 1000 * 1000)
|
||||
#define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000)
|
||||
|
||||
/* Struct Definitions */
|
||||
typedef struct ip_header_struct {
|
||||
|
@ -36,6 +36,7 @@ int Beb_activated = 1;
|
||||
uint32_t Beb_detid = 0;
|
||||
int Beb_top =0;
|
||||
|
||||
uint64_t Beb_deactivatedStartFrameNumber = 0;
|
||||
|
||||
|
||||
void BebInfo_BebInfo(struct BebInfo* bebInfo, unsigned int beb_num) {
|
||||
@ -409,6 +410,10 @@ int Beb_Activate(int enable) {
|
||||
}
|
||||
|
||||
|
||||
int Beb_GetActivate() {
|
||||
return Beb_activated;
|
||||
}
|
||||
|
||||
int Beb_Set32bitOverflow(int val) {
|
||||
if (!Beb_activated)
|
||||
return val;
|
||||
@ -1262,6 +1267,62 @@ int Beb_SetDetectorPosition(int pos[]) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Beb_SetStartingFrameNumber(uint64_t value) {
|
||||
if (!Beb_activated) {
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Setting start frame number: %llu\n", (long long unsigned int)value));
|
||||
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
// since the read is not implemented in firmware yet
|
||||
Beb_deactivatedStartFrameNumber = value;
|
||||
|
||||
// decrement for firmware
|
||||
uint64_t valueInFirmware = value - 1;
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_LSB_OFST, valueInFirmware & (0xffffffff));
|
||||
Beb_Write32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST, (valueInFirmware >> 32) & (0xffffffff));
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
|
||||
uint64_t retval = -1;
|
||||
if ((Beb_GetStartingFrameNumber(&retval) == OK) && (retval == value)) {
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
int Beb_GetStartingFrameNumber(uint64_t* retval) {
|
||||
if (!Beb_activated) {
|
||||
*retval = Beb_deactivatedStartFrameNumber;
|
||||
return OK;
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Getting start frame number\n"));
|
||||
|
||||
// since it is not implemented in firmware yet
|
||||
*retval = Beb_deactivatedStartFrameNumber;
|
||||
/*
|
||||
u_int32_t* csp0base = 0;
|
||||
int fd = Beb_open(&csp0base, XPAR_PLB_GPIO_TEST_BASEADDR);
|
||||
if (fd < 0) {
|
||||
FILE_LOG(logERROR, ("Set Start Frame Number FAIL\n"));
|
||||
return FAIL;
|
||||
} else {
|
||||
*retval = Beb_Read32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST);
|
||||
uint32_t lretval = Beb_Read32(csp0base, UDP_HEADER_FRAME_NUMBER_MSB_OFST);
|
||||
*retval = (*retval << 32) | lretval;
|
||||
Beb_close(fd,csp0base);
|
||||
}
|
||||
*/
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
uint16_t Beb_swap_uint16( uint16_t val) {
|
||||
return (val << 8) | (val >> 8 );
|
||||
|
@ -39,6 +39,7 @@ void Beb_EndofDataSend(int tengiga);
|
||||
int Beb_SetMasterViaSoftware();
|
||||
int Beb_SetSlaveViaSoftware();
|
||||
int Beb_Activate(int enable);
|
||||
int Beb_GetActivate();
|
||||
int Beb_Set32bitOverflow(int val);
|
||||
int Beb_SetNetworkParameter(enum NETWORKINDEX mode, int val);
|
||||
int Beb_ResetToHardwareSettings();
|
||||
@ -74,6 +75,8 @@ int Beb_GetBebFPGATemp();
|
||||
|
||||
void Beb_SetDetectorNumber(uint32_t detid);
|
||||
int Beb_SetDetectorPosition(int pos[]);
|
||||
int Beb_SetStartingFrameNumber(uint64_t value);
|
||||
int Beb_GetStartingFrameNumber(uint64_t* retval);
|
||||
|
||||
uint16_t Beb_swap_uint16( uint16_t val);
|
||||
int Beb_open(u_int32_t** csp0base, u_int32_t offset);
|
||||
|
57
slsDetectorServers/eigerDetectorServer/CMakeLists.txt
Normal file
57
slsDetectorServers/eigerDetectorServer/CMakeLists.txt
Normal file
@ -0,0 +1,57 @@
|
||||
set(src
|
||||
slsDetectorFunctionList.c
|
||||
slsDetectorServer.c
|
||||
slsDetectorServer_funcs.c
|
||||
communication_funcs.c
|
||||
)
|
||||
|
||||
add_executable(eigerDetectorServerMaster
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerMaster
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerMaster
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL DVIRTUAL_9M
|
||||
PUBLIC VIRTUAL_MASTER
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerMaster
|
||||
PUBLIC pthread rt
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerMaster PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerMaster
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
||||
|
||||
add_executable(eigerDetectorServerSlave
|
||||
${src}
|
||||
)
|
||||
|
||||
target_include_directories(eigerDetectorServerSlave
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(eigerDetectorServerSlave
|
||||
PUBLIC EIGERD PCCOMPILE STOP_SERVER
|
||||
PUBLIC VIRTUAL DVIRTUAL_9M
|
||||
)
|
||||
|
||||
target_link_libraries(eigerDetectorServerSlave
|
||||
PUBLIC pthread rt
|
||||
)
|
||||
|
||||
set_target_properties(eigerDetectorServerSlave PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS eigerDetectorServerSlave
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
@ -202,8 +202,9 @@
|
||||
#define UDP_HEADER_Y_OFST (16)
|
||||
#define UDP_HEADER_Y_MSK (0xFFFF << UDP_HEADER_Y_OFST)
|
||||
|
||||
|
||||
|
||||
// udp header (frame number)
|
||||
#define UDP_HEADER_FRAME_NUMBER_LSB_OFST (0x0140)
|
||||
#define UDP_HEADER_FRAME_NUMBER_MSB_OFST (0x0160)
|
||||
|
||||
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
CC = gcc
|
||||
CFLAGS += -Wall -DEIGERD -DPCCOMPILE -DSTOP_SERVER #-DVERBOSE
|
||||
CFLAGS += -DVIRTUAL -DVIRTUAL_9M
|
||||
MASTERFLAG += -DVIRTUAL_MASTER
|
||||
LDLIBS += -lm -lstdc++ -pthread
|
||||
|
||||
DESTDIR ?= bin
|
||||
|
||||
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
|
||||
|
||||
|
||||
|
||||
all: clean master slave
|
||||
|
||||
|
||||
master: $(SRC_CLNT)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o eigerDetectorServer_virtualMaster $(SRC_CLNT) $(CFLAGS) $(MASTERFLAG) $(LDLIBS)
|
||||
mv eigerDetectorServer_virtualMaster $(DESTDIR)
|
||||
|
||||
slave: $(SRC_CLNT)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o eigerDetectorServer_virtualSlave $(SRC_CLNT) $(CFLAGS) $(LDLIBS)
|
||||
mv eigerDetectorServer_virtualSlave $(DESTDIR)
|
||||
|
||||
clean:
|
||||
rm -rf $(DESTDIR)/eigerDetectorServer_virtualMaster $(DESTDIR)/eigerDetectorServer_virtualSlave *.o
|
||||
|
Binary file not shown.
Binary file not shown.
1
slsDetectorServers/eigerDetectorServer/communication_funcs_UDP.h
Symbolic link
1
slsDetectorServers/eigerDetectorServer/communication_funcs_UDP.h
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServer/communication_funcs_UDP.h
|
@ -11,6 +11,7 @@
|
||||
#include <unistd.h> //to gethostname
|
||||
#include <string.h>
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
@ -84,6 +85,7 @@ int eiger_virtual_status=0;
|
||||
int eiger_virtual_activate=1;
|
||||
pthread_t eiger_virtual_tid;
|
||||
int eiger_virtual_stop = 0;
|
||||
uint64_t eiger_virtual_startingframenumber = 0;
|
||||
#endif
|
||||
|
||||
|
||||
@ -182,11 +184,8 @@ void basictests() {
|
||||
/* Ids */
|
||||
|
||||
int64_t getDetectorId(enum idMode arg) {
|
||||
#ifdef VIRTUAL
|
||||
return 0;
|
||||
#else
|
||||
int64_t retval = -1;
|
||||
|
||||
int64_t retval = -1;
|
||||
switch(arg) {
|
||||
case DETECTOR_SERIAL_NUMBER:
|
||||
retval = getDetectorNumber();/** to be implemented with mac? */
|
||||
@ -203,7 +202,7 @@ int64_t getDetectorId(enum idMode arg) {
|
||||
}
|
||||
|
||||
return retval;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
u_int64_t getFirmwareVersion() {
|
||||
@ -446,6 +445,7 @@ void setupDetector() {
|
||||
setSpeed(CLOCK_DIVIDER, DEFAULT_CLK_SPEED);//clk_devider,half speed
|
||||
setIODelay(DEFAULT_IO_DELAY);
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
setStartingFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
|
||||
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
|
||||
setRateCorrection(DEFAULT_RATE_CORRECTION);
|
||||
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
|
||||
@ -660,6 +660,24 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val) {
|
||||
|
||||
/* parameters - timer */
|
||||
|
||||
int setStartingFrameNumber(uint64_t value) {
|
||||
#ifdef VIRTUAL
|
||||
eiger_virtual_startingframenumber = value;
|
||||
return OK;
|
||||
#else
|
||||
return Beb_SetStartingFrameNumber(value);
|
||||
#endif
|
||||
}
|
||||
|
||||
int getStartingFrameNumber(uint64_t* retval) {
|
||||
#ifdef VIRTUAL
|
||||
*retval = eiger_virtual_startingframenumber;
|
||||
return OK;
|
||||
#else
|
||||
return Beb_GetStartingFrameNumber(retval);
|
||||
#endif
|
||||
}
|
||||
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
#ifndef VIRTUAL
|
||||
int64_t subdeadtime = 0;
|
||||
@ -1026,6 +1044,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
int dacval = 0;
|
||||
if (!mV) {
|
||||
(detectorModules)->dacs[ind] = val;
|
||||
}
|
||||
@ -1213,7 +1232,21 @@ enum externalCommunicationMode getTiming() {
|
||||
/* configure mac */
|
||||
|
||||
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2) {
|
||||
#ifndef VIRTUAL
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d, port2:%d)\n", cDestIp, udpport, udpport2));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
if (setUDPDestinationDetails(1, cDestIp, udpport2) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port2\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#else
|
||||
FILE_LOG(logINFO, ("Configuring MAC\n"));
|
||||
|
||||
int src_port = DEFAULT_UDP_SOURCE_PORT;
|
||||
@ -1596,8 +1629,6 @@ int prepareAcquisition() {
|
||||
#ifndef VIRTUAL
|
||||
FILE_LOG(logINFO, ("Going to prepare for acquisition with counter_bit:%d\n",Feb_Control_Get_Counter_Bit()));
|
||||
Feb_Control_PrepareForAcquisition();
|
||||
FILE_LOG(logINFO, ("Going to reset Frame Number\n"));
|
||||
Beb_ResetFrameNumber();
|
||||
#endif
|
||||
return OK;
|
||||
|
||||
@ -1606,6 +1637,14 @@ int prepareAcquisition() {
|
||||
|
||||
int startStateMachine() {
|
||||
#ifdef VIRTUAL
|
||||
// create udp socket
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
if(createUDPSocket(1) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
eiger_virtual_status = 1;
|
||||
eiger_virtual_stop = 0;
|
||||
if (pthread_create(&eiger_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
@ -1638,23 +1677,109 @@ int startStateMachine() {
|
||||
FILE_LOG(logINFOGREEN, ("Acquisition started\n"));
|
||||
}
|
||||
|
||||
/*while(getRunStatus() == IDLE) {FILE_LOG(logINFO, ("waiting for being not idle anymore\n"));}*/
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
eiger_virtual_status = 1;
|
||||
int wait_in_s = nimages_per_request * eiger_virtual_period;
|
||||
FILE_LOG(logINFO, ("going to wait for %d s\n", wait_in_s));
|
||||
while(!eiger_virtual_stop && (wait_in_s >= 0)) {
|
||||
usleep(1000 * 1000);
|
||||
wait_in_s--;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Virtual Timer Done***\n"));
|
||||
int64_t periodns = eiger_virtual_period;
|
||||
int numFrames = nimages_per_request;
|
||||
int64_t exp_ns = eiger_virtual_exptime;
|
||||
|
||||
int dr = eiger_dynamicrange;
|
||||
double bytesPerPixel = (double)dr/8.00;
|
||||
int tgEnable = send_to_ten_gig;
|
||||
int datasize = (tgEnable ? 4096 : 1024);
|
||||
int packetsize = datasize + sizeof(sls_detector_header);
|
||||
int numPacketsPerFrame = (tgEnable ? 4 : 16) * dr;
|
||||
int npixelsx = 256 * 2 * bytesPerPixel;
|
||||
int databytes = 256 * 256 * 2 * bytesPerPixel;
|
||||
FILE_LOG(logINFO, (" dr:%f\n bytesperpixel:%d\n tgenable:%d\n datasize:%d\n packetsize:%d\n numpackes:5d\n npixelsx:%d\n databytes:%d\n",
|
||||
dr, bytesPerPixel, tgEnable, datasize, packetsize, numPacketsPerFrame, npixelsx, databytes));
|
||||
|
||||
|
||||
//TODO: Generate data
|
||||
char imageData[databytes * 2];
|
||||
memset(imageData, 0, databytes * 2);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < databytes * 2; i += sizeof(uint8_t)) {
|
||||
*((uint8_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//TODO: Send data
|
||||
{
|
||||
int frameNr = 1;
|
||||
for(frameNr=1; frameNr <= numFrames; ++frameNr ) {
|
||||
int srcOffset = 0;
|
||||
int srcOffset2 = npixelsx;
|
||||
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
|
||||
usleep(exp_ns / 1000);
|
||||
|
||||
char packetData[packetsize];
|
||||
memset(packetData, 0, packetsize);
|
||||
char packetData2[packetsize];
|
||||
memset(packetData2, 0, packetsize);
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 0; i != numPacketsPerFrame; ++i) {
|
||||
int dstOffset = sizeof(sls_detector_header);
|
||||
int dstOffset2 = sizeof(sls_detector_header);
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
header = (sls_detector_header*)(packetData2);
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
// fill data
|
||||
{
|
||||
int psize = 0;
|
||||
for (psize = 0; psize < datasize; psize += npixelsx) {
|
||||
if (dr == 32 && tgEnable == 0) {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset, npixelsx/2);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2, npixelsx/2);
|
||||
srcOffset += npixelsx;
|
||||
srcOffset2 += npixelsx;
|
||||
dstOffset += npixelsx/2;
|
||||
dstOffset2 += npixelsx/2;
|
||||
} else {
|
||||
memcpy(packetData + dstOffset, imageData + srcOffset, npixelsx);
|
||||
memcpy(packetData2 + dstOffset2, imageData + srcOffset2, npixelsx);
|
||||
srcOffset += 2 * npixelsx;
|
||||
srcOffset2 += 2 * npixelsx;
|
||||
dstOffset += npixelsx;
|
||||
dstOffset2 += npixelsx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sendUDPPacket(0, packetData, packetsize);
|
||||
sendUDPPacket(1, packetData2, packetsize);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closeUDPSocket(0);
|
||||
closeUDPSocket(1);
|
||||
|
||||
eiger_virtual_status = 0;
|
||||
return NULL;
|
||||
}
|
||||
@ -1662,6 +1787,7 @@ void* start_timer(void* arg) {
|
||||
|
||||
|
||||
|
||||
|
||||
int stopStateMachine() {
|
||||
FILE_LOG(logINFORED, ("Going to stop acquisition\n"));
|
||||
#ifdef VIRTUAL
|
||||
@ -1749,10 +1875,6 @@ enum runStatus getRunStatus() {
|
||||
|
||||
void readFrame(int *ret, char *mess) {
|
||||
#ifdef VIRTUAL
|
||||
while(eiger_virtual_status) {
|
||||
//FILE_LOG(logERROR ,"Waiting for finished flag\n"));
|
||||
usleep(5000);
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
return;
|
||||
#else
|
||||
@ -1857,12 +1979,3 @@ int getTotalNumberOfChannels() {return ((int)getNumberOfChannelsPerChip() * (in
|
||||
int getNumberOfChips() {return NCHIP;}
|
||||
int getNumberOfDACs() {return NDAC;}
|
||||
int getNumberOfChannelsPerChip() {return NCHAN;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -51,6 +51,7 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_NUM_FRAMES (1)
|
||||
#define DEFAULT_STARTING_FRAME_NUMBER (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_EXPTIME (1E9) //ns
|
||||
#define DEFAULT_PERIOD (1E9) //ns
|
||||
@ -74,6 +75,8 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
|
||||
#define DEFAULT_TEST_MODE (0)
|
||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||
|
||||
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
|
||||
|
||||
#define DAC_MIN_MV (0)
|
||||
#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)
|
||||
|
26
slsDetectorServers/jungfrauDetectorServer/CMakeLists.txt
Normal file
26
slsDetectorServers/jungfrauDetectorServer/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
add_executable(jungfrauDetectorServer
|
||||
slsDetectorFunctionList.c
|
||||
slsDetectorServer.c
|
||||
slsDetectorServer_funcs.c
|
||||
communication_funcs.c
|
||||
)
|
||||
|
||||
target_include_directories(jungfrauDetectorServer
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
target_compile_definitions(jungfrauDetectorServer
|
||||
PUBLIC JUNGFRAUD VIRTUAL STOP_SERVER
|
||||
)
|
||||
|
||||
target_link_libraries(jungfrauDetectorServer
|
||||
PUBLIC pthread rt
|
||||
)
|
||||
|
||||
set_target_properties(jungfrauDetectorServer PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
|
||||
install(TARGETS jungfrauDetectorServer
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
)
|
@ -1,27 +0,0 @@
|
||||
CC = gcc
|
||||
CFLAGS += -Wall -DJUNGFRAUD -DVIRTUAL -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
|
||||
LDLIBS += -lm -lstdc++ -pthread
|
||||
|
||||
PROGS = jungfrauDetectorServer_virtual
|
||||
DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
|
||||
OBJS = $(SRC_CLNT:.c=.o)
|
||||
|
||||
all: clean versioning $(PROGS)
|
||||
|
||||
boot: $(OBJS)
|
||||
|
||||
versioning:
|
||||
@echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
|
||||
|
||||
$(PROGS): $(OBJS)
|
||||
# echo $(OBJS)
|
||||
mkdir -p $(DESTDIR)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDLIBS)
|
||||
mv $(PROGS) $(DESTDIR)
|
||||
|
||||
clean:
|
||||
rm -rf $(DESTDIR)/$(PROGS) *.o
|
||||
|
@ -388,6 +388,10 @@
|
||||
#define SET_EXPTIME_LSB_REG (0x68 << MEM_MAP_SHIFT)
|
||||
#define SET_EXPTIME_MSB_REG (0x69 << MEM_MAP_SHIFT)
|
||||
|
||||
/* Frame number 64 bit register */
|
||||
#define FRAME_NUMBER_LSB_REG (0x6A << MEM_MAP_SHIFT)
|
||||
#define FRAME_NUMBER_MSB_REG (0x6B << MEM_MAP_SHIFT)
|
||||
|
||||
/* Trigger Delay 32 bit register */
|
||||
#define SET_TRIGGER_DELAY_LSB_REG (0x70 << MEM_MAP_SHIFT)
|
||||
#define SET_TRIGGER_DELAY_MSB_REG (0x71 << MEM_MAP_SHIFT)
|
||||
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
../slsDetectorServer/communication_funcs_UDP.h
|
@ -1,7 +1,7 @@
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "versionAPI.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <sys/select.h>
|
||||
#include "AD9257.h" // commonServerFunctions.h, blackfin.h, ansi.h
|
||||
#include "LTC2620.h" // dacs
|
||||
#include "MAX1932.h" // hv
|
||||
@ -9,6 +9,7 @@
|
||||
#ifndef VIRTUAL
|
||||
#include "programfpga.h"
|
||||
#else
|
||||
#include "communication_funcs_UDP.h"
|
||||
#include "blackfin.h"
|
||||
#include <string.h>
|
||||
#include <unistd.h> // usleep
|
||||
@ -440,6 +441,7 @@ void setupDetector() {
|
||||
selectStoragecellStart(DEFAULT_STRG_CLL_STRT);
|
||||
/*setClockDivider(HALF_SPEED); depends if all the previous stuff works*/
|
||||
setTiming(DEFAULT_TIMING_MODE);
|
||||
setStartingFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
|
||||
|
||||
|
||||
// temp threshold and reset event
|
||||
@ -554,6 +556,20 @@ int selectStoragecellStart(int pos) {
|
||||
return ((bus_r(DAQ_REG) & DAQ_STRG_CELL_SLCT_MSK) >> DAQ_STRG_CELL_SLCT_OFST);
|
||||
}
|
||||
|
||||
int setStartingFrameNumber(uint64_t value) {
|
||||
FILE_LOG(logINFO, ("Setting starting frame number: %llu\n",(long long unsigned int)value));
|
||||
// decrement is for firmware
|
||||
setU64BitReg(value - 1, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
|
||||
// need to set it twice for the firmware to catch
|
||||
setU64BitReg(value - 1, FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getStartingFrameNumber(uint64_t* retval) {
|
||||
// increment is for firmware
|
||||
*retval = (getU64BitReg(FRAME_NUMBER_LSB_REG, FRAME_NUMBER_MSB_REG) + 1);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val) {
|
||||
@ -1097,6 +1113,14 @@ int configureMAC(int numInterfaces, int selInterface,
|
||||
uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport,
|
||||
uint32_t destip2, uint64_t destmac2, uint64_t sourcemac2, uint32_t sourceip2, uint32_t udpport2) {
|
||||
#ifdef VIRTUAL
|
||||
char cDestIp[MAX_STR_LENGTH];
|
||||
memset(cDestIp, 0, MAX_STR_LENGTH);
|
||||
sprintf(cDestIp, "%d.%d.%d.%d", (destip>>24)&0xff,(destip>>16)&0xff,(destip>>8)&0xff,(destip)&0xff);
|
||||
FILE_LOG(logINFO, ("1G UDP: Destination (IP: %s, port:%d)\n", cDestIp, udpport));
|
||||
if (setUDPDestinationDetails(0, cDestIp, udpport) == FAIL) {
|
||||
FILE_LOG(logERROR, ("could not set udp destination IP and port\n"));
|
||||
return FAIL;
|
||||
}
|
||||
return OK;
|
||||
#endif
|
||||
FILE_LOG(logINFOBLUE, ("Configuring MAC\n"));
|
||||
@ -1437,7 +1461,7 @@ void setAdcPhase(int val, int degrees){
|
||||
alignDeserializer();
|
||||
}
|
||||
|
||||
int getPhase(degrees) {
|
||||
int getPhase(int degrees) {
|
||||
if (!degrees)
|
||||
return adcPhase;
|
||||
// convert back to degrees
|
||||
@ -1581,11 +1605,16 @@ int setNetworkParameter(enum NETWORKINDEX mode, int value) {
|
||||
|
||||
int startStateMachine(){
|
||||
#ifdef VIRTUAL
|
||||
// create udp socket
|
||||
if(createUDPSocket(0) != OK) {
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOBLUE, ("starting state machine\n"));
|
||||
virtual_status = 1;
|
||||
virtual_stop = 0;
|
||||
if(pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) {
|
||||
virtual_status = 0;
|
||||
FILE_LOG(logERROR, ("Could not start Virtual acquisition thread\n"));
|
||||
virtual_status = 0;
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Virtual Acquisition started\n"));
|
||||
@ -1606,16 +1635,69 @@ int startStateMachine(){
|
||||
|
||||
#ifdef VIRTUAL
|
||||
void* start_timer(void* arg) {
|
||||
int wait_in_s = (setTimer(FRAME_NUMBER, -1) *
|
||||
int64_t periodns = setTimer(FRAME_PERIOD, -1);
|
||||
int numFrames = (setTimer(FRAME_NUMBER, -1) *
|
||||
setTimer(CYCLES_NUMBER, -1) *
|
||||
(setTimer(STORAGE_CELL_NUMBER, -1) + 1) *
|
||||
(setTimer(FRAME_PERIOD, -1)/(1E9)));
|
||||
FILE_LOG(logDEBUG1, ("going to wait for %d s\n", wait_in_s));
|
||||
while(!virtual_stop && (wait_in_s >= 0)) {
|
||||
usleep(1000 * 1000);
|
||||
wait_in_s--;
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("Virtual Timer Done\n"));
|
||||
(setTimer(STORAGE_CELL_NUMBER, -1) + 1));
|
||||
int64_t exp_ns = setTimer(ACQUISITION_TIME, -1);
|
||||
|
||||
//TODO: Generate data
|
||||
char imageData[DATA_BYTES];
|
||||
memset(imageData, 0, DATA_BYTES);
|
||||
{
|
||||
int i = 0;
|
||||
for (i = 0; i < DATA_BYTES; i += sizeof(uint16_t)) {
|
||||
*((uint16_t*)(imageData + i)) = i;
|
||||
}
|
||||
}
|
||||
int datasize = 8192;
|
||||
|
||||
|
||||
//TODO: Send data
|
||||
{
|
||||
int frameNr = 0;
|
||||
for(frameNr=0; frameNr!= numFrames; ++frameNr ) {
|
||||
int srcOffset = 0;
|
||||
|
||||
struct timespec begin, end;
|
||||
clock_gettime(CLOCK_REALTIME, &begin);
|
||||
|
||||
usleep(exp_ns / 1000);
|
||||
|
||||
const int size = datasize + 112;
|
||||
char packetData[size];
|
||||
memset(packetData, 0, sizeof(sls_detector_header));
|
||||
|
||||
// loop packet
|
||||
{
|
||||
int i = 0;
|
||||
for(i=0; i!=128; ++i) {
|
||||
// set header
|
||||
sls_detector_header* header = (sls_detector_header*)(packetData);
|
||||
header->frameNumber = frameNr;
|
||||
header->packetNumber = i;
|
||||
// fill data
|
||||
memcpy(packetData + sizeof(sls_detector_header), imageData + srcOffset, datasize);
|
||||
srcOffset += datasize;
|
||||
|
||||
sendUDPPacket(0, packetData, size);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO, ("Sent frame: %d\n", frameNr));
|
||||
clock_gettime(CLOCK_REALTIME, &end);
|
||||
int64_t time_ns = ((end.tv_sec - begin.tv_sec) * 1E9 +
|
||||
(end.tv_nsec - begin.tv_nsec));
|
||||
|
||||
if (periodns > time_ns) {
|
||||
usleep((periodns - time_ns)/ 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
|
||||
closeUDPSocket(0);
|
||||
|
||||
virtual_status = 0;
|
||||
return NULL;
|
||||
@ -1694,10 +1776,7 @@ enum runStatus getRunStatus(){
|
||||
|
||||
void readFrame(int *ret, char *mess){
|
||||
#ifdef VIRTUAL
|
||||
while(virtual_status) {
|
||||
//FILE_LOG(logERROR, ("Waiting for finished flag\n");
|
||||
usleep(5000);
|
||||
}
|
||||
FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n"));
|
||||
return;
|
||||
#endif
|
||||
// wait for status to be done
|
||||
@ -1745,5 +1824,3 @@ int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int
|
||||
int getNumberOfChips(){return NCHIP;}
|
||||
int getNumberOfDACs(){return NDAC;}
|
||||
int getNumberOfChannelsPerChip(){return NCHAN;}
|
||||
|
||||
|
||||
|
@ -63,6 +63,7 @@ enum NETWORKINDEX { TXN_FRAME, FLOWCTRL_10G };
|
||||
|
||||
/** Default Parameters */
|
||||
#define DEFAULT_NUM_FRAMES (100*1000*1000)
|
||||
#define DEFAULT_STARTING_FRAME_NUMBER (1)
|
||||
#define DEFAULT_NUM_CYCLES (1)
|
||||
#define DEFAULT_EXPTIME (10*1000) //ns
|
||||
#define DEFAULT_PERIOD (2*1000*1000) //ns
|
||||
|
@ -97,6 +97,29 @@ int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Read unsigned 64 bit from a 64 bit register
|
||||
* @param aLSB LSB offset address
|
||||
* @param aMSB MSB offset address
|
||||
* @returns unsigned 64 bit data read
|
||||
*/
|
||||
uint64_t getU64BitReg(int aLSB, int aMSB){
|
||||
uint64_t retval = bus_r(aMSB);
|
||||
retval = (retval << 32) | bus_r(aLSB);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write unsigned 64 bit into a 64 bit register
|
||||
* @param value unsigned 64 bit data
|
||||
* @param aLSB LSB offset address
|
||||
* @param aMSB MSB offset address
|
||||
*/
|
||||
void setU64BitReg(uint64_t value, int aLSB, int aMSB){
|
||||
bus_w(aLSB, value & (0xffffffff));
|
||||
bus_w(aMSB, (value >> 32) & (0xffffffff));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read from a 32 bit register (literal register value provided by client)
|
||||
* @param offset address offset
|
||||
|
@ -4,8 +4,12 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <sys/select.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
|
||||
#define SEND_REC_MAX_SIZE 4096
|
||||
#define DEFAULT_PORTNO 1952
|
||||
#define DEFAULT_BACKLOG 5
|
||||
|
@ -15,25 +15,25 @@
|
||||
#include <errno.h>
|
||||
#include <netdb.h>
|
||||
|
||||
int udpSockfd = -1;
|
||||
struct addrinfo* udpServerAddrInfo = 0;
|
||||
unsigned short int udpDestinationPort = 0;
|
||||
char udpDestinationIp[MAX_STR_LENGTH] = "";
|
||||
int udpSockfd[2] = {-1, -1};
|
||||
struct addrinfo* udpServerAddrInfo[2] = {0, 0};
|
||||
unsigned short int udpDestinationPort[2] = {0, 0};
|
||||
char udpDestinationIp[2][MAX_STR_LENGTH] = {"", ""};
|
||||
|
||||
//DEFAULT_TX_UDP_PORT;// src port
|
||||
int getUdPSocketDescriptor() {
|
||||
return udpSockfd;
|
||||
int getUdPSocketDescriptor(int index) {
|
||||
return udpSockfd[index];
|
||||
}
|
||||
|
||||
int setUDPDestinationDetails(const char* ip, unsigned short int port) {
|
||||
udpDestinationPort = port;
|
||||
int setUDPDestinationDetails(int index, const char* ip, unsigned short int port) {
|
||||
udpDestinationPort[index] = port;
|
||||
size_t len = strlen(ip);
|
||||
memset(udpDestinationIp, 0, MAX_STR_LENGTH);
|
||||
strncpy(udpDestinationIp, ip, len > MAX_STR_LENGTH ? MAX_STR_LENGTH : len );
|
||||
memset(udpDestinationIp[index], 0, MAX_STR_LENGTH);
|
||||
strncpy(udpDestinationIp[index], ip, len > MAX_STR_LENGTH ? MAX_STR_LENGTH : len );
|
||||
|
||||
if (udpServerAddrInfo) {
|
||||
freeaddrinfo(udpServerAddrInfo);
|
||||
udpServerAddrInfo = 0;
|
||||
if (udpServerAddrInfo[index]) {
|
||||
freeaddrinfo(udpServerAddrInfo[index]);
|
||||
udpServerAddrInfo[index] = 0;
|
||||
}
|
||||
|
||||
// convert ip to internet address
|
||||
@ -45,73 +45,73 @@ int setUDPDestinationDetails(const char* ip, unsigned short int port) {
|
||||
hints.ai_protocol = 0;
|
||||
char sport[100];
|
||||
memset(sport, 0, 100);
|
||||
sprintf(sport, "%d", udpDestinationPort);
|
||||
int err = getaddrinfo(udpDestinationIp, sport, &hints, &udpServerAddrInfo);
|
||||
sprintf(sport, "%d", udpDestinationPort[index]);
|
||||
int err = getaddrinfo(udpDestinationIp[index], sport, &hints, &udpServerAddrInfo[index]);
|
||||
if (err != 0) {
|
||||
FILE_LOG(logERROR, ("Failed to resolve remote socket address %s at port %d. "
|
||||
"(Error code:%d, %s)\n", udpDestinationIp, udpDestinationPort, err, gai_strerror(err)));
|
||||
"(Error code:%d, %s)\n", udpDestinationIp[index], udpDestinationPort[index], err, gai_strerror(err)));
|
||||
return FAIL;
|
||||
}
|
||||
if (udpServerAddrInfo == NULL) {
|
||||
if (udpServerAddrInfo[index] == NULL) {
|
||||
FILE_LOG(logERROR, ("Failed to resolve remote socket address %s at port %d "
|
||||
"(getaddrinfo returned NULL)\n", udpDestinationIp, udpDestinationPort));
|
||||
udpServerAddrInfo = 0;
|
||||
"(getaddrinfo returned NULL)\n", udpDestinationIp[index], udpDestinationPort[index]));
|
||||
udpServerAddrInfo[index] = 0;
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int createUDPSocket() {
|
||||
FILE_LOG(logDEBUG2, ("Creating UDP Socket\n"));
|
||||
if (!strlen(udpDestinationIp)) {
|
||||
int createUDPSocket(int index) {
|
||||
FILE_LOG(logDEBUG2, ("Creating UDP Socket %d\n", index));
|
||||
if (!strlen(udpDestinationIp[index])) {
|
||||
FILE_LOG(logERROR, ("No destination UDP ip specified.\n"));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (udpSockfd != -1) {
|
||||
if (udpSockfd[index] != -1) {
|
||||
FILE_LOG(logERROR, ("Strange that Udp socket was still open. Closing it to create a new one\n"));
|
||||
close(udpSockfd);
|
||||
udpSockfd = -1;
|
||||
close(udpSockfd[index]);
|
||||
udpSockfd[index] = -1;
|
||||
}
|
||||
|
||||
// Creating socket file descriptor
|
||||
udpSockfd = socket(udpServerAddrInfo->ai_family, udpServerAddrInfo->ai_socktype, udpServerAddrInfo->ai_protocol);
|
||||
if (udpSockfd == -1 ) {
|
||||
udpSockfd[index] = socket(udpServerAddrInfo[index]->ai_family, udpServerAddrInfo[index]->ai_socktype, udpServerAddrInfo[index]->ai_protocol);
|
||||
if (udpSockfd[index] == -1 ) {
|
||||
FILE_LOG(logERROR, ("UDP socket at port %d failed. (Error code:%d, %s)\n",
|
||||
udpDestinationPort, errno, gai_strerror(errno)));
|
||||
udpDestinationPort[index], errno, gai_strerror(errno)));
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG(logINFO, ("Udp client socket created for server (port %d, ip:%s)\n",
|
||||
udpDestinationPort, udpDestinationIp));
|
||||
udpDestinationPort[index], udpDestinationIp[index]));
|
||||
|
||||
// connecting allows to use "send/write" instead of "sendto", avoiding checking for server address for each packet
|
||||
// using write without a connect will end in segv
|
||||
if (connect(udpSockfd,udpServerAddrInfo->ai_addr, udpServerAddrInfo->ai_addrlen)==-1) {
|
||||
if (connect(udpSockfd[index],udpServerAddrInfo[index]->ai_addr, udpServerAddrInfo[index]->ai_addrlen)==-1) {
|
||||
FILE_LOG(logERROR, ("Could not connect to UDP server at ip:%s, port:%d. (Error code:%d, %s)\n",
|
||||
udpDestinationIp, udpDestinationPort, errno, gai_strerror(errno)));
|
||||
udpDestinationIp[index], udpDestinationPort[index], errno, gai_strerror(errno)));
|
||||
}
|
||||
FILE_LOG(logINFO, ("Udp client socket connected\n",
|
||||
udpDestinationPort, udpDestinationIp));
|
||||
udpDestinationPort[index], udpDestinationIp[index]));
|
||||
return OK;
|
||||
}
|
||||
|
||||
int sendUDPPacket(const char* buf, int length) {
|
||||
int n = write(udpSockfd, buf, length);
|
||||
int sendUDPPacket(int index, const char* buf, int length) {
|
||||
int n = write(udpSockfd[index], buf, length);
|
||||
// udp sends atomically, no need to handle partial data
|
||||
if (n == -1) {
|
||||
FILE_LOG(logERROR, ("Could not send udp packet. (Error code:%d, %s)\n",
|
||||
n, errno, gai_strerror(errno)));
|
||||
FILE_LOG(logERROR, ("Could not send udp packet for socket %d. (Error code:%d, %s)\n",
|
||||
index, n, errno, gai_strerror(errno)));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG2, ("%d bytes sent\n", n));
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void closeUDPSocket() {
|
||||
if (udpSockfd != -1) {
|
||||
void closeUDPSocket(int index) {
|
||||
if (udpSockfd[index] != -1) {
|
||||
FILE_LOG(logINFO, ("Udp client socket closed\n"));
|
||||
close(udpSockfd);
|
||||
udpSockfd = -1;
|
||||
close(udpSockfd[index]);
|
||||
udpSockfd[index] = -1;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h> // FILE
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/****************************************************
|
||||
This functions are used by the slsDetectroServer_funcs interface.
|
||||
@ -139,6 +139,10 @@ enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
||||
#ifdef JUNGFRAUD
|
||||
int selectStoragecellStart(int pos);
|
||||
#endif
|
||||
#if defined(JUNGFRAUD) || defined(EIGERD)
|
||||
int setStartingFrameNumber(uint64_t value);
|
||||
int getStartingFrameNumber(uint64_t* value);
|
||||
#endif
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val);
|
||||
int64_t getTimeLeft(enum timerIndex ind);
|
||||
#if defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(CHIPTESTBOARDD) || defined(MOENCHD)
|
||||
|
@ -30,7 +30,6 @@ void error(char *msg){
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
|
||||
// print version
|
||||
if (argc > 1 && !strcasecmp(argv[1], "-version")) {
|
||||
int version = 0;
|
||||
@ -142,4 +141,3 @@ int main(int argc, char *argv[]){
|
||||
FILE_LOG(logINFO,("Goodbye!\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -242,6 +242,8 @@ const char* getFunctionName(enum detFuncs func) {
|
||||
case F_GET_ADC_INVERT: return "F_GET_ADC_INVERT";
|
||||
case F_EXTERNAL_SAMPLING_SOURCE: return "F_EXTERNAL_SAMPLING_SOURCE";
|
||||
case F_EXTERNAL_SAMPLING: return "F_EXTERNAL_SAMPLING";
|
||||
case F_SET_STARTING_FRAME_NUMBER: return "F_SET_STARTING_FRAME_NUMBER";
|
||||
case F_GET_STARTING_FRAME_NUMBER: return "F_GET_STARTING_FRAME_NUMBER";
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
}
|
||||
@ -324,6 +326,8 @@ void function_table() {
|
||||
flist[F_GET_ADC_INVERT] = &get_adc_invert;
|
||||
flist[F_EXTERNAL_SAMPLING_SOURCE] = &set_external_sampling_source;
|
||||
flist[F_EXTERNAL_SAMPLING] = &set_external_sampling;
|
||||
flist[F_SET_STARTING_FRAME_NUMBER] = &set_starting_frame_number;
|
||||
flist[F_GET_STARTING_FRAME_NUMBER] = &get_starting_frame_number;
|
||||
|
||||
// check
|
||||
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
|
||||
@ -3999,3 +4003,79 @@ int set_external_sampling(int file_des) {
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT32, UPDATE, &retval, sizeof(retval));
|
||||
}
|
||||
|
||||
|
||||
|
||||
int set_starting_frame_number(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t arg = 0;
|
||||
|
||||
if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0)
|
||||
return printSocketReadError();
|
||||
FILE_LOG(logINFO, ("Setting starting frame number to %llu\n", arg));
|
||||
|
||||
#if (!defined(EIGERD)) && (!defined(JUNGFRAUD))
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// only set
|
||||
if (Server_VerifyLock() == OK) {
|
||||
if (arg == 0) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set starting frame number. Cannot be 0.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
#ifdef EIGERD
|
||||
else if (arg > UDP_HEADER_MAX_FRAME_VALUE) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set starting frame number. Must be less then %lld (0x%llx)\n", UDP_HEADER_MAX_FRAME_VALUE, UDP_HEADER_MAX_FRAME_VALUE);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
ret = setStartingFrameNumber(arg);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not set starting frame number. Failed to map address.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
if (ret == OK) {
|
||||
uint64_t retval = 0;
|
||||
ret = getStartingFrameNumber(&retval);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not get starting frame number. Failed to map address.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
if (arg != retval) {
|
||||
ret = FAIL;
|
||||
sprintf(mess, "Could not set starting frame number. Set 0x%llx, but read 0x%llx\n", arg, retval);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, UPDATE, NULL, 0);
|
||||
}
|
||||
|
||||
int get_starting_frame_number(int file_des) {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
uint64_t retval = -1;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Getting Starting frame number \n"));
|
||||
|
||||
#if (!defined(EIGERD)) && (!defined(JUNGFRAUD))
|
||||
functionNotImplemented();
|
||||
#else
|
||||
// get
|
||||
ret = getStartingFrameNumber(&retval);
|
||||
if (ret == FAIL) {
|
||||
sprintf(mess, "Could not get starting frame number. Failed to map address.\n");
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1, ("Start frame number retval: %u\n", retval));
|
||||
}
|
||||
#endif
|
||||
return Server_SendResult(file_des, INT64, UPDATE, &retval, sizeof(retval));
|
||||
}
|
@ -103,3 +103,5 @@ int set_adc_invert(int);
|
||||
int get_adc_invert(int);
|
||||
int set_external_sampling_source(int);
|
||||
int set_external_sampling(int);
|
||||
int set_starting_frame_number(int);
|
||||
int get_starting_frame_number(int);
|
@ -622,6 +622,20 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
* @returns OK or FAIL
|
||||
*/
|
||||
int configureMAC(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Set starting frame number for the next acquisition
|
||||
* @param val starting frame number
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
*/
|
||||
void setStartingFrameNumber(const uint64_t value, int detPos = -1);
|
||||
|
||||
/**
|
||||
* Get starting frame number for the next acquisition
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns starting frame number
|
||||
*/
|
||||
uint64_t getStartingFrameNumber(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Set/get timer value (not all implemented for all detectors)
|
||||
@ -1785,9 +1799,9 @@ class multiSlsDetector : public virtual slsDetectorDefs {
|
||||
/**
|
||||
* Gets the current frame index of receiver
|
||||
* @param detPos -1 for all detectors in list or specific detector position
|
||||
* @returns current frame index of receiver
|
||||
* @returns average of all current frame index of receiver
|
||||
*/
|
||||
int getReceiverCurrentFrameIndex(int detPos = -1);
|
||||
uint64_t getReceiverCurrentFrameIndex(int detPos = -1);
|
||||
|
||||
/**
|
||||
* Resets framescaught in receiver
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include "CmdLineParser.h"
|
||||
#include "CmdProxy.h"
|
||||
#include "container_utils.h"
|
||||
#include "string_utils.h"
|
||||
#include "multiSlsDetector.h"
|
||||
#include "slsDetectorCommand.h"
|
||||
#include "sls_detector_exceptions.h"
|
||||
#include "string_utils.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
@ -23,14 +23,17 @@ inline int dummyCallback(detectorData *d, int p, void *) {
|
||||
class multiSlsDetectorClient {
|
||||
public:
|
||||
multiSlsDetectorClient(int argc, char *argv[], int action,
|
||||
multiSlsDetector *myDetector = nullptr)
|
||||
: action_(action), detPtr(myDetector) {
|
||||
multiSlsDetector *myDetector = nullptr,
|
||||
std::ostream &output = std::cout)
|
||||
: action_(action), detPtr(myDetector), os(output) {
|
||||
parser.Parse(argc, argv);
|
||||
runCommand();
|
||||
|
||||
}
|
||||
multiSlsDetectorClient(const std::string &args, int action,
|
||||
multiSlsDetector *myDetector = nullptr)
|
||||
: action_(action), detPtr(myDetector) {
|
||||
multiSlsDetector *myDetector = nullptr,
|
||||
std::ostream &output = std::cout)
|
||||
: action_(action), detPtr(myDetector), os(output) {
|
||||
parser.Parse(args);
|
||||
runCommand();
|
||||
}
|
||||
@ -39,30 +42,31 @@ class multiSlsDetectorClient {
|
||||
int action_;
|
||||
CmdLineParser parser;
|
||||
multiSlsDetector *detPtr = nullptr;
|
||||
std::ostream &os;
|
||||
|
||||
void runCommand() {
|
||||
bool verify = true;
|
||||
bool update = true;
|
||||
if (action_ == slsDetectorDefs::PUT_ACTION &&
|
||||
parser.n_arguments() == 0) {
|
||||
std::cout << "Wrong usage - should be: " << parser.executable()
|
||||
<< "[id-][pos:]channel arg" << std::endl;
|
||||
std::cout << std::endl;
|
||||
os << "Wrong usage - should be: " << parser.executable()
|
||||
<< "[id-][pos:]channel arg" << std::endl;
|
||||
os << std::endl;
|
||||
return;
|
||||
};
|
||||
if (action_ == slsDetectorDefs::GET_ACTION &&
|
||||
parser.command().empty()) {
|
||||
std::cout << "Wrong usage - should be: " << parser.executable()
|
||||
<< "[id-][pos:]channel arg" << std::endl;
|
||||
std::cout << std::endl;
|
||||
os << "Wrong usage - should be: " << parser.executable()
|
||||
<< "[id-][pos:]channel arg" << std::endl;
|
||||
os << std::endl;
|
||||
return;
|
||||
};
|
||||
|
||||
if (action_ == slsDetectorDefs::READOUT_ACTION &&
|
||||
parser.detector_id() != -1) {
|
||||
std::cout << "detector_id: " << parser.detector_id()
|
||||
<< " ,readout of individual detectors is not allowed!"
|
||||
<< std::endl;
|
||||
os << "detector_id: " << parser.detector_id()
|
||||
<< " ,readout of individual detectors is not allowed!"
|
||||
<< std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -78,7 +82,6 @@ class multiSlsDetectorClient {
|
||||
update = false;
|
||||
}
|
||||
|
||||
// std::cout<<"id:"<<id<<" pos:"<<pos<<std::endl;
|
||||
// create multiSlsDetector class if required
|
||||
std::unique_ptr<multiSlsDetector> localDet;
|
||||
if (detPtr == nullptr) {
|
||||
@ -87,15 +90,15 @@ class multiSlsDetectorClient {
|
||||
verify, update);
|
||||
detPtr = localDet.get();
|
||||
} catch (const RuntimeError &e) {
|
||||
/*std::cout << e.GetMessage() << std::endl;*/
|
||||
/*os << e.GetMessage() << std::endl;*/
|
||||
return;
|
||||
} catch (...) {
|
||||
std::cout << " caught exception\n";
|
||||
os << " caught exception\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (parser.detector_id() >= detPtr->getNumberOfDetectors()) {
|
||||
std::cout << "position is out of bounds.\n";
|
||||
os << "position is out of bounds.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
@ -120,13 +123,13 @@ class multiSlsDetectorClient {
|
||||
action_, parser.detector_id());
|
||||
|
||||
if (parser.multi_id() != 0)
|
||||
std::cout << parser.multi_id() << '-';
|
||||
os << parser.multi_id() << '-';
|
||||
if (parser.detector_id() != -1)
|
||||
std::cout << parser.detector_id() << ':';
|
||||
os << parser.detector_id() << ':';
|
||||
|
||||
if (action_ != slsDetectorDefs::READOUT_ACTION) {
|
||||
std::cout << parser.command() << " ";
|
||||
os << parser.command() << " ";
|
||||
}
|
||||
std::cout << answer << std::endl;
|
||||
os << answer << std::endl;
|
||||
}
|
||||
};
|
||||
|
@ -730,6 +730,18 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
*/
|
||||
int configureMAC();
|
||||
|
||||
/**
|
||||
* Set starting frame number for the next acquisition
|
||||
* @param val starting frame number
|
||||
*/
|
||||
void setStartingFrameNumber(const uint64_t value);
|
||||
|
||||
/**
|
||||
* Get starting frame number for the next acquisition
|
||||
* @returns starting frame number
|
||||
*/
|
||||
uint64_t getStartingFrameNumber();
|
||||
|
||||
/**
|
||||
* Set/get timer value (not all implemented for all detectors)
|
||||
* @param index timer index
|
||||
@ -1695,7 +1707,7 @@ class slsDetector : public virtual slsDetectorDefs{
|
||||
* Gets the current frame index of receiver
|
||||
* @returns current frame index of receiver
|
||||
*/
|
||||
int getReceiverCurrentFrameIndex();
|
||||
uint64_t getReceiverCurrentFrameIndex();
|
||||
|
||||
/**
|
||||
* Resets framescaught in receiver
|
||||
|
@ -1057,6 +1057,34 @@ int multiSlsDetector::configureMAC(int detPos) {
|
||||
return sls::allEqualTo(r, static_cast<int>(OK)) ? OK : FAIL;
|
||||
}
|
||||
|
||||
void multiSlsDetector::setStartingFrameNumber(const uint64_t value, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->setStartingFrameNumber(value);
|
||||
}
|
||||
|
||||
// multi
|
||||
parallelCall(&slsDetector::setStartingFrameNumber, value);
|
||||
}
|
||||
|
||||
uint64_t multiSlsDetector::getStartingFrameNumber(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getStartingFrameNumber();
|
||||
}
|
||||
|
||||
// multi
|
||||
auto r = parallelCall(&slsDetector::getStartingFrameNumber);
|
||||
if (sls::allEqual(r)) {
|
||||
return r.front();
|
||||
}
|
||||
|
||||
// can't have different values for next acquisition
|
||||
std::ostringstream ss;
|
||||
ss << "Error: Different Values for starting frame number";
|
||||
throw RuntimeError(ss.str());
|
||||
}
|
||||
|
||||
int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t, int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
@ -3121,7 +3149,7 @@ int multiSlsDetector::getFramesCaughtByReceiver(int detPos) {
|
||||
return ((sls::sum(r)) / (int)detectors.size());
|
||||
}
|
||||
|
||||
int multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
|
||||
uint64_t multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
|
||||
// single
|
||||
if (detPos >= 0) {
|
||||
return detectors[detPos]->getReceiverCurrentFrameIndex();
|
||||
@ -3131,7 +3159,7 @@ int multiSlsDetector::getReceiverCurrentFrameIndex(int detPos) {
|
||||
auto r = parallelCall(&slsDetector::getReceiverCurrentFrameIndex);
|
||||
|
||||
// prevent divide by all or do not take avg when -1 for "did not connect"
|
||||
if ((detectors.empty()) || (sls::anyEqualTo(r, -1))) {
|
||||
if ((detectors.empty()) || (sls::anyEqualTo(r, static_cast<uint64_t>(-1)))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -3343,11 +3371,7 @@ void multiSlsDetector::readFrameFromReceiver() {
|
||||
(char *)image + (i * singledetrowoffset), singledetrowoffset);
|
||||
}
|
||||
} else {
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < nPixelsY; ++i) {
|
||||
std::cout << i << " " << ((yoffset + i) * rowoffset) + xoffset << " " << (i * singledetrowoffset) << " " << singledetrowoffset << std::endl;
|
||||
|
||||
memcpy(((char *)multiframe) + ((yoffset + i) * rowoffset) + xoffset,
|
||||
(char *)image + (i * singledetrowoffset), singledetrowoffset);
|
||||
}
|
||||
@ -3369,7 +3393,6 @@ void multiSlsDetector::readFrameFromReceiver() {
|
||||
}
|
||||
// normal pixels
|
||||
else {
|
||||
// std::cout << "creating detectorData" << std::endl;
|
||||
thisData = new detectorData(getCurrentProgress(), currentFileName.c_str(), nCompletePixelsX,
|
||||
nCompletePixelsY, multiframe, multisize, dynamicRange,
|
||||
currentFileIndex);
|
||||
|
@ -1497,6 +1497,23 @@ int slsDetector::configureMAC() {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void slsDetector::setStartingFrameNumber(const uint64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting starting frame number to " << value;
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
sendToDetector(F_SET_STARTING_FRAME_NUMBER, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t slsDetector::getStartingFrameNumber() {
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting starting frame number";
|
||||
if (shm()->onlineFlag == ONLINE_FLAG) {
|
||||
sendToDetector(F_GET_STARTING_FRAME_NUMBER, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "Starting frame number :" << retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
int ret = FAIL;
|
||||
int64_t args[]{static_cast<int64_t>(index), t};
|
||||
@ -1554,6 +1571,7 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
DIGITAL_SAMPLES,
|
||||
STORAGE_CELL_NUMBER};
|
||||
|
||||
// if in list (lambda)
|
||||
if (std::any_of(std::begin(rt), std::end(rt),
|
||||
[index](timerIndex t) { return t == index; })) {
|
||||
args[1] = shm()->timerValue[index];
|
||||
@ -1943,7 +1961,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
enableTenGigabitEthernet(shm()->tenGigaEnable);
|
||||
setReadOutFlags(GET_READOUT_FLAGS);
|
||||
break;
|
||||
|
||||
|
||||
case CHIPTESTBOARD:
|
||||
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
|
||||
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
|
||||
@ -3592,8 +3610,8 @@ int slsDetector::getFramesCaughtByReceiver() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getReceiverCurrentFrameIndex() {
|
||||
int retval = -1;
|
||||
uint64_t slsDetector::getReceiverCurrentFrameIndex() {
|
||||
uint64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Current Frame Index of Receiver";
|
||||
if (shm()->rxOnlineFlag == ONLINE_FLAG) {
|
||||
sendToReceiver(F_GET_RECEIVER_FRAME_INDEX, nullptr, retval);
|
||||
|
@ -596,6 +596,13 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>startingfnum [i]</b> sets/gets starting frame number for the next acquisition. Only for Jungfrau and Eiger. \c Returns \c (long long int)
|
||||
*/
|
||||
descrToFuncMap[i].m_pFuncName = "startingfnum";
|
||||
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdTimer;
|
||||
++i;
|
||||
|
||||
/*! \page timing
|
||||
- <b>cycles [i]</b> sets/gets number of triggers. Timing mode should be set appropriately. \c Returns \c (long long int)
|
||||
*/
|
||||
@ -4477,6 +4484,16 @@ std::string slsDetectorCommand::cmdTimer(int narg, const char * const args[], in
|
||||
}
|
||||
sprintf(answer, "%d", myDet->setStoragecellStart(-1, detPos));
|
||||
return std::string(answer);
|
||||
} else if (cmd == "startingfnum") {
|
||||
myDet->setOnline(ONLINE_FLAG, detPos);
|
||||
if (action == PUT_ACTION) {
|
||||
uint64_t ival = -1;
|
||||
if (!sscanf(args[1], "%lu", &ival))
|
||||
return std::string("cannot scan starting frame number value ") + std::string(args[1]);
|
||||
myDet->setStartingFrameNumber(ival, detPos);
|
||||
return std::string(args[1]);
|
||||
}
|
||||
return std::to_string(myDet->getStartingFrameNumber(detPos));
|
||||
} else
|
||||
return std::string("could not decode timer ") + cmd;
|
||||
|
||||
@ -4528,6 +4545,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
|
||||
os << "period t \t sets the frame period in s" << std::endl;
|
||||
os << "delay t \t sets the delay after trigger in s" << std::endl;
|
||||
os << "frames t \t sets the number of frames per cycle (e.g. after each trigger)" << std::endl;
|
||||
os << "startingfnum t \t sets starting frame number for the next acquisition. Only for Jungfrau and Eiger." << std::endl;
|
||||
os << "cycles t \t sets the number of cycles (e.g. number of triggers)" << std::endl;
|
||||
os << "samples t \t sets the number of samples (both analog and digital) expected from the ctb" << std::endl;
|
||||
os << "asamples t \t sets the number of analog samples expected from the ctb" << std::endl;
|
||||
@ -4545,6 +4563,7 @@ std::string slsDetectorCommand::helpTimer(int action) {
|
||||
os << "period \t gets the frame period in s" << std::endl;
|
||||
os << "delay \t gets the delay after trigger in s" << std::endl;
|
||||
os << "frames \t gets the number of frames per cycle (e.g. after each trigger)" << std::endl;
|
||||
os << "startingfnum \t gets starting frame number for the next acquisition. Only for Jungfrau and Eiger." << std::endl;
|
||||
os << "cycles \t gets the number of cycles (e.g. number of triggers)" << std::endl;
|
||||
os << "samples \t gets the number of samples (both analog and digital) expected from the ctb" << std::endl;
|
||||
os << "asamples \t gets the number of analog samples expected from the ctb" << std::endl;
|
||||
@ -5078,7 +5097,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
|
||||
if (action == PUT_ACTION)
|
||||
return std::string("cannot put");
|
||||
else {
|
||||
sprintf(answer, "%d", myDet->getReceiverCurrentFrameIndex(detPos));
|
||||
sprintf(answer, "%lu", myDet->getReceiverCurrentFrameIndex(detPos));
|
||||
return std::string(answer);
|
||||
}
|
||||
} else if (cmd == "r_readfreq") {
|
||||
|
@ -26,5 +26,6 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef HELP
|
||||
int action = slsDetectorDefs::HELP_ACTION;
|
||||
#endif
|
||||
|
||||
multiSlsDetectorClient(argc, argv, action);
|
||||
}
|
||||
|
@ -2,4 +2,5 @@ target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-SharedMemory.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-multiSlsDetector.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-multiSlsDetectorClient.cpp
|
||||
)
|
40
slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp
Normal file
40
slsDetectorSoftware/tests/test-multiSlsDetectorClient.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "catch.hpp"
|
||||
#include "multiSlsDetectorClient.h"
|
||||
#include "sls_detector_defs.h"
|
||||
#include <sstream>
|
||||
|
||||
auto GET = slsDetectorDefs::GET_ACTION;
|
||||
auto PUT = slsDetectorDefs::PUT_ACTION;
|
||||
|
||||
TEST_CASE("rx_fifodepth", "[.cmd]") {
|
||||
auto oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("rx_fifodepth 10", PUT, nullptr, oss);
|
||||
REQUIRE(oss.str() == "rx_fifodepth 10\n");
|
||||
|
||||
oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("rx_fifodepth 100", PUT, nullptr, oss);
|
||||
REQUIRE(oss.str() == "rx_fifodepth 100\n");
|
||||
|
||||
oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("rx_fifodepth", GET, nullptr, oss);
|
||||
REQUIRE(oss.str() == "rx_fifodepth 100\n");
|
||||
|
||||
oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("0:rx_fifodepth", GET, nullptr, oss);
|
||||
REQUIRE(oss.str() == "0:rx_fifodepth 100\n");
|
||||
}
|
||||
|
||||
TEST_CASE("frames", "[.cmd]"){
|
||||
auto oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("frames 1000", PUT, nullptr, oss);
|
||||
REQUIRE(oss.str() == "frames 1000\n");
|
||||
|
||||
oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("frames", GET, nullptr, oss);
|
||||
REQUIRE(oss.str() == "frames 1000\n");
|
||||
|
||||
oss = std::ostringstream{};
|
||||
multiSlsDetectorClient("frames 1", PUT, nullptr, oss);
|
||||
REQUIRE(oss.str() == "frames 1\n");
|
||||
|
||||
}
|
@ -92,7 +92,7 @@ if (SLS_USE_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif(SLS_USE_TESTS)
|
||||
|
||||
install(TARGETS slsReceiverShared
|
||||
install(TARGETS slsReceiverShared slsReceiver
|
||||
EXPORT "${TARGETS_EXPORT_NAME}"
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
|
@ -156,9 +156,9 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
|
||||
/**
|
||||
* Get Current Frame Index for an entire acquisition (including all scans)
|
||||
* @return -1 if no frames have been caught, else current frame index (represents all scans too)
|
||||
* @return 0 if no frames have been caught, else average of all current frame index
|
||||
*/
|
||||
int64_t getAcquisitionIndex() const;
|
||||
uint64_t getAcquisitionIndex() const;
|
||||
|
||||
|
||||
//***connection parameters***
|
||||
@ -586,7 +586,7 @@ class slsReceiverImplementation: private virtual slsDetectorDefs {
|
||||
* The data receiver status will change from running to idle when it gets this number of frames
|
||||
* @param i number of frames expected
|
||||
*/
|
||||
int setNumberOfFrames(const uint64_t i);
|
||||
void setNumberOfFrames(const uint64_t i);
|
||||
|
||||
/**
|
||||
* Set Number of Analog Samples expected by receiver from detector
|
||||
|
@ -249,7 +249,7 @@ uint64_t slsReceiverImplementation::getFramesCaught() const {
|
||||
return (sum/dataProcessor.size());
|
||||
}
|
||||
|
||||
int64_t slsReceiverImplementation::getAcquisitionIndex() const {
|
||||
uint64_t slsReceiverImplementation::getAcquisitionIndex() const {
|
||||
uint64_t sum = 0;
|
||||
uint32_t flagsum = 0;
|
||||
|
||||
@ -259,7 +259,7 @@ int64_t slsReceiverImplementation::getAcquisitionIndex() const {
|
||||
}
|
||||
//no data processed
|
||||
if (flagsum != dataProcessor.size())
|
||||
return -1;
|
||||
return 0;
|
||||
|
||||
return (sum/dataProcessor.size());
|
||||
}
|
||||
@ -963,13 +963,11 @@ void slsReceiverImplementation::setSubPeriod(const uint64_t i) {
|
||||
FILE_LOG(logINFO) << "Sub Exposure Period: " << (double)subPeriod/(1E9) << "s";
|
||||
}
|
||||
|
||||
int slsReceiverImplementation::setNumberOfFrames(const uint64_t i) {
|
||||
void slsReceiverImplementation::setNumberOfFrames(const uint64_t i) {
|
||||
FILE_LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||
|
||||
numberOfFrames = i;
|
||||
FILE_LOG(logINFO) << "Number of Frames: " << numberOfFrames;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1205,7 +1205,7 @@ int slsReceiverTCPIPInterface::set_file_index(sls::ServerInterface2 &socket) {
|
||||
int slsReceiverTCPIPInterface::get_frame_index(sls::ServerInterface2 &socket){
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int retval = -1;
|
||||
uint64_t retval = -1;
|
||||
|
||||
if(receiver == nullptr){
|
||||
NullObjectError(ret, mess);
|
||||
|
@ -87,6 +87,8 @@ enum detFuncs{
|
||||
F_GET_ADC_INVERT, /** < get adc invert reg */
|
||||
F_EXTERNAL_SAMPLING_SOURCE, /** < set/get external sampling source for ctb */
|
||||
F_EXTERNAL_SAMPLING, /**< enable/disable external sampling for ctb */
|
||||
F_SET_STARTING_FRAME_NUMBER,
|
||||
F_GET_STARTING_FRAME_NUMBER,
|
||||
NUM_DET_FUNCTIONS,
|
||||
|
||||
RECEIVER_ENUM_START = 128, /**< detector function should not exceed this (detector server should not compile anyway) */
|
||||
@ -227,7 +229,8 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
|
||||
case F_GET_ADC_INVERT: return "F_GET_ADC_INVERT";
|
||||
case F_EXTERNAL_SAMPLING_SOURCE: return "F_EXTERNAL_SAMPLING_SOURCE";
|
||||
case F_EXTERNAL_SAMPLING: return "F_EXTERNAL_SAMPLING";
|
||||
|
||||
case F_SET_STARTING_FRAME_NUMBER: return "F_SET_STARTING_FRAME_NUMBER";
|
||||
case F_GET_STARTING_FRAME_NUMBER: return "F_GET_STARTING_FRAME_NUMBER";
|
||||
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
|
||||
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#define APILIB 0x190405
|
||||
#define APIRECEIVER 0x190405
|
||||
#define APIGUI 0x190405
|
||||
#define APIEIGER 0x190516
|
||||
|
||||
#define APICTB 0x190528
|
||||
#define APIJUNGFRAU 0x190528
|
||||
#define APIEIGER 0x190531
|
||||
#define APIJUNGFRAU 0x190531
|
||||
#define APICTB 0x190603
|
||||
|
@ -65,7 +65,7 @@ int DataSocket::setReceiveTimeout(int us) {
|
||||
|
||||
int DataSocket::sendData(const void *buffer, size_t size) {
|
||||
int dataSent = 0;
|
||||
while (dataSent < size) {
|
||||
while (dataSent < (int)size) {
|
||||
dataSent +=
|
||||
write(getSocketId(), reinterpret_cast<const char *>(buffer) + dataSent,
|
||||
size - dataSent);
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
|
||||
struct SingleDetectorConfig {
|
||||
slsDetectorDefs::detectorType type_enum =
|
||||
slsDetectorDefs::detectorType::CHIPTESTBOARD;
|
||||
const std::string hostname = "bchip173";
|
||||
const std::string type_string = "Chiptestboard";
|
||||
slsDetectorDefs::detectorType type_enum = slsDetectorDefs::detectorType::EIGER;
|
||||
const std::string hostname = "beb031+beb032+";
|
||||
const std::string type_string = "Eiger";
|
||||
const std::string my_ip = "129.129.205.171";
|
||||
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user