diff --git a/CMakeLists.txt b/CMakeLists.txt index 60ac7bde0..d7d325436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,6 +232,8 @@ if (NOT TARGET slsProjectCSettings) -Wredundant-decls -Wdouble-promotion -Werror=return-type + -Wno-format-overflow + -Wno-format-truncation ) sls_disable_c_warning("-Wstringop-truncation") endif() diff --git a/python/slsdet/detector.py b/python/slsdet/detector.py index 8a900a588..717255564 100755 --- a/python/slsdet/detector.py +++ b/python/slsdet/detector.py @@ -414,7 +414,7 @@ class Detector(CppDetectorApi): @element def framecounter(self): """ - [Jungfrau][Moench][Mythen3][Gotthard2][CTB] Number of frames from start run control. + [Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx Ctb] Number of frames from start run control. Note ----- @@ -443,12 +443,13 @@ class Detector(CppDetectorApi): @element def powerchip(self): """ - [Jungfrau][Moench][Mythen3][Gotthard2] Power the chip. + [Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] Power the chip. Note ---- [Jungfrau][Moench] Default is disabled. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1).\n [Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail. + [Xilinx Ctb] Default is 0. Also configures the chip if powered on. """ return self.getPowerChip() @@ -456,6 +457,16 @@ class Detector(CppDetectorApi): def powerchip(self, value): ut.set_using_dict(self.setPowerChip, value) + def configtransceiver(self): + """ + [Xilinx Ctb] Waits for transceiver to be aligned. + + Note + ---- + Chip had to be configured (powered on) before this. + """ + self.configureTransceiver() + @property @element def triggers(self): @@ -620,7 +631,7 @@ class Detector(CppDetectorApi): @element def periodl(self): """ - [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Period left for current frame. + [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx Ctb] Period left for current frame. Note ----- @@ -642,7 +653,7 @@ class Detector(CppDetectorApi): @element def delay(self): """ - [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta + [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx Ctb] Delay after trigger, accepts either a value in seconds, DurationWrapper or datetime.timedelta :getter: always returns in seconds. To get in DurationWrapper, use getDelayAfterTrigger @@ -684,7 +695,7 @@ class Detector(CppDetectorApi): @element def delayl(self): """ - [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] Delay left after trigger during acquisition, accepts either a value in seconds, datetime.timedelta or DurationWrapper + [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx Ctb] Delay left after trigger during acquisition, accepts either a value in seconds, datetime.timedelta or DurationWrapper Note ----- @@ -732,7 +743,7 @@ class Detector(CppDetectorApi): @property @element def nextframenumber(self): - """[Eiger][Jungfrau][Moench][CTB] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """ + """[Eiger][Jungfrau][Moench][CTB][Xilinx CTB] Next frame number. Stopping acquisition might result in different frame numbers for different modules. """ return self.getNextFrameNumber() @nextframenumber.setter @@ -1964,7 +1975,7 @@ class Detector(CppDetectorApi): @property @element def frametime(self): - """[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Timestamp at a frame start. + """[Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx Ctb] Timestamp at a frame start. Note ---- @@ -2602,7 +2613,7 @@ class Detector(CppDetectorApi): @property @element def runtime(self): - """[Jungfrau][Moench][Mythen3][Gotthard2][CTB] Time from detector start up. + """[Jungfrau][Moench][Mythen3][Gotthard2][CTB][Xilinx Ctb] Time from detector start up. Note ----- @@ -3237,7 +3248,7 @@ class Detector(CppDetectorApi): @property @element def transceiverenable(self): - """[Ctb] Transceiver Enable Mask. Enable for each 4 transceiver channel.""" + """[CTB][Xilinx CTB] Transceiver Enable Mask. Enable for each 4 transceiver channel.""" return self.getTransceiverEnableMask() @transceiverenable.setter @@ -3276,8 +3287,10 @@ class Detector(CppDetectorApi): Note ------ - Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL, TRANSCEIVER_ONLY, DIGITAL_AND_TRANSCEIVER - Default: ANALOG_ONLY + [CTB] Options: ANALOG_ONLY, DIGITAL_ONLY, ANALOG_AND_DIGITAL, TRANSCEIVER_ONLY, DIGITAL_AND_TRANSCEIVER + [CTB] Default: ANALOG_ONLY + [Xilinx CTB] Options: TRANSCEIVER_ONLY + [Xilinx CTB] Default: TRANSCEIVER_ONLY Example -------- @@ -3314,7 +3327,7 @@ class Detector(CppDetectorApi): @property @element def tsamples(self): - """[CTB] Number of transceiver samples expected. """ + """[CTB][Xilinx CTB] Number of transceiver samples expected. """ return self.getNumberOfTransceiverSamples() @tsamples.setter @@ -3833,7 +3846,7 @@ class Detector(CppDetectorApi): @property @element def v_a(self): - """[Ctb] Power supply a in mV.""" + """[Ctb][Xilinx Ctb] Power supply a in mV.""" return self.getPower(dacIndex.V_POWER_A) @v_a.setter @@ -3844,7 +3857,7 @@ class Detector(CppDetectorApi): @property @element def v_b(self): - """[Ctb] Power supply b in mV.""" + """[Ctb][Xilinx Ctb] Power supply b in mV.""" return self.getPower(dacIndex.V_POWER_B) @v_b.setter @@ -3855,7 +3868,7 @@ class Detector(CppDetectorApi): @property @element def v_c(self): - """[Ctb] Power supply c in mV.""" + """[Ctb][Xilinx Ctb] Power supply c in mV.""" return self.getPower(dacIndex.V_POWER_C) @v_c.setter @@ -3866,7 +3879,7 @@ class Detector(CppDetectorApi): @property @element def v_d(self): - """[Ctb] Power supply d in mV.""" + """[Ctb][Xilinx Ctb] Power supply d in mV.""" return self.getPower(dacIndex.V_POWER_D) @v_d.setter @@ -3877,7 +3890,7 @@ class Detector(CppDetectorApi): @property @element def v_io(self): - """[Ctb] Power supply io in mV. Minimum 1200 mV. + """[Ctb][Xilinx Ctb] Power supply io in mV. Minimum 1200 mV. Note ---- @@ -3893,7 +3906,7 @@ class Detector(CppDetectorApi): @property @element def v_limit(self): - """[Ctb] Soft limit for power supplies (ctb only) and DACS in mV.""" + """[Ctb][Xilinx Ctb] Soft limit for power supplies (ctb only) and DACS in mV.""" return self.getPower(dacIndex.V_LIMIT) @v_limit.setter diff --git a/python/src/detector.cpp b/python/src/detector.cpp index a1e211ae4..7ae9c1be1 100644 --- a/python/src/detector.cpp +++ b/python/src/detector.cpp @@ -1778,6 +1778,10 @@ void init_det(py::module &m) { (std::string(Detector::*)(const defs::dacIndex) const) & Detector::getSlowADCName, py::arg()); + CppDetectorApi.def("configureTransceiver", + (void (Detector::*)(sls::Positions)) & + Detector::configureTransceiver, + py::arg() = Positions{}); CppDetectorApi.def( "getPatterFileName", (Result(Detector::*)(sls::Positions) const) & diff --git a/python/src/enums.cpp b/python/src/enums.cpp index 6651b9fc4..0bc9de6d8 100644 --- a/python/src/enums.cpp +++ b/python/src/enums.cpp @@ -25,6 +25,8 @@ void init_enums(py::module &m) { .value("MOENCH", slsDetectorDefs::detectorType::MOENCH) .value("MYTHEN3", slsDetectorDefs::detectorType::MYTHEN3) .value("GOTTHARD2", slsDetectorDefs::detectorType::GOTTHARD2) + .value("XILINX_CHIPTESTBOARD", + slsDetectorDefs::detectorType::XILINX_CHIPTESTBOARD) .export_values(); py::enum_(Defs, "runStatus") diff --git a/slsDetectorServers/ctbDetectorServer/CMakeLists.txt b/slsDetectorServers/ctbDetectorServer/CMakeLists.txt index bacf25136..fd2cf796e 100644 --- a/slsDetectorServers/ctbDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/ctbDetectorServer/CMakeLists.txt @@ -37,8 +37,7 @@ target_compile_definitions(ctbDetectorServer_virtual ) target_link_libraries(ctbDetectorServer_virtual - PUBLIC pthread rt slsProjectCSettings - m + PUBLIC pthread rt m slsProjectCSettings ) set_target_properties(ctbDetectorServer_virtual PROPERTIES diff --git a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer index 46a6e3bc4..9d3380f17 100755 Binary files a/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer and b/slsDetectorServers/ctbDetectorServer/bin/ctbDetectorServer_developer differ diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h index d1b89c91f..683338861 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorServer_defs.h @@ -55,7 +55,9 @@ #define DEFAULT_SYNC_CLK (40) // 20 #define DEFAULT_DBIT_CLK (200) #define DEFAULT_TRANSCEIVER_MASK (0x3) -#define MAX_TRANSCEIVER_MASK (0xF) + +#define MAX_TRANSCEIVER_MASK (0xF) +#define MAX_TRANSCEIVER_SAMPLES (0xFFFF) #define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF) diff --git a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer index c88182af4..218c11e89 100755 Binary files a/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and b/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer index 7e05b13de..90b23f707 100755 Binary files a/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer and b/slsDetectorServers/gotthard2DetectorServer/bin/gotthard2DetectorServer_developer differ diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c index e7401f474..dbf91df17 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorFunctionList.c @@ -471,7 +471,8 @@ void setupDetector() { // hv DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME); // dacs - LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC); + LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 1, + 0, ""); // on chip dacs ASIC_Driver_SetDefines(ONCHIP_DAC_DRIVER_FILE_NAME); setTimingSource(DEFAULT_TIMING_SOURCE); diff --git a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h index 6c3dd1f0b..b8a513b18 100644 --- a/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/gotthard2DetectorServer/slsDetectorServer_defs.h @@ -35,6 +35,7 @@ #define TEMPERATURE_FILE_NAME ("/sys/class/hwmon/hwmon0/temp1_input") #endif #define CONFIG_FILE ("config_gotthard2.txt") +#define DAC_MIN_MV (0) #define DAC_MAX_MV (2048) #define ONCHIP_DAC_MAX_VAL (0x3FF) #define ADU_MAX_VAL (0xFFF) diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer index 55866dae2..985b0bfc4 100755 Binary files a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_developer differ diff --git a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer index 7dfc45b9e..edf95ee6a 100755 Binary files a/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and b/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer differ diff --git a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer index 16b15b856..d00d2da38 100755 Binary files a/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer and b/slsDetectorServers/moenchDetectorServer/bin/moenchDetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer index 290738b43..4ef9c1328 100755 Binary files a/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer and b/slsDetectorServers/mythen3DetectorServer/bin/mythen3DetectorServer_developer differ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 4c069b452..4b8fa905d 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -483,7 +483,8 @@ void setupDetector() { // hv DAC6571_SetDefines(HV_HARD_MAX_VOLTAGE, HV_DRIVER_FILE_NAME); // dac - LTC2620_D_SetDefines(DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC); + LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC, 1, + 0, ""); resetCore(); resetPeripheral(); diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index e9e020ca0..89b294ffc 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -34,6 +34,7 @@ #else #define TEMPERATURE_FILE_NAME ("/sys/class/hwmon/hwmon0/temp1_input") #endif +#define DAC_MIN_MV (0) #define DAC_MAX_MV (2048) #define TYPE_MYTHEN3_MODULE_VAL (93) #define TYPE_TOLERANCE (5) diff --git a/slsDetectorServers/slsDetectorServer/include/LTC2620_Driver.h b/slsDetectorServers/slsDetectorServer/include/LTC2620_Driver.h index 6a05cde62..4a9cfd72d 100644 --- a/slsDetectorServers/slsDetectorServer/include/LTC2620_Driver.h +++ b/slsDetectorServers/slsDetectorServer/include/LTC2620_Driver.h @@ -4,18 +4,11 @@ #include -/** - * Set Defines - * @param hardMaxV maximum hardware limit - * @param driverfname driver file name - * @param numdacs number of dacs - */ -void LTC2620_D_SetDefines(int hardMaxV, char *driverfname, int numdacs); - -/** - * Get max number of steps - */ +void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname, + int numdacs, int numdevices, int startingDeviceIndex, + char *powerdownDriverfname); int LTC2620_D_GetMaxNumSteps(); +int LTC2620_D_GetPowerDownValue(); /** * Convert voltage to dac units diff --git a/slsDetectorServers/slsDetectorServer/include/arm64.h b/slsDetectorServers/slsDetectorServer/include/arm64.h index 06e8f7b26..6614bfe65 100644 --- a/slsDetectorServers/slsDetectorServer/include/arm64.h +++ b/slsDetectorServers/slsDetectorServer/include/arm64.h @@ -9,4 +9,7 @@ void bus_w(u_int32_t offset, u_int32_t data); u_int32_t bus_r(u_int32_t offset); uint64_t getU64BitReg(int aLSB, int aMSB); void setU64BitReg(uint64_t value, int aLSB, int aMSB); +u_int32_t readRegister(u_int32_t offset); +u_int32_t writeRegister(u_int32_t offset, u_int32_t data); int mapCSP0(void); +u_int32_t *Arm_getUDPBaseAddress(); diff --git a/slsDetectorServers/slsDetectorServer/include/loadPattern.h b/slsDetectorServers/slsDetectorServer/include/loadPattern.h index 290e50506..7cc9b5a88 100644 --- a/slsDetectorServers/slsDetectorServer/include/loadPattern.h +++ b/slsDetectorServers/slsDetectorServer/include/loadPattern.h @@ -11,7 +11,7 @@ void initializePatternAddresses(); void initializePatternWord(); #endif #endif -#if defined(CHIPTESTBOARDD) // TODO || defined(XILINX_CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) uint64_t validate_readPatternIOControl(); int validate_writePatternIOControl(char *message, uint64_t arg); void writePatternIOControl(uint64_t word); diff --git a/slsDetectorServers/slsDetectorServer/include/programViaArm.h b/slsDetectorServers/slsDetectorServer/include/programViaArm.h new file mode 100644 index 000000000..d2434b94d --- /dev/null +++ b/slsDetectorServers/slsDetectorServer/include/programViaArm.h @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#pragma once + +#include + +int resetFPGA(char *mess); +int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex); + +int checksBeforeCreatingDeviceTree(char *mess); +int createDeviceTree(char *mess); +int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 7cbc24cf0..c36823eee 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -27,6 +27,7 @@ #ifdef ARMPROCESSOR #include "arm64.h" +#include "programViaArm.h" #endif #ifdef MYTHEN3D @@ -68,8 +69,12 @@ void basictests(); #if !defined(EIGERD) int checkType(); int testFpga(); +#ifdef XILINX_CHIPTESTBOARDD +int testFixedFPGAPattern(); +#else int testBus(); #endif +#endif #if defined(GOTTHARDD) || \ ((defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD)) && \ @@ -84,9 +89,7 @@ u_int64_t getFirmwareVersion(); #ifdef EIGERD uint64_t getFrontEndFirmwareVersion(enum fpgaPosition fpgaPosition); #endif -#ifndef XILINX_CHIPTESTBOARDD u_int64_t getFirmwareAPIVersion(); -#endif void getHardwareVersion(char *version); #ifdef EIGERD int getHardwareVersionNumber(); @@ -178,6 +181,22 @@ uint32_t readRegister16And32(uint32_t offset); #endif // firmware functions (resets) +#if defined(XILINX_CHIPTESTBOARDD) +void cleanFifos(); +void resetFlow(); +int waitTranseiverReset(char *mess); +#ifdef VIRTUAL +void setTransceiverAlignment(int align); +#endif +int isTransceiverAligned(); +int waitTransceiverAligned(char *mess); +int configureTransceiver(char *mess); +int isChipConfigured(); +int powerChip(int on, char *mess); +int getPowerChip(); +int configureChip(char *mess); +void startPeriphery(); +#endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ defined(MYTHEN3D) || defined(GOTTHARD2D) void cleanFifos(); @@ -217,6 +236,12 @@ uint32_t getTransceiverEnableMask(); void setADCInvertRegister(uint32_t val); uint32_t getADCInvertRegister(); #endif +#ifdef XILINX_CHIPTESTBOARDD +void setADCEnableMask_10G(uint32_t mask); +uint32_t getADCEnableMask_10G(); +int setTransceiverEnableMask(uint32_t mask); +uint32_t getTransceiverEnableMask(); +#endif #if defined(CHIPTESTBOARDD) int setExternalSamplingSource(int val); int setExternalSampling(int val); @@ -232,7 +257,7 @@ int getParallelMode(); int setOverFlowMode(int mode); int getOverFlowMode(); #endif -#ifdef CHIPTESTBOARDD +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) int setReadoutMode(enum readoutMode mode); int getReadoutMode(); #endif @@ -243,7 +268,7 @@ int selectStoragecellStart(int pos); int getMaxStoragecellStart(); #endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(EIGERD) || \ - defined(CHIPTESTBOARDD) + defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) int setNextFrameNumber(uint64_t value); int getNextFrameNumber(uint64_t *value); #endif @@ -251,14 +276,12 @@ void setNumFrames(int64_t val); int64_t getNumFrames(); void setNumTriggers(int64_t val); int64_t getNumTriggers(); -#ifndef XILINX_CHIPTESTBOARDD #ifndef MYTHEN3D int setExpTime(int64_t val); int64_t getExpTime(); #endif int setPeriod(int64_t val); int64_t getPeriod(); -#endif #ifdef MYTHEN3D void setNumIntGates(int val); void setNumGates(int val); @@ -290,11 +313,9 @@ int getNumAdditionalStorageCells(); int setStorageCellDelay(int64_t val); int64_t getStorageCellDelay(); #endif -#if defined(CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) int setNumAnalogSamples(int val); int getNumAnalogSamples(); -#endif -#ifdef CHIPTESTBOARDD int setNumDigitalSamples(int val); int getNumDigitalSamples(); int setNumTransceiverSamples(int val); @@ -312,10 +333,10 @@ int64_t getNumFramesLeft(); int64_t getNumTriggersLeft(); #endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARDD) || \ - defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) + defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) || \ + defined(XILINX_CHIPTESTBOARDD) int setDelayAfterTrigger(int64_t val); int64_t getDelayAfterTrigger(); - int64_t getDelayAfterTriggerLeft(); int64_t getPeriodLeft(); #endif @@ -326,7 +347,7 @@ int64_t getNumBurstsLeft(); int64_t getExpTimeLeft(); #endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(CHIPTESTBOARDD) || \ - defined(MYTHEN3D) || defined(GOTTHARD2D) + defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) int64_t getFramesFromStart(); int64_t getActualTime(); int64_t getMeasurementTime(); @@ -379,15 +400,11 @@ void setDAC(enum DACINDEX ind, int val, int mV, int counterEnableCheck); void setGeneralDAC(enum DACINDEX ind, int val, int mV); void setVthDac(int index, int enable); #else -#ifndef XILINX_CHIPTESTBOARDD void setDAC(enum DACINDEX ind, int val, int mV); #endif -#endif -#ifndef XILINX_CHIPTESTBOARDD int getDAC(enum DACINDEX ind, int mV); int getMaxDacSteps(); -#endif -#if defined(CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) int dacToVoltage(int dac); int checkVLimitCompliant(int mV); int checkVLimitDacCompliant(int dac); @@ -406,20 +423,24 @@ int isPowerValid(enum DACINDEX ind, int val); int getPower(); void setPower(enum DACINDEX ind, int val); void powerOff(); +#elif XILINX_CHIPTESTBOARDD +int getPower(); +void setPower(enum DACINDEX ind, int val); #endif -#if defined(MYTHEN3D) || defined(GOTTHARD2D) +#if defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) int getADC(enum ADCINDEX ind, int *value); #else -#ifndef XILINX_CHIPTESTBOARDD int getADC(enum ADCINDEX ind); #endif -#endif #ifdef CHIPTESTBOARDD int getSlowADC(int ichan); int getSlowADCTemperature(); #endif -#ifndef XILINX_CHIPTESTBOARDD +#ifdef XILINX_CHIPTESTBOARDD +int getSlowADC(int ichan, int *retval); +int getTemperature(int *retval); +#else int setHighVoltage(int val); #endif @@ -491,7 +512,8 @@ void setupHeader(int iRxEntry, enum interfaceType type, uint32_t destip, uint32_t sourceip, uint16_t sourceport); #endif #if defined(JUNGFRAUD) || defined(MOENCHD) || defined(GOTTHARD2D) || \ - defined(MYTHEN3D) || defined(CHIPTESTBOARDD) + defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \ + defined(XILINX_CHIPTESTBOARDD) void calcChecksum(udp_header *udp); #endif #ifdef GOTTHARDD @@ -694,30 +716,27 @@ int setTransmissionDelayRight(int value); #endif // aquisition -#ifndef XILINX_CHIPTESTBOARDD int startStateMachine(); #ifdef VIRTUAL void *start_timer(void *arg); #endif int stopStateMachine(); -#endif -#ifdef MYTHEN3D +#if defined(MYTHEN3D) || defined(XILINX_CHIPTESTBOARDD) int softwareTrigger(); #endif #if defined(EIGERD) || defined(JUNGFRAUD) || defined(MOENCHD) int softwareTrigger(int block); #endif -#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) +#if defined(EIGERD) || defined(MYTHEN3D) || defined(CHIPTESTBOARDD) || \ + defined(XILINX_CHIPTESTBOARDD) int startReadOut(); #endif enum runStatus getRunStatus(); #ifdef EIGERD void waitForAcquisitionEnd(int *ret, char *mess); #else -#ifndef XILINX_CHIPTESTBOARDD void waitForAcquisitionEnd(); #endif -#endif #if defined(CHIPTESTBOARDD) int validateUDPSocket(); void readandSendUDPFrames(); @@ -729,7 +748,8 @@ int readFrameFromFifo(); #endif #if defined(GOTTHARDD) || defined(JUNGFRAUD) || defined(MOENCHD) || \ - defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) + defined(CHIPTESTBOARDD) || defined(MYTHEN3D) || defined(GOTTHARD2D) || \ + defined(XILINX_CHIPTESTBOARDD) u_int32_t runBusy(); #endif @@ -738,15 +758,11 @@ u_int32_t runState(enum TLogLevel lev); #endif // common -#ifndef XILINX_CHIPTESTBOARDD int calculateDataBytes(); int getTotalNumberOfChannels(); -#endif #if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) void getNumberOfChannels(int *nchanx, int *nchany); #endif -#ifndef XILINX_CHIPTESTBOARDD int getNumberOfChips(); int getNumberOfDACs(); -int getNumberOfChannelsPerChip(); -#endif \ No newline at end of file +int getNumberOfChannelsPerChip(); \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index 4bf70907f..1840884fb 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -329,3 +329,4 @@ int getColumn(); int setColumn(int); int get_pedestal_mode(int); int set_pedestal_mode(int); +int config_transceiver(int); diff --git a/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c b/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c index 5add339b1..3de5a7c36 100644 --- a/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c +++ b/slsDetectorServers/slsDetectorServer/src/LTC2620_Driver.c @@ -13,35 +13,54 @@ #define LTC2620_D_MAX_STEPS (LTC2620_D_MAX_DAC_VAL + 1) // defines from the fpga +int LTC2620_D_HardMinVoltage = 0; int LTC2620_D_HardMaxVoltage = 0; char LTC2620_D_DriverFileName[MAX_STR_LENGTH]; +char LTC2620_D_PowerDownDriverFileName[MAX_STR_LENGTH]; int LTC2620_D_NumDacs = 0; +int LTC2620_D_NumDevices = 0; +int LTC2620_D_NumChannelsPerDevice = 0; +int LTC2620_D_DacDriverStartingDeviceIndex = 0; -void LTC2620_D_SetDefines(int hardMaxV, char *driverfname, int numdacs) { +void LTC2620_D_SetDefines(int hardMinV, int hardMaxV, char *driverfname, + int numdacs, int numdevices, int startingDeviceIndex, + char *powerdownDriverfname) { LOG(logINFOBLUE, - ("Configuring DACs (LTC2620) to %s (numdacs:%d, hard max: %dmV)\n", - driverfname, numdacs, hardMaxV)); + ("Configuring DACs (LTC2620) to %s\n\t (numdacs:%d, hard min:%d, hard " + "max: %dmV, idev:%d)\n", + driverfname, numdacs, hardMinV, hardMaxV, startingDeviceIndex)); + LTC2620_D_HardMinVoltage = hardMinV; LTC2620_D_HardMaxVoltage = hardMaxV; memset(LTC2620_D_DriverFileName, 0, MAX_STR_LENGTH); strcpy(LTC2620_D_DriverFileName, driverfname); + memset(LTC2620_D_PowerDownDriverFileName, 0, MAX_STR_LENGTH); + strcpy(LTC2620_D_PowerDownDriverFileName, powerdownDriverfname); LTC2620_D_NumDacs = numdacs; + LTC2620_D_NumDevices = numdevices; + LTC2620_D_NumChannelsPerDevice = LTC2620_D_NumDacs / LTC2620_D_NumDevices; + LTC2620_D_DacDriverStartingDeviceIndex = startingDeviceIndex; } int LTC2620_D_GetMaxNumSteps() { return LTC2620_D_MAX_STEPS; } +int LTC2620_D_GetPowerDownValue() { return LTC2620_D_PWR_DOWN_VAL; } + int LTC2620_D_VoltageToDac(int voltage, int *dacval) { - return ConvertToDifferentRange(0, LTC2620_D_HardMaxVoltage, 0, + return ConvertToDifferentRange(LTC2620_D_HardMinVoltage, + LTC2620_D_HardMaxVoltage, 0, LTC2620_D_MAX_DAC_VAL, voltage, dacval); } int LTC2620_D_DacToVoltage(int dacval, int *voltage) { - return ConvertToDifferentRange(0, LTC2620_D_MAX_DAC_VAL, 0, + return ConvertToDifferentRange(0, LTC2620_D_MAX_DAC_VAL, + LTC2620_D_HardMinVoltage, LTC2620_D_HardMaxVoltage, dacval, voltage); } int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname, int *dacval) { LOG(logDEBUG1, ("dacnum:%d, val:%d, ismV:%d\n", dacnum, val, mV)); + // validate index if (dacnum < 0 || dacnum >= LTC2620_D_NumDacs) { LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, @@ -49,53 +68,90 @@ int LTC2620_D_SetDACValue(int dacnum, int val, int mV, char *dacname, return FAIL; } - // get + // validate set if (val < 0 && val != LTC2620_D_PWR_DOWN_VAL) return FAIL; - // convert to dac or get mV value - *dacval = val; - int dacmV = val; int ret = OK; - if (mV) { - ret = LTC2620_D_VoltageToDac(val, dacval); - } else if (val >= 0) { - // do not convert power down dac val - ret = LTC2620_D_DacToVoltage(val, &dacmV); - } - - // conversion out of bounds - if (ret == FAIL) { - LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, - (mV ? "mV" : "dac units"))); - return FAIL; - } - - // set - if ((*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) { - LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n", dacnum, - dacname, *dacval, dacmV)); - + *dacval = val; #ifndef VIRTUAL - char fname[MAX_STR_LENGTH]; - strcpy(fname, LTC2620_D_DriverFileName); - char temp[20]; - memset(temp, 0, sizeof(temp)); - sprintf(temp, "%d", dacnum); - strcat(fname, temp); - LOG(logDEBUG1, ("fname %s\n", fname)); + char fnameFormat[MAX_STR_LENGTH]; + memset(fnameFormat, 0, MAX_STR_LENGTH); + strcpy(fnameFormat, LTC2620_D_DriverFileName); +#endif - // open file - FILE *fd = fopen(fname, "w"); - if (fd == NULL) { - LOG(logERROR, ("Could not open file %s for writing to set dac %d\n", - fname, dacnum)); - return FAIL; - } - // convert to string, add 0 and write to file - fprintf(fd, "%d\n", *dacval); - fclose(fd); + // power down dac (different file name) + if (val == LTC2620_D_PWR_DOWN_VAL) { +#if defined(XILINX_CHIPTESTBOARDD) && !defined(VIRTUAL) + LOG(logINFO, ("Powering down DAC %2d [%-6s] \n", dacnum, dacname)); + strcpy(fnameFormat, LTC2620_D_PowerDownDriverFileName); #endif } + + // proper value to set + else { + // convert to dac or get mV value + int dacmV = val; + if (mV) { + ret = LTC2620_D_VoltageToDac(val, dacval); + } else if (val >= 0) { + // do not convert power down dac val + ret = LTC2620_D_DacToVoltage(val, &dacmV); + } + + // conversion out of bounds + if (ret == FAIL) { + LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, + (mV ? "mV" : "dac units"))); + return FAIL; + } + + // print and set +#ifdef XILINX_CHIPTESTBOARDD + if (*dacval >= 0) { + LOG(logINFO, ("Setting DAC %2d [%-6s] : %d dac (%d mV)\n", dacnum, + dacname, *dacval, dacmV)); + } +#else + if ((*dacval >= 0) || (*dacval == LTC2620_D_PWR_DOWN_VAL)) { + LOG(logINFO, ("Setting DAC %2d [%-12s] : %d dac (%d mV)\n", dacnum, + dacname, *dacval, dacmV)); + } +#endif + } + + // set in file +#ifndef VIRTUAL + char fname[MAX_STR_LENGTH]; + memset(fname, 0, MAX_STR_LENGTH); +#ifdef XILINX_CHIPTESTBOARDD + int idev = LTC2620_D_DacDriverStartingDeviceIndex + + (dacnum / LTC2620_D_NumChannelsPerDevice); + int idac = dacnum % LTC2620_D_NumChannelsPerDevice; + sprintf(fname, fnameFormat, idev, idac); +#else + sprintf(fname, "%s%d", fnameFormat, dacnum); +#endif + LOG(logDEBUG1, ("fname %s\n", fname)); + + // open file + FILE *fd = fopen(fname, "w"); + if (fd == NULL) { + LOG(logERROR, ("Could not open file %s for writing to set dac %d\n", + fname, dacnum)); + return FAIL; + } + // convert to string, add 0 and write to file +#ifdef XILINX_CHIPTESTBOARDD + // not changing *dacval from -100 (cant write -100 to file: invalid arg) + int writeValue = *dacval; + if (writeValue == LTC2620_D_PWR_DOWN_VAL) + writeValue = 1; + fprintf(fd, "%d\n", writeValue); +#else + fprintf(fd, "%d\n", *dacval); +#endif + fclose(fd); +#endif return OK; } diff --git a/slsDetectorServers/slsDetectorServer/src/arm64.c b/slsDetectorServers/slsDetectorServer/src/arm64.c index 8fff6550b..2cbc4afda 100644 --- a/slsDetectorServers/slsDetectorServer/src/arm64.c +++ b/slsDetectorServers/slsDetectorServer/src/arm64.c @@ -11,10 +11,13 @@ #include // mmap /* global variables */ -#define CSP0 (0xB0010000) -#define MEM_SIZE 0x100000 - +#define CSP0 (0xB0080000) +#define CSP1 (0xB0050000) // udp +#define MEM_SIZE (0x10000) +//#define MEM_SIZE_CSP0 (4096) +//#define MEM_SIZE_CSP1 (2 * 4096) u_int32_t *csp0base = 0; +u_int32_t *csp1base = 0; void bus_w(u_int32_t offset, u_int32_t data) { volatile u_int32_t *ptr1; @@ -39,35 +42,53 @@ void setU64BitReg(uint64_t value, int aLSB, int aMSB) { bus_w(aMSB, (value >> 32) & (0xffffffff)); } +u_int32_t readRegister(u_int32_t offset) { return bus_r(offset); } + +u_int32_t writeRegister(u_int32_t offset, u_int32_t data) { + bus_w(offset, data); + return readRegister(offset); +} + int mapCSP0(void) { - // if not mapped - if (csp0base == 0) { - LOG(logINFO, ("Mapping memory\n")); + u_int32_t csps[2] = {CSP0, CSP1}; + u_int32_t **cspbases[2] = {&csp0base, &csp1base}; + char names[2][10] = {"csp0base", "csp1base"}; + + for (int i = 0; i < 2; ++i) { + // if not mapped + if (*cspbases[i] == 0) { + LOG(logINFO, ("Mapping memory for %s\n", names[i])); #ifdef VIRTUAL - csp0base = malloc(MEM_SIZE); - if (csp0base == NULL) { - LOG(logERROR, ("Could not allocate virtual memory.\n")); - return FAIL; - } - LOG(logINFO, ("memory allocated\n")); + *cspbases[i] = malloc(MEM_SIZE); + if (*cspbases[i] == NULL) { + LOG(logERROR, + ("Could not allocate virtual memory for %s.\n", names[i])); + return FAIL; + } + LOG(logINFO, ("memory allocated for %s\n", names[i])); #else - int fd; - fd = open("/dev/mem", O_RDWR | O_SYNC, 0); - if (fd == -1) { - LOG(logERROR, ("Can't find /dev/mem\n")); - return FAIL; - } - LOG(logDEBUG1, ("/dev/mem opened\n")); - csp0base = (u_int32_t *)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_SHARED, fd, CSP0); - if (csp0base == MAP_FAILED) { - LOG(logERROR, ("Can't map memmory area\n")); - return FAIL; - } + int fd = open("/dev/mem", O_RDWR | O_SYNC, 0); + if (fd == -1) { + LOG(logERROR, ("Can't find /dev/mem for %s\n", names[i])); + return FAIL; + } + LOG(logDEBUG1, + ("/dev/mem opened for %s, (CSP:0x%x)\n", names[i], csps[i])); + *cspbases[i] = + (u_int32_t *)mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE, + MAP_FILE | MAP_SHARED, fd, csps[i]); + if (*cspbases[i] == MAP_FAILED) { + LOG(logERROR, ("Can't map memmory area for %s\n", names[i])); + return FAIL; + } #endif - LOG(logINFO, ("csp0base mapped from %p to %p\n", csp0base, - (csp0base + MEM_SIZE))); - } else - LOG(logINFO, ("Memory already mapped before\n")); + LOG(logINFO, ("%s mapped from %p to %p,(CSP:0x%x) \n", names[i], + *cspbases[i], *cspbases[i] + MEM_SIZE, csps[i])); + // LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG))); + } else + LOG(logINFO, ("Memory %s already mapped before\n", names[i])); + } return OK; } + +u_int32_t *Arm_getUDPBaseAddress() { return csp1base; } diff --git a/slsDetectorServers/slsDetectorServer/src/common.c b/slsDetectorServers/slsDetectorServer/src/common.c index 64784b543..a94f0008f 100644 --- a/slsDetectorServers/slsDetectorServer/src/common.c +++ b/slsDetectorServers/slsDetectorServer/src/common.c @@ -752,13 +752,17 @@ int readADCFromFile(char *fname, int *value) { *value = -1; if (sscanf(line, "%d", value) != 1) { +#ifdef XILINX_CHIPTESTBOARDD + LOG(logERROR, ("Could not scan adc from %s\n", line)); +#else LOG(logERROR, ("Could not scan temperature from %s\n", line)); +#endif return FAIL; } #ifdef EIGERD *value /= 10; -#else +#elif !defined(XILINX_CHIPTESTBOARDD) LOG(logINFO, ("Temperature: %.2f °C\n", (double)(*value) / 1000.00)); #endif diff --git a/slsDetectorServers/slsDetectorServer/src/loadPattern.c b/slsDetectorServers/slsDetectorServer/src/loadPattern.c index 0cec27019..02399321e 100644 --- a/slsDetectorServers/slsDetectorServer/src/loadPattern.c +++ b/slsDetectorServers/slsDetectorServer/src/loadPattern.c @@ -52,12 +52,26 @@ void initializePatternWord() { #endif #endif -#if defined(CHIPTESTBOARDD) // TODO || defined(XILINX_CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) uint64_t validate_readPatternIOControl() { +#if defined(CHIPTESTBOARDD) return getU64BitReg(PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG); +#elif defined(XILINX_CHIPTESTBOARDD) + return (uint64_t)(bus_r(PINIOCTRLREG)); +#endif } int validate_writePatternIOControl(char *message, uint64_t arg) { + // validate input +#ifdef XILINX_CHIPTESTBOARDD + if (arg > BIT32_MSK) { + strcpy(message, "Could not set pattern IO Control. Must be 32 bit for " + "this detector\n"); + LOG(logERROR, (message)); + return FAIL; + } +#endif + writePatternIOControl(arg); // validate result @@ -77,9 +91,15 @@ int validate_writePatternIOControl(char *message, uint64_t arg) { } void writePatternIOControl(uint64_t word) { +#ifdef CHIPTESTBOARDD LOG(logINFO, ("Setting Pattern I/O Control: 0x%llx\n", (long long int)word)); setU64BitReg(word, PATTERN_IO_CNTRL_LSB_REG, PATTERN_IO_CNTRL_MSB_REG); +#elif defined(XILINX_CHIPTESTBOARDD) + uint32_t val = (uint32_t)word; + LOG(logINFO, ("Setting Pattern I/O Control: 0x%x\n", val)); + bus_w(PINIOCTRLREG, val); +#endif } #endif diff --git a/slsDetectorServers/slsDetectorServer/src/programViaArm.c b/slsDetectorServers/slsDetectorServer/src/programViaArm.c new file mode 100644 index 000000000..adc05ac8e --- /dev/null +++ b/slsDetectorServers/slsDetectorServer/src/programViaArm.c @@ -0,0 +1,196 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "programViaArm.h" +#include "clogger.h" +#include "sls/sls_detector_defs.h" + +#include //memset +#include // access + +#define CMD_ARM_LOAD_BIT_FILE \ + "~/fpgautil/fpgautil -b /root/apps/xilinx-ctb/XilinxCTB.bit -f Full" +#define CMD_ARM_DEVICE_TREE_API_FOLDER \ + "/sys/kernel/config/device-tree/overlays/spidr" +#define CMD_ARM_DEVICE_TREE_OVERLAY_FILE "/root/apps/xilinx-ctb/pl.dtbo" +#define CMD_ARM_LOAD_DEVICE_TREE_FORMAT "cat %s > %s/dtbo" +#define CMD_ARM_DEVICE_TREE_DST "/sys/bus/iio/devices/iio:device" +#define CMD_ARM_DEVICE_NAME "xilinx-ams", "ad7689", "dac@0", "dac@1", "dac@2" +#define TIME_LOAD_DEVICE_TREE_MS (500) + +extern int executeCommand(char *command, char *result, enum TLogLevel level); + +int resetFPGA(char *mess) { + LOG(logINFOBLUE, ("Reseting FPGA...\n")); +#ifndef VIRTUAL + char retvals[MAX_STR_LENGTH] = {0}; + if (executeCommand(CMD_ARM_LOAD_BIT_FILE, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not reset fpga. Command to load bit file failed (%s)\n", + retvals); + LOG(logERROR, (mess)); + return FAIL; + } +#endif + LOG(logINFOBLUE, ("FPGA reset successfully\n")) + return OK; +} + +int loadDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) { + if (verifyDeviceTree(mess, adcDeviceIndex, dacDeviceIndex) == OK) + return OK; + + if (checksBeforeCreatingDeviceTree(mess) == FAIL) + return FAIL; + + if (createDeviceTree(mess) == FAIL) + return FAIL; + + if (verifyDeviceTree(mess, adcDeviceIndex, dacDeviceIndex) == FAIL) { + LOG(logERROR, ("Device tree loading failed at verification\n")); + return FAIL; + } + + LOG(logINFOBLUE, ("Device tree loaded successfully\n")) + return OK; +} + +int checksBeforeCreatingDeviceTree(char *mess) { + // check if device tree overlay file exists + if (access(CMD_ARM_DEVICE_TREE_OVERLAY_FILE, F_OK) != 0) { + snprintf(mess, MAX_STR_LENGTH, + "Device tree overlay file (%s) does not exist\n", + CMD_ARM_DEVICE_TREE_OVERLAY_FILE); + LOG(logERROR, (mess)); + return FAIL; + } + LOG(logINFO, ("\tDevice tree overlay file exists (%s)\n", + CMD_ARM_DEVICE_TREE_OVERLAY_FILE)); + + // check if device tree folder exists. If it does, remove it + if (access(CMD_ARM_DEVICE_TREE_API_FOLDER, F_OK) == 0) { + // remove it + char cmd[MAX_STR_LENGTH] = {0}; + memset(cmd, 0, MAX_STR_LENGTH); + sprintf(cmd, "rmdir %s", CMD_ARM_DEVICE_TREE_API_FOLDER); + char retvals[MAX_STR_LENGTH] = {0}; + memset(retvals, 0, MAX_STR_LENGTH); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not unload device tree overlay api with %s (%s)\n", + cmd, retvals); + LOG(logWARNING, (mess)); + return FAIL; + } + LOG(logINFO, ("\tUnloaded existing device tree overlay api (%s)\n", + CMD_ARM_DEVICE_TREE_API_FOLDER)); + } else { + LOG(logINFO, ("\tNo existing device tree overlay api found(%s)\n", + CMD_ARM_DEVICE_TREE_API_FOLDER)); + } + + // create device tree overlay folder + { + char cmd[MAX_STR_LENGTH] = {0}; + memset(cmd, 0, MAX_STR_LENGTH); + sprintf(cmd, "mkdir %s", CMD_ARM_DEVICE_TREE_API_FOLDER); + char retvals[MAX_STR_LENGTH] = {0}; + memset(retvals, 0, MAX_STR_LENGTH); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not create device tree overlay api with %s (%s)\n", + cmd, retvals); + LOG(logWARNING, (mess)); + return FAIL; + } + LOG(logINFO, ("\tDevice tree overlay api created (%s)\n", + CMD_ARM_DEVICE_TREE_API_FOLDER)); + } + + return OK; +} + +int createDeviceTree(char *mess) { + char cmd[MAX_STR_LENGTH] = {0}; + memset(cmd, 0, MAX_STR_LENGTH); + sprintf(cmd, CMD_ARM_LOAD_DEVICE_TREE_FORMAT, + CMD_ARM_DEVICE_TREE_OVERLAY_FILE, CMD_ARM_DEVICE_TREE_API_FOLDER); + char retvals[MAX_STR_LENGTH] = {0}; + memset(retvals, 0, MAX_STR_LENGTH); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not load device tree overlay with %s (%s)\n", cmd, + retvals); + LOG(logWARNING, (mess)); + return FAIL; + } + LOG(logINFO, ("\tDevice tree overlay created (cmd: %s)\n", cmd)); + + usleep(TIME_LOAD_DEVICE_TREE_MS * 1000); + return OK; +} + +int verifyDeviceTree(char *mess, int *adcDeviceIndex, int *dacDeviceIndex) { + LOG(logINFOBLUE, ("Verifying Device Tree...\n")); + *adcDeviceIndex = 1; + *dacDeviceIndex = 2; +#ifndef VIRTUAL + + // check if iio:device0-4 exists in device tree destination + int hardcodedDeviceIndex = 0; + for (int i = 0; i != 5; ++i) { + char deviceName[MAX_STR_LENGTH] = {0}; + memset(deviceName, 0, MAX_STR_LENGTH); + sprintf(deviceName, "%s%d/name", CMD_ARM_DEVICE_TREE_DST, i); + // check if device exist + if (access(deviceName, F_OK) != 0) { + snprintf(mess, MAX_STR_LENGTH, + "Could not verify device tree. Device %s does not exist\n", + deviceName); + LOG(logWARNING, (mess)); + return FAIL; + } + // find name + char cmd[MAX_STR_LENGTH] = {0}; + memset(cmd, 0, MAX_STR_LENGTH); + sprintf(cmd, "cat %s", deviceName); + char retvals[MAX_STR_LENGTH] = {0}; + memset(retvals, 0, MAX_STR_LENGTH); + if (executeCommand(cmd, retvals, logDEBUG1) == FAIL) { + snprintf(mess, MAX_STR_LENGTH, + "Could not retrieve device name from device %s (%s)\n", + deviceName, retvals); + LOG(logWARNING, (mess)); + return FAIL; + } + // verify name + char *deviceNames[] = {CMD_ARM_DEVICE_NAME}; + if (strstr(retvals, deviceNames[hardcodedDeviceIndex]) == NULL) { + // dacs got loaded first + if (i == 1 && + strstr(retvals, deviceNames[hardcodedDeviceIndex + 1]) != + NULL) { + ++hardcodedDeviceIndex; + *adcDeviceIndex = 4; + *dacDeviceIndex = 1; + } else { + snprintf( + mess, MAX_STR_LENGTH, + "Could not verify device tree. Device %s expected %s but " + "got %s\n", + deviceName, deviceNames[i], retvals); + LOG(logWARNING, (mess)); + return FAIL; + } + } + ++hardcodedDeviceIndex; + // in case dacs were loaded first + if (hardcodedDeviceIndex == 5) + hardcodedDeviceIndex = 1; + } +#endif + LOG(logINFOBLUE, ("Device tree verified successfully [temp: 0, adc:%d, " + "dac:%d, %d, %d]\n", + *adcDeviceIndex, *dacDeviceIndex, *dacDeviceIndex + 1, + *dacDeviceIndex + 2)); + return OK; +} \ No newline at end of file diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c index 9f608bbd1..5064999b3 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer.c @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) { "\t-v, --version : Software version\n" "\t-p, --port : TCP communication port with client. " "\n" - "\t-g, --nomodule : [Mythen3][Gotthard2] \n" + "\t-g, --nomodule : [Mythen3][Gotthard2][Xilinx Ctb] \n" "\t Generic or No Module mode. Skips " "detector type checks. \n" "\t-f, --phaseshift : [Gotthard] only. Sets phase shift. \n" diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 2bd34870b..811d113f3 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -491,6 +491,7 @@ void function_table() { flist[F_SET_COLUMN] = &set_column; flist[F_GET_PEDESTAL_MODE] = &get_pedestal_mode; flist[F_SET_PEDESTAL_MODE] = &set_pedestal_mode; + flist[F_CONFIG_TRANSCEIVER] = &config_transceiver; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -805,7 +806,8 @@ int set_firmware_test(int file_des) { LOG(logDEBUG1, ("Executing firmware test\n")); #if !defined(GOTTHARDD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \ - !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D) + !defined(CHIPTESTBOARDD) && !defined(GOTTHARD2D) && !defined(MYTHEN3D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else ret = testFpga(); @@ -971,6 +973,22 @@ enum DACINDEX getDACIndex(enum dacIndex ind) { case V_POWER_CHIP: serverDacIndex = D_PWR_CHIP; break; +#elif XILINX_CHIPTESTBOARDD + case V_POWER_A: + serverDacIndex = D_PWR_A; + break; + case V_POWER_B: + serverDacIndex = D_PWR_B; + break; + case V_POWER_C: + serverDacIndex = D_PWR_C; + break; + case V_POWER_D: + serverDacIndex = D_PWR_D; + break; + case V_POWER_IO: + serverDacIndex = D_PWR_IO; + break; #elif MYTHEN3D case VCASSH: serverDacIndex = M_VCASSH; @@ -1122,12 +1140,10 @@ enum DACINDEX getDACIndex(enum dacIndex ind) { case IBIAS_SFP: serverDacIndex = MO_IBIAS_SFP; break; -#elif XILINX_CHIPTESTBOARDD - #endif default: -#ifdef CHIPTESTBOARDD +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) if (ind < NDAC_ONLY) { // For CTB use the index directly, no conversion serverDacIndex = (enum DACINDEX)ind; @@ -1143,16 +1159,19 @@ enum DACINDEX getDACIndex(enum dacIndex ind) { int validateAndSetDac(enum dacIndex ind, int val, int mV) { int retval = -1; -#ifndef XILINX_CHIPTESTBOARDD enum DACINDEX serverDacIndex = 0; // valid enums switch (ind) { +#ifndef XILINX_CHIPTESTBOARDD case HIGH_VOLTAGE: +#endif #ifdef EIGERD case IO_DELAY: #elif CHIPTESTBOARDD case ADC_VPP: case V_LIMIT: +#elif XILINX_CHIPTESTBOARDD + case V_LIMIT: #endif break; default: @@ -1192,7 +1211,8 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { break; #endif - // high voltage + // high voltage +#ifndef XILINX_CHIPTESTBOARDD case HIGH_VOLTAGE: retval = setHighVoltage(val); LOG(logDEBUG1, ("High Voltage: %d\n", retval)); @@ -1226,9 +1246,9 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { } #endif break; - - // power, vlimit -#ifdef CHIPTESTBOARDD +#endif + // power +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) case V_POWER_A: case V_POWER_B: case V_POWER_C: @@ -1249,7 +1269,9 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { "exceeds voltage limit %d.\n", ind, getVLimit()); LOG(logERROR, (mess)); - } else if (!isPowerValid(serverDacIndex, val)) { + } +#ifdef CHIPTESTBOARDD + else if (!isPowerValid(serverDacIndex, val)) { ret = FAIL; sprintf( mess, @@ -1259,15 +1281,21 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { (serverDacIndex == D_PWR_IO ? VIO_MIN_MV : POWER_RGLTR_MIN), (VCHIP_MAX_MV - VCHIP_POWER_INCRMNT)); LOG(logERROR, (mess)); - } else { + } +#endif + else { setPower(serverDacIndex, val); } } - retval = getPower(serverDacIndex); - LOG(logDEBUG1, ("Power regulator(%d): %d\n", ind, retval)); - validate(&ret, mess, val, retval, "set power regulator", DEC); + if (ret == OK) { + retval = getPower(serverDacIndex); + LOG(logDEBUG1, ("Power regulator(%d): %d\n", ind, retval)); + validate(&ret, mess, val, retval, "set power regulator", DEC); + } break; +#endif +#ifdef CHIPTESTBOARDD case V_POWER_CHIP: if (val >= 0) { ret = FAIL; @@ -1297,7 +1325,8 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { break; #endif -#if defined(CHIPTESTBOARDD) + // vlimit +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) case V_LIMIT: if (val >= 0) { if (!mV) { @@ -1331,7 +1360,7 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { ind, val, getMaxDacSteps()); LOG(logERROR, (mess)); } else { -#if defined(CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) if ((val != GET_FLAG && mV && checkVLimitCompliant(val) == FAIL) || (val != GET_FLAG && !mV && checkVLimitDacCompliant(val) == FAIL)) { @@ -1395,7 +1424,6 @@ int validateAndSetDac(enum dacIndex ind, int val, int mV) { #endif break; } -#endif return retval; } @@ -1408,9 +1436,6 @@ int set_dac(int file_des) { if (receiveData(file_des, args, sizeof(args), INT32) < 0) return printSocketReadError(); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else enum dacIndex ind = args[0]; int mV = args[1]; int val = args[2]; @@ -1421,7 +1446,6 @@ int set_dac(int file_des) { if ((val == GET_FLAG) || (Server_VerifyLock() == OK)) { retval = validateAndSetDac(ind, val, mV); } -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -1434,9 +1458,6 @@ int get_adc(int file_des) { if (receiveData(file_des, &ind, sizeof(ind), INT32) < 0) return printSocketReadError(); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else enum ADCINDEX serverAdcIndex = 0; // get @@ -1536,6 +1557,34 @@ int get_adc(int file_des) { case SLOW_ADC_TEMP: serverAdcIndex = S_TMP; break; +#elif XILINX_CHIPTESTBOARDD + case TEMPERATURE_FPGA: + serverAdcIndex = TEMP_FPGA; + break; + case SLOW_ADC0: + serverAdcIndex = S_ADC0; + break; + case SLOW_ADC1: + serverAdcIndex = S_ADC1; + break; + case SLOW_ADC2: + serverAdcIndex = S_ADC2; + break; + case SLOW_ADC3: + serverAdcIndex = S_ADC3; + break; + case SLOW_ADC4: + serverAdcIndex = S_ADC4; + break; + case SLOW_ADC5: + serverAdcIndex = S_ADC5; + break; + case SLOW_ADC6: + serverAdcIndex = S_ADC6; + break; + case SLOW_ADC7: + serverAdcIndex = S_ADC7; + break; #endif default: modeNotImplemented("Adc Index", (int)ind); @@ -1545,10 +1594,14 @@ int get_adc(int file_des) { // valid index if (ret == OK) { LOG(logDEBUG1, ("Getting ADC %d\n", serverAdcIndex)); -#if defined(MYTHEN3D) || defined(GOTTHARD2D) +#if defined(MYTHEN3D) || defined(GOTTHARD2D) || defined(XILINX_CHIPTESTBOARDD) ret = getADC(serverAdcIndex, &retval); if (ret == FAIL) { - strcpy(mess, "Could not get temperature\n"); + if (ind == TEMPERATURE_FPGA) { + strcpy(mess, "Could not get temperature\n"); + } else { + strcpy(mess, "Could not get ADC\n"); + } LOG(logERROR, (mess)); } else { LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval)); @@ -1558,7 +1611,6 @@ int get_adc(int file_des) { LOG(logDEBUG1, ("ADC(%d): %d\n", serverAdcIndex, retval)); #endif } -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -1575,9 +1627,6 @@ int write_register(int file_des) { uint32_t val = args[1]; LOG(logDEBUG1, ("Writing to register 0x%x, data 0x%x\n", addr, val)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { #ifdef GOTTHARDD @@ -1612,7 +1661,6 @@ int write_register(int file_des) { } LOG(logDEBUG1, ("Write register (0x%x): 0x%x\n", retval)); } -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -1627,10 +1675,6 @@ int read_register(int file_des) { LOG(logDEBUG1, ("Reading from register 0x%x\n", addr)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else - // get #ifdef GOTTHARDD retval = readRegister16And32(addr); @@ -1647,7 +1691,6 @@ int read_register(int file_des) { retval = readRegister(addr); #endif LOG(logINFO, ("Read register (0x%x): 0x%x\n", addr, retval)); -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -1928,113 +1971,130 @@ int acquire(int blocking, int file_des) { } else { LOG(logINFOBLUE, ("Unblocking Acquisition\n")); } -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { -#if defined(JUNGFRAUD) - // chipv1.1 has to be configured before acquisition - if (getChipVersion() == 11 && !isChipConfigured()) { +#if defined(XILINX_CHIPTESTBOARDD) + if (!isChipConfigured()) { ret = FAIL; strcpy(mess, "Could not start acquisition. Chip is not configured. " "Power it on to configure it.\n"); LOG(logERROR, (mess)); + } else if ((getReadoutMode() == TRANSCEIVER_ONLY || + getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && + (isTransceiverAligned() == 0)) { + ret = FAIL; + strcpy(mess, "Could not start acquisition. Transceiver not " + "aligned. Use configtransceiver command.\n"); + LOG(logERROR, (mess)); } else #endif -#ifdef CHIPTESTBOARDD - if ((getReadoutMode() == ANALOG_AND_DIGITAL || - getReadoutMode() == ANALOG_ONLY) && - (getNumAnalogSamples() <= 0)) { - ret = FAIL; - sprintf(mess, - "Could not start acquisition. Invalid number of analog " - "samples: %d.\n", - getNumAnalogSamples()); - LOG(logERROR, (mess)); - } else if ((getReadoutMode() == ANALOG_AND_DIGITAL || - getReadoutMode() == DIGITAL_ONLY || - getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && - (getNumDigitalSamples() <= 0)) { - ret = FAIL; - sprintf(mess, +#if defined(JUNGFRAUD) + // chipv1.1 has to be configured before acquisition + if (getChipVersion() == 11 && !isChipConfigured()) { + ret = FAIL; + strcpy(mess, + "Could not start acquisition. Chip is not configured. " + "Power it on to configure it.\n"); + LOG(logERROR, (mess)); + } else +#endif +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) + if ((getReadoutMode() == ANALOG_AND_DIGITAL || + getReadoutMode() == ANALOG_ONLY) && + (getNumAnalogSamples() <= 0)) { + ret = FAIL; + sprintf(mess, + "Could not start acquisition. Invalid number of analog " + "samples: %d.\n", + getNumAnalogSamples()); + LOG(logERROR, (mess)); + } else if ((getReadoutMode() == ANALOG_AND_DIGITAL || + getReadoutMode() == DIGITAL_ONLY || + getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && + (getNumDigitalSamples() <= 0)) { + ret = FAIL; + sprintf( + mess, "Could not start acquisition. Invalid number of digital " "samples: %d.\n", getNumDigitalSamples()); - LOG(logERROR, (mess)); - } else if ((getReadoutMode() == TRANSCEIVER_ONLY || - getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && - (getNumTransceiverSamples() <= 0)) { - ret = FAIL; - sprintf( - mess, - "Could not start acquisition. Invalid number of transceiver " - "samples: %d.\n", - getNumTransceiverSamples()); - LOG(logERROR, (mess)); - } else + LOG(logERROR, (mess)); + } else if ((getReadoutMode() == TRANSCEIVER_ONLY || + getReadoutMode() == DIGITAL_AND_TRANSCEIVER) && + (getNumTransceiverSamples() <= 0)) { + ret = FAIL; + sprintf(mess, + "Could not start acquisition. Invalid number of " + "transceiver " + "samples: %d.\n", + getNumTransceiverSamples()); + LOG(logERROR, (mess)); + } else #endif #ifdef EIGERD - // check for hardware mac and hardware ip - if (udpDetails[0].srcmac != getDetectorMAC()) { - ret = FAIL; - uint64_t sourcemac = getDetectorMAC(); - char src_mac[MAC_ADDRESS_SIZE]; - getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); - sprintf(mess, - "Invalid udp source mac address for this detector. Must be " - "same as hardware detector mac address %s\n", - src_mac); - LOG(logERROR, (mess)); - } else if (!enableTenGigabitEthernet(GET_FLAG) && - (udpDetails[0].srcip != getDetectorIP())) { - ret = FAIL; - uint32_t sourceip = getDetectorIP(); - char src_ip[INET_ADDRSTRLEN]; - getIpAddressinString(src_ip, sourceip); - sprintf(mess, - "Invalid udp source ip address for this detector. Must be " - "same as hardware detector ip address %s in 1G readout " - "mode \n", - src_ip); - LOG(logERROR, (mess)); - } else + // check for hardware mac and hardware ip + if (udpDetails[0].srcmac != getDetectorMAC()) { + ret = FAIL; + uint64_t sourcemac = getDetectorMAC(); + char src_mac[MAC_ADDRESS_SIZE]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, sourcemac); + sprintf(mess, + "Invalid udp source mac address for this detector. " + "Must be " + "same as hardware detector mac address %s\n", + src_mac); + LOG(logERROR, (mess)); + } else if (!enableTenGigabitEthernet(GET_FLAG) && + (udpDetails[0].srcip != getDetectorIP())) { + ret = FAIL; + uint32_t sourceip = getDetectorIP(); + char src_ip[INET_ADDRSTRLEN]; + getIpAddressinString(src_ip, sourceip); + sprintf( + mess, + "Invalid udp source ip address for this detector. Must " + "be " + "same as hardware detector ip address %s in 1G readout " + "mode \n", + src_ip); + LOG(logERROR, (mess)); + } else #endif - if (configured == FAIL) { - ret = FAIL; - strcpy(mess, "Could not start acquisition because "); - strcat(mess, configureMessage); - LOG(logERROR, (mess)); - } else if (sharedMemory_getScanStatus() == RUNNING) { - ret = FAIL; - strcpy(mess, "Could not start acquisition because a scan is " - "already running!\n"); - LOG(logERROR, (mess)); - } else { - memset(scanErrMessage, 0, MAX_STR_LENGTH); - sharedMemory_setScanStop(0); - sharedMemory_setScanStatus(IDLE); // if it was error - if (pthread_create(&pthread_tid, NULL, &start_state_machine, - &blocking)) { - ret = FAIL; - strcpy(mess, "Could not start acquisition thread!\n"); - LOG(logERROR, (mess)); - } else { - // wait for blocking always (scan or not) - // non blocking-no scan also wait (for error message) - // non blcoking-scan dont wait (there is scanErrorMessage) - if (blocking || !scan) { - pthread_join(pthread_tid, NULL); + if (configured == FAIL) { + ret = FAIL; + strcpy(mess, "Could not start acquisition because "); + strcat(mess, configureMessage); + LOG(logERROR, (mess)); + } else if (sharedMemory_getScanStatus() == RUNNING) { + ret = FAIL; + strcpy(mess, + "Could not start acquisition because a scan is " + "already running!\n"); + LOG(logERROR, (mess)); + } else { + memset(scanErrMessage, 0, MAX_STR_LENGTH); + sharedMemory_setScanStop(0); + sharedMemory_setScanStatus(IDLE); // if it was error + if (pthread_create(&pthread_tid, NULL, &start_state_machine, + &blocking)) { + ret = FAIL; + strcpy(mess, "Could not start acquisition thread!\n"); + LOG(logERROR, (mess)); + } else { + // wait for blocking always (scan or not) + // non blocking-no scan also wait (for error message) + // non blcoking-scan dont wait (there is + // scanErrorMessage) + if (blocking || !scan) { + pthread_join(pthread_tid, NULL); + } + } } - } - } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } void *start_state_machine(void *arg) { -#ifndef XILINX_CHIPTESTBOARDD int *blocking = (int *)arg; int times = 1; // start of scan @@ -2047,6 +2107,7 @@ void *start_state_machine(void *arg) { if (scan == 0) { LOG(logINFOBLUE, ("Normal Acquisition (not scan)\n")); } +#ifndef XILINX_CHIPTESTBOARDD // scan else { // check scan stop @@ -2089,6 +2150,7 @@ void *start_state_machine(void *arg) { } usleep(scanSettleTime_ns / 1000); } +#endif ret = startStateMachine(); LOG(logDEBUG2, ("Starting Acquisition ret: %d\n", ret)); if (ret == FAIL) { @@ -2160,7 +2222,6 @@ void *start_state_machine(void *arg) { if (scan && sharedMemory_getScanStatus() != ERROR) { sharedMemory_setScanStatus(IDLE); } -#endif return NULL; } @@ -2178,9 +2239,6 @@ int stop_acquisition(int file_des) { memset(mess, 0, sizeof(mess)); LOG(logDEBUG1, ("Stopping Acquisition\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { ret = stopStateMachine(); @@ -2190,7 +2248,6 @@ int stop_acquisition(int file_des) { } LOG(logDEBUG1, ("Stopping Acquisition ret: %d\n", ret)); } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -2200,13 +2257,9 @@ int get_run_status(int file_des) { enum runStatus retval = ERROR; LOG(logDEBUG1, ("Getting status\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only get retval = getRunStatus(); LOG(logDEBUG1, ("Status: %d\n", retval)); -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -2384,7 +2437,7 @@ int get_num_analog_samples(int file_des) { memset(mess, 0, sizeof(mess)); int retval = -1; -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -2403,7 +2456,7 @@ int set_num_analog_samples(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting number of analog samples %d\n", arg)); -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -2433,7 +2486,7 @@ int get_num_digital_samples(int file_des) { memset(mess, 0, sizeof(mess)); int retval = -1; -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -2452,7 +2505,7 @@ int set_num_digital_samples(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting number of digital samples %d\n", arg)); -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -2484,9 +2537,6 @@ int get_exptime(int file_des) { if (receiveData(file_des, &gateIndex, sizeof(gateIndex), INT32) < 0) return printSocketReadError(); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only #ifdef MYTHEN3D if (gateIndex < 0 || gateIndex > 2) { @@ -2510,7 +2560,6 @@ int get_exptime(int file_des) { retval = getExpTime(); LOG(logDEBUG1, ("retval exptime %lld ns\n", (long long int)retval)); } -#endif #endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -2527,9 +2576,6 @@ int set_exptime(int file_des) { LOG(logDEBUG1, ("Setting exptime %lld ns (gateIndex:%d)\n", (long long int)val, gateIndex)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { #ifdef MYTHEN3D @@ -2594,7 +2640,6 @@ int set_exptime(int file_des) { } #endif } -#endif return Server_SendResult(file_des, INT64, NULL, 0); } @@ -2603,13 +2648,9 @@ int get_period(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = getPeriod(); LOG(logDEBUG1, ("retval period %lld ns\n", (long long int)retval)); -#endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -2622,9 +2663,6 @@ int set_period(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting period %lld ns\n", (long long int)arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { ret = setPeriod(arg); @@ -2636,7 +2674,6 @@ int set_period(int file_des) { LOG(logERROR, (mess)); } } -#endif return Server_SendResult(file_des, INT64, NULL, 0); } @@ -2646,7 +2683,8 @@ int get_delay_after_trigger(int file_des) { int64_t retval = -1; #if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \ - !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) + !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -2668,7 +2706,8 @@ int set_delay_after_trigger(int file_des) { ("Setting delay after trigger %lld ns\n", (long long int)arg)); #if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \ - !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) + !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -2926,9 +2965,9 @@ int get_period_left(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#if !defined(JUNGFRAUD) && !defined(MOENCHD) && \ - !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \ -&& !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/ +#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \ + !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -2943,9 +2982,9 @@ int get_delay_after_trigger_left(int file_des) { memset(mess, 0, sizeof(mess)); int64_t retval = -1; -#if !defined(JUNGFRAUD) && !defined(MOENCHD) && \ - !defined(GOTTHARDD) /* && !defined(CHIPTESTBOARDD) \ -&& !defined(MYTHEN3D) && !defined(GOTTHARD2D)*/ +#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARDD) && \ + !defined(CHIPTESTBOARDD) && !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -2993,7 +3032,8 @@ int get_frames_from_start(int file_des) { int64_t retval = -1; #if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \ - !defined(MYTHEN3D) && !defined(GOTTHARD2D) + !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -3009,7 +3049,8 @@ int get_actual_time(int file_des) { int64_t retval = -1; #if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \ - !defined(MYTHEN3D) && !defined(GOTTHARD2D) + !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -3025,7 +3066,8 @@ int get_measurement_time(int file_des) { int64_t retval = -1; #if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(CHIPTESTBOARDD) && \ - !defined(MYTHEN3D) && !defined(GOTTHARD2D) + !defined(MYTHEN3D) && !defined(GOTTHARD2D) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -3306,7 +3348,7 @@ int set_pattern_io_control(int file_des) { if (receiveData(file_des, &arg, sizeof(arg), INT64) < 0) return printSocketReadError(); -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else LOG(logDEBUG1, @@ -3323,7 +3365,7 @@ int get_pattern_io_control(int file_des) { memset(mess, 0, sizeof(mess)); uint64_t retval64 = -1; -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else LOG(logDEBUG1, ("Getting Pattern IO Control\n")); @@ -4008,7 +4050,7 @@ int reset_fpga(int file_des) { LOG(logDEBUG1, ("Reset FPGA\n")); #if defined(EIGERD) || defined(GOTTHARDD) || defined(GOTTHARD2D) || \ - defined(MYTHEN3D) || defined(XILINX_CHIPTESTBOARDD) + defined(MYTHEN3D) functionNotImplemented(); #else // only set @@ -4050,7 +4092,7 @@ int power_chip(int file_des) { LOG(logDEBUG1, ("Powering chip to %d\n", arg)); #if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(MYTHEN3D) && \ - !defined(GOTTHARD2D) + !defined(GOTTHARD2D) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // set & get @@ -4069,11 +4111,30 @@ int power_chip(int file_des) { } } #endif +#ifdef XILINX_CHIPTESTBOARDD + if (ret == OK) { + if (arg != -1) { + if (arg != 0 && arg != 1) { + ret = FAIL; + sprintf(mess, "Power chip %d should be 0 or 1\n", arg); + LOG(logERROR, (mess)); + } else { + ret = powerChip(arg, mess); + } + } + if (ret == OK) { + retval = getPowerChip(); + LOG(logDEBUG1, ("Power chip: %d\n", retval)); + validate(&ret, mess, arg, retval, "power on/off chip", DEC); + } + } +#else if (ret == OK) { retval = powerChip(arg); LOG(logDEBUG1, ("Power chip: %d\n", retval)); } validate(&ret, mess, arg, retval, "power on/off chip", DEC); +#endif #if defined(JUNGFRAUD) || defined(MOENCHD) // narrow down error when powering on if (ret == FAIL && arg > 0) { @@ -4388,7 +4449,7 @@ int reboot_controller(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); -#if defined(EIGERD) || defined(XILINX_CHIPTESTBOARDD) +#if defined(EIGERD) functionNotImplemented(); #elif VIRTUAL ret = GOODBYE; @@ -4469,7 +4530,7 @@ int set_adc_enable_mask_10g(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Seting 10Gb ADC Enable Mask to %u\n", arg)); -#if (!defined(CHIPTESTBOARDD)) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -4496,7 +4557,7 @@ int get_adc_enable_mask_10g(int file_des) { LOG(logDEBUG1, ("Getting 10Gb ADC Enable Mask\n")); -#if (!defined(CHIPTESTBOARDD)) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get @@ -4619,7 +4680,7 @@ int set_next_frame_number(int file_des) { LOG(logDEBUG1, ("Setting next frame number to %llu\n", arg)); #if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \ - !defined(CHIPTESTBOARDD) + !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -4669,7 +4730,7 @@ int set_next_frame_number(int file_des) { } else { if (arg != retval) { ret = FAIL; -#ifdef VIRTUAL +#if defined(VIRTUAL) || defined(XILINX_CHIPTESTBOARDD) sprintf(mess, "Could not set next frame number. Set " "0x%lx, but read 0x%lx\n", @@ -4698,7 +4759,7 @@ int get_next_frame_number(int file_des) { LOG(logDEBUG1, ("Getting next frame number \n")); #if !defined(EIGERD) && !defined(JUNGFRAUD) && !defined(MOENCHD) && \ - !defined(CHIPTESTBOARDD) + !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get @@ -5146,9 +5207,6 @@ int set_source_udp_ip(int file_des) { arg = __builtin_bswap32(arg); LOG(logINFO, ("Setting udp source ip: 0x%x\n", arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { if (check_detector_idle("configure mac") == OK) { @@ -5161,7 +5219,6 @@ int set_source_udp_ip(int file_des) { } } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -5171,14 +5228,10 @@ int get_source_udp_ip(int file_des) { uint32_t retval = -1; LOG(logDEBUG1, ("Getting udp source ip\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = udpDetails[0].srcip; retval = __builtin_bswap32(retval); LOG(logDEBUG1, ("udp soure ip retval: 0x%x\n", retval)); -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -5238,9 +5291,6 @@ int set_dest_udp_ip(int file_des) { arg = __builtin_bswap32(arg); LOG(logINFO, ("Setting udp destination ip: 0x%x\n", arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { if (check_detector_idle("configure mac") == OK) { @@ -5250,7 +5300,6 @@ int set_dest_udp_ip(int file_des) { } } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -5260,14 +5309,10 @@ int get_dest_udp_ip(int file_des) { uint32_t retval = -1; LOG(logDEBUG1, ("Getting destination ip\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = udpDetails[0].dstip; retval = __builtin_bswap32(retval); LOG(logDEBUG1, ("udp destination ip retval: 0x%x\n", retval)); -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -5323,9 +5368,6 @@ int set_source_udp_mac(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting udp source mac: 0x%lx\n", arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { if (check_detector_idle("configure mac") == OK) { @@ -5347,7 +5389,6 @@ int set_source_udp_mac(int file_des) { } } } -#endif return Server_SendResult(file_des, INT64, NULL, 0); } @@ -5356,13 +5397,9 @@ int get_source_udp_mac(int file_des) { memset(mess, 0, sizeof(mess)); uint64_t retval = -1; LOG(logDEBUG1, ("Getting udp source mac\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = udpDetails[0].srcmac; LOG(logDEBUG1, ("udp soure mac retval: 0x%lx\n", retval)); -#endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -5419,9 +5456,6 @@ int set_dest_udp_mac(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting udp destination mac: 0x%lx\n", arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { if (check_detector_idle("configure mac") == OK) { @@ -5431,7 +5465,6 @@ int set_dest_udp_mac(int file_des) { } } } -#endif return Server_SendResult(file_des, INT64, NULL, 0); } @@ -5440,13 +5473,9 @@ int get_dest_udp_mac(int file_des) { memset(mess, 0, sizeof(mess)); uint64_t retval = -1; LOG(logDEBUG1, ("Getting udp destination mac\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = udpDetails[0].dstmac; LOG(logDEBUG1, ("udp destination mac retval: 0x%lx\n", retval)); -#endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -5500,9 +5529,6 @@ int set_dest_udp_port(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting udp destination port: %hu\n", arg)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { if (check_detector_idle("configure mac") == OK) { @@ -5512,7 +5538,6 @@ int set_dest_udp_port(int file_des) { } } } -#endif return Server_SendResult(file_des, INT16, NULL, 0); } @@ -5521,13 +5546,9 @@ int get_dest_udp_port(int file_des) { memset(mess, 0, sizeof(mess)); uint16_t retval = -1; LOG(logDEBUG1, ("Getting destination port")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // get only retval = udpDetails[0].dstport; LOG(logDEBUG, ("udp destination port retval: %hu\n", retval)); -#endif return Server_SendResult(file_des, INT16, &retval, sizeof(retval)); } @@ -5583,8 +5604,7 @@ int set_num_interfaces(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting number of interfaces: %d\n", arg)); -#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D) && \ - !defined(XLINX_CHIPTESTBOARDD) +#if !defined(JUNGFRAUD) && !defined(MOENCHD) && !defined(GOTTHARD2D) // fixed number of udp interfaces int num_interfaces = getNumberofUDPInterfaces(); if (arg != num_interfaces) { @@ -5817,7 +5837,7 @@ int set_readout_mode(int file_des) { return printSocketReadError(); LOG(logINFO, ("Setting readout mode: %u\n", arg)); -#ifndef CHIPTESTBOARDD +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set @@ -5863,7 +5883,7 @@ int get_readout_mode(int file_des) { LOG(logDEBUG1, ("Getting readout mode\n")); -#ifndef CHIPTESTBOARDD +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -7118,10 +7138,6 @@ int get_receiver_parameters(int file_des) { memset(mess, 0, sizeof(mess)); LOG(logDEBUG1, ("Getting receiver parameters\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); - Server_SendResult(file_des, INT32, NULL, 0); -#else // get only Server_SendResult(file_des, INT32, NULL, 0); @@ -7245,7 +7261,7 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); // analog samples -#if defined(CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) i32 = getNumAnalogSamples(); #else i32 = 0; @@ -7255,7 +7271,7 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); // digital samples -#ifdef CHIPTESTBOARDD +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) i32 = getNumDigitalSamples(); #else i32 = 0; @@ -7394,7 +7410,7 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); // readout mode -#ifdef CHIPTESTBOARDD +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) i32 = getReadoutMode(); #else i32 = 0; @@ -7414,7 +7430,7 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); // 10g adc mask -#if defined(CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) u32 = getADCEnableMask_10G(); #else u32 = 0; @@ -7559,7 +7575,7 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); // transceiver samples -#ifdef CHIPTESTBOARDD +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) i32 = getNumTransceiverSamples(); #else i32 = 0; @@ -7569,7 +7585,7 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); // transceiver mask -#if defined(CHIPTESTBOARDD) +#if defined(CHIPTESTBOARDD) || defined(XILINX_CHIPTESTBOARDD) u32 = getTransceiverEnableMask(); #else u32 = 0; @@ -7579,7 +7595,6 @@ int get_receiver_parameters(int file_des) { return printSocketReadError(); LOG(logINFO, ("Sent %d bytes for receiver parameters\n", n)); -#endif return OK; } @@ -7924,9 +7939,6 @@ int set_scan(int file_des) { if (receiveData(file_des, &dacTime, sizeof(dacTime), INT64) < 0) return printSocketReadError(); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { int enable = args[0]; @@ -8016,7 +8028,6 @@ int set_scan(int file_des) { } } } -#endif return Server_SendResult(file_des, INT64, &retval, sizeof(retval)); } @@ -8374,9 +8385,6 @@ int reconfigure_udp(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else if (Server_VerifyLock() == OK) { LOG(logINFO, ("Reconfiguring UDP\n")); if (check_detector_idle("configure mac") == OK) { @@ -8389,7 +8397,6 @@ int reconfigure_udp(int file_des) { } } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -8426,7 +8433,8 @@ int get_bursts_left(int file_des) { int start_readout(int file_des) { ret = OK; memset(mess, 0, sizeof(mess)); -#if !defined(MYTHEN3D) && !defined(CHIPTESTBOARDD) +#if !defined(MYTHEN3D) && !defined(CHIPTESTBOARDD) && \ + !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else if (Server_VerifyLock() == OK) { @@ -9566,10 +9574,6 @@ int clear_all_udp_dst(int file_des) { LOG(logINFO, ("Clearing all udp destinations\n")); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else - if (Server_VerifyLock() == OK) { if (check_detector_idle("clear all udp destinations") == OK) { memset(udpDetails, 0, sizeof(udpDetails)); @@ -9597,7 +9601,6 @@ int clear_all_udp_dst(int file_des) { } } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -10567,10 +10570,6 @@ int set_bit(int file_des) { int nBit = (int)args[1]; LOG(logDEBUG1, ("Setting bit %d of reg 0x%x\n", nBit, addr)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else - // only set if (Server_VerifyLock() == OK) { if (nBit < 0 || nBit > 31) { @@ -10601,7 +10600,6 @@ int set_bit(int file_des) { } } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -10616,9 +10614,6 @@ int clear_bit(int file_des) { int nBit = (int)args[1]; LOG(logDEBUG1, ("Clearing bit %d of reg 0x%x\n", nBit, addr)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else // only set if (Server_VerifyLock() == OK) { if (nBit < 0 || nBit > 31) { @@ -10649,7 +10644,6 @@ int clear_bit(int file_des) { } } } -#endif return Server_SendResult(file_des, INT32, NULL, 0); } @@ -10665,9 +10659,6 @@ int get_bit(int file_des) { int nBit = (int)args[1]; LOG(logDEBUG1, ("Getting bit %d of reg 0x%x\n", nBit, addr)); -#ifdef XILINX_CHIPTESTBOARDD - functionNotImplemented(); -#else if (nBit < 0 || nBit > 31) { ret = FAIL; sprintf(mess, @@ -10692,7 +10683,6 @@ int get_bit(int file_des) { LOG(logDEBUG1, ("regval: 0x%x bit value:0%d\n", regval, retval)); #endif } -#endif return Server_SendResult(file_des, INT32, &retval, sizeof(retval)); } @@ -10701,7 +10691,7 @@ int get_num_transceiver_samples(int file_des) { memset(mess, 0, sizeof(mess)); int retval = -1; -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get only @@ -10720,24 +10710,33 @@ int set_num_transceiver_samples(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting number of transceiver samples %d\n", arg)); -#if !defined(CHIPTESTBOARDD) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set if (Server_VerifyLock() == OK) { - ret = setNumTransceiverSamples(arg); - if (ret == FAIL) { - sprintf( - mess, - "Could not set number of transceiver samples to %d. Could not " - "allocate RAM\n", - arg); + if (arg < 0 || arg > MAX_TRANSCEIVER_SAMPLES) { + ret = FAIL; + sprintf(mess, + "Could not set number of transceiver samples. Invalid " + "value %d. Must be 0-%d\n", + arg, MAX_TRANSCEIVER_SAMPLES); LOG(logERROR, (mess)); } else { - int retval = getNumTransceiverSamples(); - LOG(logDEBUG1, ("retval num transceiver samples %d\n", retval)); - validate(&ret, mess, arg, retval, - "set number of transceiver samples", DEC); + ret = setNumTransceiverSamples(arg); + if (ret == FAIL) { + sprintf(mess, + "Could not set number of transceiver samples to %d. " + "Could not " + "allocate RAM\n", + arg); + LOG(logERROR, (mess)); + } else { + int retval = getNumTransceiverSamples(); + LOG(logDEBUG1, ("retval num transceiver samples %d\n", retval)); + validate(&ret, mess, arg, retval, + "set number of transceiver samples", DEC); + } } } #endif @@ -10753,14 +10752,14 @@ int set_transceiver_enable(int file_des) { return printSocketReadError(); LOG(logDEBUG1, ("Setting Transceiver Enable Mask to %u\n", arg)); -#if (!defined(CHIPTESTBOARDD)) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // only set if (Server_VerifyLock() == OK) { if (arg > MAX_TRANSCEIVER_MASK) { ret = FAIL; - sprintf(mess, "Invalid Transceiver Mask. Max: 0x%x\n", + sprintf(mess, "Invalid Transceiver Mask. Option: 0 - 0x%x\n", MAX_TRANSCEIVER_MASK); LOG(logERROR, (mess)); } else { @@ -10795,7 +10794,7 @@ int get_transceiver_enable(int file_des) { LOG(logDEBUG1, ("Getting Transceiver Enable Mask \n")); -#if (!defined(CHIPTESTBOARDD)) +#if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD) functionNotImplemented(); #else // get @@ -11032,3 +11031,21 @@ int set_pedestal_mode(int file_des) { #endif return Server_SendResult(file_des, INT32, NULL, 0); } + +int config_transceiver(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + +#if !defined(XILINX_CHIPTESTBOARDD) + functionNotImplemented(); +#else + if (Server_VerifyLock() == OK) { + LOG(logINFO, ("Configuring Transceiver\n")); + ret = configureTransceiver(mess); + if (ret == FAIL) { + LOG(logERROR, (mess)); + } + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); +} diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt b/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt index 2f93c61f8..78a5fbfb7 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt +++ b/slsDetectorServers/xilinx_ctbDetectorServer/CMakeLists.txt @@ -9,7 +9,10 @@ add_executable(xilinx_ctbDetectorServer_virtual ../slsDetectorServer/src/common.c ../slsDetectorServer/src/sharedMemory.c ../slsDetectorServer/src/loadPattern.c + ../slsDetectorServer/src/programViaArm.c + ../slsDetectorServer/src/communication_funcs_UDP.c ../../slsSupportLib/src/md5.c + ../slsDetectorServer/src/LTC2620_Driver.c ) include_directories( @@ -23,11 +26,11 @@ target_include_directories(xilinx_ctbDetectorServer_virtual ) target_compile_definitions(xilinx_ctbDetectorServer_virtual - PUBLIC XILINX_CHIPTESTBOARDD ARMPROCESSOR VIRTUAL STOP_SERVER + PUBLIC XILINX_CHIPTESTBOARDD ARMPROCESSOR VIRTUAL STOP_SERVER ) target_link_libraries(xilinx_ctbDetectorServer_virtual - PUBLIC pthread rt slsProjectCSettings + PUBLIC pthread rt m slsProjectCSettings ) set_target_properties(xilinx_ctbDetectorServer_virtual PROPERTIES diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/Makefile b/slsDetectorServers/xilinx_ctbDetectorServer/Makefile index e5e3a6b54..e8589a5c7 100755 --- a/slsDetectorServers/xilinx_ctbDetectorServer/Makefile +++ b/slsDetectorServers/xilinx_ctbDetectorServer/Makefile @@ -18,7 +18,7 @@ DESTDIR ?= bin INSTMODE = 0777 SRCS = slsDetectorFunctionList.c -SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)arm64.c $(main_src)common.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c +SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)arm64.c $(main_src)common.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c $(main_src)programViaArm.c $(main_src)LTC2620_Driver.c OBJS = $(SRCS:.c=.o) diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h b/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h index 6055a2c94..1bd4ca554 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/RegisterDefs.h @@ -2,28 +2,48 @@ // Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once -#define CTRLREG1 (0x0) +#define CTRL_REG (0x0) -#define CTRLREG2 (0x4) +#define POWER_VIO_OFST (0) +#define POWER_VIO_MSK (0x00000001 << POWER_VIO_OFST) +#define POWER_VCC_A_OFST (1) +#define POWER_VCC_A_MSK (0x00000001 << POWER_VCC_A_OFST) +#define POWER_VCC_B_OFST (2) +#define POWER_VCC_B_MSK (0x00000001 << POWER_VCC_B_OFST) +#define POWER_VCC_C_OFST (3) +#define POWER_VCC_C_MSK (0x00000001 << POWER_VCC_C_OFST) +#define POWER_VCC_D_OFST (4) +#define POWER_VCC_D_MSK (0x00000001 << POWER_VCC_D_OFST) + +#define EMPTY4REG (0x4) #define STATUSREG1 (0x8) +#define TRANSMISSIONBUSY_OFST (0) +#define TRANSMISSIONBUSY_MSK (0x00000001 << TRANSMISSIONBUSY_OFST) + #define STATUSREG2 (0xC) #define FPGAVERSIONREG (0x10) -#define COMPDATE_OFST (0) -#define COMPDATE_MSK (0x00ffffff << COMPDATE_OFST) -#define DETTYPE_OFST (24) -#define DETTYPE_MSK (0x000000ff << DETTYPE_OFST) +#define FPGACOMPDATE_OFST (0) +#define FPGACOMPDATE_MSK (0x00ffffff << FPGACOMPDATE_OFST) +#define FPGADETTYPE_OFST (24) +#define FPGADETTYPE_MSK (0x000000ff << FPGADETTYPE_OFST) #define EMPTY14REG (0x14) -#define EMPTY18REG (0x18) +#define FIXEDPATTERNREG (0x18) +#define FIXEDPATTERNVAL (0xACDC2016) #define EMPTY1CREG (0x1C) -#define EMPTY20REG (0x20) +#define APIVERSIONREG (0x20) + +#define APICOMPDATE_OFST (0) +#define APICOMPDATE_MSK (0x00ffffff << APICOMPDATE_OFST) +#define APIDETTYPE_OFST (24) +#define APIDETTYPE_MSK (0x000000ff << APIDETTYPE_OFST) #define EMPTY24REG (0x24) @@ -112,75 +132,75 @@ #define EMPTY9CREG (0x9C) -#define FLOWSTATUSREG (0x100) +#define FLOW_STATUS_REG (0x100) -#define RSMBUSY_OFST (0) -#define RSMBUSY_MSK (0x00000001 << RSMBUSY_OFST) -#define RSMTRGWAIT_OFST (3) -#define RSMTRGWAIT_MSK (0x00000001 << RSMTRGWAIT_OFST) -#define CSMBUSY_OFST (17) -#define CSMBUSY_MSK (0x00000001 << CSMBUSY_OFST) +#define RSM_BUSY_OFST (0) +#define RSM_BUSY_MSK (0x00000001 << RSM_BUSY_OFST) +#define RSM_TRG_WAIT_OFST (3) +#define RSM_TRG_WAIT_MSK (0x00000001 << RSM_TRG_WAIT_OFST) +#define CSM_BUSY_OFST (17) +#define CSM_BUSY_MSK (0x00000001 << CSM_BUSY_OFST) #define EMPTY104REG (0x104) -#define FLOWCONTROLREG (0x108) +#define FLOW_CONTROL_REG (0x108) -#define STARTF_OFST (0) -#define STARTF_MSK (0x00000001 << STARTF_OFST) -#define STOPF_OFST (1) -#define STOPF_MSK (0x00000001 << STOPF_OFST) -#define RSTF_OFST (2) -#define RSTF_MSK (0x00000001 << RSTF_OFST) -#define SWTRIGGERF_OFST (3) -#define SWTRIGGERF_MSK (0x00000001 << SWTRIGGERF_OFST) -#define TRIGGERENABLE_OFST (4) -#define TRIGGERENABLE_MSK (0x00000001 << TRIGGERENABLE_OFST) +#define START_F_OFST (0) +#define START_F_MSK (0x00000001 << START_F_OFST) +#define STOP_F_OFST (1) +#define STOP_F_MSK (0x00000001 << STOP_F_OFST) +#define RST_F_OFST (2) +#define RST_F_MSK (0x00000001 << RST_F_OFST) +#define SW_TRIGGER_F_OFST (3) +#define SW_TRIGGER_F_MSK (0x00000001 << SW_TRIGGER_F_OFST) +#define TRIGGER_ENABLE_OFST (4) +#define TRIGGER_ENABLE_MSK (0x00000001 << TRIGGER_ENABLE_OFST) #define EMPTY10CREG (0x10C) -#define TIMEFROMSTARTOUTREG1 (0x110) +#define TIME_FROM_START_OUT_REG_1 (0x110) -#define TIMEFROMSTARTOUTREG2 (0x114) +#define TIME_FROM_START_OUT_REG_2 (0x114) -#define FRAMESFROMSTARTOUTREG1 (0x118) +#define FRAMES_FROM_START_OUT_REG_1 (0x118) -#define FRAMESFROMSTARTOUTREG2 (0x11C) +#define FRAMES_FROM_START_OUT_REG_2 (0x11C) -#define FRAMETIMEOUTREG1 (0x120) +#define FRAME_TIME_OUT_REG_1 (0x120) -#define FRAMETIMEOUTREG2 (0x124) +#define FRAME_TIME_OUT_REG_2 (0x124) -#define DELAYOUTREG1 (0x128) +#define DELAY_OUT_REG_1 (0x128) -#define DELAYOUTREG2 (0x12C) +#define DELAY_OUT_REG_2 (0x12C) -#define CYCLESOUTREG1 (0x130) +#define CYCLES_OUT_REG_1 (0x130) -#define CYCLESOUTREG2 (0x134) +#define CYCLES_OUT_REG_2 (0x134) -#define FRAMESOUTREG1 (0x138) +#define FRAMES_OUT_REG_1 (0x138) -#define FRAMESOUTREG2 (0x13C) +#define FRAMES_OUT_REG_2 (0x13C) -#define PERIODOUTREG1 (0x140) +#define PERIOD_OUT_REG_1 (0x140) -#define PERIODOUTREG2 (0x144) +#define PERIOD_OUT_REG_2 (0x144) -#define DELAYINREG1 (0x148) +#define DELAY_IN_REG_1 (0x148) -#define DELAYINREG2 (0x14C) +#define DELAY_IN_REG_2 (0x14C) -#define CYCLESINREG1 (0x150) +#define CYCLES_IN_REG_1 (0x150) -#define CYCLESINREG2 (0x154) +#define CYCLES_IN_REG_2 (0x154) -#define FRAMESINREG1 (0x158) +#define FRAMES_IN_REG_1 (0x158) -#define FRAMESINREG2 (0x15C) +#define FRAMES_IN_REG_2 (0x15C) -#define PERIODINREG1 (0x160) +#define PERIOD_IN_REG_1 (0x160) -#define PERIODINREG2 (0x164) +#define PERIOD_IN_REG_2 (0x164) #define EMPTY168REG (0x168) @@ -484,18 +504,15 @@ #define EMPTY3FCREG (0x3FC) -#define EXPCTRLREG (0x400) - -#define STARTP_OFST (0) -#define STARTP_MSK (0x00000001 << STARTP_OFST) +#define EMPTY400REG (0x400) #define EMPTY404REG (0x404) -#define EXPFRAMESREG (0x408) +#define EMPTY408REG (0x408) #define EMPTY40CREG (0x40C) -#define EXPTIMEREG (0x410) +#define EMPTY410REG (0x410) #define EMPTY414REG (0x414) @@ -615,47 +632,56 @@ #define EMPTY4FCREG (0x4FC) -#define FIFOTOGBCONTROLREG (0x500) +#define FIFO_TO_GB_CONTROL_REG (0x500) -#define ENABLEDCHANNELS_OFST (0) -#define ENABLEDCHANNELS_MSK (0x00001fff << ENABLEDCHANNELS_OFST) -#define ROMODE_OFST (13) -#define ROMODE_MSK (0x00000007 << ROMODE_OFST) -#define COUNTFRAMESFROMUPDATE_OFST (16) -#define COUNTFRAMESFROMUPDATE_MSK (0x00000001 << COUNTFRAMESFROMUPDATE_OFST) -#define STARTSTREAMING_P_OFST (17) -#define STARTSTREAMING_P_MSK (0x00000001 << STARTSTREAMING_P_OFST) +#define ENABLED_CHANNELS_ADC_OFST (0) +#define ENABLED_CHANNELS_ADC_MSK (0x000000ff << ENABLED_CHANNELS_ADC_OFST) +#define ENABLED_CHANNELS_D_OFST (8) +#define ENABLED_CHANNELS_D_MSK (0x00000001 << ENABLED_CHANNELS_D_OFST) +#define ENABLED_CHANNELS_X_OFST (9) +#define ENABLED_CHANNELS_X_MSK (0x0000000f << ENABLED_CHANNELS_X_OFST) +#define RO_MODE_ADC_OFST (13) +#define RO_MODE_ADC_MSK (0x00000001 << RO_MODE_ADC_OFST) +#define RO_MODE_D_OFST (14) +#define RO_MODE_D_MSK (0x00000001 << RO_MODE_D_OFST) +#define RO_MODE_X_OFST (15) +#define RO_MODE_X_MSK (0x00000001 << RO_MODE_X_OFST) +#define COUNT_FRAMES_FROM_UPDATE_OFST (16) +#define COUNT_FRAMES_FROM_UPDATE_MSK \ + (0x00000001 << COUNT_FRAMES_FROM_UPDATE_OFST) +#define START_STREAMING_P_OFST (17) +#define START_STREAMING_P_MSK (0x00000001 << START_STREAMING_P_OFST) #define EMPTY504REG (0x504) -#define NOSAMPLESDREG (0x508) +#define NO_SAMPLES_D_REG (0x508) -#define NOSAMPLESD_OFST (0) -#define NOSAMPLESD_MSK (0x00003fff << NOSAMPLESD_OFST) +#define NO_SAMPLES_D_OFST (0) +#define NO_SAMPLES_D_MSK (0x00003fff << NO_SAMPLES_D_OFST) #define EMPTY50CREG (0x50C) -#define NOSAMPLESAREG (0x510) +#define NO_SAMPLES_A_REG (0x510) -#define NOSAMPLESA_OFST (0) -#define NOSAMPLESA_MSK (0x00003fff << NOSAMPLESA_OFST) +#define NO_SAMPLES_A_OFST (0) +#define NO_SAMPLES_A_MSK (0x00003fff << NO_SAMPLES_A_OFST) #define EMPTY514REG (0x514) -#define NOSAMPLESXREG (0x518) +#define NO_SAMPLES_X_REG (0x518) -#define NOSAMPLESX_OFST (0) -#define NOSAMPLESX_MSK (0x00001fff << NOSAMPLESX_OFST) +#define NO_SAMPLES_X_OFST (0) +#define NO_SAMPLES_X_MSK (0x00001fff << NO_SAMPLES_X_OFST) #define EMPTY51CREG (0x51C) -#define COUNTFRAMESFROMREG1 (0x520) +#define COUNT_FRAMES_FROM_REG_1 (0x520) -#define COUNTFRAMESFROMREG2 (0x524) +#define COUNT_FRAMES_FROM_REG_2 (0x524) -#define LOCALFRAMENUMBERREG1 (0x528) +#define LOCAL_FRAME_NUMBER_REG_1 (0x528) -#define LOCALFRAMENUMBERREG2 (0x52C) +#define LOCAL_FRAME_NUMBER_REG_2 (0x52C) #define EMPTY530REG (0x530) @@ -697,51 +723,75 @@ #define EMPTY57CREG (0x57C) -#define EMPTY580REG (0x580) +#define A_FIFO_OVERFLOW_STATUS_REG (0x580) #define EMPTY584REG (0x584) -#define EMPTY588REG (0x588) +#define A_FIFO_EMPTY_STATUS_REG (0x588) #define EMPTY58CREG (0x58C) -#define EMPTY590REG (0x590) +#define A_FIFO_FULL_STATUS_REG (0x590) #define EMPTY594REG (0x594) -#define EMPTY598REG (0x598) +#define D_FIFO_OVERFLOW_STATUS_REG (0x598) + +#define D_FIFO_OVERFLOW_STATUS_OFST (0) +#define D_FIFO_OVERFLOW_STATUS_MSK (0x00000001 << D_FIFO_OVERFLOW_STATUS_OFST) #define EMPTY59CREG (0x59C) -#define EMPTY5A0REG (0x5A0) +#define D_FIFO_EMPTY_STATUS_REG (0x5A0) + +#define D_FIFO_EMPTY_STATUS_OFST (0) +#define D_FIFO_EMPTY_STATUS_MSK (0x00000001 << D_FIFO_EMPTY_STATUS_OFST) #define EMPTY5A4REG (0x5A4) -#define EMPTY5A8REG (0x5A8) +#define D_FIFO_FULL_STATUS_REG (0x5A8) + +#define D_FIFO_FULL_STATUS_OFST (0) +#define D_FIFO_FULL_STATUS_MSK (0x00000001 << D_FIFO_FULL_STATUS_OFST) #define EMPTY5ACREG (0x5AC) -#define EMPTY5B0REG (0x5B0) +#define X_FIFO_OVERFLOW_STATUS_REG (0x5B0) + +#define X_FIFO_OVERFLOW_STATUS_OFST (0) +#define X_FIFO_OVERFLOW_STATUS_MSK (0x0000000f << X_FIFO_OVERFLOW_STATUS_OFST) #define EMPTY5B4REG (0x5B4) -#define EMPTY5B8REG (0x5B8) +#define X_FIFO_EMPTY_STATUS_REG (0x5B8) + +#define X_FIFO_EMPTY_STATUS_OFST (0) +#define X_FIFO_EMPTY_STATUS_MSK (0x0000000f << X_FIFO_EMPTY_STATUS_OFST) #define EMPTY5BCREG (0x5BC) -#define EMPTY5C0REG (0x5C0) +#define X_FIFO_FULL_STATUS_REG (0x5C0) + +#define X_FIFO_FULL_STATUS_OFST (0) +#define X_FIFO_FULL_STATUS_MSK (0x0000000f << X_FIFO_FULL_STATUS_OFST) #define EMPTY5C4REG (0x5C4) -#define EMPTY5C8REG (0x5C8) +#define A_FIFO_CLEAN_REG (0x5C8) #define EMPTY5CCREG (0x5CC) -#define EMPTY5D0REG (0x5D0) +#define D_FIFO_CLEAN_REG (0x5D0) + +#define D_FIFO_CLEAN_OFST (0) +#define D_FIFO_CLEAN_MSK (0x00000001 << D_FIFO_CLEAN_OFST) #define EMPTY5D4REG (0x5D4) -#define EMPTY5D8REG (0x5D8) +#define X_FIFO_CLEAN_REG (0x5D8) + +#define X_FIFO_CLEAN_OFST (0) +#define X_FIFO_CLEAN_MSK (0x0000000f << X_FIFO_CLEAN_OFST) #define EMPTY5DCREG (0x5DC) @@ -777,6 +827,8 @@ #define STARTREAD_P_MSK (0x00000001 << STARTREAD_P_OFST) #define BUSY_OFST (4) #define BUSY_MSK (0x00000001 << BUSY_OFST) +#define READOUTFROMASIC_OFST (5) +#define READOUTFROMASIC_MSK (0x00000001 << READOUTFROMASIC_OFST) #define EMPTY60CREG (0x60C) diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer index 92c65c1ba..20f329de2 100755 Binary files a/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer and b/slsDetectorServers/xilinx_ctbDetectorServer/bin/xilinx_ctbDetectorServer_developer differ diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c index 589693c22..caa446311 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorFunctionList.c @@ -4,10 +4,18 @@ #include "arm64.h" #include "clogger.h" #include "common.h" +#include "programViaArm.h" #include "sharedMemory.h" #include "sls/versionAPI.h" +#include "LTC2620_Driver.h" + #include "loadPattern.h" +#ifdef VIRTUAL +#include "communication_funcs_UDP.h" +#include //ceil +#include +#endif #include // INET_ADDRSTRLEN #include @@ -16,10 +24,14 @@ // Global variable from slsDetectorServer_funcs extern int debugflag; extern int updateFlag; +extern int checkModuleFlag; +extern udpStruct udpDetails[MAX_UDP_DESTINATION]; extern const enum detectorType myDetectorType; // Global variable from communication_funcs.c extern int isControlServer; +extern void getMacAddressinString(char *cmac, int size, uint64_t mac); +extern void getIpAddressinString(char *cip, uint32_t ip); int initError = OK; int initCheckDone = 0; @@ -27,6 +39,20 @@ char initErrorMessage[MAX_STR_LENGTH]; int detPos[2] = {0, 0}; +int adcDeviceIndex = 0; +int dacDeviceIndex = 0; +int chipConfigured = 0; +int analogEnable = 0; +int digitalEnable = 0; +int transceiverEnable = 0; +int dacValues[NDAC] = {}; +// software limit that depends on the current chip on the ctb +int vLimit = 0; + +#ifdef VIRTUAL +pthread_t pthread_virtual_tid; +#endif + int isInitCheckDone() { return initCheckDone; } int getInitResult(char **mess) { @@ -43,6 +69,18 @@ void basictests() { #else LOG(logINFOBLUE, ("********** Xilinx Chip Test Board Server **********\n")); #endif + + initError = resetFPGA(initErrorMessage); + if (initError == FAIL) { + return; + } + + initError = + loadDeviceTree(initErrorMessage, &adcDeviceIndex, &dacDeviceIndex); + if (initError == FAIL) { + return; + } + if (mapCSP0() == FAIL) { strcpy(initErrorMessage, "Could not map to memory. Cannot proceed. Check Firmware.\n"); @@ -54,8 +92,7 @@ void basictests() { #ifndef VIRTUAL if ((!debugflag) && (!updateFlag) && ((validateKernelVersion(KERNEL_DATE_VRSN) == FAIL) || - (checkType() == FAIL) || (testFpga() == FAIL) || - (testBus() == FAIL))) { + (checkType() == FAIL) || (testFixedFPGAPattern() == FAIL))) { sprintf(initErrorMessage, "Could not pass basic tests of FPGA and bus. Cannot proceed. " "Check Firmware. (Firmware version:0x%lx) \n", @@ -65,31 +102,83 @@ void basictests() { return; } #endif + char hversion[MAX_STR_LENGTH] = {0}; + memset(hversion, 0, MAX_STR_LENGTH); + getHardwareVersion(hversion); uint32_t ipadd = getDetectorIP(); uint64_t macadd = getDetectorMAC(); int64_t fwversion = getFirmwareVersion(); char swversion[MAX_STR_LENGTH] = {0}; memset(swversion, 0, MAX_STR_LENGTH); getServerVersion(swversion); - uint32_t requiredFirmwareVersion = REQRD_FRMWRE_VRSN; + int64_t sw_fw_apiversion = getFirmwareAPIVersion(); + uint64_t requiredfwversion = REQRD_FRMWRE_VRSN; LOG(logINFOBLUE, ("**************************************************\n" + "Hardware Version:\t\t %s\n" + "Detector IP Addr:\t\t 0x%x\n" "Detector MAC Addr:\t\t 0x%lx\n\n" "Firmware Version:\t\t 0x%lx\n" "Software Version:\t\t %s\n" - "Required Firmware Version:\t 0x%x\n" + "F/w-S/w API Version:\t\t 0x%lx\n" + "Required Firmware Version:\t 0x%lx\n" "********************************************************\n", - ipadd, macadd, fwversion, swversion, requiredFirmwareVersion)); + hversion, ipadd, macadd, fwversion, swversion, sw_fw_apiversion, + requiredfwversion)); + +#ifndef VIRTUAL + // return if flag is not zero, debug mode + if (debugflag || updateFlag) { + return; + } + + // cant read versions + LOG(logINFO, ("Testing Firmware-software compatibility:\n")); + if (!fwversion || !sw_fw_apiversion) { + strcpy(initErrorMessage, + "Cant read versions from FPGA. Please update firmware.\n"); + LOG(logERROR, (initErrorMessage)); + initError = FAIL; + return; + } + + // check for API compatibility - old server + if (sw_fw_apiversion > requiredfwversion) { + sprintf(initErrorMessage, + "This firmware-software api version (0x%lx) is incompatible " + "with the software's minimum required firmware version " + "(0x%lx).\nPlease update detector software to be compatible " + "with this firmware.\n", + sw_fw_apiversion, requiredfwversion); + LOG(logERROR, (initErrorMessage)); + initError = FAIL; + return; + } + + // check for firmware compatibility - old firmware + if (requiredfwversion > fwversion) { + sprintf(initErrorMessage, + "This firmware version (0x%lx) is incompatible.\n" + "Please update firmware (min. 0x%lx) to be compatible with " + "this server.\n", + fwversion, requiredfwversion); + LOG(logERROR, (initErrorMessage)); + initError = FAIL; + return; + } + LOG(logINFO, ("\tCompatibility - success\n")); +#endif } int checkType() { #ifdef VIRTUAL return OK; #endif - u_int32_t type = ((bus_r(FPGAVERSIONREG) & DETTYPE_MSK) >> DETTYPE_OFST); + u_int32_t type = + ((bus_r(FPGAVERSIONREG) & FPGADETTYPE_MSK) >> FPGADETTYPE_OFST); if (type != XILINX_CHIPTESTBOARD) { LOG(logERROR, ("This is not a Xilinx CTB firmware (read %d, expected %d)\n", type, @@ -100,30 +189,15 @@ int checkType() { } int testFpga() { -#ifdef VIRTUAL - return OK; -#endif LOG(logINFO, ("Testing FPGA:\n")); // fixed pattern - int ret = OK; - - /* TODO: FIX PATTERN not defined in firmware - uint32_t val = bus_r(FIX_PATT_REG); - if (val == FIX_PATT_VAL) { - LOG(logINFO, ("\tFixed pattern: successful match (0x%08x)\n", val)); - } else { - LOG(logERROR, - ("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", - val, FIX_PATT_VAL)); - ret = FAIL; - } - */ + int ret = testFixedFPGAPattern(); if (ret == OK) { // Delay LSB reg LOG(logINFO, ("\tTesting Delay LSB Register:\n")); - uint32_t addr = DELAYINREG1; + uint32_t addr = DELAY_IN_REG_1; // store previous delay value uint32_t previousValue = bus_r(addr); @@ -168,6 +242,7 @@ int testFpga() { break; } } + // write back previous value bus_w(addr, previousValue); if (ret == OK) { @@ -176,43 +251,25 @@ int testFpga() { times)); } } - return ret; } -int testBus() { -#ifdef VIRTUAL - return OK; +int testFixedFPGAPattern() { + LOG(logINFO, ("Testing FPGA Fixed Pattern:\n")); +#ifndef VIRTUAL + uint32_t val = bus_r(FIXEDPATTERNREG); + if (val == FIXEDPATTERNVAL) { + LOG(logINFO, ("\tFixed pattern: successful match (0x%08x)\n", val)); + } else { + LOG(logERROR, + ("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n", + val, FIXEDPATTERNVAL)); + return FAIL; + } #endif - LOG(logINFO, ("Testing Bus:\n")); - - int ret = OK; - uint32_t addr = DELAYINREG1; - - // store previous delay value - uint32_t previousValue = bus_r(addr); - - volatile uint32_t val = 0, readval = 0; - int times = 1000 * 1000; - - for (int i = 0; i < times; ++i) { - val += 0xbbbbb; - bus_w(addr, val); - readval = bus_r(addr); - if (readval != val) { - LOG(logERROR, ("Mismatch! Loop(%d): Wrote 0x%x, read 0x%x\n", i, - val, readval)); - ret = FAIL; - } - } - - // write back previous value - bus_w(addr, previousValue); - - if (ret == OK) { - LOG(logINFO, ("\tSuccessfully tested bus %d times\n", times)); - } - return ret; + LOG(logINFO, + ("\tSuccessfully read FPGA Fixed Pattern (0x%x)\n", FIXEDPATTERNVAL)); + return OK; } /* Ids */ @@ -223,7 +280,14 @@ uint64_t getFirmwareVersion() { #ifdef VIRTUAL return REQRD_FRMWRE_VRSN; #endif - return ((bus_r(FPGAVERSIONREG) & COMPDATE_MSK) >> COMPDATE_OFST); + return ((bus_r(FPGAVERSIONREG) & FPGACOMPDATE_MSK) >> FPGACOMPDATE_OFST); +} + +uint64_t getFirmwareAPIVersion() { +#ifdef VIRTUAL + return 0; +#endif + return ((bus_r(APIVERSIONREG) & APICOMPDATE_MSK) >> APICOMPDATE_OFST); } void getHardwareVersion(char *version) { strcpy(version, "Not applicable"); } @@ -290,6 +354,7 @@ void initControlServer() { void initStopServer() { if (!updateFlag && initError == OK) { usleep(CTRL_SRVR_INIT_TIME_US); + LOG(logINFOBLUE, ("Configuring Stop server\n")); if (mapCSP0() == FAIL) { initError = FAIL; strcpy(initErrorMessage, @@ -309,17 +374,259 @@ void initStopServer() { void setupDetector() { LOG(logINFO, ("Setting up Server for 1 Xilinx Chip Test Board\n")); + + // default variables + chipConfigured = 0; + analogEnable = 0; + digitalEnable = 0; + transceiverEnable = 0; + for (int i = 0; i < NDAC; ++i) + dacValues[i] = -1; + vLimit = DEFAULT_VLIMIT; + #ifdef VIRTUAL sharedMemory_setStatus(IDLE); + setupUDPCommParameters(); initializePatternWord(); #endif + // initialization only at start up (restart fpga) + initError = waitTranseiverReset(initErrorMessage); + if (initError == FAIL) { + return; + } + // power off chip + initError = powerChip(0, initErrorMessage); + if (initError == FAIL) { + return; + } + + LTC2620_D_SetDefines(DAC_MAX_MV, DAC_MIN_MV, DAC_DRIVER_FILE_NAME, NDAC, + DAC_DRIVER_NUM_DEVICES, dacDeviceIndex, + DAC_POWERDOWN_DRIVER_FILE_NAME); + LOG(logINFOBLUE, ("Powering down all dacs\n")); + for (int idac = 0; idac < NDAC; ++idac) { + setDAC(idac, LTC2620_D_GetPowerDownValue(), 0); + } + + resetFlow(); + cleanFifos(); - LOG(logINFOBLUE, ("Setting Default parameters\n")); initializePatternAddresses(); + LOG(logINFOBLUE, ("Setting Default readout\n")); + setNumAnalogSamples(DEFAULT_NUM_ASAMPLES); + setNumDigitalSamples(DEFAULT_NUM_DSAMPLES); + setADCEnableMask_10G(BIT32_MSK); + setTransceiverEnableMask(DEFAULT_TRANSCEIVER_MASK); + setNumTransceiverSamples(DEFAULT_NUM_TSAMPLES); + setReadoutMode(DEFAULT_READOUT_MODE); + + LOG(logINFOBLUE, ("Setting Default parameters\n")); setNumFrames(DEFAULT_NUM_FRAMES); setNumTriggers(DEFAULT_NUM_CYCLES); setTiming(DEFAULT_TIMING_MODE); + setExpTime(DEFAULT_EXPTIME); + setPeriod(DEFAULT_PERIOD); + setDelayAfterTrigger(DEFAULT_DELAY); + + setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER); +} + +/* firmware functions (resets) */ + +void cleanFifos() { +#ifdef VIRTUAL + return; +#endif + LOG(logINFO, ("Clearing Acquisition Fifos\n")); + bus_w(A_FIFO_CLEAN_REG, bus_r(A_FIFO_CLEAN_REG) | BIT32_MSK); + bus_w(D_FIFO_CLEAN_REG, bus_r(D_FIFO_CLEAN_REG) | D_FIFO_CLEAN_MSK); + bus_w(X_FIFO_CLEAN_REG, bus_r(X_FIFO_CLEAN_REG) | X_FIFO_CLEAN_MSK); + + bus_w(A_FIFO_CLEAN_REG, 0); + bus_w(D_FIFO_CLEAN_REG, bus_r(D_FIFO_CLEAN_REG) & ~D_FIFO_CLEAN_MSK); + bus_w(X_FIFO_CLEAN_REG, bus_r(X_FIFO_CLEAN_REG) & ~X_FIFO_CLEAN_MSK); +} + +void resetFlow() { +#ifdef VIRTUAL + return; +#endif + LOG(logINFO, ("Resetting Core\n")); + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | RST_F_MSK); + usleep(0); + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) & ~RST_F_MSK); +} + +int waitTranseiverReset(char *mess) { +#ifndef VIRTUAL + int resetTransceiverDone = (bus_r(TRANSCEIVERSTATUS) & RESETRXDONE_MSK); + int times = 0; + struct timespec begin, end; + clock_gettime(CLOCK_REALTIME, &begin); + while (resetTransceiverDone == 0) { + if (times++ > WAIT_TIME_OUT_0US_TIMES) { + clock_gettime(CLOCK_REALTIME, &end); + int64_t timeNs = ((end.tv_sec - begin.tv_sec) * 1E9 + + (end.tv_nsec - begin.tv_nsec)); + + sprintf(mess, "Resetting transceiver timed out, time:%.2fs\n", + (timeNs / (1E9))); + LOG(logERROR, (mess)); + + LOG(logINFORED, ("Waiting for Firmware to be fixed here. Skipping " + "this error for now.\n")); + return OK; + + return FAIL; + } + usleep(0); + resetTransceiverDone = (bus_r(TRANSCEIVERSTATUS) & RESETRXDONE_MSK); + } +#endif + LOG(logINFOBLUE, ("Transceiver reset done\n")); + return OK; +} + +#ifdef VIRTUAL +void setTransceiverAlignment(int align) { + if (align) { + bus_w(TRANSCEIVERSTATUS, + (bus_r(TRANSCEIVERSTATUS) | RXBYTEISALIGNED_MSK)); + } else { + bus_w(TRANSCEIVERSTATUS, + (bus_r(TRANSCEIVERSTATUS) & ~RXBYTEISALIGNED_MSK)); + } +} +#endif + +int isTransceiverAligned() { + return (bus_r(TRANSCEIVERSTATUS) & RXBYTEISALIGNED_MSK); +} + +int waitTransceiverAligned(char *mess) { +#ifdef VIRTUAL + setTransceiverAlignment(1); +#else + + // no module: transceiver will never get aligned + if (!checkModuleFlag) { + LOG(logWARNING, ("No module: Transceiver will never get aligned. " + "Ignoring alignment check.\n")); + return OK; + } + + int transceiverWordAligned = isTransceiverAligned(); + int times = 0; + while (transceiverWordAligned == 0) { + if (times++ > WAIT_TIME_OUT_0US_TIMES) { + sprintf(mess, "Transceiver alignment timed out\n"); + LOG(logERROR, (mess)); + return FAIL; + } + usleep(0); + transceiverWordAligned = isTransceiverAligned(); + } +#endif + LOG(logINFOBLUE, ("Transceiver alignment done\n")); + return OK; +} + +int configureTransceiver(char *mess) { + LOG(logINFOBLUE, ("\tConfiguring transceiver\n")); + + if (chipConfigured == 0) { + sprintf(mess, + "Chip not configured. Use powerchip to power on chip first.\n"); + LOG(logERROR, (mess)); + return FAIL; + } + return waitTransceiverAligned(mess); +} + +int isChipConfigured() { return chipConfigured; } + +// TODO powerchip and configurechip should be separate commands (not +// requirement) in the future +// TODO differentiate between power on board (va, vb, vc, vd, vio) and power +// chip (only chip with voltage vchip)? +int powerChip(int on, char *mess) { + uint32_t addr = CTRL_REG; + uint32_t mask = POWER_VIO_MSK | POWER_VCC_A_MSK | POWER_VCC_B_MSK | + POWER_VCC_C_MSK | POWER_VCC_D_MSK; + if (on) { + LOG(logINFOBLUE, ("Powering chip: on\n")); + bus_w(addr, bus_r(addr) & ~mask); + + if (configureChip(mess) == FAIL) + return FAIL; + + startPeriphery(); + + chipConfigured = 1; + } else { + LOG(logINFOBLUE, ("Powering chip: off\n")); + bus_w(addr, bus_r(addr) | mask); + + chipConfigured = 0; + +#ifdef VIRTUAL + setTransceiverAlignment(0); +#endif + // transceiver alignment should be reset at power off + if (isTransceiverAligned()) { + sprintf(mess, "Transceiver alignment not reset\n"); + LOG(logERROR, (mess)); + return FAIL; + } + LOG(logINFO, ("\tTransceiver alignment has been reset\n")); + } + return OK; +} + +int getPowerChip() { + uint32_t addr = CTRL_REG; + uint32_t mask = POWER_VIO_MSK | POWER_VCC_A_MSK | POWER_VCC_B_MSK | + POWER_VCC_C_MSK | POWER_VCC_D_MSK; + return (((bus_r(addr) & mask) == mask) ? 0 : 1); +} + +int configureChip(char *mess) { + LOG(logINFOBLUE, ("\tConfiguring chip\n")); + + // enable correct endianness (Only for MH_PR_2) + // uint32_t addr = MATTERHORNSPIREG1; + // bus_w(addr, bus_r(addr) &~MATTERHORNSPI1_MSK); + // bus_w(addr, bus_r(addr) | ((0x40000 << MATTERHORNSPI1_OFST) & + // MATTERHORNSPI1_MSK)); + + // start configuration + uint32_t addr = MATTERHORNSPICTRL; + bus_w(addr, bus_r(addr) | CONFIGSTART_MSK); + bus_w(addr, bus_r(addr) & ~CONFIGSTART_MSK); + + // wait until configuration is done +#ifndef VIRTUAL + int configDone = (bus_r(MATTERHORNSPICTRL) & BUSY_MSK); + int times = 0; + while (configDone == 0) { + if (times++ > WAIT_TIME_OUT_0US_TIMES) { + sprintf(mess, "Configuration of chip timed out\n"); + LOG(logERROR, (mess)); + return FAIL; + } + usleep(0); + configDone = (bus_r(MATTERHORNSPICTRL) & BUSY_MSK); + } +#endif + LOG(logINFOBLUE, ("\tChip configured\n")); + return OK; +} + +void startPeriphery() { + LOG(logINFOBLUE, ("\tStarting periphery\n")); + bus_w(MATTERHORNSPICTRL, bus_r(MATTERHORNSPICTRL) | START_P_MSK); + // TODO ? } /* set parameters - dr */ @@ -335,32 +642,540 @@ int getDynamicRange(int *retval) { return OK; } +void setADCEnableMask_10G(uint32_t mask) { + // convert 32 bit mask to 8 bit mask + uint8_t actualMask = 0; + int ival = 0; + for (int ich = 0; ich < NCHAN_ANALOG; ich = ich + 4) { + if ((1 << ich) & mask) { + actualMask |= (1 << ival); + } + ++ival; + } + + LOG(logINFO, ("Setting adcEnableMask 10G to 0x%x (from 0x%08x)\n", + actualMask, mask)); + uint32_t addr = FIFO_TO_GB_CONTROL_REG; + bus_w(addr, bus_r(addr) & (~ENABLED_CHANNELS_ADC_MSK)); + bus_w(addr, bus_r(addr) | ((actualMask << ENABLED_CHANNELS_ADC_OFST) & + ENABLED_CHANNELS_ADC_MSK)); +} + +uint32_t getADCEnableMask_10G() { + uint32_t mask = + ((bus_r(FIFO_TO_GB_CONTROL_REG) & ENABLED_CHANNELS_ADC_MSK) >> + ENABLED_CHANNELS_ADC_OFST); + + // convert 8 bit mask to 32 bit mask + uint32_t retval = 0; + if (mask) { + for (int ival = 0; ival < 8; ++ival) { + // if bit in 8 bit mask set + if ((1 << ival) & mask) { + // set it for 4 bits in 32 bit mask + for (int iloop = 0; iloop < 4; ++iloop) { + retval |= (1 << (ival * 4 + iloop)); + } + } + } + } + return retval; +} + +int setTransceiverEnableMask(uint32_t mask) { + if (mask > MAX_TRANSCEIVER_MASK) { + LOG(logERROR, ("Invalid transceiver mask: 0x%x\n", mask)); + return FAIL; + } + LOG(logINFO, ("Setting transceivermask to 0x%x\n", mask)); + + uint32_t addr = FIFO_TO_GB_CONTROL_REG; + bus_w(addr, bus_r(addr) & ~ENABLED_CHANNELS_X_MSK); + bus_w(addr, bus_r(addr) | ((mask << ENABLED_CHANNELS_X_OFST) & + ENABLED_CHANNELS_X_MSK)); + + return OK; +} + +uint32_t getTransceiverEnableMask() { + return ((bus_r(FIFO_TO_GB_CONTROL_REG) & ENABLED_CHANNELS_X_MSK) >> + ENABLED_CHANNELS_X_OFST); +} + +/* parameters - readout */ + +int setReadoutMode(enum readoutMode mode) { + analogEnable = 0, digitalEnable = 0, transceiverEnable = 0; + switch (mode) { + case ANALOG_ONLY: + LOG(logINFO, ("Setting Analog Only Readout\n")); + analogEnable = 1; + break; + case DIGITAL_ONLY: + LOG(logINFO, ("Setting Digital Only Readout\n")); + digitalEnable = 1; + break; + case ANALOG_AND_DIGITAL: + LOG(logINFO, ("Setting Analog & Digital Readout\n")); + analogEnable = 1; + digitalEnable = 1; + break; + case TRANSCEIVER_ONLY: + LOG(logINFO, ("Setting Transceiver Only Readout\n")); + transceiverEnable = 1; + break; + case DIGITAL_AND_TRANSCEIVER: + LOG(logINFO, ("Setting Digital & Transceiver Readout\n")); + digitalEnable = 1; + transceiverEnable = 1; + break; + default: + LOG(logERROR, ("Cannot set unknown readout flag. 0x%x\n", mode)); + return FAIL; + } + + uint32_t val = 0; + if (analogEnable == 1) { + val |= RO_MODE_ADC_MSK; + } + if (digitalEnable == 1) { + val |= RO_MODE_D_MSK; + } + if (transceiverEnable == 1) { + val |= RO_MODE_X_MSK; + } + + uint32_t addr = FIFO_TO_GB_CONTROL_REG; + bus_w(addr, + bus_r(addr) & ~(RO_MODE_ADC_MSK | RO_MODE_D_MSK | RO_MODE_X_MSK)); + bus_w(addr, bus_r(addr) | val); + + return OK; +} + +int getReadoutMode() { + uint32_t retval = bus_r(FIFO_TO_GB_CONTROL_REG); + if (retval & RO_MODE_ADC_MSK) { + analogEnable = 1; + } + if (retval & RO_MODE_D_MSK) { + digitalEnable = 1; + } + if (retval & RO_MODE_X_MSK) { + transceiverEnable = 1; + } + + if (analogEnable && digitalEnable && !transceiverEnable) { + LOG(logDEBUG1, ("Getting readout: Analog & Digita\n")); + return ANALOG_AND_DIGITAL; + } else if (analogEnable && !digitalEnable && !transceiverEnable) { + LOG(logDEBUG1, ("Getting readout: Analog Only\n")); + return ANALOG_ONLY; + } else if (!analogEnable && digitalEnable && !transceiverEnable) { + LOG(logDEBUG1, ("Getting readout: Digital Only\n")); + return DIGITAL_ONLY; + } else if (!analogEnable && !digitalEnable && transceiverEnable) { + LOG(logDEBUG1, ("Getting readout: Transceiver Only\n")); + return TRANSCEIVER_ONLY; + } else if (!analogEnable && digitalEnable && transceiverEnable) { + LOG(logDEBUG1, ("Getting readout: Digital & Transceiver\n")); + return DIGITAL_AND_TRANSCEIVER; + } else { + LOG(logERROR, ("Read unknown readout (analog enable:%d digital " + "enable:%d transceiver enable:%d)\n", + analogEnable, digitalEnable, transceiverEnable)); + return -1; + } +} + /* parameters - timer */ +int setNextFrameNumber(uint64_t value) { + LOG(logINFO, ("Setting next frame number: %lu\n", value)); + setU64BitReg(value, LOCAL_FRAME_NUMBER_REG_1, LOCAL_FRAME_NUMBER_REG_2); + return OK; +} + +int getNextFrameNumber(uint64_t *retval) { + *retval = getU64BitReg(LOCAL_FRAME_NUMBER_REG_1, LOCAL_FRAME_NUMBER_REG_2); + return OK; +} void setNumFrames(int64_t val) { if (val > 0) { LOG(logINFO, ("Setting number of frames %ld\n", val)); - setU64BitReg(val, FRAMESINREG1, FRAMESINREG2); + setU64BitReg(val, FRAMES_IN_REG_1, FRAMES_IN_REG_2); } } -int64_t getNumFrames() { return getU64BitReg(FRAMESINREG1, FRAMESINREG2); } +int64_t getNumFrames() { + return getU64BitReg(FRAMES_IN_REG_1, FRAMES_IN_REG_2); +} void setNumTriggers(int64_t val) { if (val > 0) { LOG(logINFO, ("Setting number of triggers %ld\n", val)); - setU64BitReg(val, CYCLESINREG1, CYCLESINREG2); + setU64BitReg(val, CYCLES_IN_REG_1, CYCLES_IN_REG_2); } } -int64_t getNumTriggers() { return getU64BitReg(CYCLESINREG1, CYCLESINREG2); } +int64_t getNumTriggers() { + return getU64BitReg(CYCLES_IN_REG_1, CYCLES_IN_REG_2); +} + +int setNumAnalogSamples(int val) { + if (val < 0 || val > MAX_ANALOG_SAMPLES) { + LOG(logERROR, ("Invalid analog samples: %d\n", val)); + return FAIL; + } + LOG(logINFO, ("Setting number of analog samples %d\n", val)); + + uint32_t addr = NO_SAMPLES_A_REG; + bus_w(addr, bus_r(addr) & ~NO_SAMPLES_A_MSK); + bus_w(addr, bus_r(addr) | ((val << NO_SAMPLES_A_OFST) & NO_SAMPLES_A_MSK)); + return OK; +} + +int getNumAnalogSamples() { + return ((bus_r(NO_SAMPLES_A_REG) & NO_SAMPLES_A_MSK) >> NO_SAMPLES_A_OFST); +} + +int setNumDigitalSamples(int val) { + if (val < 0 || val > MAX_DIGITAL_SAMPLES) { + LOG(logERROR, ("Invalid digital samples: %d\n", val)); + return FAIL; + } + LOG(logINFO, ("Setting number of digital samples %d\n", val)); + + uint32_t addr = NO_SAMPLES_D_REG; + bus_w(addr, bus_r(addr) & ~NO_SAMPLES_D_MSK); + bus_w(addr, bus_r(addr) | ((val << NO_SAMPLES_D_OFST) & NO_SAMPLES_D_MSK)); + return OK; +} + +int getNumDigitalSamples() { + return ((bus_r(NO_SAMPLES_D_REG) & NO_SAMPLES_D_MSK) >> NO_SAMPLES_D_OFST); +} + +int setNumTransceiverSamples(int val) { + if (val < 0 || val > MAX_TRANSCEIVER_SAMPLES) { + LOG(logERROR, ("Invalid transceiver samples: %d\n", val)); + return FAIL; + } + LOG(logINFO, ("Setting number of transceiver samples %d\n", val)); + + uint32_t addr = NO_SAMPLES_X_REG; + bus_w(addr, bus_r(addr) & ~NO_SAMPLES_X_MSK); + bus_w(addr, bus_r(addr) | ((val << NO_SAMPLES_X_OFST) & NO_SAMPLES_X_MSK)); + return OK; +} + +int getNumTransceiverSamples() { + return ((bus_r(NO_SAMPLES_X_REG) & NO_SAMPLES_X_MSK) >> NO_SAMPLES_X_OFST); +} + +int setExpTime(int64_t val) { + if (val < 0) { + LOG(logERROR, ("Invalid exptime: %lld ns\n", (long long int)val)); + return FAIL; + } + LOG(logINFO, ("Setting exptime %lld ns\n", (long long int)val)); + val *= (1E-3 * RUN_CLK); + setPatternWaitTime(0, val); + + // validate for tolerance + int64_t retval = getExpTime(); + val /= (1E-3 * RUN_CLK); + if (val != retval) { + return FAIL; + } + return OK; +} + +int64_t getExpTime() { return getPatternWaitTime(0) / (1E-3 * RUN_CLK); } + +int setPeriod(int64_t val) { + if (val < 0) { + LOG(logERROR, ("Invalid period: %lld ns\n", (long long int)val)); + return FAIL; + } + LOG(logINFO, ("Setting period %lld ns\n", (long long int)val)); + val *= (1E-3 * RUN_CLK); + setU64BitReg(val, PERIOD_IN_REG_1, PERIOD_IN_REG_2); + + // validate for tolerance + int64_t retval = getPeriod(); + val /= (1E-3 * RUN_CLK); + if (val != retval) { + return FAIL; + } + return OK; +} + +int64_t getPeriod() { + return getU64BitReg(PERIOD_IN_REG_1, PERIOD_IN_REG_2) / (1E-3 * RUN_CLK); +} + +int setDelayAfterTrigger(int64_t val) { + if (val < 0) { + LOG(logERROR, ("Invalid delay after trigger: %ld ns\n", val)); + return FAIL; + } + LOG(logINFO, ("Setting delay after trigger %ld ns\n", val)); + val *= (1E-3 * RUN_CLK); + setU64BitReg(val, DELAY_IN_REG_1, DELAY_IN_REG_2); + + // validate for tolerance + int64_t retval = getDelayAfterTrigger(); + val /= (1E-3 * RUN_CLK); + if (val != retval) { + return FAIL; + } + return OK; +} + +int64_t getDelayAfterTrigger() { + return getU64BitReg(DELAY_IN_REG_1, DELAY_IN_REG_2) / (1E-3 * RUN_CLK); +} int64_t getNumFramesLeft() { - return getU64BitReg(FRAMESOUTREG1, FRAMESOUTREG2); + return getU64BitReg(FRAMES_OUT_REG_1, FRAMES_OUT_REG_2); } int64_t getNumTriggersLeft() { - return getU64BitReg(CYCLESOUTREG1, CYCLESOUTREG2); + return getU64BitReg(CYCLES_OUT_REG_1, CYCLES_OUT_REG_2); +} + +int64_t getDelayAfterTriggerLeft() { + return getU64BitReg(DELAY_OUT_REG_1, DELAY_OUT_REG_2) / (1E-3 * RUN_CLK); +} + +int64_t getPeriodLeft() { + return getU64BitReg(PERIOD_OUT_REG_1, PERIOD_OUT_REG_2) / (1E-3 * RUN_CLK); +} + +int64_t getFramesFromStart() { + return getU64BitReg(FRAMES_FROM_START_OUT_REG_1, + FRAMES_FROM_START_OUT_REG_2); +} + +int64_t getActualTime() { + return getU64BitReg(TIME_FROM_START_OUT_REG_1, TIME_FROM_START_OUT_REG_2) / + (1E-3 * TICK_CLK); +} + +int64_t getMeasurementTime() { + return getU64BitReg(FRAME_TIME_OUT_REG_1, FRAME_TIME_OUT_REG_2) / + (1E-3 * TICK_CLK); +} + +/* parameters - dac, adc, hv */ + +void setDAC(enum DACINDEX ind, int val, int mV) { + char dacName[MAX_STR_LENGTH] = {0}; + memset(dacName, 0, MAX_STR_LENGTH); + sprintf(dacName, "dac%d", (int)ind); + + if (val < 0 && val != LTC2620_D_GetPowerDownValue()) + return; + + LOG(logDEBUG1, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dacName, val, + (mV ? "mV" : "dac units"))); + int dacval = val; + +#ifdef VIRTUAL + LOG(logINFO, ("Setting dac[%d - %s]: %d %s \n", (int)ind, dacName, val, + (mV ? "mV" : "dac units"))); + if (!mV) { + dacValues[ind] = val; + } + // convert to dac units + else if (LTC2620_D_VoltageToDac(val, &dacval) == OK) { + dacValues[ind] = dacval; + } +#else + if (LTC2620_D_SetDACValue((int)ind, val, mV, dacName, &dacval) == OK) + dacValues[ind] = dacval; +#endif +} + +int getDAC(enum DACINDEX ind, int mV) { + if (!mV) { + LOG(logDEBUG1, ("Getting DAC %d : %d dac\n", ind, dacValues[ind])); + return dacValues[ind]; + } + int voltage = -1; + LTC2620_D_DacToVoltage(dacValues[ind], &voltage); + LOG(logDEBUG1, + ("Getting DAC %d : %d dac (%d mV)\n", ind, dacValues[ind], voltage)); + return voltage; +} + +int getMaxDacSteps() { return LTC2620_D_GetMaxNumSteps(); } + +int dacToVoltage(int dac) { + int val; + if (LTC2620_D_DacToVoltage(dac, &val) == FAIL) { + return -1; + } + return val; +} + +int checkVLimitCompliant(int mV) { + if (vLimit > 0 && mV > vLimit) + return FAIL; + return OK; +} + +int checkVLimitDacCompliant(int dac) { + if (vLimit > 0 && dac != -1 && dac != LTC2620_D_GetPowerDownValue()) { + int mv = 0; + // could not convert + if (LTC2620_D_DacToVoltage(dac, &mv) == FAIL) + return FAIL; + if (mv > vLimit) + return FAIL; + } + return OK; +} + +int getVLimit() { return vLimit; } + +void setVLimit(int l) { + if (l >= 0) + vLimit = l; +} + +int getPower(enum DACINDEX ind) { + // check power enable first + uint32_t addr = CTRL_REG; + uint32_t offset = POWER_VCC_A_OFST + (int)(D_PWR_A - ind); + if (ind == D_PWR_IO) + offset = POWER_VIO_OFST; + uint32_t mask = (1 << offset); + if ((bus_r(addr) & mask) != 0) { + LOG(logINFO, ("Power for dac %d is off\n", ind)); + return 0; + } + + // check dac value + // not set yet + if (dacValues[ind] == -1) { + LOG(logERROR, + ("Power enabled, but unknown dac value for power index %d!", ind)); + return -1; + } + + // dac powered off + if (dacValues[ind] == LTC2620_D_GetPowerDownValue()) { + LOG(logWARNING, + ("Power %d enabled, dac value %d, voltage at minimum or 0\n", ind, + LTC2620_D_GetPowerDownValue())); + return LTC2620_D_GetPowerDownValue(); + } + + // get dac in mV + // (unless its a different voltage range compared to other dacs) + return getDAC(ind, 1); +} + +void setPower(enum DACINDEX ind, int val) { + + uint32_t addr = CTRL_REG; + uint32_t offset = POWER_VCC_A_OFST + (int)(D_PWR_A - ind); + if (ind == D_PWR_IO) + offset = POWER_VIO_OFST; + uint32_t mask = (1 << offset); + + if (val >= 0 || val == LTC2620_D_GetPowerDownValue()) { + if (val > 0) { + LOG(logINFO, ("Setting Power to %d mV\n", val)); + } + + // switch off power enable + LOG(logINFO, ("\tSwitching off enable for P%d (ctrl reg)\n", + (int)(ind - D_PWR_A))); + bus_w(addr, bus_r(addr) | mask); + + // power down dac + LOG(logINFO, ("\tPowering down P%d\n", (int)(ind - D_PWR_A))); + setDAC(ind, LTC2620_D_GetPowerDownValue(), 0); + + // set dac in mV + if (val > 0) { + LOG(logINFO, ("\tSetting Power P%d (DAC %d) to %d mV\n", + (int)(ind - D_PWR_A), (int)ind, val)); + setDAC(ind, val, 1); + } + + // switch on power enable + if (getDAC(ind, 1) == val || val == LTC2620_D_GetPowerDownValue()) { + LOG(logINFO, ("\tSwitching on enable for P%d (ctrl reg)\n", + (int)(ind - D_PWR_A))); + bus_w(addr, bus_r(addr) & ~mask); + } + } +} + +int getADC(enum ADCINDEX ind, int *value) { + *value = 0; +#ifdef VIRTUAL + return OK; +#endif + switch (ind) { + // slow adcs + case S_ADC0: + case S_ADC1: + case S_ADC2: + case S_ADC3: + case S_ADC4: + case S_ADC5: + case S_ADC6: + case S_ADC7: + LOG(logDEBUG1, ("Reading Slow ADC Channel %d\n", (int)ind - S_ADC0)); + return getSlowADC((int)ind - S_ADC0, value); + case TEMP_FPGA: + LOG(logDEBUG1, ("Reading FPGA Temperature\n")); + return getTemperature(value); + default: + LOG(logERROR, ("Adc Index %d not defined \n", (int)ind)); + return FAIL; + } +} + +int getSlowADC(int ichan, int *retval) { + *retval = 0; +#ifndef VIRTUAL + char fname[MAX_STR_LENGTH]; + memset(fname, 0, MAX_STR_LENGTH); + sprintf(fname, SLOWADC_DRIVER_FILE_NAME, adcDeviceIndex, ichan); + LOG(logDEBUG1, ("fname %s\n", fname)); + + if (readADCFromFile(fname, retval) == FAIL) { + return FAIL; + } + + // TODO assuming already converted to uV + // convert to uV + // double value = SLOWDAC_CONVERTION_FACTOR_TO_UV * (double)(*retval); + // LOG(logINFO, ("Slow ADC [%d]: %f uV\n", ichan, value)); + //*retval = (int)value; + + LOG(logINFO, ("Slow ADC [%d]: %d uV\n", ichan, (*retval))); +#endif + return OK; +} + +int getTemperature(int *retval) { + *retval = 0; +#ifndef VIRTUAL + if (readADCFromFile(TEMP_DRIVER_FILE_NAME, retval) == FAIL) { + return FAIL; + } + + // value already in millidegree celsius + LOG(logINFO, ("Temperature: %.2f °C\n", (double)(*retval) / 1000.00)); +#endif + return OK; } /* parameters - timing, extsig */ @@ -369,11 +1184,11 @@ void setTiming(enum timingMode arg) { switch (arg) { case AUTO_TIMING: LOG(logINFO, ("Set Timing: Auto\n")); - bus_w(FLOWCONTROLREG, bus_r(FLOWCONTROLREG) & ~TRIGGERENABLE_MSK); + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) & ~TRIGGER_ENABLE_MSK); break; case TRIGGER_EXPOSURE: LOG(logINFO, ("Set Timing: Trigger\n")); - bus_w(FLOWCONTROLREG, bus_r(FLOWCONTROLREG) | TRIGGERENABLE_MSK); + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | TRIGGER_ENABLE_MSK); break; default: LOG(logERROR, ("Unknown timing mode %d\n", arg)); @@ -381,7 +1196,7 @@ void setTiming(enum timingMode arg) { } enum timingMode getTiming() { - if (bus_r(FLOWCONTROLREG) == TRIGGERENABLE_MSK) + if (bus_r(FLOW_CONTROL_REG) == TRIGGER_ENABLE_MSK) return TRIGGER_EXPOSURE; return AUTO_TIMING; } @@ -392,18 +1207,335 @@ int setDetectorPosition(int pos[]) { return OK; } -int configureMAC() { - // TODO - LOG(logINFO, ("Configuring MAC\n")); - return OK; -} - int *getDetectorPosition() { return detPos; } int getNumberofUDPInterfaces() { return 1; } +void calcChecksum(udp_header *udp) { + int count = IP_HEADER_SIZE; + long int sum = 0; + + // start at ip_tos as the memory is not continous for ip header + uint16_t *addr = (uint16_t *)(&(udp->ip_tos)); + + sum += *addr++; + count -= 2; + + // ignore ethertype (from udp header) + addr++; + + // from identification to srcip_lsb + while (count > 2) { + sum += *addr++; + count -= 2; + } + + // ignore src udp port (from udp header) + addr++; + + if (count > 0) + sum += *addr; // Add left-over byte, if any + while (sum >> 16) + sum = (sum & 0xffff) + (sum >> 16); // Fold 32-bit sum to 16 bits + long int checksum = sum & 0xffff; + checksum += UDP_IP_HEADER_LENGTH_BYTES; + udp->ip_checksum = checksum; +} + +int configureMAC() { + uint32_t srcip = udpDetails[0].srcip; + uint32_t dstip = udpDetails[0].dstip; + uint64_t srcmac = udpDetails[0].srcmac; + uint64_t dstmac = udpDetails[0].dstmac; + uint16_t srcport = udpDetails[0].srcport; + uint16_t dstport = udpDetails[0].dstport; + + LOG(logINFOBLUE, ("Configuring MAC\n")); + char src_mac[MAC_ADDRESS_SIZE], src_ip[INET_ADDRSTRLEN], + dst_mac[MAC_ADDRESS_SIZE], dst_ip[INET_ADDRSTRLEN]; + getMacAddressinString(src_mac, MAC_ADDRESS_SIZE, srcmac); + getMacAddressinString(dst_mac, MAC_ADDRESS_SIZE, dstmac); + getIpAddressinString(src_ip, srcip); + getIpAddressinString(dst_ip, dstip); + + LOG(logINFO, ("\tSource IP : %s\n" + "\tSource MAC : %s\n" + "\tSource Port : %hu\n" + "\tDest IP : %s\n" + "\tDest MAC : %s\n" + "\tDest Port : %hu\n", + src_ip, src_mac, srcport, dst_ip, dst_mac, dstport)); + +#ifdef VIRTUAL + if (setUDPDestinationDetails(0, 0, dst_ip, dstport) == FAIL) { + LOG(logERROR, ("could not set udp destination IP and port\n")); + return FAIL; + } +#endif + + // get struct memory + udp_header *udp = (udp_header *)(Arm_getUDPBaseAddress()); + memset(udp, 0, sizeof(udp_header)); + + // mac addresses + // msb (32) + lsb (16) + udp->udp_destmac_msb = ((dstmac >> 16) & BIT32_MASK); + udp->udp_destmac_lsb = ((dstmac >> 0) & BIT16_MASK); + // msb (16) + lsb (32) + udp->udp_srcmac_msb = ((srcmac >> 32) & BIT16_MASK); + udp->udp_srcmac_lsb = ((srcmac >> 0) & BIT32_MASK); + + // ip addresses + udp->ip_srcip_msb = ((srcip >> 16) & BIT16_MASK); + udp->ip_srcip_lsb = ((srcip >> 0) & BIT16_MASK); + udp->ip_destip_msb = ((dstip >> 16) & BIT16_MASK); + udp->ip_destip_lsb = ((dstip >> 0) & BIT16_MASK); + + // source port + udp->udp_srcport = srcport; + udp->udp_destport = dstport; + + // other defines + udp->udp_ethertype = 0x800; + udp->ip_ver = 0x4; + udp->ip_ihl = 0x5; + udp->ip_flags = 0x2; // FIXME + udp->ip_ttl = 0x40; + udp->ip_protocol = 0x11; + // total length is redefined in firmware + + calcChecksum(udp); + + return OK; +} + /* aquisition */ +int startStateMachine() { +#ifdef VIRTUAL + // create udp socket + if (createUDPSocket(0) != OK) { + return FAIL; + } + LOG(logINFOBLUE, ("Starting State Machine\n")); + if (sharedMemory_getStop() != 0) { + LOG(logERROR, ("Cant start acquisition. " + "Stop server has not updated stop status to 0\n")); + return FAIL; + } + sharedMemory_setStatus(RUNNING); + if (pthread_create(&pthread_virtual_tid, NULL, &start_timer, NULL)) { + LOG(logERROR, ("Could not start Virtual acquisition thread\n")); + sharedMemory_setStatus(IDLE); + return FAIL; + } + LOG(logINFOGREEN, ("Virtual Acquisition started\n")); + return OK; +#endif + + LOG(logINFOBLUE, ("Starting State Machine\n")); + cleanFifos(); + + // start state machine + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | START_F_MSK); + + LOG(logINFORED, ("Waiting for exposing to be done\n")); + int exposingDone = (bus_r(FLOW_STATUS_REG) & RSM_BUSY_MSK); + while (exposingDone != 0) { + usleep(0); + exposingDone = (bus_r(FLOW_STATUS_REG) & RSM_BUSY_MSK); + } + + LOG(logINFORED, ("Starting readout of chip to fifo\n")); + bus_w(MATTERHORNSPICTRL, bus_r(MATTERHORNSPICTRL) | STARTREAD_P_MSK); + + LOG(logINFORED, ("Waiting until k-words or end of acquisition\n")); + usleep(0); + int commaDet = (bus_r(TRANSCEIVERSTATUS) & RXCOMMADET_MSK); + while (commaDet == 0) { + usleep(0); + commaDet = (bus_r(TRANSCEIVERSTATUS) & RXCOMMADET_MSK); + } + + return OK; +} + +#ifdef VIRTUAL +void *start_timer(void *arg) { + if (!isControlServer) { + return NULL; + } + + int64_t periodNs = getPeriod(); + int numFrames = (getNumFrames() * getNumTriggers()); + int64_t expUs = getExpTime() / 1000; + + int imageSize = calculateDataBytes(); + int maxDataSize = MAX_DATA_SIZE_IN_PACKET; + int packetSize = sizeof(sls_detector_header) + maxDataSize; + int packetsPerFrame = ceil((double)imageSize / (double)maxDataSize); + + LOG(logDEBUG1, ("period: %lld ns, exp: %lld us, numFrames: %d, " + "imageSize: %d, maxDataSize: %d, packetsize: %d, " + "packetsPerFrame: %d\n", + periodNs, expUs, numFrames, imageSize, maxDataSize, + packetSize, packetsPerFrame)); + + // Generate Data + char imageData[imageSize]; + memset(imageData, 0, imageSize); + for (int i = 0; i < imageSize; i += sizeof(uint16_t)) { + *((uint16_t *)(imageData + i)) = i; + } + + // Send data + uint64_t frameNr = 0; + getNextFrameNumber(&frameNr); + // loop over number of frames + for (int iframes = 0; iframes != numFrames; ++iframes) { + + // check if manual stop + if (sharedMemory_getStop() == 1) { + setNextFrameNumber(frameNr + iframes + 1); + break; + } + + // sleep for exposure time + struct timespec begin, end; + clock_gettime(CLOCK_REALTIME, &begin); + usleep(expUs); + + int srcOffset = 0; + // loop packet + for (int i = 0; i != packetsPerFrame; ++i) { + + char packetData[packetSize]; + memset(packetData, 0, packetSize); + // set header + sls_detector_header *header = (sls_detector_header *)(packetData); + header->detType = (uint16_t)myDetectorType; + header->version = SLS_DETECTOR_HEADER_VERSION; + header->frameNumber = frameNr + iframes; + header->packetNumber = i; + header->modId = 0; + header->row = detPos[Y]; + header->column = detPos[X]; + + // fill data + memcpy(packetData + sizeof(sls_detector_header), + imageData + srcOffset, + (imageSize < maxDataSize ? imageSize : maxDataSize)); + srcOffset += maxDataSize; + + sendUDPPacket(0, 0, packetData, packetSize); + } + LOG(logINFO, ("Sent frame: %d [%lld]\n", iframes, frameNr + iframes)); + clock_gettime(CLOCK_REALTIME, &end); + int64_t timeNs = + ((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec)); + + // sleep for (period - exptime) + if (iframes < numFrames) { // if there is a next frame + if (periodNs > timeNs) { + usleep((periodNs - timeNs) / 1000); + } + } + } + setNextFrameNumber(frameNr + numFrames); + closeUDPSocket(0); + + sharedMemory_setStatus(IDLE); + LOG(logINFOBLUE, ("Transmitting frames done\n")); + return NULL; +} +#endif + +int stopStateMachine() { + LOG(logINFORED, ("Stopping State Machine\n")); + // if scan active, stop scan + if (sharedMemory_getScanStatus() == RUNNING) { + sharedMemory_setScanStop(1); + } +#ifdef VIRTUAL + sharedMemory_setStop(1); + // read till status is idle + while (sharedMemory_getStatus() == RUNNING) + usleep(500); + sharedMemory_setStop(0); + LOG(logINFO, ("Stopped State Machine\n")); + return OK; +#endif + // stop state machine + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | STOP_F_MSK); + + return OK; +} + +int startReadOut() { + LOG(logINFOBLUE, ("Starting Readout\n")); +#ifdef VIRTUAL + // cannot set #frames and exptiem temporarily to 1 and 0, + // because have to set it back after readout (but this is non blocking) + return startStateMachine(); +#endif + // check if data in fifo + int ret = FAIL; + if (transceiverEnable) { + if ((bus_r(X_FIFO_EMPTY_STATUS_REG) & X_FIFO_EMPTY_STATUS_MSK) != + X_FIFO_EMPTY_STATUS_MSK) { + LOG(logINFO, ("Data in transceiver fifo\n")); + ret = OK; + } + } + if (analogEnable) { + if (bus_r(A_FIFO_EMPTY_STATUS_REG) != BIT32_MSK) { + LOG(logINFO, ("Data in analog fifo\n")); + ret = OK; + } + } + if (digitalEnable) { + if ((bus_r(D_FIFO_EMPTY_STATUS_REG) & D_FIFO_EMPTY_STATUS_MSK) != + D_FIFO_EMPTY_STATUS_MSK) { + LOG(logINFO, ("Data in digital fifo\n")); + ret = OK; + } + } + // if no module, dont check fifo empty + if (checkModuleFlag && ret == FAIL) { + LOG(logERROR, ("No data in fifo\n")); + return FAIL; + } + + LOG(logINFOBLUE, ("Streaming data from fifo\n")); + bus_w(FIFO_TO_GB_CONTROL_REG, + bus_r(FIFO_TO_GB_CONTROL_REG) | START_STREAMING_P_MSK); + + // wait until streaming is done (not same as fifo empty) + int streamingBusy = (bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK); + while (streamingBusy != 0) { + usleep(0); + streamingBusy = (bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK); + } + + return OK; +} + +int softwareTrigger() { +#ifndef VIRTUAL + // ready for trigger + if (getRunStatus() != WAITING) { + LOG(logWARNING, ("Not yet ready for trigger!\n")); + return FAIL; + } +#endif + LOG(logINFO, ("Sending Software Trigger\n")); + bus_w(FLOW_CONTROL_REG, bus_r(FLOW_CONTROL_REG) | SW_TRIGGER_F_MSK); + // wait to make sure its out of this state and even 'wait for start frame' + // TODO: usleep(100); + + return OK; +} + enum runStatus getRunStatus() { LOG(logDEBUG1, ("Getting status\n")); // scan error or running @@ -423,13 +1555,116 @@ enum runStatus getRunStatus() { LOG(logINFOBLUE, ("Status: IDLE\n")); return IDLE; #endif - // TODO: get status + uint32_t retval = bus_r(FLOW_STATUS_REG); + LOG(logINFO, ("Flow Status Register: %08x\n", retval)); + + if (retval & RSM_TRG_WAIT_MSK) { + LOG(logINFOBLUE, ("Status: WAITING\n")); + return WAITING; + } else if (retval & RSM_BUSY_MSK) { + LOG(logINFOBLUE, ("Status: RUNNING (exposing)\n")); + return RUNNING; + } else if (bus_r(MATTERHORNSPICTRL) & READOUTFROMASIC_MSK) { + LOG(logINFOBLUE, ("Status: RUNNING (data from chip to fifo)\n")); + return RUNNING; + } else if (bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK) { + LOG(logINFOBLUE, ("Status: TRANSMITTING\n")); + return TRANSMITTING; + } + LOG(logINFOBLUE, ("Status: IDLE\n")); return IDLE; + // TODO: STOPPED, ERROR? +} + +u_int32_t runBusy() { +#ifdef VIRTUAL + return ((sharedMemory_getStatus() == RUNNING) ? 1 : 0); +#endif + uint32_t exposingBusy = bus_r(FLOW_STATUS_REG) & RSM_BUSY_MSK; + uint32_t fillingFifoBusy = bus_r(MATTERHORNSPICTRL) & READOUTFROMASIC_MSK; + uint32_t streamingBusy = bus_r(STATUSREG1) & TRANSMISSIONBUSY_MSK; + return (exposingBusy || fillingFifoBusy || streamingBusy); +} + +void waitForAcquisitionEnd() { + while (runBusy()) { + usleep(500); + } +#ifndef VIRTUAL + int64_t retval = getNumFramesLeft() + 1; + if (retval > 0) { + LOG(logINFORED, ("%lld frames left\n", (long long int)retval)); + } +#endif + LOG(logINFOGREEN, ("Blocking Acquisition done\n")); +} + +int calculateDataBytes() { + int analogDataBytes = 0; + int digitalDataBytes = 0; + int transceiverDataBytes = 0; + int nachans = 0, ndchans = 0, ntchans = 0; + + if (analogEnable) { + nachans = __builtin_popcount(getADCEnableMask_10G()); + analogDataBytes = nachans * (DYNAMIC_RANGE / 8) * getNumAnalogSamples(); + LOG(logINFO, ("\t#Analog Channels:%d, Databytes:%d\n", nachans, + analogDataBytes)); + } + + if (digitalEnable) { + ndchans = 64; + digitalDataBytes = (sizeof(uint64_t) * getNumDigitalSamples()); + LOG(logINFO, ("\t#Digital Channels:%d, Databytes:%d\n", ndchans, + digitalDataBytes)); + } + + if (transceiverEnable) { + ntchans = __builtin_popcount(getTransceiverEnableMask()); + transceiverDataBytes = + ntchans * (NBITS_PER_TRANSCEIVER / 8) * getNumTransceiverSamples(); + LOG(logINFO, ("\t#Transceiver Channels:%d, Databytes:%d\n", ntchans, + transceiverDataBytes)); + } + + // total + int nchans = nachans + ndchans + ntchans; + int dataBytes = analogDataBytes + digitalDataBytes + transceiverDataBytes; + + LOG(logINFO, + ("\t#Total Channels:%d, Total Databytes:%d\n", nchans, dataBytes)); + return dataBytes; +} + +int getTotalNumberOfChannels() { + int nchanx = 0, nchany = 0; + getNumberOfChannels(&nchanx, &nchany); + return nchanx * nchany; } void getNumberOfChannels(int *nchanx, int *nchany) { - // TODO - *nchanx = NCHAN; + int nachans = 0, ndchans = 0, ntchans = 0; + + if (analogEnable) { + nachans = __builtin_popcount(getADCEnableMask_10G()); + LOG(logDEBUG1, ("Analog Channels: %d\n", nachans)); + } + + if (digitalEnable) { + ndchans = 64; + LOG(logDEBUG, ("Digital Channels: %d\n", ndchans)); + } + + if (transceiverEnable) { + ntchans = __builtin_popcount(getTransceiverEnableMask()); + LOG(logDEBUG1, ("Transceiver Channels: %d\n", ntchans)); + } + *nchanx = nachans + ndchans + ntchans; + LOG(logDEBUG1, ("Total #Channels: %d\n", *nchanx)); *nchany = 1; -} \ No newline at end of file +} + +int getNumberOfChips() { return NCHIP; } +int getNumberOfDACs() { return NDAC; } +int getNumberOfChannelsPerChip() { return NCHAN; } diff --git a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h index 4e15e20d2..288275dbd 100644 --- a/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/xilinx_ctbDetectorServer/slsDetectorServer_defs.h @@ -4,7 +4,7 @@ #include "RegisterDefs.h" #include "sls/sls_detector_defs.h" -#define REQRD_FRMWRE_VRSN (0x230000) +#define REQRD_FRMWRE_VRSN (0x230710) #define KERNEL_DATE_VRSN "Wed Nov 29 17:32:14 CET 2023" #define LINKED_SERVER_NAME "xilinx_ctbDetectorServer" @@ -12,16 +12,134 @@ #define CTRL_SRVR_INIT_TIME_US (2 * 1000 * 1000) /* Hardware Definitions */ -#define NCHAN (1) +#define NCHAN (40) +#define NCHAN_ANALOG (32) +#define NCHAN_DIGITAL (64) +#define NCHAN_TRANSCEIVER (4) +#define NBITS_PER_TRANSCEIVER (64) +#define NCHIP (1) +#define NDAC (24) +#define NPWR (6) +#define NDAC_ONLY (NDAC - NPWR) -enum ADCINDEX { V_PWR_IO }; -enum DACINDEX { D0 }; +#define DYNAMIC_RANGE (16) +#define NUM_BYTES_PER_PIXEL (DYNAMIC_RANGE / 8) + +#define DAC_DRIVER_NUM_DEVICES (3) +#define DAC_DRIVER_FILE_NAME \ + ("/sys/bus/iio/devices/iio:device%d/out_voltage%d_raw") +#define DAC_POWERDOWN_DRIVER_FILE_NAME \ + ("/sys/bus/iio/devices/iio:device%d/out_voltage%d_powerdown") + +#define SLOWADC_DRIVER_FILE_NAME \ + ("/sys/bus/iio/devices/iio:device%d/in_voltage%d_raw") +//#define SLOWDAC_CONVERTION_FACTOR_TO_UV (62.500953) + +#define TEMP_DRIVER_FILE_NAME \ + ("/sys/bus/iio/devices/iio:device0/in_temp7_input") /** Default Parameters */ -#define DEFAULT_NUM_FRAMES (1) -#define DEFAULT_NUM_CYCLES (1) -#define DYNAMIC_RANGE (16) -#define DEFAULT_TIMING_MODE (AUTO_TIMING) +#define DEFAULT_NUM_FRAMES (1) +#define DEFAULT_NUM_CYCLES (1) +#define DEFAULT_TIMING_MODE (AUTO_TIMING) +#define DEFAULT_EXPTIME (0) +#define DEFAULT_PERIOD (300 * 1000) // 300us +#define DEFAULT_READOUT_MODE (TRANSCEIVER_ONLY) +#define DEFAULT_READOUT_MODE_STR "transceiver_only" +#define DEFAULT_TRANSCEIVER_MASK (0x3) // TODO: check +#define DEFAULT_NUM_ASAMPLES (1) +#define DEFAULT_NUM_DSAMPLES (1) +#define DEFAULT_NUM_TSAMPLES (200) +#define DEFAULT_STARTING_FRAME_NUMBER (1) +#define DEFAULT_VLIMIT (-100) +#define DEFAULT_DELAY (0) + +#define MAX_TRANSCEIVER_MASK (0xF) +#define MAX_TRANSCEIVER_SAMPLES (0x1FFF) + +#define MAX_ANALOG_SAMPLES (0x3FFF) +#define MAX_DIGITAL_SAMPLES (0x3FFF) + +#define DAC_MIN_MV (0) +#define DAC_MAX_MV (2500) + +#define TICK_CLK (20) // MHz (trig_timeFromStart, frametime, timeFromStart) +#define RUN_CLK \ + (100) // MHz (framesFromStart, c_swTrigger, run, waitForTrigger, starting, + // acquiring, waitForPeriod, internalStop, c_framesFromSTart_reset, + // s_start, c_stop, triggerEnable, period, frames, cycles, delay) /* Defines in the Firmware */ -#define WAIT_TIME_PATTERN_READ (10) \ No newline at end of file +#define WAIT_TIME_PATTERN_READ (10) +#define WAIT_TIME_OUT_0US_TIMES (35000) // 2s + +#define BIT32_MSK (0xFFFFFFFF) +#define BIT16_MASK (0xFFFF) + +#define MAX_DATA_SIZE_IN_PACKET (8144) + +/* Enum Definitions */ +enum ADCINDEX { + S_ADC0, + S_ADC1, + S_ADC2, + S_ADC3, + S_ADC4, + S_ADC5, + S_ADC6, + S_ADC7, + TEMP_FPGA +}; +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_EMPTY, + D_PWR_IO, + D_PWR_A, + D_PWR_B, + D_PWR_C +}; + +/* Struct Definitions */ +typedef struct udp_header_struct { + uint32_t udp_destmac_msb; + uint16_t udp_srcmac_msb; + uint16_t udp_destmac_lsb; + uint32_t udp_srcmac_lsb; + uint8_t ip_tos; + uint8_t ip_ihl : 4, ip_ver : 4; + uint16_t udp_ethertype; + uint16_t ip_identification; + uint16_t ip_totallength; + uint8_t ip_protocol; + uint8_t ip_ttl; + uint16_t ip_fragmentoffset : 13, ip_flags : 3; + uint16_t ip_srcip_msb; + uint16_t ip_checksum; + uint16_t ip_destip_msb; + uint16_t ip_srcip_lsb; + uint16_t udp_srcport; + uint16_t ip_destip_lsb; + uint16_t udp_checksum; + uint16_t udp_destport; +} udp_header; + +#define IP_HEADER_SIZE (20) +#define UDP_IP_HEADER_LENGTH_BYTES (28) diff --git a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh index 6ed628f94..dc698ef1b 100644 --- a/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/bash_autocomplete.sh @@ -80,7 +80,7 @@ _sd() { local IS_PATH=0 -local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase column compdisabletime confadc config counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit patternX patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " +local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit patternX patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " __acquire() { FCN_RETURN="" return 0 @@ -477,6 +477,16 @@ fi fi return 0 } +__configtransceiver() { +FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +IS_PATH=1 +fi +fi +return 0 +} __counters() { FCN_RETURN="" return 0 diff --git a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh index 0ac10863c..30f0b032f 100644 --- a/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh +++ b/slsDetectorSoftware/generator/autocomplete/zsh_autocomplete.sh @@ -4,7 +4,7 @@ _sd() { -local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase column compdisabletime confadc config counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit patternX patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " +local SLS_COMMANDS=" acquire activate adcclk adcenable adcenable10g adcindex adcinvert adclist adcname adcphase adcpipeline adcreg adcvpp apulse asamples autocompdisable badchannels blockingtrigger burstmode burstperiod bursts burstsl bustest cdsgain chipversion clearbit clearbusy clearroi clientversion clkdiv clkfreq clkphase column compdisabletime confadc config configtransceiver counters currentsource dac dacindex daclist dacname dacvalues datastream dbitclk dbitphase dbitpipeline defaultdac defaultpattern delay delayl detectorserverversion detsize diodelay dpulse dr drlist dsamples execcommand exptime exptime1 exptime2 exptime3 exptimel extrastoragecells extsampling extsamplingsrc extsig fformat filtercells filterresistor findex firmwaretest firmwareversion fliprows flowcontrol10g fmaster fname foverwrite fpath framecounter frames framesl frametime free fwrite gaincaps gainmode gappixels gatedelay gatedelay1 gatedelay2 gatedelay3 gates getbit hardwareversion highvoltage hostname im_a im_b im_c im_d im_io imagetest initialchecks inj_ch interpolation interruptsubframe kernelversion lastclient led lock master maxadcphaseshift maxclkphaseshift maxdbitphaseshift measuredperiod measuredsubperiod moduleid nextframenumber nmod numinterfaces overflow packageversion parallel parameters partialreset patfname patioctrl patlimits patloop patloop0 patloop1 patloop2 patmask patnloop patnloop0 patnloop1 patnloop2 patsetbit patternX patternstart patwait patwait0 patwait1 patwait2 patwaittime patwaittime0 patwaittime1 patwaittime2 patword pedestalmode period periodl polarity port powerchip powerindex powerlist powername powervalues programfpga pulse pulsechip pulsenmove pumpprobe quad ratecorr readnrows readout readoutspeed readoutspeedlist rebootcontroller reg resetdacs resetfpga roi romode row runclk runtime rx_arping rx_clearroi rx_dbitlist rx_dbitoffset rx_discardpolicy rx_fifodepth rx_frameindex rx_framescaught rx_framesperfile rx_hostname rx_jsonaddheader rx_jsonpara rx_lastclient rx_lock rx_missingpackets rx_padding rx_printconfig rx_realudpsocksize rx_roi rx_silent rx_start rx_status rx_stop rx_tcpport rx_threads rx_udpsocksize rx_version rx_zmqfreq rx_zmqhwm rx_zmqip rx_zmqport rx_zmqstartfnum rx_zmqstream samples savepattern scan scanerrmsg selinterface serialnumber setbit settings settingslist settingspath signalindex signallist signalname slowadc slowadcindex slowadclist slowadcname slowadcvalues start status stop stopport storagecell_delay storagecell_start subdeadtime subexptime sync syncclk temp_10ge temp_adc temp_control temp_dcdc temp_event temp_fpga temp_fpgaext temp_fpgafl temp_fpgafr temp_slowadc temp_sodl temp_sodr temp_threshold templist tempvalues tengiga threshold thresholdnotb timing timinglist timingsource top transceiverenable trigger triggers triggersl trimbits trimen trimval tsamples txdelay txdelay_frame txdelay_left txdelay_right type udp_cleardst udp_dstip udp_dstip2 udp_dstlist udp_dstmac udp_dstmac2 udp_dstport udp_dstport2 udp_firstdst udp_numdst udp_reconfigure udp_srcip udp_srcip2 udp_srcmac udp_srcmac2 udp_validate update updatedetectorserver updatekernel updatemode user v_a v_b v_c v_chip v_d v_io v_limit vchip_comp_adc vchip_comp_fe vchip_cs vchip_opa_1st vchip_opa_fd vchip_ref_comp_fe versions veto vetoalg vetofile vetophoton vetoref vetostream virtual vm_a vm_b vm_c vm_d vm_io zmqhwm zmqip zmqport " __acquire() { FCN_RETURN="" return 0 @@ -401,6 +401,16 @@ fi fi return 0 } +__configtransceiver() { +FCN_RETURN="" +if [[ ${IS_GET} -eq 1 ]]; then +if [[ "${cword}" == "2" ]]; then +FCN_RETURN="" +IS_PATH=1 +fi +fi +return 0 +} __counters() { FCN_RETURN="" return 0 diff --git a/slsDetectorSoftware/generator/commands.yaml b/slsDetectorSoftware/generator/commands.yaml index 68f3ca907..19745ce46 100644 --- a/slsDetectorSoftware/generator/commands.yaml +++ b/slsDetectorSoftware/generator/commands.yaml @@ -441,7 +441,7 @@ period: function: setPeriod delay: - help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Delay after trigger" + help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Moench][Xilinx Ctb] Delay after trigger" inherit_actions: TIME_COMMAND actions: GET: @@ -496,14 +496,14 @@ burstperiod: ################# TIME_GET_COMMAND ############# delayl: - help: "\n\t[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Delay Left in Acquisition. \n\t[Gotthard2] only in continuous mode." + help: "\n\t[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Delay Left in Acquisition. \n\t[Gotthard2] only in continuous mode." inherit_actions: TIME_GET_COMMAND actions: GET: function: getDelayAfterTriggerLeft periodl: - help: "\n\t[Gotthard][Jungfrau][Moench][Ctb][Mythen3][Gotthard2] Period left for current frame. \n\t[Gotthard2] only in continuous mode." + help: "\n\t[Gotthard][Jungfrau][Moench][Ctb][Mythen3][Gotthard2][Xilinx Ctb] Period left for current frame. \n\t[Gotthard2] only in continuous mode." inherit_actions: TIME_GET_COMMAND actions: GET: @@ -531,14 +531,14 @@ exptimel: function: getExptimeLeft runtime: - help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Time from detector start up.\n\t[Gotthard2] not in burst and auto mode." + help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Time from detector start up.\n\t[Gotthard2] not in burst and auto mode." inherit_actions: TIME_GET_COMMAND actions: GET: function: getActualTime frametime: - help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Timestamp at a frame start.\n\t[Gotthard2] not in burst and auto mode." + help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Timestamp at a frame start.\n\t[Gotthard2] not in burst and auto mode." inherit_actions: TIME_GET_COMMAND actions: GET: @@ -622,7 +622,7 @@ adcenable10g: function: setTenGigaADCEnableMask transceiverenable: - help: "[bitmask]\n\t[Ctb] Transceiver Enable Mask. Enable for each 4 Transceiver channel." + help: "[bitmask]\n\t[Ctb][Xilinx Ctb] Transceiver Enable Mask. Enable for each 4 Transceiver channel." inherit_actions: INTEGER_COMMAND_HEX actions: GET: @@ -707,7 +707,7 @@ highvoltage: function: setHighVoltage powerchip: - help: "[0, 1]\n\t[Jungfrau][Moench][Mythen3][Gotthard2] Power the chip. \n\t[Jungfrau][Moench] Default is 0. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail." + help: "[0, 1]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] Power the chip. \n\t[Jungfrau][Moench] Default is 0. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail.\n\t[Xilinx Ctb] Default is 0. Also configures the chip if powered on." inherit_actions: INTEGER_COMMAND_VEC_ID actions: GET: @@ -764,7 +764,7 @@ readnrows: function: setReadNRows nextframenumber: - help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Ctb] Next frame number. Stopping acquisition might result in different frame numbers for different modules." + help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Ctb][Xilinx Ctb] Next frame number. Stopping acquisition might result in different frame numbers for different modules." inherit_actions: INTEGER_COMMAND_VEC_ID actions: GET: @@ -1298,7 +1298,7 @@ dsamples: function: setNumberOfDigitalSamples tsamples: - help: "[n_value]\n\t[Ctb] Number of transceiver samples expected." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Number of transceiver samples expected." inherit_actions: INTEGER_COMMAND_VEC_ID actions: GET: @@ -1307,7 +1307,7 @@ tsamples: function: setNumberOfTransceiverSamples romode: - help: "[analog|digital|analog_digital|transceiver|digital_transceiver]\n\t[Ctb] Readout mode. Default is analog." + help: "[analog|digital|analog_digital|transceiver|digital_transceiver]\n\t[Ctb][xilinx Ctb] Readout mode. [Ctb] Default is analog. [Xilinx Ctb] Default is Transceiver (only one implemented so far)" inherit_actions: INTEGER_COMMAND_VEC_ID actions: GET: @@ -1555,7 +1555,7 @@ fmaster: ################# INTEGER_IND_COMMAND ####################### v_limit: inherit_actions: INTEGER_IND_COMMAND - help: "[n_value]\n\t[Ctb] Soft limit for power supplies (ctb only) and DACS in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Soft limit for power supplies (ctb only) and DACS in mV." actions: GET: function: getPower @@ -1566,7 +1566,7 @@ v_limit: v_a: inherit_actions: INTEGER_IND_COMMAND - help: "[n_value]\n\t[Ctb] Power supply a in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply a in mV." actions: GET: function: getPower @@ -1577,7 +1577,7 @@ v_a: v_b: inherit_actions: INTEGER_IND_COMMAND - help: "[n_value]\n\t[Ctb] Power supply b in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply b in mV." actions: GET: function: getPower @@ -1588,7 +1588,7 @@ v_b: v_c: inherit_actions: INTEGER_IND_COMMAND - help: "[n_value]\n\t[Ctb] Power supply c in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply c in mV." actions: GET: function: getPower @@ -1599,7 +1599,7 @@ v_c: v_d: inherit_actions: INTEGER_IND_COMMAND - help: "[n_value]\n\t[Ctb] Power supply d in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply d in mV." actions: GET: function: getPower @@ -1610,7 +1610,7 @@ v_d: v_io: inherit_actions: INTEGER_IND_COMMAND - help: "[n_value]\n\t[Ctb] Power supply io in mV. Minimum 1200 mV. Must be the first power regulator to be set after fpga reset (on-board detector server start up)." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply io in mV. Minimum 1200 mV. Must be the first power regulator to be set after fpga reset (on-board detector server start up)." actions: GET: function: getPower @@ -1792,21 +1792,21 @@ patternstart: resetfpga: inherit_actions: EXECUTE_SET_COMMAND - help: "\n\t[Jungfrau][Moench][Ctb] Reset FPGA." + help: "\n\t[Jungfrau][Moench][Ctb][Xilinx Ctb] Reset FPGA." actions: PUT: function: resetFPGA rebootcontroller: inherit_actions: EXECUTE_SET_COMMAND - help: "\n\t[Jungfrau][Moench][Ctb][Gotthard][Mythen3][Gotthard2] Reboot controller of detector." + help: "\n\t[Jungfrau][Moench][Ctb][Gotthard][Mythen3][Gotthard2][Xilinx Ctb] Reboot controller of detector." actions: PUT: function: rebootController firmwaretest: inherit_actions: EXECUTE_SET_COMMAND - help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] Firmware test, ie. reads a read fixed pattern from a register." + help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Firmware test, ie. reads a read fixed pattern from a register." actions: PUT: function: executeFirmwareTest @@ -1818,6 +1818,13 @@ bustest: PUT: function: executeBusTest +configtransceiver: + inherit_actions: EXECUTE_SET_COMMAND + help: "\n\t[Xilinx Ctb] Waits for transceiver to be aligned. Chip had to be configured (powered on) before this." + actions: + PUT: + function: configureTransceiver + ################# EXECUTE_SET_COMMAND_NOID_1ARG ############## config: inherit_actions: EXECUTE_SET_COMMAND_NOID_1ARG @@ -2011,7 +2018,7 @@ lastclient: framecounter: inherit_actions: GET_COMMAND - help: "\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Number of frames from start run control.\n\t[Gotthard2] only in continuous mode." + help: "\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Number of frames from start run control.\n\t[Gotthard2] only in continuous mode." actions: GET: function: getNumberOfFramesFromStart @@ -2080,7 +2087,7 @@ temp_adc: temp_fpga: inherit_actions: GET_IND_COMMAND - help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Gotthard][Mythen3][Gotthard2] FPGA Temperature" + help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Xilinx CTB] FPGA Temperature" actions: GET: function: getTemperature @@ -2307,7 +2314,7 @@ slowadcvalues: GETFCNLIST: getSlowADCList GETFCNNAME: getSlowADCNames GETFCN: getSlowADC - suffix: "mV" + suffix: "uV" printable_name: "*name_it++" tempvalues: @@ -2818,7 +2825,7 @@ Exptime: exptime: inherit_actions: Exptime - help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Ctb] Exposure time\n\t[Mythen3] Exposure time of all gate signals in auto and trigger mode (internal gating). To specify gate index, use exptime1, exptime2, exptime3." + help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Ctb][Xilinx Ctb] Exposure time\n\t[Mythen3] Exposure time of all gate signals in auto and trigger mode (internal gating). To specify gate index, use exptime1, exptime2, exptime3." actions: GET: function: getExptime diff --git a/slsDetectorSoftware/generator/extended_commands.yaml b/slsDetectorSoftware/generator/extended_commands.yaml index c5e5c67b2..f3c0b3fc9 100644 --- a/slsDetectorSoftware/generator/extended_commands.yaml +++ b/slsDetectorSoftware/generator/extended_commands.yaml @@ -1615,6 +1615,28 @@ config: help: "\n\tFrees shared memory before loading configuration file. Set up once." infer_action: true template: true +configtransceiver: + actions: + PUT: + args: + - arg_types: [] + argc: 0 + cast_input: [] + check_det_id: false + convert_det_id: true + function: configureTransceiver + input: [] + input_types: [] + output: + - '"successful"' + require_det_id: true + store_result_in_t: false + command_name: configtransceiver + function_alias: configtransceiver + help: "\n\t[Xilinx Ctb] Waits for transceiver to be aligned. Chip had to be configured\ + \ (powered on) before this." + infer_action: true + template: true counters: actions: GET: @@ -2495,8 +2517,8 @@ delay: store_result_in_t: false command_name: delay function_alias: delay - help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Moench]\ - \ Delay after trigger" + help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Moench][Xilinx\ + \ Ctb] Delay after trigger" infer_action: true template: true delayl: @@ -2530,8 +2552,8 @@ delayl: store_result_in_t: true command_name: delayl function_alias: delayl - help: "\n\t[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Delay Left in Acquisition.\ - \ \n\t[Gotthard2] only in continuous mode." + help: "\n\t[Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Delay\ + \ Left in Acquisition. \n\t[Gotthard2] only in continuous mode." infer_action: true template: true detectorserverversion: @@ -2891,9 +2913,10 @@ exptime: store_result_in_t: false command_name: exptime function_alias: exptime - help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Ctb]\ - \ Exposure time\n\t[Mythen3] Exposure time of all gate signals in auto and trigger\ - \ mode (internal gating). To specify gate index, use exptime1, exptime2, exptime3." + help: "[duration] [(optional unit) ns|us|ms|s]\n\t[Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Ctb][Xilinx\ + \ Ctb] Exposure time\n\t[Mythen3] Exposure time of all gate signals in auto and\ + \ trigger mode (internal gating). To specify gate index, use exptime1, exptime2,\ + \ exptime3." infer_action: true template: true exptime1: @@ -3610,8 +3633,8 @@ firmwaretest: store_result_in_t: false command_name: firmwaretest function_alias: firmwaretest - help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] Firmware test,\ - \ ie. reads a read fixed pattern from a register." + help: "\n\t[Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Firmware\ + \ test, ie. reads a read fixed pattern from a register." infer_action: true template: true firmwareversion: @@ -3906,8 +3929,8 @@ framecounter: store_result_in_t: true command_name: framecounter function_alias: framecounter - help: "\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Number of frames from start\ - \ run control.\n\t[Gotthard2] only in continuous mode." + help: "\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Number of frames\ + \ from start run control.\n\t[Gotthard2] only in continuous mode." infer_action: true template: true frames: @@ -4005,8 +4028,8 @@ frametime: store_result_in_t: true command_name: frametime function_alias: frametime - help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb]\ - \ Timestamp at a frame start.\n\t[Gotthard2] not in burst and auto mode." + help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx\ + \ Ctb] Timestamp at a frame start.\n\t[Gotthard2] not in burst and auto mode." infer_action: true template: true free: @@ -5474,8 +5497,8 @@ nextframenumber: store_result_in_t: false command_name: nextframenumber function_alias: nextframenumber - help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Ctb] Next frame number. Stopping acquisition\ - \ might result in different frame numbers for different modules." + help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Ctb][Xilinx Ctb] Next frame number.\ + \ Stopping acquisition might result in different frame numbers for different modules." infer_action: true template: true nmod: @@ -7179,8 +7202,8 @@ periodl: store_result_in_t: true command_name: periodl function_alias: periodl - help: "\n\t[Gotthard][Jungfrau][Moench][Ctb][Mythen3][Gotthard2] Period left for\ - \ current frame. \n\t[Gotthard2] only in continuous mode." + help: "\n\t[Gotthard][Jungfrau][Moench][Ctb][Mythen3][Gotthard2][Xilinx Ctb] Period\ + \ left for current frame. \n\t[Gotthard2] only in continuous mode." infer_action: true template: true polarity: @@ -7299,11 +7322,12 @@ powerchip: store_result_in_t: false command_name: powerchip function_alias: powerchip - help: "[0, 1]\n\t[Jungfrau][Moench][Mythen3][Gotthard2] Power the chip. \n\t[Jungfrau][Moench]\ - \ Default is 0. Get will return power status. Can be off if temperature event\ - \ occured (temperature over temp_threshold with temp_control enabled. Will configure\ - \ chip (only chip v1.1)\n\t[Mythen3][Gotthard2] Default is 1. If module not connected\ - \ or wrong module, powerchip will fail." + help: "[0, 1]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] Power the chip.\ + \ \n\t[Jungfrau][Moench] Default is 0. Get will return power status. Can be off\ + \ if temperature event occured (temperature over temp_threshold with temp_control\ + \ enabled. Will configure chip (only chip v1.1)\n\t[Mythen3][Gotthard2] Default\ + \ is 1. If module not connected or wrong module, powerchip will fail.\n\t[Xilinx\ + \ Ctb] Default is 0. Also configures the chip if powered on." infer_action: true template: true powerindex: @@ -7915,8 +7939,8 @@ rebootcontroller: store_result_in_t: false command_name: rebootcontroller function_alias: rebootcontroller - help: "\n\t[Jungfrau][Moench][Ctb][Gotthard][Mythen3][Gotthard2] Reboot controller\ - \ of detector." + help: "\n\t[Jungfrau][Moench][Ctb][Gotthard][Mythen3][Gotthard2][Xilinx Ctb] Reboot\ + \ controller of detector." infer_action: true template: true reg: @@ -8030,7 +8054,7 @@ resetfpga: store_result_in_t: false command_name: resetfpga function_alias: resetfpga - help: "\n\t[Jungfrau][Moench][Ctb] Reset FPGA." + help: "\n\t[Jungfrau][Moench][Ctb][Xilinx Ctb] Reset FPGA." infer_action: true template: true roi: @@ -8117,8 +8141,9 @@ romode: store_result_in_t: false command_name: romode function_alias: romode - help: "[analog|digital|analog_digital|transceiver|digital_transceiver]\n\t[Ctb]\ - \ Readout mode. Default is analog." + help: "[analog|digital|analog_digital|transceiver|digital_transceiver]\n\t[Ctb][xilinx\ + \ Ctb] Readout mode. [Ctb] Default is analog. [Xilinx Ctb] Default is Transceiver\ + \ (only one implemented so far)" infer_action: true template: true row: @@ -8231,8 +8256,8 @@ runtime: store_result_in_t: true command_name: runtime function_alias: runtime - help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb]\ - \ Time from detector start up.\n\t[Gotthard2] not in burst and auto mode." + help: "[(optional unit) ns|us|ms|s]\n\t[Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx\ + \ Ctb] Time from detector start up.\n\t[Gotthard2] not in burst and auto mode." infer_action: true template: true rx_arping: @@ -10096,7 +10121,7 @@ slowadcvalues: GETFCNLIST: getSlowADCList GETFCNNAME: getSlowADCNames printable_name: '*name_it++' - suffix: mV + suffix: uV function: '' input: [] input_types: [] @@ -10759,8 +10784,8 @@ temp_fpga: store_result_in_t: true command_name: temp_fpga function_alias: temp_fpga - help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Gotthard][Mythen3][Gotthard2] FPGA\ - \ Temperature" + help: "[n_value]\n\t[Eiger][Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Xilinx\ + \ CTB] FPGA Temperature" infer_action: true template: true temp_fpgaext: @@ -11371,8 +11396,8 @@ transceiverenable: store_result_in_t: false command_name: transceiverenable function_alias: transceiverenable - help: "[bitmask]\n\t[Ctb] Transceiver Enable Mask. Enable for each 4 Transceiver\ - \ channel." + help: "[bitmask]\n\t[Ctb][Xilinx Ctb] Transceiver Enable Mask. Enable for each 4\ + \ Transceiver channel." infer_action: true template: true trigger: @@ -11617,7 +11642,7 @@ tsamples: store_result_in_t: false command_name: tsamples function_alias: tsamples - help: "[n_value]\n\t[Ctb] Number of transceiver samples expected." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Number of transceiver samples expected." infer_action: true template: true txdelay: @@ -12578,7 +12603,7 @@ v_a: store_result_in_t: false command_name: v_a function_alias: v_a - help: "[n_value]\n\t[Ctb] Power supply a in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply a in mV." infer_action: true template: true v_b: @@ -12624,7 +12649,7 @@ v_b: store_result_in_t: false command_name: v_b function_alias: v_b - help: "[n_value]\n\t[Ctb] Power supply b in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply b in mV." infer_action: true template: true v_c: @@ -12670,7 +12695,7 @@ v_c: store_result_in_t: false command_name: v_c function_alias: v_c - help: "[n_value]\n\t[Ctb] Power supply c in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply c in mV." infer_action: true template: true v_chip: @@ -12763,7 +12788,7 @@ v_d: store_result_in_t: false command_name: v_d function_alias: v_d - help: "[n_value]\n\t[Ctb] Power supply d in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply d in mV." infer_action: true template: true v_io: @@ -12809,8 +12834,9 @@ v_io: store_result_in_t: false command_name: v_io function_alias: v_io - help: "[n_value]\n\t[Ctb] Power supply io in mV. Minimum 1200 mV. Must be the first\ - \ power regulator to be set after fpga reset (on-board detector server start up)." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Power supply io in mV. Minimum 1200 mV. Must\ + \ be the first power regulator to be set after fpga reset (on-board detector server\ + \ start up)." infer_action: true template: true v_limit: @@ -12856,7 +12882,8 @@ v_limit: store_result_in_t: false command_name: v_limit function_alias: v_limit - help: "[n_value]\n\t[Ctb] Soft limit for power supplies (ctb only) and DACS in mV." + help: "[n_value]\n\t[Ctb][Xilinx Ctb] Soft limit for power supplies (ctb only) and\ + \ DACS in mV." infer_action: true template: true vchip_comp_adc: diff --git a/slsDetectorSoftware/include/sls/Detector.h b/slsDetectorSoftware/include/sls/Detector.h index 55e7826bb..a5a9e20af 100644 --- a/slsDetectorSoftware/include/sls/Detector.h +++ b/slsDetectorSoftware/include/sls/Detector.h @@ -303,11 +303,11 @@ class Detector { void setNumberOfTriggers(int64_t value); - /** [Gotthard][Jungfrau][Moench][Eiger][CTB][Gotthard2] \n + /** [Gotthard][Jungfrau][Moench][Eiger][CTB][Xilinx CTB][Gotthard2] \n * [Mythen3] use function with gate index **/ Result getExptime(Positions pos = {}) const; - /** [Gotthard][Jungfrau][Moench][Eiger][CTB][Gotthard2] \n + /** [Gotthard][Jungfrau][Moench][Eiger][CTB][Xilinx CTB][Gotthard2] \n * [Mythen3] sets exptime for all gate signals. To specify gate index, use * function with gate index **/ void setExptime(ns t, Positions pos = {}); @@ -316,10 +316,10 @@ class Detector { void setPeriod(ns t, Positions pos = {}); - /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] */ + /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx CTB] */ Result getDelayAfterTrigger(Positions pos = {}) const; - /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] */ + /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx CTB] */ void setDelayAfterTrigger(ns value, Positions pos = {}); /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Xilinx CTB] @@ -330,11 +330,11 @@ class Detector { * Only when external trigger used */ Result getNumberOfTriggersLeft(Positions pos = {}) const; - /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2] + /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Gotthard2][Xilinx CTB] * [Gotthard2] only in continuous mode */ Result getPeriodLeft(Positions pos = {}) const; - /** [Gotthard][Jungfrau][Moench][CTB][Mythen3] + /** [Gotthard][Jungfrau][Moench][CTB][Mythen3][Xilinx CTB] * [Gotthard2] only in continuous mode */ Result getDelayAfterTriggerLeft(Positions pos = {}) const; @@ -456,16 +456,17 @@ class Detector { */ void setHighVoltage(int value, Positions pos = {}); - /** [Jungfrau][Moench][Mythen3][Gotthard2] */ + /** [Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] */ Result getPowerChip(Positions pos = {}) const; - /** [Jungfrau][Moench][Mythen3][Gotthard2] Power the chip. \n + /** [Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] Power the chip. \n * Default is disabled. \n * [Jungfrau][Moench] Default is disabled. Get will return power status. Can * be off if temperature event occured (temperature over temp_threshold with * temp_control enabled. Will configure chip (only chip v1.1)\n * [Mythen3][Gotthard2] Default is 1. If module not connected or wrong - * module, powerchip will fail. + * module, powerchip will fail.\n + * [Xilinx CTB] Default is 0. Also configures chip if powered on. */ void setPowerChip(bool on, Positions pos = {}); @@ -483,7 +484,7 @@ class Detector { /** * (Degrees) - * [Mythen3][Gotthard2] Options: TEMPERATURE_FPGA + * [Mythen3][Gotthard2][Xilinx Ctb] Options: TEMPERATURE_FPGA * [Gotthard] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n * [Jungfrau][Moench] Options: TEMPERATURE_ADC, TEMPERATURE_FPGA \n * [Eiger] Options: TEMPERATURE_FPGA, TEMPERATURE_FPGAEXT, TEMPERATURE_10GE, @@ -657,11 +658,11 @@ class Detector { Result> getRxCurrentFrameIndex(Positions pos = {}) const; - /** [Eiger][Jungfrau][Moench][CTB] */ + /** [Eiger][Jungfrau][Moench][CTB][Xilinx CTB] */ Result getNextFrameNumber(Positions pos = {}) const; - /** [Eiger][Jungfrau][Moench][CTB] Stopping acquisition might result in - * different frame numbers for different modules.*/ + /** [Eiger][Jungfrau][Moench][CTB][Xilinx CTB] Stopping acquisition might + * result in different frame numbers for different modules.*/ void setNextFrameNumber(uint64_t value, Positions pos = {}); /** [Eiger][Mythen3][Jungfrau][Moench] Sends an internal software trigger to @@ -1607,7 +1608,7 @@ class Detector { ///@{ /************************************************** * * - * CTB Specific * + * CTB / Xilinx CTB Specific * * * * ************************************************/ /** [CTB] */ @@ -1637,12 +1638,12 @@ class Detector { /** gets list of slow adc enums */ std::vector getSlowADCList() const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ Result getPower(defs::dacIndex index, Positions pos = {}) const; /** - * [CTB] mV - * [Ctb] Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C, + * [CTB][Xilinx CTB] mV + * [Ctb][Xilinx CTB] Options: V_LIMIT, V_POWER_A, V_POWER_B, V_POWER_C, * V_POWER_D, V_POWER_IO, V_POWER_CHIP */ void setPower(defs::dacIndex index, int value, Positions pos = {}); @@ -1668,39 +1669,30 @@ class Detector { "complete 4 bits are enabled */ void setTenGigaADCEnableMask(uint32_t mask, Positions pos = {}); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ Result getTransceiverEnableMask(Positions pos = {}) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setTransceiverEnableMask(uint32_t mask, Positions pos = {}); - ///@} - - /** @name CTB Specific */ - ///@{ - /************************************************** - * * - * CTB Specific * - * * - * ************************************************/ - /** [CTB] */ Result getNumberOfDigitalSamples(Positions pos = {}) const; /** [CTB] */ void setNumberOfDigitalSamples(int value, Positions pos = {}); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ Result getNumberOfTransceiverSamples(Positions pos = {}) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setNumberOfTransceiverSamples(int value, Positions pos = {}); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ Result getReadoutMode(Positions pos = {}) const; /** [CTB] Options: ANALOG_ONLY (default), DIGITAL_ONLY, ANALOG_AND_DIGITAL, * TRANSCEIVER_ONLY, DIGITAL_AND_TRANSCEIVER + * [Xilinx CTB] Options: TRANSCEIVER_ONLY (default) */ void setReadoutMode(defs::readoutMode value, Positions pos = {}); @@ -1722,7 +1714,7 @@ class Detector { Result getMeasuredCurrent(defs::dacIndex index, Positions pos = {}) const; - /** [CTB] Options: SLOW_ADC0 - SLOW_ADC7 in uV */ + /** [CTB][Xilinx CTB] Options: SLOW_ADC0 - SLOW_ADC7 in uV */ Result getSlowADC(defs::dacIndex index, Positions pos = {}) const; /** [CTB] */ @@ -1764,81 +1756,95 @@ class Detector { /** [CTB] Default is enabled. */ void setLEDEnable(bool enable, Positions pos = {}); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setDacNames(const std::vector names); + /** [CTB][Xilinx CTB] */ std::vector getDacNames() const; + /** [CTB][Xilinx CTB] */ defs::dacIndex getDacIndex(const std::string &name) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setDacName(const defs::dacIndex i, const std::string &name); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::string getDacName(const defs::dacIndex i) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setAdcNames(const std::vector names); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::vector getAdcNames() const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ int getAdcIndex(const std::string &name) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setAdcName(const int i, const std::string &name); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::string getAdcName(const int i) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setSignalNames(const std::vector names); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::vector getSignalNames() const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ int getSignalIndex(const std::string &name) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setSignalName(const int i, const std::string &name); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::string getSignalName(const int i) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setPowerNames(const std::vector names); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::vector getPowerNames() const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ defs::dacIndex getPowerIndex(const std::string &name) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setPowerName(const defs::dacIndex i, const std::string &name); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::string getPowerName(const defs::dacIndex i) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setSlowADCNames(const std::vector names); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::vector getSlowADCNames() const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ defs::dacIndex getSlowADCIndex(const std::string &name) const; - /** [CTB] */ + /** [CTB][Xilinx CTB] */ void setSlowADCName(const defs::dacIndex i, const std::string &name); - /** [CTB] */ + /** [CTB][Xilinx CTB] */ std::string getSlowADCName(const defs::dacIndex i) const; ///@} + /** @name Xilinx CTB Specific */ + ///@{ + /************************************************** + * * + * Xilinx CTB Specific * + * * + * ************************************************/ + ///@} + + /** [Xilinx Ctb] */ + void configureTransceiver(Positions pos = {}); + /** @name Pattern */ ///@{ /************************************************** @@ -1986,7 +1992,7 @@ class Detector { void programFPGA(const std::string &fname, const bool forceDeleteNormalFile, Positions pos = {}); - /** [Jungfrau][Moench][CTB] Advanced user Function! */ + /** [Jungfrau][Moench][CTB][Xilinx CTB] Advanced user Function! */ void resetFPGA(Positions pos = {}); /** [Jungfrau][Moench][Eiger][Ctb][Mythen3][Gotthard2] Copies detector @@ -2004,8 +2010,8 @@ class Detector { */ void updateKernel(const std::string &fname, Positions pos = {}); - /** [Jungfrau][Moench][Gotthard][CTB][Mythen3][Gotthard2] Advanced user - * Function! */ + /** [Jungfrau][Moench][Gotthard][CTB][Mythen3][Gotthard2][Xilinx CTB] + * Advanced user Function! */ void rebootController(Positions pos = {}); /** @@ -2109,16 +2115,16 @@ class Detector { Result executeCommand(const std::string &value, Positions pos = {}); - /** [Jungfrau][Moench][Mythen3][CTB] + /** [Jungfrau][Moench][Mythen3][CTB][Xilinx CTB] * [Gotthard2] only in continuous mode */ Result getNumberOfFramesFromStart(Positions pos = {}) const; - /** [Jungfrau][Moench][Mythen3][CTB] Get time from detector start - * [Gotthard2] not in burst and auto mode */ + /** [Jungfrau][Moench][Mythen3][CTB][Xilinx CTB] Get time from detector + * start [Gotthard2] not in burst and auto mode */ Result getActualTime(Positions pos = {}) const; - /** [Jungfrau][Moench][Mythen3][CTB] Get timestamp at a frame start - * [Gotthard2] not in burst and auto mode */ + /** [Jungfrau][Moench][Mythen3][CTB][Xilinx CTB] Get timestamp at a frame + * start [Gotthard2] not in burst and auto mode */ Result getMeasurementTime(Positions pos = {}) const; /** get user details from shared memory (hostname, type, PID, User, Date) diff --git a/slsDetectorSoftware/src/Caller.cpp b/slsDetectorSoftware/src/Caller.cpp index 163811d93..8cf88561e 100644 --- a/slsDetectorSoftware/src/Caller.cpp +++ b/slsDetectorSoftware/src/Caller.cpp @@ -2247,6 +2247,46 @@ std::string Caller::config(int action) { return os.str(); } +std::string Caller::configtransceiver(int action) { + + std::ostringstream os; + // print help + if (action == slsDetectorDefs::HELP_ACTION) { + os << "Command: configtransceiver" << std::endl; + os << R"V0G0N( + [Xilinx Ctb] Waits for transceiver to be aligned. Chip had to be configured (powered on) before this. )V0G0N" + << std::endl; + return os.str(); + } + + // check if action and arguments are valid + if (action == slsDetectorDefs::PUT_ACTION) { + if (1 && args.size() != 0) { + throw RuntimeError("Wrong number of arguments for action PUT"); + } + + if (args.size() == 0) { + } + + } + + else { + + throw RuntimeError( + "INTERNAL ERROR: Invalid action: supported actions are ['PUT']"); + } + + // generate code for each action + if (action == slsDetectorDefs::PUT_ACTION) { + if (args.size() == 0) { + det->configureTransceiver(std::vector{det_id}); + os << "successful" << '\n'; + } + } + + return os.str(); +} + std::string Caller::dac(int action) { std::ostringstream os; @@ -3161,7 +3201,7 @@ std::string Caller::delay(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: delay" << std::endl; os << R"V0G0N([duration] [(optional unit) ns|us|ms|s] - [Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Moench] Delay after trigger )V0G0N" + [Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Moench][Xilinx Ctb] Delay after trigger )V0G0N" << std::endl; return os.str(); } @@ -3250,7 +3290,7 @@ std::string Caller::delayl(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: delayl" << std::endl; os << R"V0G0N( - [Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Delay Left in Acquisition. + [Gotthard][Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Delay Left in Acquisition. [Gotthard2] only in continuous mode. )V0G0N" << std::endl; return os.str(); @@ -3685,7 +3725,7 @@ std::string Caller::exptime(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: exptime" << std::endl; os << R"V0G0N([duration] [(optional unit) ns|us|ms|s] - [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Ctb] Exposure time + [Eiger][Jungfrau][Moench][Gotthard][Gotthard2][Ctb][Xilinx Ctb] Exposure time [Mythen3] Exposure time of all gate signals in auto and trigger mode (internal gating). To specify gate index, use exptime1, exptime2, exptime3. )V0G0N" << std::endl; return os.str(); @@ -4666,7 +4706,7 @@ std::string Caller::firmwaretest(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: firmwaretest" << std::endl; os << R"V0G0N( - [Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb] Firmware test, ie. reads a read fixed pattern from a register. )V0G0N" + [Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Firmware test, ie. reads a read fixed pattern from a register. )V0G0N" << std::endl; return os.str(); } @@ -5132,7 +5172,7 @@ std::string Caller::framecounter(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: framecounter" << std::endl; os << R"V0G0N( - [Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Number of frames from start run control. + [Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Number of frames from start run control. [Gotthard2] only in continuous mode. )V0G0N" << std::endl; return os.str(); @@ -5283,7 +5323,7 @@ std::string Caller::frametime(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: frametime" << std::endl; os << R"V0G0N([(optional unit) ns|us|ms|s] - [Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Timestamp at a frame start. + [Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Timestamp at a frame start. [Gotthard2] not in burst and auto mode. )V0G0N" << std::endl; return os.str(); @@ -7224,7 +7264,7 @@ std::string Caller::nextframenumber(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: nextframenumber" << std::endl; os << R"V0G0N([n_value] - [Eiger][Jungfrau][Moench][Ctb] Next frame number. Stopping acquisition might result in different frame numbers for different modules. )V0G0N" + [Eiger][Jungfrau][Moench][Ctb][Xilinx Ctb] Next frame number. Stopping acquisition might result in different frame numbers for different modules. )V0G0N" << std::endl; return os.str(); } @@ -9141,7 +9181,7 @@ std::string Caller::periodl(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: periodl" << std::endl; os << R"V0G0N( - [Gotthard][Jungfrau][Moench][Ctb][Mythen3][Gotthard2] Period left for current frame. + [Gotthard][Jungfrau][Moench][Ctb][Mythen3][Gotthard2][Xilinx Ctb] Period left for current frame. [Gotthard2] only in continuous mode. )V0G0N" << std::endl; return os.str(); @@ -9317,9 +9357,10 @@ std::string Caller::powerchip(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: powerchip" << std::endl; os << R"V0G0N([0, 1] - [Jungfrau][Moench][Mythen3][Gotthard2] Power the chip. + [Jungfrau][Moench][Mythen3][Gotthard2][Xilinx Ctb] Power the chip. [Jungfrau][Moench] Default is 0. Get will return power status. Can be off if temperature event occured (temperature over temp_threshold with temp_control enabled. Will configure chip (only chip v1.1) - [Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail. )V0G0N" + [Mythen3][Gotthard2] Default is 1. If module not connected or wrong module, powerchip will fail. + [Xilinx Ctb] Default is 0. Also configures the chip if powered on. )V0G0N" << std::endl; return os.str(); } @@ -10230,7 +10271,7 @@ std::string Caller::rebootcontroller(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: rebootcontroller" << std::endl; os << R"V0G0N( - [Jungfrau][Moench][Ctb][Gotthard][Mythen3][Gotthard2] Reboot controller of detector. )V0G0N" + [Jungfrau][Moench][Ctb][Gotthard][Mythen3][Gotthard2][Xilinx Ctb] Reboot controller of detector. )V0G0N" << std::endl; return os.str(); } @@ -10399,7 +10440,7 @@ std::string Caller::resetfpga(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: resetfpga" << std::endl; os << R"V0G0N( - [Jungfrau][Moench][Ctb] Reset FPGA. )V0G0N" + [Jungfrau][Moench][Ctb][Xilinx Ctb] Reset FPGA. )V0G0N" << std::endl; return os.str(); } @@ -10505,7 +10546,7 @@ std::string Caller::romode(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: romode" << std::endl; os << R"V0G0N([analog|digital|analog_digital|transceiver|digital_transceiver] - [Ctb] Readout mode. Default is analog. )V0G0N" + [Ctb][xilinx Ctb] Readout mode. [Ctb] Default is analog. [Xilinx Ctb] Default is Transceiver (only one implemented so far) )V0G0N" << std::endl; return os.str(); } @@ -10696,7 +10737,7 @@ std::string Caller::runtime(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: runtime" << std::endl; os << R"V0G0N([(optional unit) ns|us|ms|s] - [Jungfrau][Moench][Mythen3][Gotthard2][Ctb] Time from detector start up. + [Jungfrau][Moench][Mythen3][Gotthard2][Ctb][Xilinx Ctb] Time from detector start up. [Gotthard2] not in burst and auto mode. )V0G0N" << std::endl; return os.str(); @@ -13298,7 +13339,7 @@ std::string Caller::slowadcvalues(int action) { if (action == slsDetectorDefs::GET_ACTION) { if (args.size() == 0) { - std::string suffix = " mV"; + std::string suffix = " uV"; auto t = det->getSlowADCList(); auto names = det->getSlowADCNames(); @@ -14215,7 +14256,7 @@ std::string Caller::temp_fpga(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: temp_fpga" << std::endl; os << R"V0G0N([n_value] - [Eiger][Jungfrau][Moench][Gotthard][Mythen3][Gotthard2] FPGA Temperature )V0G0N" + [Eiger][Jungfrau][Moench][Gotthard][Mythen3][Gotthard2][Xilinx CTB] FPGA Temperature )V0G0N" << std::endl; return os.str(); } @@ -14960,7 +15001,7 @@ std::string Caller::transceiverenable(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: transceiverenable" << std::endl; os << R"V0G0N([bitmask] - [Ctb] Transceiver Enable Mask. Enable for each 4 Transceiver channel. )V0G0N" + [Ctb][Xilinx Ctb] Transceiver Enable Mask. Enable for each 4 Transceiver channel. )V0G0N" << std::endl; return os.str(); } @@ -15294,7 +15335,7 @@ std::string Caller::tsamples(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: tsamples" << std::endl; os << R"V0G0N([n_value] - [Ctb] Number of transceiver samples expected. )V0G0N" + [Ctb][Xilinx Ctb] Number of transceiver samples expected. )V0G0N" << std::endl; return os.str(); } @@ -16568,7 +16609,7 @@ std::string Caller::v_a(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: v_a" << std::endl; os << R"V0G0N([n_value] - [Ctb] Power supply a in mV. )V0G0N" + [Ctb][Xilinx Ctb] Power supply a in mV. )V0G0N" << std::endl; return os.str(); } @@ -16631,7 +16672,7 @@ std::string Caller::v_b(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: v_b" << std::endl; os << R"V0G0N([n_value] - [Ctb] Power supply b in mV. )V0G0N" + [Ctb][Xilinx Ctb] Power supply b in mV. )V0G0N" << std::endl; return os.str(); } @@ -16694,7 +16735,7 @@ std::string Caller::v_c(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: v_c" << std::endl; os << R"V0G0N([n_value] - [Ctb] Power supply c in mV. )V0G0N" + [Ctb][Xilinx Ctb] Power supply c in mV. )V0G0N" << std::endl; return os.str(); } @@ -16821,7 +16862,7 @@ std::string Caller::v_d(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: v_d" << std::endl; os << R"V0G0N([n_value] - [Ctb] Power supply d in mV. )V0G0N" + [Ctb][Xilinx Ctb] Power supply d in mV. )V0G0N" << std::endl; return os.str(); } @@ -16884,7 +16925,7 @@ std::string Caller::v_io(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: v_io" << std::endl; os << R"V0G0N([n_value] - [Ctb] Power supply io in mV. Minimum 1200 mV. Must be the first power regulator to be set after fpga reset (on-board detector server start up). )V0G0N" + [Ctb][Xilinx Ctb] Power supply io in mV. Minimum 1200 mV. Must be the first power regulator to be set after fpga reset (on-board detector server start up). )V0G0N" << std::endl; return os.str(); } @@ -16947,7 +16988,7 @@ std::string Caller::v_limit(int action) { if (action == slsDetectorDefs::HELP_ACTION) { os << "Command: v_limit" << std::endl; os << R"V0G0N([n_value] - [Ctb] Soft limit for power supplies (ctb only) and DACS in mV. )V0G0N" + [Ctb][Xilinx Ctb] Soft limit for power supplies (ctb only) and DACS in mV. )V0G0N" << std::endl; return os.str(); } diff --git a/slsDetectorSoftware/src/Caller.h b/slsDetectorSoftware/src/Caller.h index 679f76526..b3ec879b4 100644 --- a/slsDetectorSoftware/src/Caller.h +++ b/slsDetectorSoftware/src/Caller.h @@ -93,6 +93,7 @@ class Caller { std::string compdisabletime(int action); std::string confadc(int action); std::string config(int action); + std::string configtransceiver(int action); std::string counters(int action); std::string currentsource(int action); std::string dac(int action); @@ -435,6 +436,7 @@ class Caller { {"compdisabletime", &Caller::compdisabletime}, {"confadc", &Caller::confadc}, {"config", &Caller::config}, + {"configtransceiver", &Caller::configtransceiver}, {"counters", &Caller::counters}, {"currentsource", &Caller::currentsource}, {"dac", &Caller::dac}, diff --git a/slsDetectorSoftware/src/CallerSpecial.cpp b/slsDetectorSoftware/src/CallerSpecial.cpp index dfd5a0d68..c760a9c4f 100644 --- a/slsDetectorSoftware/src/CallerSpecial.cpp +++ b/slsDetectorSoftware/src/CallerSpecial.cpp @@ -232,7 +232,6 @@ std::string Caller::acquire(int action) { if (det_id >= 0) { throw RuntimeError("Individual detectors not allowed for readout."); } - det->acquire(); if (det->getUseReceiverFlag().squash(false)) { diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 0473c3c9a..d344703c0 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -667,6 +667,7 @@ std::vector Detector::getTemperatureList() const { defs::TEMPERATURE_FPGA2, defs::TEMPERATURE_FPGA3}; case defs::MYTHEN3: case defs::GOTTHARD2: + case defs::XILINX_CHIPTESTBOARD: return std::vector{defs::TEMPERATURE_FPGA}; default: return std::vector{}; @@ -697,6 +698,7 @@ Result Detector::getTemperature(defs::dacIndex index, case defs::MOENCH: case defs::MYTHEN3: case defs::GOTTHARD2: + case defs::XILINX_CHIPTESTBOARD: for (auto &it : res) { it /= 1000; } @@ -2486,6 +2488,12 @@ std::string Detector::getSlowADCName(const defs::dacIndex i) const { return pimpl->getCtbSlowADCName(i); } +// Xilinx Ctb Specific + +void Detector::configureTransceiver(Positions pos) { + pimpl->Parallel(&Module::configureTransceiver, pos); +} + // Pattern Result Detector::getPatterFileName(Positions pos) const { diff --git a/slsDetectorSoftware/src/DetectorImpl.cpp b/slsDetectorSoftware/src/DetectorImpl.cpp index a44bbadec..523c472f8 100644 --- a/slsDetectorSoftware/src/DetectorImpl.cpp +++ b/slsDetectorSoftware/src/DetectorImpl.cpp @@ -1375,7 +1375,7 @@ void DetectorImpl::stopDetector(Positions pos) { void DetectorImpl::printProgress(double progress) { // spaces for python printout - std::cout << " " << std::fixed << std::setprecision(2) << std::setw(6) + std::cout << " " << std::fixed << std::setprecision(2) << std::setw(10) << progress << " \%"; std::cout << '\r' << std::flush; } diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 0f8596036..cdc753a6a 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -2383,6 +2383,7 @@ void Module::setNumberOfAnalogSamples(int value) { // update #nchan, as it depends on #samples, adcmask updateNumberOfChannels(); if (shm()->useReceiverFlag) { + LOG(logINFORED) << "receiver up!"; sendToReceiver(F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value, nullptr); } } @@ -2531,6 +2532,13 @@ void Module::setLEDEnable(bool enable) { sendToDetector(F_LED, static_cast(enable)); } +// Xilinx Ctb Specific +void Module::configureTransceiver() { + sendToDetector(F_CONFIG_TRANSCEIVER); + LOG(logINFO) << "Module " << moduleIndex << " (" << shm()->hostname + << "): Transceiver configured successfully!"; +} + // Pattern std::string Module::getPatterFileName() const { char retval[MAX_STR_LENGTH]{}; @@ -3334,7 +3342,13 @@ void Module::initializeModuleStructure(detectorType type) { shm()->numberOfModule.y = 0; shm()->controlPort = DEFAULT_TCP_CNTRL_PORTNO; shm()->stopPort = DEFAULT_TCP_STOP_PORTNO; - strcpy_safe(shm()->settingsDir, getenv("HOME")); + char *home_directory = getenv("HOME"); + if (home_directory != nullptr) + strcpy_safe(shm()->settingsDir, home_directory); + else { + strcpy_safe(shm()->settingsDir, ""); + LOG(logWARNING) << "HOME directory not set"; + } strcpy_safe(shm()->rxHostname, "none"); shm()->rxTCPPort = DEFAULT_TCP_RX_PORTNO + moduleIndex; shm()->useReceiverFlag = false; diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index 4c3d5a97f..b8b73e3f4 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -528,6 +528,13 @@ class Module : public virtual slsDetectorDefs { bool getLEDEnable() const; void setLEDEnable(bool enable); + /************************************************** + * * + * Xilinx Ctb Specific * + * * + * ************************************************/ + void configureTransceiver(); + /************************************************** * * * Pattern * diff --git a/slsDetectorSoftware/src/inferAction.cpp b/slsDetectorSoftware/src/inferAction.cpp index 31ae6919d..cb0bdc28b 100644 --- a/slsDetectorSoftware/src/inferAction.cpp +++ b/slsDetectorSoftware/src/inferAction.cpp @@ -562,6 +562,18 @@ int InferAction::config() { } } +int InferAction::configtransceiver() { + + if (args.size() == 0) { + return slsDetectorDefs::PUT_ACTION; + } + + else { + + throw RuntimeError("Could not infer action: Wrong number of arguments"); + } +} + int InferAction::counters() { throw RuntimeError("sls_detector is disabled for command: counters. Use " diff --git a/slsDetectorSoftware/src/inferAction.h b/slsDetectorSoftware/src/inferAction.h index 84de19490..3b0538a3e 100644 --- a/slsDetectorSoftware/src/inferAction.h +++ b/slsDetectorSoftware/src/inferAction.h @@ -48,6 +48,7 @@ class InferAction { int compdisabletime(); int confadc(); int config(); + int configtransceiver(); int counters(); int currentsource(); int dac(); @@ -381,6 +382,7 @@ class InferAction { {"compdisabletime", &InferAction::compdisabletime}, {"confadc", &InferAction::confadc}, {"config", &InferAction::config}, + {"configtransceiver", &InferAction::configtransceiver}, {"counters", &InferAction::counters}, {"currentsource", &InferAction::currentsource}, {"dac", &InferAction::dac}, diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt index ddd9abbb3..a255c12b0 100755 --- a/slsDetectorSoftware/tests/CMakeLists.txt +++ b/slsDetectorSoftware/tests/CMakeLists.txt @@ -15,6 +15,7 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-gotthard2.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-gotthard.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-chiptestboard.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-xilinx-chiptestboard.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-moench.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-global.cpp diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp index 510f0ea8b..8ef02e85e 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp @@ -368,7 +368,8 @@ TEST_CASE("CALLER::powervalues", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_NOTHROW(caller.call("powervalues", {}, -1, GET)); REQUIRE_THROWS(caller.call("powervalues", {}, -1, PUT)); } else { @@ -380,7 +381,8 @@ TEST_CASE("CALLER::slowadcvalues", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_NOTHROW(caller.call("slowadcvalues", {}, -1, GET)); REQUIRE_THROWS(caller.call("slowadcvalues", {}, -1, PUT)); } else { @@ -496,12 +498,7 @@ TEST_CASE("CALLER::dac", "[.cmdcall][.dacs]") { det_type == defs::XILINX_CHIPTESTBOARD) { for (int i = 0; i < 18; ++i) { SECTION("dac " + std::to_string(i)) { - if (det_type == defs::CHIPTESTBOARD) { - test_dac_caller(static_cast(i), "dac", 0); - } else { - REQUIRE_THROWS( - caller.call("dac", {std::to_string(i)}, -1, GET)); - } + test_dac_caller(static_cast(i), "dac", 0); } } @@ -613,12 +610,10 @@ TEST_CASE("CALLER::samples", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_asamples = det.getNumberOfAnalogSamples(); - Result prev_dsamples = 0; - if (det_type == defs::CHIPTESTBOARD) { - prev_dsamples = det.getNumberOfDigitalSamples(); - } + auto prev_dsamples = det.getNumberOfDigitalSamples(); { std::ostringstream oss; caller.call("samples", {"25"}, -1, PUT, oss); @@ -639,16 +634,15 @@ TEST_CASE("CALLER::samples", "[.cmdcall]") { caller.call("asamples", {}, -1, GET, oss); REQUIRE(oss.str() == "asamples 450\n"); } - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { std::ostringstream oss; caller.call("dsamples", {}, -1, GET, oss); REQUIRE(oss.str() == "dsamples 450\n"); } for (int i = 0; i != det.size(); ++i) { det.setNumberOfAnalogSamples(prev_asamples[i], {i}); - if (det_type == defs::CHIPTESTBOARD) { - det.setNumberOfDigitalSamples(prev_dsamples[i], {i}); - } + det.setNumberOfDigitalSamples(prev_dsamples[i], {i}); } } else { REQUIRE_THROWS(caller.call("samples", {}, -1, GET)); @@ -660,7 +654,8 @@ TEST_CASE("CALLER::asamples", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getNumberOfAnalogSamples(); { std::ostringstream oss; @@ -764,7 +759,8 @@ TEST_CASE("CALLER::v_limit", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPower(defs::V_LIMIT); { std::ostringstream oss; @@ -832,7 +828,8 @@ TEST_CASE("CALLER::adcenable10g", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getTenGigaADCEnableMask(); { std::ostringstream oss; @@ -862,7 +859,8 @@ TEST_CASE("CALLER::transceiverenable", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getTransceiverEnableMask(); { std::ostringstream oss; @@ -894,7 +892,8 @@ TEST_CASE("CALLER::dsamples", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getNumberOfDigitalSamples(); { std::ostringstream oss; @@ -924,7 +923,8 @@ TEST_CASE("CALLER::tsamples", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getNumberOfTransceiverSamples(); { std::ostringstream oss; @@ -953,7 +953,8 @@ TEST_CASE("CALLER::romode", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_romode = det.getReadoutMode(); auto prev_asamples = det.getNumberOfAnalogSamples(); auto prev_dsamples = det.getNumberOfDigitalSamples(); @@ -1037,7 +1038,8 @@ TEST_CASE("CALLER::v_a", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPower(defs::V_POWER_A); { std::ostringstream oss1, oss2; @@ -1058,7 +1060,8 @@ TEST_CASE("CALLER::v_b", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPower(defs::V_POWER_B); { std::ostringstream oss1, oss2; @@ -1079,7 +1082,8 @@ TEST_CASE("CALLER::v_c", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPower(defs::V_POWER_C); { std::ostringstream oss1, oss2; @@ -1100,7 +1104,8 @@ TEST_CASE("CALLER::v_d", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPower(defs::V_POWER_D); { std::ostringstream oss1, oss2; @@ -1121,7 +1126,8 @@ TEST_CASE("CALLER::v_io", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { // better not to play with setting it REQUIRE_NOTHROW(caller.call("v_io", {}, -1, GET)); } else { @@ -1251,11 +1257,12 @@ TEST_CASE("CALLER::im_io", "[.cmdcall]") { } } -TEST_CASE("CALLER::adc", "[.cmdcall]") { +TEST_CASE("CALLER::slowadc", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { for (int i = 0; i <= 7; ++i) { REQUIRE_NOTHROW( caller.call("slowadc", {std::to_string(i)}, -1, GET)); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp index 275612d89..20637cd16 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-pattern.cpp @@ -81,9 +81,10 @@ TEST_CASE("Caller::patioctrl", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPatternIOControl(); - { + if (det_type == defs::CHIPTESTBOARD) { std::ostringstream oss; caller.call("patioctrl", {"0xc15004808d0a21a4"}, -1, PUT, oss); REQUIRE(oss.str() == "patioctrl 0xc15004808d0a21a4\n"); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp index e5f996318..b2c86bfaa 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx.cpp @@ -27,192 +27,156 @@ python/scripts/list_tested_cmd.py to check if all commands are covered TEST_CASE("Caller::rx_version", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - std::ostringstream oss; - caller.call("rx_version", {}, -1, GET, oss); - sls::Version v(APIRECEIVER); - std::ostringstream vs; - vs << "rx_version " << v.concise() << '\n'; - REQUIRE(oss.str() == vs.str()); + std::ostringstream oss; + caller.call("rx_version", {}, -1, GET, oss); + sls::Version v(APIRECEIVER); + std::ostringstream vs; + vs << "rx_version " << v.concise() << '\n'; + REQUIRE(oss.str() == vs.str()); - REQUIRE_THROWS(caller.call("rx_version", {"0"}, -1, PUT)); - } else { - REQUIRE_THROWS(caller.call("rx_version", {}, -1, GET)); - } + REQUIRE_THROWS(caller.call("rx_version", {"0"}, -1, PUT)); } /* acquisition */ TEST_CASE("Caller::rx_start", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - det.setFileWrite(false); // avoid writing or error on file creation - // PUT only command - REQUIRE_THROWS(caller.call("rx_start", {}, -1, GET)); - { - std::ostringstream oss; - caller.call("rx_start", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_start successful\n"); - } - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status running\n"); - } - } else { - REQUIRE_THROWS(caller.call("rx_start", {}, -1, GET)); + det.setFileWrite(false); // avoid writing or error on file creation + // PUT only command + REQUIRE_THROWS(caller.call("rx_start", {}, -1, GET)); + { + std::ostringstream oss; + caller.call("rx_start", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_start successful\n"); + } + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status running\n"); } } TEST_CASE("Caller::rx_stop", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - // PUT only command - REQUIRE_THROWS(caller.call("rx_stop", {}, -1, GET)); - { - std::ostringstream oss; - caller.call("rx_stop", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_stop successful\n"); - } - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status idle\n"); - } - } else { - REQUIRE_THROWS(caller.call("rx_stop", {}, -1, GET)); + // PUT only command + REQUIRE_THROWS(caller.call("rx_stop", {}, -1, GET)); + { + std::ostringstream oss; + caller.call("rx_stop", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_stop successful\n"); + } + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status idle\n"); } } TEST_CASE("Caller::rx_status", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - det.setFileWrite(false); // avoid writing or error on file creation - Caller caller(&det); - det.startReceiver(); - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status running\n"); - } - det.stopReceiver(); - { - std::ostringstream oss; - caller.call("rx_status", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_status idle\n"); - } - } else { - REQUIRE_THROWS(caller.call("rx_status", {}, -1, GET)); + det.setFileWrite(false); // avoid writing or error on file creation + det.startReceiver(); + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status running\n"); + } + det.stopReceiver(); + { + std::ostringstream oss; + caller.call("rx_status", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_status idle\n"); } } TEST_CASE("Caller::rx_framescaught", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - // This ensures 0 caught frames - auto prev_val = det.getFileWrite(); - det.setFileWrite(false); // avoid writing or error on file creation - det.startReceiver(); - det.stopReceiver(); - { - std::ostringstream oss; - caller.call("rx_framescaught", {}, -1, GET, oss); - if (det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of interfaces") == 1) { - REQUIRE(oss.str() == "rx_framescaught [0]\n"); - } else { - REQUIRE(oss.str() == "rx_framescaught [0, 0]\n"); - } + // This ensures 0 caught frames + auto prev_val = det.getFileWrite(); + det.setFileWrite(false); // avoid writing or error on file creation + det.startReceiver(); + det.stopReceiver(); + { + std::ostringstream oss; + caller.call("rx_framescaught", {}, -1, GET, oss); + if (det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of interfaces") == 1) { + REQUIRE(oss.str() == "rx_framescaught [0]\n"); + } else { + REQUIRE(oss.str() == "rx_framescaught [0, 0]\n"); } + } - // Currently disabled may activate if we have a stable env - // Now take one frame and see that we caught it - // det.setNumberOfFrames(1); - // det.acquire(); - // { - // std::ostringstream oss; - // caller.call("rx_framescaught", {}, -1, GET, oss); - // REQUIRE(oss.str() == "rx_framescaught 1\n"); - // } + // Currently disabled may activate if we have a stable env + // Now take one frame and see that we caught it + // det.setNumberOfFrames(1); + // det.acquire(); + // { + // std::ostringstream oss; + // caller.call("rx_framescaught", {}, -1, GET, oss); + // REQUIRE(oss.str() == "rx_framescaught 1\n"); + // } - for (int i = 0; i != det.size(); ++i) { - det.setFileWrite(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_framescaught", {}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.setFileWrite(prev_val[i], {i}); } } TEST_CASE("Caller::rx_missingpackets", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFileWrite(); - det.setFileWrite(false); // avoid writing or error on file creation - Caller caller(&det); - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - det.setNumberOfFrames(100); - { - // some missing packets - det.startReceiver(); - det.stopReceiver(); - std::ostringstream oss; - caller.call("rx_missingpackets", {}, -1, GET, oss); - if (det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of interfaces") == 1) { - REQUIRE(oss.str() != "rx_missingpackets [0]\n"); - } else { - REQUIRE(oss.str() != "rx_missingpackets [0, 0]\n"); - } + auto prev_val = det.getFileWrite(); + det.setFileWrite(false); // avoid writing or error on file creation + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + det.setNumberOfFrames(100); + { + // some missing packets + det.startReceiver(); + det.stopReceiver(); + std::ostringstream oss; + caller.call("rx_missingpackets", {}, -1, GET, oss); + if (det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of interfaces") == 1) { + REQUIRE(oss.str() != "rx_missingpackets [0]\n"); + } else { + REQUIRE(oss.str() != "rx_missingpackets [0, 0]\n"); } - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - // 0 missing packets (takes into account that acquisition is - // stopped) - det.startReceiver(); - det.startDetector(); - det.stopDetector(); - det.stopReceiver(); - std::ostringstream oss; - caller.call("rx_missingpackets", {}, -1, GET, oss); - if (det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of interfaces") == 1) { - REQUIRE(oss.str() == "rx_missingpackets [0]\n"); - } else { - REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n"); - } - } - for (int i = 0; i != det.size(); ++i) { - det.setFileWrite(prev_val[i], {i}); - } - det.setNumberOfFrames(prev_frames); - } else { - REQUIRE_THROWS(caller.call("rx_missingpackets", {}, -1, GET)); } + auto det_type = det.getDetectorType().squash(); + if (det_type != defs::CHIPTESTBOARD && + det_type != defs::XILINX_CHIPTESTBOARD) { + // 0 missing packets (takes into account that acquisition is + // stopped) + det.startReceiver(); + det.startDetector(); + det.stopDetector(); + det.stopReceiver(); + std::ostringstream oss; + caller.call("rx_missingpackets", {}, -1, GET, oss); + if (det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of interfaces") == 1) { + REQUIRE(oss.str() == "rx_missingpackets [0]\n"); + } else { + REQUIRE(oss.str() == "rx_missingpackets [0, 0]\n"); + } + } + for (int i = 0; i != det.size(); ++i) { + det.setFileWrite(prev_val[i], {i}); + } + det.setNumberOfFrames(prev_frames); } TEST_CASE("Caller::rx_frameindex", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - caller.call("rx_frameindex", {}, -1, GET); + caller.call("rx_frameindex", {}, -1, GET); - // This is a get only command - REQUIRE_THROWS(caller.call("rx_frameindex", {"2"}, -1, PUT)); - } else { - REQUIRE_THROWS(caller.call("rx_frameindex", {}, -1, GET)); - } + // This is a get only command + REQUIRE_THROWS(caller.call("rx_frameindex", {"2"}, -1, PUT)); } /* Network Configuration (Detector<->Receiver) */ @@ -220,12 +184,7 @@ TEST_CASE("Caller::rx_frameindex", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_printconfig", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - REQUIRE_NOTHROW(caller.call("rx_printconfig", {}, -1, GET)); - } else { - REQUIRE_THROWS(caller.call("rx_printconfig", {}, -1, GET)); - } + REQUIRE_NOTHROW(caller.call("rx_printconfig", {}, -1, GET)); } /* Receiver Config */ @@ -233,37 +192,32 @@ TEST_CASE("Caller::rx_printconfig", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_hostname", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxHostname(); + auto prev_val = det.getRxHostname(); - // Cannot set rx_hostname (will reset parameters in rxr and no shm - // variables to update) - // { - // // disable receiver - // std::ostringstream oss; - // caller.call("rx_hostname", {"none"}, -1, PUT, oss); - // REQUIRE(oss.str() == "rx_hostname [none]\n"); - // } - // { - // std::ostringstream oss; - // caller.call("rx_hostname", {}, -1, GET, oss); - // REQUIRE(oss.str() == "rx_hostname none\n"); - // // receiver should be disabled - // REQUIRE(det.getUseReceiverFlag().tsquash( - // "different values of flag in test") == false); - // } - // put back old values (not necessary when we dont set it to none) - // for (int i = 0; i != det.size(); ++i) { - // det.setRxHostname(prev_val[i], {i}); - // } - { - std::ostringstream oss; - caller.call("rx_hostname", {}, 0, GET, oss); - REQUIRE(oss.str() == "rx_hostname " + prev_val[0] + "\n"); - } - } else { - REQUIRE_THROWS(caller.call("rx_hostname", {"localhost"}, -1, PUT)); + // Cannot set rx_hostname (will reset parameters in rxr and no shm + // variables to update) + // { + // // disable receiver + // std::ostringstream oss; + // caller.call("rx_hostname", {"none"}, -1, PUT, oss); + // REQUIRE(oss.str() == "rx_hostname [none]\n"); + // } + // { + // std::ostringstream oss; + // caller.call("rx_hostname", {}, -1, GET, oss); + // REQUIRE(oss.str() == "rx_hostname none\n"); + // // receiver should be disabled + // REQUIRE(det.getUseReceiverFlag().tsquash( + // "different values of flag in test") == false); + // } + // put back old values (not necessary when we dont set it to none) + // for (int i = 0; i != det.size(); ++i) { + // det.setRxHostname(prev_val[i], {i}); + // } + { + std::ostringstream oss; + caller.call("rx_hostname", {}, 0, GET, oss); + REQUIRE(oss.str() == "rx_hostname " + prev_val[0] + "\n"); } } @@ -309,255 +263,205 @@ TEST_CASE("Caller::rx_tcpport", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_fifodepth", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxFifoDepth(); - { - std::ostringstream oss; - caller.call("rx_fifodepth", {"10"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_fifodepth 10\n"); - } - { - std::ostringstream oss; - caller.call("rx_fifodepth", {"100"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_fifodepth 100\n"); - } - { - std::ostringstream oss; - caller.call("rx_fifodepth", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_fifodepth 100\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxFifoDepth(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_fifodepth", {}, -1, GET)); + auto prev_val = det.getRxFifoDepth(); + { + std::ostringstream oss; + caller.call("rx_fifodepth", {"10"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_fifodepth 10\n"); + } + { + std::ostringstream oss; + caller.call("rx_fifodepth", {"100"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_fifodepth 100\n"); + } + { + std::ostringstream oss; + caller.call("rx_fifodepth", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_fifodepth 100\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxFifoDepth(prev_val[i], {i}); } } TEST_CASE("Caller::rx_silent", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxSilentMode(); - { - std::ostringstream oss; - caller.call("rx_silent", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_silent 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_silent", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_silent 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_silent", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_silent 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxSilentMode(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_silent", {}, -1, GET)); + auto prev_val = det.getRxSilentMode(); + { + std::ostringstream oss; + caller.call("rx_silent", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_silent 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_silent", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_silent 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_silent", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_silent 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxSilentMode(prev_val[i], {i}); } } TEST_CASE("Caller::rx_discardpolicy", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxFrameDiscardPolicy(); - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {"discardempty"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); - } - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); - } - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {"discardpartial"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_discardpolicy discardpartial\n"); - } - { - std::ostringstream oss; - caller.call("rx_discardpolicy", {"nodiscard"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_discardpolicy nodiscard\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxFrameDiscardPolicy(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_discardpolicy", {}, -1, GET)); + auto prev_val = det.getRxFrameDiscardPolicy(); + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {"discardempty"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); + } + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_discardpolicy discardempty\n"); + } + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {"discardpartial"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_discardpolicy discardpartial\n"); + } + { + std::ostringstream oss; + caller.call("rx_discardpolicy", {"nodiscard"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_discardpolicy nodiscard\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxFrameDiscardPolicy(prev_val[i], {i}); } } TEST_CASE("Caller::rx_padding", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPartialFramesPadding(); - { - std::ostringstream oss; - caller.call("rx_padding", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_padding 0\n"); - } - { - std::ostringstream oss; - caller.call("rx_padding", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_padding 0\n"); - } - { - std::ostringstream oss; - caller.call("rx_padding", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_padding 1\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPartialFramesPadding(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_padding", {}, -1, GET)); + auto prev_val = det.getPartialFramesPadding(); + { + std::ostringstream oss; + caller.call("rx_padding", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_padding 0\n"); + } + { + std::ostringstream oss; + caller.call("rx_padding", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_padding 0\n"); + } + { + std::ostringstream oss; + caller.call("rx_padding", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_padding 1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPartialFramesPadding(prev_val[i], {i}); } } TEST_CASE("Caller::rx_udpsocksize", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash( - "Need same udp socket buffer size to test"); - std::string s_new_val = std::to_string(prev_val); - /*std::string s_new_val = std::to_string(prev_val - 1000); - { Need permissions - std::ostringstream oss; - caller.call("rx_udpsocksize", {s_new_val}, -1, PUT, oss); - REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); - }*/ - { - std::ostringstream oss; - caller.call("rx_udpsocksize", {}, -1, GET, oss); - REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); - } - det.setRxUDPSocketBufferSize(prev_val); - } else { - REQUIRE_THROWS(caller.call("rx_udpsocksize", {}, -1, GET)); + int64_t prev_val = det.getRxUDPSocketBufferSize().tsquash( + "Need same udp socket buffer size to test"); + std::string s_new_val = std::to_string(prev_val); + /*std::string s_new_val = std::to_string(prev_val - 1000); + { Need permissions + std::ostringstream oss; + caller.call("rx_udpsocksize", {s_new_val}, -1, PUT, oss); + REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); + }*/ + { + std::ostringstream oss; + caller.call("rx_udpsocksize", {}, -1, GET, oss); + REQUIRE(oss.str() >= "rx_udpsocksize " + s_new_val + "\n"); } + det.setRxUDPSocketBufferSize(prev_val); } TEST_CASE("Caller::rx_realudpsocksize", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - uint64_t val = 0; - { - std::ostringstream oss; - caller.call("rx_udpsocksize", {}, -1, GET, oss); - std::string s = (oss.str()).erase(0, strlen("rx_udpsocksize ")); - val = std::stol(s); - } - { - std::ostringstream oss; - caller.call("rx_realudpsocksize", {}, -1, GET, oss); - std::string s = (oss.str()).erase(0, strlen("rx_realudpsocksize ")); - uint64_t rval = std::stol(s); - REQUIRE(rval >= val * 2); - } - } else { - REQUIRE_THROWS(caller.call("rx_realudpsocksize", {}, -1, GET)); + uint64_t val = 0; + { + std::ostringstream oss; + caller.call("rx_udpsocksize", {}, -1, GET, oss); + std::string s = (oss.str()).erase(0, strlen("rx_udpsocksize ")); + val = std::stol(s); + } + { + std::ostringstream oss; + caller.call("rx_realudpsocksize", {}, -1, GET, oss); + std::string s = (oss.str()).erase(0, strlen("rx_realudpsocksize ")); + uint64_t rval = std::stol(s); + REQUIRE(rval >= val * 2); } } TEST_CASE("Caller::rx_lock", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxLock(); - { - std::ostringstream oss; - caller.call("rx_lock", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_lock 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_lock", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_lock 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_lock", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_lock 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxLock(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_lock", {}, -1, GET)); + auto prev_val = det.getRxLock(); + { + std::ostringstream oss; + caller.call("rx_lock", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_lock 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_lock", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_lock 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_lock", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_lock 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxLock(prev_val[i], {i}); } } TEST_CASE("Caller::rx_lastclient", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - std::ostringstream oss; - REQUIRE_NOTHROW(caller.call("rx_lastclient", {}, -1, GET, oss)); - if (test::my_ip != "undefined") { - REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n"); - } - } else { - REQUIRE_THROWS(caller.call("rx_lastclient", {}, -1, GET)); + std::ostringstream oss; + REQUIRE_NOTHROW(caller.call("rx_lastclient", {}, -1, GET, oss)); + if (test::my_ip != "undefined") { + REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n"); } } TEST_CASE("Caller::rx_threads", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - std::ostringstream oss; - REQUIRE_NOTHROW(caller.call("rx_threads", {}, -1, GET, oss)); - } else { - REQUIRE_THROWS(caller.call("rx_threads", {}, -1, GET)); - } + std::ostringstream oss; + REQUIRE_NOTHROW(caller.call("rx_threads", {}, -1, GET, oss)); } TEST_CASE("Caller::rx_arping", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxArping(); - { - std::ostringstream oss; - caller.call("rx_arping", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_arping 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_arping", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_arping 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_arping", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_arping 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxArping(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_arping", {}, -1, GET)); + auto prev_val = det.getRxArping(); + { + std::ostringstream oss; + caller.call("rx_arping", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_arping 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_arping", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_arping 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_arping", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_arping 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxArping(prev_val[i], {i}); } } @@ -565,65 +469,61 @@ TEST_CASE("Caller::rx_roi", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - if (det_type == defs::CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("rx_roi", {"5", "10"}, -1, PUT)); - } else { - auto prev_val = det.getRxROI(); - defs::xy detsize = det.getDetectorSize(); - - // 1d - if (det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 || - det_type == defs::MYTHEN3) { - { - std::ostringstream oss; - caller.call("rx_roi", {"5", "10"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [5, 10]\n"); - } - { - std::ostringstream oss; - caller.call("rx_roi", {"10", "15"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [10, 15]\n"); - } - REQUIRE_THROWS(caller.call("rx_roi", {"-1", "-1"}, -1, PUT)); - REQUIRE_THROWS( - caller.call("rx_roi", {"10", "15", "25", "30"}, -1, PUT)); - } - // 2d - else { - { - std::ostringstream oss; - caller.call("rx_roi", {"10", "15", "1", "5"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_roi [10, 15, 1, 5]\n"); - } - { - std::ostringstream oss; - caller.call("rx_roi", {"10", "22", "18", "19"}, -1, PUT, - oss); - REQUIRE(oss.str() == "rx_roi [10, 22, 18, 19]\n"); - } - { - std::ostringstream oss; - caller.call("rx_roi", - {"1", std::to_string(detsize.x - 5), "1", - std::to_string(detsize.y - 5)}, - -1, PUT, oss); - REQUIRE(oss.str() == std::string("rx_roi [1, ") + - std::to_string(detsize.x - 5) + - std::string(", 1, ") + - std::to_string(detsize.y - 5) + - std::string("]\n")); - } - REQUIRE_THROWS( - caller.call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT)); - } - - for (int i = 0; i != det.size(); ++i) { - det.setRxROI(prev_val); - } - } + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("rx_roi", {"5", "10"}, -1, PUT)); } else { - REQUIRE_THROWS(caller.call("rx_roi", {}, -1, GET)); + auto prev_val = det.getRxROI(); + defs::xy detsize = det.getDetectorSize(); + + // 1d + if (det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2 || + det_type == defs::MYTHEN3) { + { + std::ostringstream oss; + caller.call("rx_roi", {"5", "10"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [5, 10]\n"); + } + { + std::ostringstream oss; + caller.call("rx_roi", {"10", "15"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [10, 15]\n"); + } + REQUIRE_THROWS(caller.call("rx_roi", {"-1", "-1"}, -1, PUT)); + REQUIRE_THROWS( + caller.call("rx_roi", {"10", "15", "25", "30"}, -1, PUT)); + } + // 2d + else { + { + std::ostringstream oss; + caller.call("rx_roi", {"10", "15", "1", "5"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [10, 15, 1, 5]\n"); + } + { + std::ostringstream oss; + caller.call("rx_roi", {"10", "22", "18", "19"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_roi [10, 22, 18, 19]\n"); + } + { + std::ostringstream oss; + caller.call("rx_roi", + {"1", std::to_string(detsize.x - 5), "1", + std::to_string(detsize.y - 5)}, + -1, PUT, oss); + REQUIRE(oss.str() == std::string("rx_roi [1, ") + + std::to_string(detsize.x - 5) + + std::string(", 1, ") + + std::to_string(detsize.y - 5) + + std::string("]\n")); + } + REQUIRE_THROWS( + caller.call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT)); + } + + for (int i = 0; i != det.size(); ++i) { + det.setRxROI(prev_val); + } } } @@ -631,22 +531,19 @@ TEST_CASE("Caller::rx_clearroi", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - if (det_type == defs::CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("rx_clearroi", {}, -1, PUT)); - } else { - auto prev_val = det.getRxROI(); - { - std::ostringstream oss; - caller.call("rx_clearroi", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_clearroi successful\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxROI(prev_val); - } - } - } else { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_THROWS(caller.call("rx_clearroi", {}, -1, PUT)); + } else { + auto prev_val = det.getRxROI(); + { + std::ostringstream oss; + caller.call("rx_clearroi", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_clearroi successful\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxROI(prev_val); + } } } @@ -655,228 +552,188 @@ TEST_CASE("Caller::rx_clearroi", "[.cmdcall]") { TEST_CASE("Caller::fformat", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFileFormat(); - { - std::ostringstream oss; - caller.call("fformat", {"binary"}, -1, PUT, oss); - REQUIRE(oss.str() == "fformat binary\n"); - } - { - std::ostringstream oss; - caller.call("fformat", {}, -1, GET, oss); - REQUIRE(oss.str() == "fformat binary\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFileFormat(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("fformat", {}, -1, GET)); + auto prev_val = det.getFileFormat(); + { + std::ostringstream oss; + caller.call("fformat", {"binary"}, -1, PUT, oss); + REQUIRE(oss.str() == "fformat binary\n"); + } + { + std::ostringstream oss; + caller.call("fformat", {}, -1, GET, oss); + REQUIRE(oss.str() == "fformat binary\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFileFormat(prev_val[i], {i}); } } TEST_CASE("Caller::fpath", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFilePath(); - { - std::ostringstream oss; - caller.call("fpath", {"/tmp"}, -1, PUT, oss); - REQUIRE(oss.str() == "fpath /tmp\n"); - } - { - std::ostringstream oss; - caller.call("fpath", {}, -1, GET, oss); - REQUIRE(oss.str() == "fpath /tmp\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFilePath(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("fpath", {}, -1, GET)); + auto prev_val = det.getFilePath(); + { + std::ostringstream oss; + caller.call("fpath", {"/tmp"}, -1, PUT, oss); + REQUIRE(oss.str() == "fpath /tmp\n"); + } + { + std::ostringstream oss; + caller.call("fpath", {}, -1, GET, oss); + REQUIRE(oss.str() == "fpath /tmp\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFilePath(prev_val[i], {i}); } } TEST_CASE("Caller::fname", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFileNamePrefix(); - { - std::ostringstream oss; - caller.call("fname", {"somename"}, -1, PUT, oss); - REQUIRE(oss.str() == "fname somename\n"); - } - { - std::ostringstream oss; - caller.call("fname", {}, -1, GET, oss); - REQUIRE(oss.str() == "fname somename\n"); - } - { - std::ostringstream oss; - caller.call("fname", {"run"}, -1, PUT, oss); - REQUIRE(oss.str() == "fname run\n"); - } - REQUIRE_THROWS(caller.call("fname", {"fdf/dfd"}, -1, PUT)); - REQUIRE_THROWS(caller.call("fname", {"fdf dfd"}, -1, PUT)); + auto prev_val = det.getFileNamePrefix(); + { + std::ostringstream oss; + caller.call("fname", {"somename"}, -1, PUT, oss); + REQUIRE(oss.str() == "fname somename\n"); + } + { + std::ostringstream oss; + caller.call("fname", {}, -1, GET, oss); + REQUIRE(oss.str() == "fname somename\n"); + } + { + std::ostringstream oss; + caller.call("fname", {"run"}, -1, PUT, oss); + REQUIRE(oss.str() == "fname run\n"); + } + REQUIRE_THROWS(caller.call("fname", {"fdf/dfd"}, -1, PUT)); + REQUIRE_THROWS(caller.call("fname", {"fdf dfd"}, -1, PUT)); - for (int i = 0; i != det.size(); ++i) { - det.setFileNamePrefix(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("fname", {}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.setFileNamePrefix(prev_val[i], {i}); } } TEST_CASE("Caller::findex", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getAcquisitionIndex(); - { - std::ostringstream oss; - caller.call("findex", {"57"}, -1, PUT, oss); - REQUIRE(oss.str() == "findex 57\n"); - } - { - std::ostringstream oss; - caller.call("findex", {}, -1, GET, oss); - REQUIRE(oss.str() == "findex 57\n"); - } - { - std::ostringstream oss; - caller.call("findex", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "findex 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setAcquisitionIndex(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("findex", {}, -1, GET)); + auto prev_val = det.getAcquisitionIndex(); + { + std::ostringstream oss; + caller.call("findex", {"57"}, -1, PUT, oss); + REQUIRE(oss.str() == "findex 57\n"); + } + { + std::ostringstream oss; + caller.call("findex", {}, -1, GET, oss); + REQUIRE(oss.str() == "findex 57\n"); + } + { + std::ostringstream oss; + caller.call("findex", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "findex 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setAcquisitionIndex(prev_val[i], {i}); } } TEST_CASE("Caller::fwrite", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFileWrite(); - { - std::ostringstream oss; - caller.call("fwrite", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "fwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("fwrite", {}, -1, GET, oss); - REQUIRE(oss.str() == "fwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("fwrite", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "fwrite 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFileWrite(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("fwrite", {}, -1, GET)); + auto prev_val = det.getFileWrite(); + { + std::ostringstream oss; + caller.call("fwrite", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "fwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("fwrite", {}, -1, GET, oss); + REQUIRE(oss.str() == "fwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("fwrite", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "fwrite 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFileWrite(prev_val[i], {i}); } } TEST_CASE("Caller::fmaster", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getMasterFileWrite(); - { - std::ostringstream oss; - caller.call("fmaster", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "fmaster 0\n"); - } - { - std::ostringstream oss; - caller.call("fmaster", {}, -1, GET, oss); - REQUIRE(oss.str() == "fmaster 0\n"); - } - { - std::ostringstream oss; - caller.call("fmaster", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "fmaster 1\n"); - } - det.setMasterFileWrite(prev_val); - } else { - REQUIRE_THROWS(caller.call("fmaster", {}, -1, GET)); + auto prev_val = det.getMasterFileWrite(); + { + std::ostringstream oss; + caller.call("fmaster", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "fmaster 0\n"); } + { + std::ostringstream oss; + caller.call("fmaster", {}, -1, GET, oss); + REQUIRE(oss.str() == "fmaster 0\n"); + } + { + std::ostringstream oss; + caller.call("fmaster", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "fmaster 1\n"); + } + det.setMasterFileWrite(prev_val); } TEST_CASE("Caller::foverwrite", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFileOverWrite(); - { - std::ostringstream oss; - caller.call("foverwrite", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "foverwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("foverwrite", {}, -1, GET, oss); - REQUIRE(oss.str() == "foverwrite 1\n"); - } - { - std::ostringstream oss; - caller.call("foverwrite", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "foverwrite 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFileOverWrite(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("foverwrite", {}, -1, GET)); + auto prev_val = det.getFileOverWrite(); + { + std::ostringstream oss; + caller.call("foverwrite", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "foverwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("foverwrite", {}, -1, GET, oss); + REQUIRE(oss.str() == "foverwrite 1\n"); + } + { + std::ostringstream oss; + caller.call("foverwrite", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "foverwrite 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFileOverWrite(prev_val[i], {i}); } } TEST_CASE("Caller::rx_framesperfile", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getFramesPerFile(); - { - std::ostringstream oss; - caller.call("rx_framesperfile", {"50"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_framesperfile 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_framesperfile", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_framesperfile 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_framesperfile", {"10000"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_framesperfile 10000\n"); - } - { - std::ostringstream oss; - caller.call("rx_framesperfile", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_framesperfile 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setFramesPerFile(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_framesperfile", {}, -1, GET)); + auto prev_val = det.getFramesPerFile(); + { + std::ostringstream oss; + caller.call("rx_framesperfile", {"50"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_framesperfile 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_framesperfile", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_framesperfile 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_framesperfile", {"10000"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_framesperfile 10000\n"); + } + { + std::ostringstream oss; + caller.call("rx_framesperfile", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_framesperfile 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setFramesPerFile(prev_val[i], {i}); } } @@ -885,201 +742,171 @@ TEST_CASE("Caller::rx_framesperfile", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_zmqstream", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxZmqDataStream(); - { - std::ostringstream oss; - caller.call("rx_zmqstream", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstream 1\n"); - REQUIRE(det.getRxZmqDataStream().squash() == true); - } - { - std::ostringstream oss; - caller.call("rx_zmqstream", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqstream 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqstream", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstream 0\n"); - REQUIRE(det.getRxZmqDataStream().squash() == false); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqDataStream(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_zmqstream", {}, -1, GET)); + auto prev_val = det.getRxZmqDataStream(); + { + std::ostringstream oss; + caller.call("rx_zmqstream", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstream 1\n"); + REQUIRE(det.getRxZmqDataStream().squash() == true); + } + { + std::ostringstream oss; + caller.call("rx_zmqstream", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqstream 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqstream", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstream 0\n"); + REQUIRE(det.getRxZmqDataStream().squash() == false); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqDataStream(prev_val[i], {i}); } } TEST_CASE("Caller::rx_zmqfreq", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxZmqFrequency(); - { - std::ostringstream oss; - caller.call("rx_zmqfreq", {"1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqfreq 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqfreq", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqfreq 1\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqfreq", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqfreq 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqFrequency(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_zmqfreq", {}, -1, GET)); + auto prev_val = det.getRxZmqFrequency(); + { + std::ostringstream oss; + caller.call("rx_zmqfreq", {"1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqfreq 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqfreq", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqfreq 1\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqfreq", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqfreq 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqFrequency(prev_val[i], {i}); } } TEST_CASE("Caller::rx_zmqstartfnum", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxZmqStartingFrame(); - { - std::ostringstream oss; - caller.call("rx_zmqstartfnum", {"5"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqstartfnum", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqstartfnum", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqstartfnum 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqStartingFrame(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_zmqstartfnum", {}, -1, GET)); + auto prev_val = det.getRxZmqStartingFrame(); + { + std::ostringstream oss; + caller.call("rx_zmqstartfnum", {"5"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqstartfnum", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqstartfnum 5\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqstartfnum", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqstartfnum 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqStartingFrame(prev_val[i], {i}); } } TEST_CASE("Caller::rx_zmqport", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); + auto prev_val_zmqport = det.getRxZmqPort(); + auto prev_val_numinterfaces = det.getNumberofUDPInterfaces().tsquash( + "inconsistent number of udp interfaces to test"); + + int socketsperdetector = 1; auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val_zmqport = det.getRxZmqPort(); - auto prev_val_numinterfaces = det.getNumberofUDPInterfaces().tsquash( - "inconsistent number of udp interfaces to test"); + if (det_type == defs::EIGER) { + socketsperdetector *= 2; + } else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { + caller.call("numinterfaces", {"2"}, -1, PUT); + socketsperdetector *= 2; + } + uint16_t port = 3500; + caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); + for (int i = 0; i != det.size(); ++i) { + std::ostringstream oss; + caller.call("rx_zmqport", {}, i, GET, oss); + REQUIRE(oss.str() == "rx_zmqport " + + std::to_string(port + i * socketsperdetector) + + '\n'); + } + port = 30001; + caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); + for (int i = 0; i != det.size(); ++i) { + std::ostringstream oss; + caller.call("rx_zmqport", {}, i, GET, oss); + REQUIRE(oss.str() == "rx_zmqport " + + std::to_string(port + i * socketsperdetector) + + '\n'); + } + test_valid_port_caller("rx_zmqport", {}, -1, PUT); + test_valid_port_caller("rx_zmqport", {}, 0, PUT); + // should fail for the second module + if (det.size() > 1) { + REQUIRE_THROWS(caller.call("rx_zmqport", {"65535"}, -1, PUT)); + } - int socketsperdetector = 1; - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::EIGER) { - socketsperdetector *= 2; - } else if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { - caller.call("numinterfaces", {"2"}, -1, PUT); - socketsperdetector *= 2; - } - uint16_t port = 3500; - caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); - for (int i = 0; i != det.size(); ++i) { - std::ostringstream oss; - caller.call("rx_zmqport", {}, i, GET, oss); - REQUIRE(oss.str() == - "rx_zmqport " + - std::to_string(port + i * socketsperdetector) + '\n'); - } - port = 30001; - caller.call("rx_zmqport", {std::to_string(port)}, -1, PUT); - for (int i = 0; i != det.size(); ++i) { - std::ostringstream oss; - caller.call("rx_zmqport", {}, i, GET, oss); - REQUIRE(oss.str() == - "rx_zmqport " + - std::to_string(port + i * socketsperdetector) + '\n'); - } - test_valid_port_caller("rx_zmqport", {}, -1, PUT); - test_valid_port_caller("rx_zmqport", {}, 0, PUT); - // should fail for the second module - if (det.size() > 1) { - REQUIRE_THROWS(caller.call("rx_zmqport", {"65535"}, -1, PUT)); - } - - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqPort(prev_val_zmqport[i], i); - } - if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { - det.setNumberofUDPInterfaces(prev_val_numinterfaces); - } - } else { - REQUIRE_THROWS(caller.call("rx_zmqport", {}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqPort(prev_val_zmqport[i], i); + } + if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH) { + det.setNumberofUDPInterfaces(prev_val_numinterfaces); } } TEST_CASE("Caller::rx_zmqip", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxZmqIP(); - { - std::ostringstream oss; - caller.call("rx_zmqip", {"127.0.0.1"}, 0, PUT, oss); - REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); - std::cout << "ZMQIP: " << det.getRxZmqIP() << '\n'; - } - { - std::ostringstream oss; - caller.call("rx_zmqip", {}, 0, GET, oss); - REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_zmqip", {}, -1, GET)); + auto prev_val = det.getRxZmqIP(); + { + std::ostringstream oss; + caller.call("rx_zmqip", {"127.0.0.1"}, 0, PUT, oss); + REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); + std::cout << "ZMQIP: " << det.getRxZmqIP() << '\n'; + } + { + std::ostringstream oss; + caller.call("rx_zmqip", {}, 0, GET, oss); + REQUIRE(oss.str() == "rx_zmqip 127.0.0.1\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqIP(prev_val[i], {i}); } } TEST_CASE("Caller::rx_zmqhwm", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getRxZmqHwm().tsquash( - "Inconsistent values for rx_zmqhwm to test"); - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {"50"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqhwm 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {}, -1, GET, oss); - REQUIRE(oss.str() == "rx_zmqhwm 50\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqhwm 0\n"); - } - { - std::ostringstream oss; - caller.call("rx_zmqhwm", {"-1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_zmqhwm -1\n"); - } - det.setRxZmqHwm(prev_val); - } else { - REQUIRE_THROWS(caller.call("rx_zmqhwm", {}, -1, GET)); + auto prev_val = + det.getRxZmqHwm().tsquash("Inconsistent values for rx_zmqhwm to test"); + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {"50"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqhwm 50\n"); } + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_zmqhwm 50\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqhwm 0\n"); + } + { + std::ostringstream oss; + caller.call("rx_zmqhwm", {"-1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_zmqhwm -1\n"); + } + det.setRxZmqHwm(prev_val); } /* CTB Specific */ @@ -1088,7 +915,8 @@ TEST_CASE("Caller::rx_dbitlist", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getRxDbitList(); { std::ostringstream oss; @@ -1117,7 +945,8 @@ TEST_CASE("Caller::rx_dbitoffset", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getRxDbitOffset(); { std::ostringstream oss; @@ -1150,68 +979,56 @@ TEST_CASE("Caller::rx_dbitoffset", "[.cmdcall][.rx]") { TEST_CASE("Caller::rx_jsonaddheader", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getAdditionalJsonHeader(); + auto prev_val = det.getAdditionalJsonHeader(); - { - std::ostringstream oss; - caller.call("rx_jsonaddheader", - {"key1", "value1", "key2", "value2"}, -1, PUT, oss); - REQUIRE(oss.str() == - "rx_jsonaddheader {key1: value1, key2: value2}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonaddheader", {}, -1, GET, oss); - REQUIRE(oss.str() == - "rx_jsonaddheader {key1: value1, key2: value2}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonaddheader", {}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonaddheader {}\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setAdditionalJsonHeader(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_jsonaddheader", {}, -1, GET)); + { + std::ostringstream oss; + caller.call("rx_jsonaddheader", {"key1", "value1", "key2", "value2"}, + -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonaddheader", {}, -1, GET, oss); + REQUIRE(oss.str() == "rx_jsonaddheader {key1: value1, key2: value2}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonaddheader", {}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonaddheader {}\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setAdditionalJsonHeader(prev_val[i], {i}); } } TEST_CASE("Caller::rx_jsonpara", "[.cmdcall][.rx]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getAdditionalJsonHeader(); - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1", "value1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonpara {key1: value1}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1", "value2"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonpara {key1: value2}\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1"}, -1, GET, oss); - REQUIRE(oss.str() == "rx_jsonpara value2\n"); - } - { - std::ostringstream oss; - caller.call("rx_jsonpara", {"key1"}, -1, PUT, oss); - REQUIRE(oss.str() == "rx_jsonpara key1 deleted\n"); - } - REQUIRE_THROWS(caller.call("rx_jsonpara", {"key1"}, -1, GET)); - for (int i = 0; i != det.size(); ++i) { - det.setAdditionalJsonHeader(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("rx_jsonpara", {}, -1, GET)); + auto prev_val = det.getAdditionalJsonHeader(); + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1", "value1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonpara {key1: value1}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1", "value2"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonpara {key1: value2}\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1"}, -1, GET, oss); + REQUIRE(oss.str() == "rx_jsonpara value2\n"); + } + { + std::ostringstream oss; + caller.call("rx_jsonpara", {"key1"}, -1, PUT, oss); + REQUIRE(oss.str() == "rx_jsonpara key1 deleted\n"); + } + REQUIRE_THROWS(caller.call("rx_jsonpara", {"key1"}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.setAdditionalJsonHeader(prev_val[i], {i}); } } diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp new file mode 100644 index 000000000..064bf263f --- /dev/null +++ b/slsDetectorSoftware/tests/Caller/test-Caller-xilinx-chiptestboard.cpp @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2021 Contributors to the SLS Detector Package +#include "Caller.h" +#include "catch.hpp" +#include "sls/Detector.h" +#include "sls/sls_detector_defs.h" +#include + +#include "sls/Result.h" +#include "sls/ToString.h" +#include "sls/versionAPI.h" +#include "test-Caller-global.h" +#include "tests/globals.h" + +namespace sls { + +using test::GET; +using test::PUT; + +/* dacs */ + +TEST_CASE("CALLER::configtransceiver", "[.cmdcall]") { + Detector det; + Caller caller(&det); + auto det_type = det.getDetectorType().squash(); + + if (det_type == defs::XILINX_CHIPTESTBOARD) { + REQUIRE_THROWS(caller.call("configtransceiver", {}, -1, GET)); + REQUIRE_NOTHROW(caller.call("configtransceiver", {}, -1, PUT)); + } else { + REQUIRE_THROWS(caller.call("configtransceiver", {}, -1, PUT)); + REQUIRE_THROWS(caller.call("configtransceiver", {}, -1, GET)); + } +} +} // namespace sls diff --git a/slsDetectorSoftware/tests/Caller/test-Caller.cpp b/slsDetectorSoftware/tests/Caller/test-Caller.cpp index 5a94f9a61..fb234912e 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller.cpp @@ -825,82 +825,73 @@ TEST_CASE("CALLER::exptime", "[.cmdcall][.time]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = det.getExptimeForAllGates().tsquash( - "inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); - } - prev_val = t[0]; - } - { - std::ostringstream oss; - caller.call("exptime", {"0.05"}, -1, PUT, oss); - REQUIRE(oss.str() == "exptime 0.05\n"); - } - if (det_type != defs::MYTHEN3) { - std::ostringstream oss; - caller.call("exptime", {}, -1, GET, oss); - REQUIRE(oss.str() == "exptime 50ms\n"); - } - { - std::ostringstream oss; - caller.call("exptime", {"1s"}, -1, PUT, oss); - REQUIRE(oss.str() == "exptime 1s\n"); - } - if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH) { - { - std::ostringstream oss; - caller.call("exptime", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "exptime 0\n"); - } - { - // Get exptime of single module - std::ostringstream oss; - caller.call("exptime", {}, 0, GET, oss); - if (det_type == defs::MYTHEN3) { - REQUIRE(oss.str() == "exptime [0ns, 0ns, 0ns]\n"); - } else { - REQUIRE(oss.str() == "exptime 0ns\n"); - } - } - } - det.setExptime(-1, prev_val); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); } else { - REQUIRE_THROWS(caller.call("exptime", {}, -1, GET)); + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } + { + std::ostringstream oss; + caller.call("exptime", {"0.05"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime 0.05\n"); + } + if (det_type != defs::MYTHEN3) { + std::ostringstream oss; + caller.call("exptime", {}, -1, GET, oss); + REQUIRE(oss.str() == "exptime 50ms\n"); + } + { + std::ostringstream oss; + caller.call("exptime", {"1s"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime 1s\n"); + } + if (det_type != defs::JUNGFRAU && det_type != defs::MOENCH) { + { + std::ostringstream oss; + caller.call("exptime", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "exptime 0\n"); + } + { + // Get exptime of single module + std::ostringstream oss; + caller.call("exptime", {}, 0, GET, oss); + if (det_type == defs::MYTHEN3) { + REQUIRE(oss.str() == "exptime [0ns, 0ns, 0ns]\n"); + } else { + REQUIRE(oss.str() == "exptime 0ns\n"); + } + } + } + det.setExptime(-1, prev_val); } TEST_CASE("CALLER::period", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPeriod(); - { - std::ostringstream oss; - caller.call("period", {"1.25s"}, -1, PUT, oss); - REQUIRE(oss.str() == "period 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("period", {}, -1, GET, oss); - REQUIRE(oss.str() == "period 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("period", {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == "period 0\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPeriod(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("period", {}, -1, GET)); + auto prev_val = det.getPeriod(); + { + std::ostringstream oss; + caller.call("period", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "period 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("period", {}, -1, GET, oss); + REQUIRE(oss.str() == "period 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("period", {"0"}, -1, PUT, oss); + REQUIRE(oss.str() == "period 0\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setPeriod(prev_val[i], {i}); } } @@ -908,36 +899,32 @@ TEST_CASE("CALLER::delay", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - if (det_type == defs::EIGER) { - REQUIRE_THROWS(caller.call("delay", {"1"}, -1, PUT)); - REQUIRE_THROWS(caller.call("delay", {}, -1, GET)); - } else if (det_type == defs::GOTTHARD) { - // extra delays for master (can throw when setting) - REQUIRE_NOTHROW(caller.call("delay", {}, -1, GET)); - } else { - auto prev_val = det.getDelayAfterTrigger(); - { - std::ostringstream oss; - caller.call("delay", {"1.25s"}, -1, PUT, oss); - REQUIRE(oss.str() == "delay 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("delay", {}, -1, GET, oss); - REQUIRE(oss.str() == "delay 1.25s\n"); - } - { - std::ostringstream oss; - caller.call("delay", {"0s"}, -1, PUT, oss); - REQUIRE(oss.str() == "delay 0s\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setDelayAfterTrigger(prev_val[i], {i}); - } - } - } else { + if (det_type == defs::EIGER) { + REQUIRE_THROWS(caller.call("delay", {"1"}, -1, PUT)); REQUIRE_THROWS(caller.call("delay", {}, -1, GET)); + } else if (det_type == defs::GOTTHARD) { + // extra delays for master (can throw when setting) + REQUIRE_NOTHROW(caller.call("delay", {}, -1, GET)); + } else { + auto prev_val = det.getDelayAfterTrigger(); + { + std::ostringstream oss; + caller.call("delay", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "delay 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("delay", {}, -1, GET, oss); + REQUIRE(oss.str() == "delay 1.25s\n"); + } + { + std::ostringstream oss; + caller.call("delay", {"0s"}, -1, PUT, oss); + REQUIRE(oss.str() == "delay 0s\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setDelayAfterTrigger(prev_val[i], {i}); + } } } @@ -969,10 +956,6 @@ TEST_CASE("CALLER::delayl", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); switch (det_type) { case defs::EIGER: - case defs::CHIPTESTBOARD: - case defs::XILINX_CHIPTESTBOARD: - case defs::GOTTHARD2: - case defs::MYTHEN3: REQUIRE_THROWS(caller.call("delayl", {}, -1, GET)); break; default: @@ -987,10 +970,6 @@ TEST_CASE("CALLER::periodl", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); switch (det_type) { case defs::EIGER: - case defs::CHIPTESTBOARD: - case defs::XILINX_CHIPTESTBOARD: - case defs::GOTTHARD2: - case defs::MYTHEN3: REQUIRE_THROWS(caller.call("periodl", {}, -1, GET)); break; default: @@ -1514,7 +1493,8 @@ TEST_CASE("CALLER::powerchip", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || - det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2 || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_val = det.getPowerChip(); { std::ostringstream oss; @@ -1533,6 +1513,9 @@ TEST_CASE("CALLER::powerchip", "[.cmdcall]") { } for (int i = 0; i != det.size(); ++i) { det.setPowerChip(prev_val[i], {i}); + if (det_type == defs::XILINX_CHIPTESTBOARD) { + det.configureTransceiver(); + } } } else { REQUIRE_THROWS(caller.call("powerchip", {}, -1, GET)); @@ -2002,8 +1985,7 @@ TEST_CASE("CALLER::temp_fpga", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::CHIPTESTBOARD && - det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type != defs::CHIPTESTBOARD) { REQUIRE_NOTHROW(caller.call("temp_fpga", {}, -1, GET)); std::ostringstream oss; REQUIRE_NOTHROW(caller.call("temp_fpga", {}, 0, GET, oss)); @@ -2021,7 +2003,8 @@ TEST_CASE("CALLER::daclist", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD) { + if (det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { REQUIRE_NOTHROW(caller.call("daclist", {}, -1, GET)); auto prev = det.getDacNames(); @@ -2054,13 +2037,8 @@ TEST_CASE("CALLER::daclist", "[.cmdcall]") { TEST_CASE("CALLER::dacvalues", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - REQUIRE_NOTHROW(caller.call("dacvalues", {}, -1, GET)); - REQUIRE_THROWS(caller.call("dacvalues", {}, -1, PUT)); - } else { - REQUIRE_THROWS(caller.call("dacvalues", {}, -1, GET)); - } + REQUIRE_NOTHROW(caller.call("dacvalues", {}, -1, GET)); + REQUIRE_THROWS(caller.call("dacvalues", {}, -1, PUT)); } TEST_CASE("CALLER::defaultdac", "[.cmdcall]") { @@ -2246,141 +2224,124 @@ TEST_CASE("CALLER::clearbusy", "[.cmdcall]") { TEST_CASE("CALLER::start", "[.cmdcall]") { Detector det; Caller caller(&det); + // PUT only command + REQUIRE_THROWS(caller.call("start", {}, -1, GET)); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - // PUT only command - REQUIRE_THROWS(caller.call("start", {}, -1, GET)); - auto det_type = det.getDetectorType().squash(); - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = det.getExptimeForAllGates().tsquash( - "inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); - } - prev_val = t[0]; - } - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - auto prev_period = - det.getPeriod().tsquash("inconsistent period in test"); - det.setExptime(-1, std::chrono::microseconds(200)); - det.setPeriod(std::chrono::milliseconds(1)); - det.setNumberOfFrames(2000); - { - std::ostringstream oss; - caller.call("start", {}, -1, PUT, oss); - REQUIRE(oss.str() == "start successful\n"); - } - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(oss.str() == "status running\n"); - } - det.stopDetector(); - det.setExptime(-1, prev_val); - det.setPeriod(prev_period); - det.setNumberOfFrames(prev_frames); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); } else { - REQUIRE_THROWS(caller.call("start", {}, -1, GET)); + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); + det.setExptime(-1, std::chrono::microseconds(200)); + det.setPeriod(std::chrono::milliseconds(1)); + det.setNumberOfFrames(2000); + { + std::ostringstream oss; + caller.call("start", {}, -1, PUT, oss); + REQUIRE(oss.str() == "start successful\n"); + } + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(oss.str() == "status running\n"); + } + det.stopDetector(); + det.setExptime(-1, prev_val); + det.setPeriod(prev_period); + det.setNumberOfFrames(prev_frames); } TEST_CASE("CALLER::stop", "[.cmdcall]") { Detector det; Caller caller(&det); + // PUT only command + REQUIRE_THROWS(caller.call("stop", {}, -1, GET)); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - // PUT only command - REQUIRE_THROWS(caller.call("stop", {}, -1, GET)); - auto det_type = det.getDetectorType().squash(); - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = det.getExptimeForAllGates().tsquash( - "inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); - } - prev_val = t[0]; - } - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - auto prev_period = - det.getPeriod().tsquash("inconsistent period in test"); - det.setExptime(-1, std::chrono::microseconds(200)); - det.setPeriod(std::chrono::milliseconds(1)); - det.setNumberOfFrames(2000); - det.startDetector(); - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(oss.str() == "status running\n"); - } - { - std::ostringstream oss; - caller.call("stop", {}, -1, PUT, oss); - REQUIRE(oss.str() == "stop successful\n"); - } - { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(((oss.str() == "status stopped\n") || - (oss.str() == "status idle\n"))); - } - det.setExptime(-1, prev_val); - det.setPeriod(prev_period); - det.setNumberOfFrames(prev_frames); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); } else { - REQUIRE_THROWS(caller.call("stop", {}, -1, GET)); + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); + det.setExptime(-1, std::chrono::microseconds(200)); + det.setPeriod(std::chrono::milliseconds(1)); + det.setNumberOfFrames(2000); + det.startDetector(); + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(oss.str() == "status running\n"); + } + { + std::ostringstream oss; + caller.call("stop", {}, -1, PUT, oss); + REQUIRE(oss.str() == "stop successful\n"); + } + { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(((oss.str() == "status stopped\n") || + (oss.str() == "status idle\n"))); + } + det.setExptime(-1, prev_val); + det.setPeriod(prev_period); + det.setNumberOfFrames(prev_frames); } TEST_CASE("CALLER::status", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - std::chrono::nanoseconds prev_val; - if (det_type != defs::MYTHEN3) { - prev_val = det.getExptime().tsquash("inconsistent exptime to test"); - } else { - auto t = det.getExptimeForAllGates().tsquash( - "inconsistent exptime to test"); - if (t[0] != t[1] || t[1] != t[2]) { - throw RuntimeError("inconsistent exptime for all gates"); - } - prev_val = t[0]; - } - auto prev_frames = - det.getNumberOfFrames().tsquash("inconsistent #frames in test"); - auto prev_period = - det.getPeriod().tsquash("inconsistent period in test"); - det.setExptime(-1, std::chrono::microseconds(200)); - det.setPeriod(std::chrono::milliseconds(1)); - det.setNumberOfFrames(2000); - det.startDetector(); - if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(oss.str() == "status running\n"); - } - det.stopDetector(); - { - std::ostringstream oss; - caller.call("status", {}, -1, GET, oss); - REQUIRE(((oss.str() == "status stopped\n") || - (oss.str() == "status idle\n"))); - } - det.setExptime(-1, prev_val); - det.setPeriod(prev_period); - det.setNumberOfFrames(prev_frames); + std::chrono::nanoseconds prev_val; + if (det_type != defs::MYTHEN3) { + prev_val = det.getExptime().tsquash("inconsistent exptime to test"); } else { - REQUIRE_THROWS(caller.call("status", {}, -1, GET)); + auto t = + det.getExptimeForAllGates().tsquash("inconsistent exptime to test"); + if (t[0] != t[1] || t[1] != t[2]) { + throw RuntimeError("inconsistent exptime for all gates"); + } + prev_val = t[0]; } + auto prev_frames = + det.getNumberOfFrames().tsquash("inconsistent #frames in test"); + auto prev_period = det.getPeriod().tsquash("inconsistent period in test"); + det.setExptime(-1, std::chrono::microseconds(200)); + det.setPeriod(std::chrono::milliseconds(1)); + det.setNumberOfFrames(2000); + det.startDetector(); + if (det_type != defs::CHIPTESTBOARD && det_type != defs::MOENCH) { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(oss.str() == "status running\n"); + } + det.stopDetector(); + { + std::ostringstream oss; + caller.call("status", {}, -1, GET, oss); + REQUIRE(((oss.str() == "status stopped\n") || + (oss.str() == "status idle\n"))); + } + det.setExptime(-1, prev_val); + det.setPeriod(prev_period); + det.setNumberOfFrames(prev_frames); } TEST_CASE("CALLER::nextframenumber", "[.cmdcall]") { @@ -2388,7 +2349,8 @@ TEST_CASE("CALLER::nextframenumber", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::EIGER || det_type == defs::JUNGFRAU || - det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD) { + det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD || + det_type == defs::XILINX_CHIPTESTBOARD) { auto prev_sfnum = det.getNextFrameNumber(); REQUIRE_THROWS(caller.call("nextframenumber", {"0"}, -1, PUT)); { @@ -2455,131 +2417,127 @@ TEST_CASE("CALLER::scan", "[.cmdcall]") { defs::dacIndex ind = defs::DAC_0; defs::dacIndex notImplementedInd = defs::DAC_0; auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - switch (det_type) { - case defs::CHIPTESTBOARD: - ind = defs::DAC_0; - notImplementedInd = defs::VSVP; - break; - case defs::EIGER: - ind = defs::VCMP_LL; - notImplementedInd = defs::VCASCP_PB; - break; - case defs::JUNGFRAU: - ind = defs::VB_COMP; - notImplementedInd = defs::VSVP; - break; - case defs::MOENCH: - ind = defs::VIN_CM; - notImplementedInd = defs::VSVP; - break; - case defs::GOTTHARD: - ind = defs::VREF_DS; - notImplementedInd = defs::VSVP; - break; - case defs::GOTTHARD2: - ind = defs::VB_COMP_FE; - notImplementedInd = defs::VSVP; - break; - case defs::MYTHEN3: - ind = defs::VTH2; - notImplementedInd = defs::VSVP; - break; - default: - break; + switch (det_type) { + case defs::CHIPTESTBOARD: + case defs::XILINX_CHIPTESTBOARD: + ind = defs::DAC_0; + notImplementedInd = defs::VSVP; + break; + case defs::EIGER: + ind = defs::VCMP_LL; + notImplementedInd = defs::VCASCP_PB; + break; + case defs::JUNGFRAU: + ind = defs::VB_COMP; + notImplementedInd = defs::VSVP; + break; + case defs::MOENCH: + ind = defs::VIN_CM; + notImplementedInd = defs::VSVP; + break; + case defs::GOTTHARD: + ind = defs::VREF_DS; + notImplementedInd = defs::VSVP; + break; + case defs::GOTTHARD2: + ind = defs::VB_COMP_FE; + notImplementedInd = defs::VSVP; + break; + case defs::MYTHEN3: + ind = defs::VTH2; + notImplementedInd = defs::VSVP; + break; + default: + break; + } + + // when taking acquisition + // auto previous = det.getDAC(ind, false); + // auto notImplementedPrevious = det.getDAC(notImplementedInd, false); + + if (det_type == defs::MYTHEN3 && det.size() > 1) { + ; // scan only allowed for single module due to sync + } else { + { + std::ostringstream oss; + caller.call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT, + oss); + CHECK(oss.str() == + "scan [" + ToString(ind) + ", 500, 1500, 500]\n"); } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + + "\nstart 500\nstop 1500\nstep " + "500\nsettleTime 1ms\n]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1, + PUT, oss); + CHECK(oss.str() == + "scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + + "\nstart 500\nstop 1500\nstep " + "500\nsettleTime 2s\n]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {"0"}, -1, PUT, oss); + CHECK(oss.str() == "scan [0]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == "scan [disabled]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT, + oss); + CHECK(oss.str() == + "scan [" + ToString(ind) + ", 1500, 500, -500]\n"); + } + CHECK_THROWS(caller.call( + "scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, + PUT)); + CHECK_THROWS(caller.call("scan", {ToString(ind), "500", "1500", "-500"}, + -1, PUT)); + CHECK_THROWS(caller.call("scan", {ToString(ind), "1500", "500", "500"}, + -1, PUT)); + + if (det_type == defs::MYTHEN3 || defs::EIGER) { + { + std::ostringstream oss; + caller.call("scan", {"trimbits", "0", "63", "16", "2s"}, -1, + PUT, oss); + CHECK(oss.str() == "scan [trimbits, 0, 63, 16, 2s]\n"); + } + { + std::ostringstream oss; + caller.call("scan", {}, -1, GET, oss); + CHECK(oss.str() == + "scan [enabled\ndac trimbits\nstart 0\nstop 48\nstep " + "16\nsettleTime 2s\n]\n"); + } + } + + // Switch off scan for future tests + det.setScan(defs::scanParameters()); + // acquire for each? // when taking acquisition - // auto previous = det.getDAC(ind, false); - // auto notImplementedPrevious = det.getDAC(notImplementedInd, false); - - if (det_type == defs::MYTHEN3 && det.size() > 1) { - ; // scan only allowed for single module due to sync - } else { - { - std::ostringstream oss; - caller.call("scan", {ToString(ind), "500", "1500", "500"}, -1, - PUT, oss); - CHECK(oss.str() == - "scan [" + ToString(ind) + ", 500, 1500, 500]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + - "\nstart 500\nstop 1500\nstep " - "500\nsettleTime 1ms\n]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {ToString(ind), "500", "1500", "500", "2s"}, - -1, PUT, oss); - CHECK(oss.str() == - "scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == "scan [enabled\ndac " + ToString(ind) + - "\nstart 500\nstop 1500\nstep " - "500\nsettleTime 2s\n]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {"0"}, -1, PUT, oss); - CHECK(oss.str() == "scan [0]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == "scan [disabled]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {ToString(ind), "1500", "500", "-500"}, -1, - PUT, oss); - CHECK(oss.str() == - "scan [" + ToString(ind) + ", 1500, 500, -500]\n"); - } - CHECK_THROWS(caller.call( - "scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, - PUT)); - CHECK_THROWS(caller.call( - "scan", {ToString(ind), "500", "1500", "-500"}, -1, PUT)); - CHECK_THROWS(caller.call( - "scan", {ToString(ind), "1500", "500", "500"}, -1, PUT)); - - if (det_type == defs::MYTHEN3 || defs::EIGER) { - { - std::ostringstream oss; - caller.call("scan", {"trimbits", "0", "63", "16", "2s"}, -1, - PUT, oss); - CHECK(oss.str() == "scan [trimbits, 0, 63, 16, 2s]\n"); - } - { - std::ostringstream oss; - caller.call("scan", {}, -1, GET, oss); - CHECK(oss.str() == - "scan [enabled\ndac trimbits\nstart 0\nstop 48\nstep " - "16\nsettleTime 2s\n]\n"); - } - } - - // Switch off scan for future tests - det.setScan(defs::scanParameters()); - // acquire for each? - - // when taking acquisition - // Reset all dacs to previous value - // for (int i = 0; i != det.size(); ++i) { - // det.setDAC(ind, previous[i], false, {i}); - // det.setDAC(notImplementedInd, notImplementedPrevious[i], - // false, {i}); - // } - } - } else { - REQUIRE_THROWS(caller.call( - "scan", {ToString(defs::DAC_0), "500", "1500", "500"}, -1, PUT)); + // Reset all dacs to previous value + // for (int i = 0; i != det.size(); ++i) { + // det.setDAC(ind, previous[i], false, {i}); + // det.setDAC(notImplementedInd, notImplementedPrevious[i], + // false, {i}); + // } } } @@ -2635,20 +2593,15 @@ TEST_CASE("CALLER::numinterfaces", "[.cmdcall]") { TEST_CASE("CALLER::udp_srcip", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getSourceUDPIP(); - REQUIRE_THROWS(caller.call("udp_srcip", {"0.0.0.0"}, -1, PUT)); - { - std::ostringstream oss; - caller.call("udp_srcip", {"129.129.205.12"}, -1, PUT, oss); - REQUIRE(oss.str() == "udp_srcip 129.129.205.12\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setSourceUDPIP(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("udp_srcip", {}, -1, GET)); + auto prev_val = det.getSourceUDPIP(); + REQUIRE_THROWS(caller.call("udp_srcip", {"0.0.0.0"}, -1, PUT)); + { + std::ostringstream oss; + caller.call("udp_srcip", {"129.129.205.12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcip 129.129.205.12\n"); + } + for (int i = 0; i != det.size(); ++i) { + det.setSourceUDPIP(prev_val[i], {i}); } } @@ -2684,14 +2637,9 @@ TEST_CASE("CALLER::udp_numdst", "[.cmdcall]") { TEST_CASE("CALLER::udp_cleardst", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, GET)); - /* dont clear all udp destinations */ - /*REQUIRE_NOTHROW(caller.call("udp_cleardst", {}, -1, PUT));*/ - } else { - REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, PUT)); - } + REQUIRE_THROWS(caller.call("udp_cleardst", {}, -1, GET)); + /* dont clear all udp destinations */ + /*REQUIRE_NOTHROW(caller.call("udp_cleardst", {}, -1, PUT));*/ } TEST_CASE("CALLER::udp_firstdst", "[.cmdcall]") { @@ -2737,23 +2685,17 @@ TEST_CASE("CALLER::udp_dstip", "[.cmdcall]") { TEST_CASE("CALLER::udp_srcmac", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getSourceUDPMAC(); - REQUIRE_THROWS( - caller.call("udp_srcmac", {"00:00:00:00:00:00"}, -1, PUT)); - { - std::ostringstream oss; - caller.call("udp_srcmac", {"00:50:c2:42:34:12"}, -1, PUT, oss); - REQUIRE(oss.str() == "udp_srcmac 00:50:c2:42:34:12\n"); + auto prev_val = det.getSourceUDPMAC(); + REQUIRE_THROWS(caller.call("udp_srcmac", {"00:00:00:00:00:00"}, -1, PUT)); + { + std::ostringstream oss; + caller.call("udp_srcmac", {"00:50:c2:42:34:12"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_srcmac 00:50:c2:42:34:12\n"); + } + for (int i = 0; i != det.size(); ++i) { + if (prev_val[i].str() != "00:00:00:00:00:00") { + det.setSourceUDPMAC(prev_val[i], {i}); } - for (int i = 0; i != det.size(); ++i) { - if (prev_val[i].str() != "00:00:00:00:00:00") { - det.setSourceUDPMAC(prev_val[i], {i}); - } - } - } else { - REQUIRE_THROWS(caller.call("udp_srcmac", {}, -1, GET)); } } @@ -2766,26 +2708,21 @@ TEST_CASE("CALLER::udp_dstmac", "[.cmdcall]") { TEST_CASE("CALLER::udp_dstport", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getDestinationUDPPort(); - { - std::ostringstream oss; - caller.call("udp_dstport", {"50084"}, -1, PUT, oss); - REQUIRE(oss.str() == "udp_dstport 50084\n"); - } - test_valid_port_caller("udp_dstport", {}, -1, PUT); - test_valid_port_caller("udp_dstport", {}, 0, PUT); - // should fail for the second module - if (det.size() > 1) { - REQUIRE_THROWS(caller.call("udp_dstport", {"65535"}, -1, PUT)); - } + auto prev_val = det.getDestinationUDPPort(); + { + std::ostringstream oss; + caller.call("udp_dstport", {"50084"}, -1, PUT, oss); + REQUIRE(oss.str() == "udp_dstport 50084\n"); + } + test_valid_port_caller("udp_dstport", {}, -1, PUT); + test_valid_port_caller("udp_dstport", {}, 0, PUT); + // should fail for the second module + if (det.size() > 1) { + REQUIRE_THROWS(caller.call("udp_dstport", {"65535"}, -1, PUT)); + } - for (int i = 0; i != det.size(); ++i) { - det.setDestinationUDPPort(prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("udp_dstport", {}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.setDestinationUDPPort(prev_val[i], {i}); } } @@ -2892,25 +2829,15 @@ TEST_CASE("CALLER::udp_dstport2", "[.cmdcall]") { TEST_CASE("CALLER::udp_reconfigure", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, GET)); - REQUIRE_NOTHROW(caller.call("udp_reconfigure", {}, -1, PUT)); - } else { - REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, PUT)); - } + REQUIRE_THROWS(caller.call("udp_reconfigure", {}, -1, GET)); + REQUIRE_NOTHROW(caller.call("udp_reconfigure", {}, -1, PUT)); } TEST_CASE("CALLER::udp_validate", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("udp_validate", {}, -1, GET)); - REQUIRE_NOTHROW(caller.call("udp_validate", {}, -1, PUT)); - } else { - REQUIRE_THROWS(caller.call("udp_validate", {}, -1, PUT)); - } + REQUIRE_THROWS(caller.call("udp_validate", {}, -1, GET)); + REQUIRE_NOTHROW(caller.call("udp_validate", {}, -1, PUT)); } TEST_CASE("CALLER::tengiga", "[.cmdcall]") { @@ -3130,19 +3057,16 @@ TEST_CASE("CALLER::zmqport", "[.cmdcall]") { TEST_CASE("CALLER::zmqip", "[.cmdcall]") { Detector det; Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - std::ostringstream oss1, oss2; - auto zmqip = det.getClientZmqIp(); - caller.call("zmqip", {}, 0, GET, oss1); - REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n'); + std::ostringstream oss1, oss2; + auto zmqip = det.getClientZmqIp(); + caller.call("zmqip", {}, 0, GET, oss1); + REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n'); - caller.call("zmqip", {zmqip[0].str()}, 0, PUT, oss2); - REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); + caller.call("zmqip", {zmqip[0].str()}, 0, PUT, oss2); + REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n'); - for (int i = 0; i != det.size(); ++i) { - det.setRxZmqIP(zmqip[i], {i}); - } + for (int i = 0; i != det.size(); ++i) { + det.setRxZmqIP(zmqip[i], {i}); } } @@ -3231,7 +3155,7 @@ TEST_CASE("CALLER::resetfpga", "[.cmdcall]") { Caller caller(&det); auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::CHIPTESTBOARD || - det_type == defs::MOENCH) { + det_type == defs::MOENCH || det_type == defs::XILINX_CHIPTESTBOARD) { // reset will also reset udp info from config file (comment out for // invdividual tests) std::ostringstream oss; caller.call("resetfpga", // {}, -1, PUT, oss); REQUIRE(oss.str() == "resetfpga successful\n"); @@ -3267,7 +3191,8 @@ TEST_CASE("CALLER::rebootcontroller", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 || - det_type == defs::GOTTHARD2 || det_type == defs::GOTTHARD) { + det_type == defs::GOTTHARD2 || det_type == defs::GOTTHARD || + det_type == defs::XILINX_CHIPTESTBOARD) { // TODO: reboot real server? // REQUIRE_NOTHROW(caller.call("rebootcontroller", {}, -1, PUT)); REQUIRE_THROWS(caller.call("rebootcontroller", {}, -1, GET)); @@ -3299,28 +3224,24 @@ TEST_CASE("CALLER::reg", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::XILINX_CHIPTESTBOARD) { - if (det_type != defs::EIGER) { - uint32_t addr = 0x64; - std::string saddr = ToStringHex(addr); - auto prev_val = det.readRegister(addr); - { - std::ostringstream oss1, oss2; - caller.call("reg", {saddr, "0x5"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "reg [" + saddr + ", 0x5]\n"); - caller.call("reg", {saddr}, -1, GET, oss2); - REQUIRE(oss2.str() == "reg 0x5\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.writeRegister(addr, prev_val[i], {i}); - } + if (det_type != defs::EIGER) { + uint32_t addr = 0x64; + std::string saddr = ToStringHex(addr); + auto prev_val = det.readRegister(addr); + { + std::ostringstream oss1, oss2; + caller.call("reg", {saddr, "0x5"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "reg [" + saddr + ", 0x5]\n"); + caller.call("reg", {saddr}, -1, GET, oss2); + REQUIRE(oss2.str() == "reg 0x5\n"); } - // cannot check for eiger virtual server - else { - REQUIRE_NOTHROW(caller.call("reg", {"0x64"}, -1, GET)); + for (int i = 0; i != det.size(); ++i) { + det.writeRegister(addr, prev_val[i], {i}); } - } else { - REQUIRE_THROWS(caller.call("reg", {}, -1, GET)); + } + // cannot check for eiger virtual server + else { + REQUIRE_NOTHROW(caller.call("reg", {"0x64"}, -1, GET)); } } @@ -3346,7 +3267,7 @@ TEST_CASE("CALLER::setbit", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::EIGER && det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type != defs::EIGER) { uint32_t addr = 0x64; std::string saddr = ToStringHex(addr); auto prev_val = det.readRegister(addr); @@ -3368,7 +3289,7 @@ TEST_CASE("CALLER::clearbit", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type != defs::EIGER && det_type != defs::XILINX_CHIPTESTBOARD) { + if (det_type != defs::EIGER) { uint32_t addr = 0x64; std::string saddr = ToStringHex(addr); auto prev_val = det.readRegister(addr); @@ -3390,9 +3311,7 @@ TEST_CASE("CALLER::getbit", "[.cmdcall]") { Detector det; Caller caller(&det); auto det_type = det.getDetectorType().squash(); - if (det_type == defs::XILINX_CHIPTESTBOARD) { - REQUIRE_THROWS(caller.call("getbit", {"0x64", "1"}, -1, GET)); - } else if (det_type != defs::EIGER) { + if (det_type != defs::EIGER) { uint32_t addr = 0x64; std::string saddr = ToStringHex(addr); auto prev_val = det.readRegister(addr); @@ -3418,7 +3337,8 @@ TEST_CASE("CALLER::firmwaretest", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD || det_type == defs::GOTTHARD || - det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2) { + det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD2 || + det_type == defs::XILINX_CHIPTESTBOARD) { std::ostringstream oss; caller.call("firmwaretest", {}, -1, PUT, oss); REQUIRE(oss.str() == "firmwaretest successful\n"); @@ -3580,7 +3500,7 @@ TEST_CASE("CALLER::framecounter", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 || - det_type == defs::GOTTHARD2) { + det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) { auto framecounter = det.getNumberOfFramesFromStart().squash(); std::ostringstream oss; caller.call("framecounter", {}, -1, GET, oss); @@ -3599,7 +3519,7 @@ TEST_CASE("CALLER::runtime", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 || - det_type == defs::GOTTHARD2) { + det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) { std::ostringstream oss; caller.call("runtime", {}, -1, GET, oss); // Get only @@ -3617,7 +3537,7 @@ TEST_CASE("CALLER::frametime", "[.cmdcall]") { auto det_type = det.getDetectorType().squash(); if (det_type == defs::JUNGFRAU || det_type == defs::MOENCH || det_type == defs::CHIPTESTBOARD || det_type == defs::MYTHEN3 || - det_type == defs::GOTTHARD2) { + det_type == defs::GOTTHARD2 || det_type == defs::XILINX_CHIPTESTBOARD) { std::ostringstream oss; caller.call("frametime", {}, -1, GET, oss); // Get only diff --git a/slsReceiverSoftware/src/ClientInterface.cpp b/slsReceiverSoftware/src/ClientInterface.cpp index 24942d6a5..273728f30 100644 --- a/slsReceiverSoftware/src/ClientInterface.cpp +++ b/slsReceiverSoftware/src/ClientInterface.cpp @@ -372,7 +372,7 @@ int ClientInterface::setup_receiver(Interface &socket) { arg.additionalStorageCells); } - if (detType == CHIPTESTBOARD) { + if (detType == CHIPTESTBOARD || detType == XILINX_CHIPTESTBOARD) { impl()->setNumberofAnalogSamples(arg.analogSamples); impl()->setNumberofDigitalSamples(arg.digitalSamples); impl()->setNumberofTransceiverSamples(arg.transceiverSamples); @@ -409,12 +409,14 @@ int ClientInterface::setup_receiver(Interface &socket) { detType == MYTHEN3) { impl()->setTenGigaEnable(arg.tenGiga); } - if (detType == CHIPTESTBOARD) { + if (detType == CHIPTESTBOARD || detType == XILINX_CHIPTESTBOARD) { impl()->setReadoutMode(arg.roMode); - impl()->setADCEnableMask(arg.adcMask); impl()->setTenGigaADCEnableMask(arg.adc10gMask); impl()->setTransceiverEnableMask(arg.transceiverMask); } + if (detType == CHIPTESTBOARD) { + impl()->setADCEnableMask(arg.adcMask); + } if (detType == GOTTHARD) { impl()->setDetectorROI(arg.roi); } @@ -448,6 +450,7 @@ void ClientInterface::setDetectorType(detectorType arg) { case GOTTHARD: case EIGER: case CHIPTESTBOARD: + case XILINX_CHIPTESTBOARD: case JUNGFRAU: case MOENCH: case MYTHEN3: @@ -568,7 +571,7 @@ int ClientInterface::set_burst_mode(Interface &socket) { int ClientInterface::set_num_analog_samples(Interface &socket) { auto value = socket.Receive(); LOG(logDEBUG1) << "Setting num analog samples to " << value; - if (detType != CHIPTESTBOARD) { + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) { functionNotImplemented(); } try { @@ -584,7 +587,7 @@ int ClientInterface::set_num_analog_samples(Interface &socket) { int ClientInterface::set_num_digital_samples(Interface &socket) { auto value = socket.Receive(); LOG(logDEBUG1) << "Setting num digital samples to " << value; - if (detType != CHIPTESTBOARD) { + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) { functionNotImplemented(); } try { @@ -1249,7 +1252,7 @@ int ClientInterface::get_padding_enable(Interface &socket) { int ClientInterface::set_readout_mode(Interface &socket) { auto arg = socket.Receive(); - if (detType != CHIPTESTBOARD) + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) functionNotImplemented(); if (arg >= 0) { @@ -1294,7 +1297,7 @@ int ClientInterface::set_adc_mask(Interface &socket) { int ClientInterface::set_dbit_list(Interface &socket) { StaticVector args; socket.Receive(args); - if (detType != CHIPTESTBOARD) + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) functionNotImplemented(); LOG(logDEBUG1) << "Setting DBIT list"; for (auto &it : args) { @@ -1307,7 +1310,7 @@ int ClientInterface::set_dbit_list(Interface &socket) { } int ClientInterface::get_dbit_list(Interface &socket) { - if (detType != CHIPTESTBOARD) + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) functionNotImplemented(); StaticVector retval; retval = impl()->getDbitList(); @@ -1317,7 +1320,7 @@ int ClientInterface::get_dbit_list(Interface &socket) { int ClientInterface::set_dbit_offset(Interface &socket) { auto arg = socket.Receive(); - if (detType != CHIPTESTBOARD) + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) functionNotImplemented(); if (arg < 0) { throw RuntimeError("Invalid dbit offset: " + std::to_string(arg)); @@ -1329,7 +1332,7 @@ int ClientInterface::set_dbit_offset(Interface &socket) { } int ClientInterface::get_dbit_offset(Interface &socket) { - if (detType != CHIPTESTBOARD) + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) functionNotImplemented(); int retval = impl()->getDbitOffset(); LOG(logDEBUG1) << "Dbit offset retval: " << retval; @@ -1735,7 +1738,7 @@ int ClientInterface::get_receiver_roi(Interface &socket) { int ClientInterface::set_receiver_roi(Interface &socket) { auto arg = socket.Receive(); - if (detType == CHIPTESTBOARD) + if (detType == CHIPTESTBOARD || detType == XILINX_CHIPTESTBOARD) functionNotImplemented(); LOG(logDEBUG1) << "Set Receiver ROI: " << ToString(arg); verifyIdle(socket); @@ -1751,7 +1754,7 @@ int ClientInterface::set_receiver_roi(Interface &socket) { int ClientInterface::set_receiver_roi_metadata(Interface &socket) { auto arg = socket.Receive(); - if (detType == CHIPTESTBOARD) + if (detType == CHIPTESTBOARD || detType == XILINX_CHIPTESTBOARD) functionNotImplemented(); LOG(logDEBUG1) << "Set Receiver ROI Metadata: " << ToString(arg); verifyIdle(socket); @@ -1768,7 +1771,7 @@ int ClientInterface::set_receiver_roi_metadata(Interface &socket) { int ClientInterface::set_num_transceiver_samples(Interface &socket) { auto value = socket.Receive(); LOG(logDEBUG1) << "Setting num transceiver samples to " << value; - if (detType != CHIPTESTBOARD) { + if (detType != CHIPTESTBOARD && detType != XILINX_CHIPTESTBOARD) { functionNotImplemented(); } try { diff --git a/slsReceiverSoftware/src/DataProcessor.cpp b/slsReceiverSoftware/src/DataProcessor.cpp index 000c2ad85..e1ad9fcc1 100644 --- a/slsReceiverSoftware/src/DataProcessor.cpp +++ b/slsReceiverSoftware/src/DataProcessor.cpp @@ -480,6 +480,7 @@ void DataProcessor::PadMissingPackets(sls_receiver_header header, char *data) { memset(data + (pnum * dsize), 0xFF, dsize + 2); break; case CHIPTESTBOARD: + case XILINX_CHIPTESTBOARD: if (pnum == (pperFrame - 1)) memset(data + (pnum * dsize), 0xFF, corrected_dsize); else diff --git a/slsReceiverSoftware/src/GeneralData.h b/slsReceiverSoftware/src/GeneralData.h index 12a46f7a2..408ece595 100644 --- a/slsReceiverSoftware/src/GeneralData.h +++ b/slsReceiverSoftware/src/GeneralData.h @@ -648,4 +648,122 @@ class ChipTestBoardData : public GeneralData { }; }; +class XilinxChipTestBoardData : public GeneralData { + private: + const int NCHAN_DIGITAL = 64; + const int NUM_BYTES_PER_ANALOG_CHANNEL = 2; + const int NUM_BYTES_PER_TRANSCEIVER_CHANNEL = 8; + int nAnalogBytes = 0; + int nDigitalBytes = 0; + int nTransceiverBytes = 0; + + public: + /** Constructor */ + XilinxChipTestBoardData() { + detType = slsDetectorDefs::XILINX_CHIPTESTBOARD; + nPixelsY = 1; // number of samples + headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header); + frameIndexMask = 0xFFFFFF; // 10g + frameIndexOffset = 8; // 10g + packetIndexMask = 0xFF; // 10g + framesPerFile = XILINX_CTB_MAX_FRAMES_PER_FILE; + fifoDepth = 2500; + standardheader = true; + dataSize = 8144; + packetSize = headerSizeinPacket + dataSize; + tengigaEnable = true; + UpdateImageSize(); + }; + + public: + int GetNumberOfAnalogDatabytes() { return nAnalogBytes; }; + + int GetNumberOfDigitalDatabytes() { return nDigitalBytes; }; + + int GetNumberOfTransceiverDatabytes() { return nTransceiverBytes; }; + + void SetNumberOfAnalogSamples(int n) { + nAnalogSamples = n; + UpdateImageSize(); + }; + + void SetNumberOfDigitalSamples(int n) { + nDigitalSamples = n; + UpdateImageSize(); + }; + + void SetNumberOfTransceiverSamples(int n) { + nTransceiverSamples = n; + UpdateImageSize(); + }; + + void SetOneGigaAdcEnableMask(int n) { + adcEnableMaskOneGiga = n; + UpdateImageSize(); + }; + + void SetTenGigaAdcEnableMask(int n) { + adcEnableMaskTenGiga = n; + UpdateImageSize(); + }; + + void SetTransceiverEnableMask(int n) { + transceiverMask = n; + UpdateImageSize(); + }; + + void SetReadoutMode(slsDetectorDefs::readoutMode r) { + readoutType = r; + UpdateImageSize(); + }; + + private: + void UpdateImageSize() { + nAnalogBytes = 0; + nDigitalBytes = 0; + nTransceiverBytes = 0; + int nAnalogChans = 0, nDigitalChans = 0, nTransceiverChans = 0; + + // analog channels (normal, analog/digital readout) + if (readoutType == slsDetectorDefs::ANALOG_ONLY || + readoutType == slsDetectorDefs::ANALOG_AND_DIGITAL) { + uint32_t adcEnableMask = adcEnableMaskTenGiga; + nAnalogChans = __builtin_popcount(adcEnableMask); + + nAnalogBytes = + nAnalogChans * NUM_BYTES_PER_ANALOG_CHANNEL * nAnalogSamples; + LOG(logDEBUG1) << " Number of Analog Channels:" << nAnalogChans + << " Databytes: " << nAnalogBytes; + } + // digital channels + if (readoutType == slsDetectorDefs::DIGITAL_ONLY || + readoutType == slsDetectorDefs::ANALOG_AND_DIGITAL || + readoutType == slsDetectorDefs::DIGITAL_AND_TRANSCEIVER) { + nDigitalChans = NCHAN_DIGITAL; + nDigitalBytes = (sizeof(uint64_t) * nDigitalSamples); + LOG(logDEBUG1) << "Number of Digital Channels:" << nDigitalChans + << " Databytes: " << nDigitalBytes; + } + // transceiver channels + if (readoutType == slsDetectorDefs::TRANSCEIVER_ONLY || + readoutType == slsDetectorDefs::DIGITAL_AND_TRANSCEIVER) { + nTransceiverChans = __builtin_popcount(transceiverMask); + ; + nTransceiverBytes = nTransceiverChans * + NUM_BYTES_PER_TRANSCEIVER_CHANNEL * + nTransceiverSamples; + LOG(logDEBUG1) << "Number of Transceiver Channels:" + << nTransceiverChans + << " Databytes: " << nTransceiverBytes; + } + nPixelsX = nAnalogChans + nDigitalChans + nTransceiverChans; + + imageSize = nAnalogBytes + nDigitalBytes + nTransceiverBytes; + packetsPerFrame = ceil((double)imageSize / (double)dataSize); + + LOG(logDEBUG1) << "Total Number of Channels:" << nPixelsX + << " Databytes: " << imageSize; + }; +}; + } // namespace sls diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index ad3613798..72b39f49b 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -116,6 +116,7 @@ void Implementation::setDetectorType(const detectorType d) { case JUNGFRAU: case MOENCH: case CHIPTESTBOARD: + case XILINX_CHIPTESTBOARD: case MYTHEN3: case GOTTHARD2: LOG(logINFO) << " ***** " << ToString(d) << " Receiver *****"; @@ -145,6 +146,9 @@ void Implementation::setDetectorType(const detectorType d) { case CHIPTESTBOARD: generalData = new ChipTestBoardData(); break; + case XILINX_CHIPTESTBOARD: + generalData = new XilinxChipTestBoardData(); + break; case MYTHEN3: generalData = new Mythen3Data(); break; diff --git a/slsReceiverSoftware/src/Listener.cpp b/slsReceiverSoftware/src/Listener.cpp index f1cb897df..45f05975b 100644 --- a/slsReceiverSoftware/src/Listener.cpp +++ b/slsReceiverSoftware/src/Listener.cpp @@ -471,6 +471,7 @@ void Listener::CopyPacket(char *dst, char *src, uint32_t dataSize, memcpy(dst + dataSize - 2, &src[detHeaderSize], dataSize + 2); break; case CHIPTESTBOARD: + case XILINX_CHIPTESTBOARD: if (pnum == (generalData->packetsPerFrame - 1)) memcpy(dst + (pnum * dataSize), &src[detHeaderSize], correctedDataSize); diff --git a/slsReceiverSoftware/src/MasterAttributes.cpp b/slsReceiverSoftware/src/MasterAttributes.cpp index 9f0c8c9a1..c7a73f4d1 100644 --- a/slsReceiverSoftware/src/MasterAttributes.cpp +++ b/slsReceiverSoftware/src/MasterAttributes.cpp @@ -31,6 +31,9 @@ void MasterAttributes::GetBinaryAttributes( case slsDetectorDefs::CHIPTESTBOARD: GetCtbBinaryAttributes(w); break; + case slsDetectorDefs::XILINX_CHIPTESTBOARD: + GetXilinxCtbBinaryAttributes(w); + break; default: throw RuntimeError("Unknown Detector type to get master attributes"); } @@ -63,6 +66,9 @@ void MasterAttributes::WriteHDF5Attributes(H5::H5File *fd, H5::Group *group) { case slsDetectorDefs::CHIPTESTBOARD: WriteCtbHDF5Attributes(fd, group); break; + case slsDetectorDefs::XILINX_CHIPTESTBOARD: + WriteXilinxCtbHDF5Attributes(fd, group); + break; default: throw RuntimeError("Unknown Detector type to get master attributes"); } @@ -814,4 +820,49 @@ void MasterAttributes::WriteCtbHDF5Attributes(H5::H5File *fd, } #endif +void MasterAttributes::GetXilinxCtbBinaryAttributes( + rapidjson::PrettyWriter *w) { + w->Key("Exptime"); + w->String(ToString(exptime).c_str()); + w->Key("Period"); + w->String(ToString(period).c_str()); + w->Key("ADC Mask"); + w->String(ToStringHex(adcmask).c_str()); + w->Key("Analog Flag"); + w->Uint(analog); + w->Key("Analog Samples"); + w->Uint(analogSamples); + w->Key("Digital Flag"); + w->Uint(digital); + w->Key("Digital Samples"); + w->Uint(digitalSamples); + w->Key("Dbit Offset"); + w->Uint(dbitoffset); + w->Key("Dbit Bitset"); + w->Uint64(dbitlist); + w->Key("Transceiver Mask"); + w->String(ToStringHex(transceiverMask).c_str()); + w->Key("Transceiver Flag"); + w->Uint(transceiver); + w->Key("Transceiver Samples"); + w->Uint(transceiverSamples); +} + +#ifdef HDF5C +void MasterAttributes::WriteXilinxCtbHDF5Attributes(H5::H5File *fd, + H5::Group *group) { + MasterAttributes::WriteHDF5Exptime(fd, group); + MasterAttributes::WriteHDF5Period(fd, group); + MasterAttributes::WriteHDF5AdcMask(fd, group); + MasterAttributes::WriteHDF5AnalogFlag(fd, group); + MasterAttributes::WriteHDF5AnalogSamples(fd, group); + MasterAttributes::WriteHDF5DigitalFlag(fd, group); + MasterAttributes::WriteHDF5DigitalSamples(fd, group); + MasterAttributes::WriteHDF5DbitOffset(fd, group); + MasterAttributes::WriteHDF5DbitList(fd, group); + MasterAttributes::WriteHDF5TransceiverMask(fd, group); + MasterAttributes::WriteHDF5TransceiverFlag(fd, group); + MasterAttributes::WriteHDF5TransceiverSamples(fd, group); +} +#endif } // namespace sls diff --git a/slsReceiverSoftware/src/MasterAttributes.h b/slsReceiverSoftware/src/MasterAttributes.h index c079fcf08..4853446fb 100644 --- a/slsReceiverSoftware/src/MasterAttributes.h +++ b/slsReceiverSoftware/src/MasterAttributes.h @@ -152,6 +152,12 @@ class MasterAttributes { #ifdef HDF5C void WriteCtbHDF5Attributes(H5::H5File *fd, H5::Group *group); #endif + + void GetXilinxCtbBinaryAttributes( + rapidjson::PrettyWriter *w); +#ifdef HDF5C + void WriteXilinxCtbHDF5Attributes(H5::H5File *fd, H5::Group *group); +#endif }; } // namespace sls diff --git a/slsReceiverSoftware/src/receiver_defs.h b/slsReceiverSoftware/src/receiver_defs.h index 2a7a4d1ed..05a10a9cb 100644 --- a/slsReceiverSoftware/src/receiver_defs.h +++ b/slsReceiverSoftware/src/receiver_defs.h @@ -22,14 +22,15 @@ namespace sls { #define HDF5_WRITER_VERSION (6.6) // 1 decimal places #define BINARY_WRITER_VERSION (7.2) // 1 decimal places -#define MAX_FRAMES_PER_FILE 20000 -#define SHORT_MAX_FRAMES_PER_FILE 100000 -#define EIGER_MAX_FRAMES_PER_FILE 10000 -#define JFRAU_MAX_FRAMES_PER_FILE 10000 -#define MOENCH_MAX_FRAMES_PER_FILE 100000 -#define CTB_MAX_FRAMES_PER_FILE 20000 -#define MYTHEN3_MAX_FRAMES_PER_FILE 10000 -#define GOTTHARD2_MAX_FRAMES_PER_FILE 20000 +#define MAX_FRAMES_PER_FILE 20000 +#define SHORT_MAX_FRAMES_PER_FILE 100000 +#define EIGER_MAX_FRAMES_PER_FILE 10000 +#define JFRAU_MAX_FRAMES_PER_FILE 10000 +#define MOENCH_MAX_FRAMES_PER_FILE 100000 +#define CTB_MAX_FRAMES_PER_FILE 20000 +#define XILINX_CTB_MAX_FRAMES_PER_FILE 20000 +#define MYTHEN3_MAX_FRAMES_PER_FILE 10000 +#define GOTTHARD2_MAX_FRAMES_PER_FILE 20000 #define STATISTIC_FRAMENUMBER_INFINITE (20000) diff --git a/slsSupportLib/include/sls/sls_detector_funcs.h b/slsSupportLib/include/sls/sls_detector_funcs.h index b0b6de884..720452bf6 100755 --- a/slsSupportLib/include/sls/sls_detector_funcs.h +++ b/slsSupportLib/include/sls/sls_detector_funcs.h @@ -292,6 +292,7 @@ enum detFuncs { F_SET_COLUMN, F_GET_PEDESTAL_MODE, F_SET_PEDESTAL_MODE, + F_CONFIG_TRANSCEIVER, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 512, /**< detector function should not exceed this @@ -691,6 +692,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_SET_COLUMN: return "F_SET_COLUMN"; case F_GET_PEDESTAL_MODE: return "F_GET_PEDESTAL_MODE"; case F_SET_PEDESTAL_MODE: return "F_SET_PEDESTAL_MODE"; + case F_CONFIG_TRANSCEIVER: return "F_CONFIG_TRANSCEIVER"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; diff --git a/slsSupportLib/include/sls/string_utils.h b/slsSupportLib/include/sls/string_utils.h index eec1a0c08..86a5d0caf 100644 --- a/slsSupportLib/include/sls/string_utils.h +++ b/slsSupportLib/include/sls/string_utils.h @@ -20,6 +20,7 @@ Still this is better than strcpy and a buffer overflow... */ template void strcpy_safe(char (&destination)[array_size], const char *source) { + assert(source != nullptr); assert(array_size > strlen(source)); strncpy(destination, source, array_size - 1); destination[array_size - 1] = '\0'; diff --git a/slsSupportLib/include/sls/versionAPI.h b/slsSupportLib/include/sls/versionAPI.h index 0c01badcc..745078acb 100644 --- a/slsSupportLib/include/sls/versionAPI.h +++ b/slsSupportLib/include/sls/versionAPI.h @@ -4,11 +4,11 @@ #define RELEASE "developer" #define APILIB "developer 0x230224" #define APIRECEIVER "developer 0x230224" -#define APICTB "developer 0x240110" -#define APIGOTTHARD "developer 0x240110" -#define APIGOTTHARD2 "developer 0x240110" -#define APIJUNGFRAU "developer 0x240110" -#define APIMYTHEN3 "developer 0x240110" -#define APIMOENCH "developer 0x240110" -#define APIEIGER "developer 0x240110" -#define APIXILINXCTB "developer 0x240111" +#define APICTB "developer 0x240207" +#define APIGOTTHARD "developer 0x240207" +#define APIGOTTHARD2 "developer 0x240207" +#define APIJUNGFRAU "developer 0x240207" +#define APIMYTHEN3 "developer 0x240207" +#define APIMOENCH "developer 0x240207" +#define APIXILINXCTB "developer 0x240207" +#define APIEIGER "developer 0x240207" diff --git a/tests/scripts/test_simulators.py b/tests/scripts/test_simulators.py index 1d26c96e7..03d435004 100644 --- a/tests/scripts/test_simulators.py +++ b/tests/scripts/test_simulators.py @@ -99,9 +99,7 @@ def loadConfig(name, rx_hostname, settingsdir): Log(Fore.GREEN, 'Loading config') try: d = Detector() - if name == 'xilinx_ctb': - d.hostname = 'localhost' - elif name == 'eiger': + if name == 'eiger': d.hostname = 'localhost:' + str(DEFAULT_TCP_CNTRL_PORTNO) + '+localhost:' + str(HALFMOD2_TCP_CNTRL_PORTNO) #d.udp_dstport = {2: 50003} # will set up for every module @@ -120,8 +118,10 @@ def loadConfig(name, rx_hostname, settingsdir): d.udp_srcip = d.udp_dstip else: d.udp_srcip = 'auto' - if d.type == detectorType.JUNGFRAU or d.type == detectorType.MOENCH: + if d.type == detectorType.JUNGFRAU or d.type == detectorType.MOENCH or d.type == detectorType.XILINX_CHIPTESTBOARD: d.powerchip = 1 + if d.type == detectorType.XILINX_CHIPTESTBOARD: + d.configureTransceiver() except: Log(Fore.RED, 'Could not load config for ' + name) raise @@ -221,7 +221,7 @@ with open(fname, 'w') as fp: startCmdTests(server, fp, file_results) cleanup(server) except: - Log(log.RED, 'Exception caught. Cleaning up.') + Log(Fore.RED, 'Exception caught. Cleaning up.') cleanup(server) sys.stdout = original_stdout sys.stderr = original_stderr