diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index 101c91cd9..a84ae993d 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -90,6 +90,7 @@ /* Config RW regiseter */ #define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) + #define CONFIG_COUNTER_ENA_OFST (0) #define CONFIG_COUNTER_ENA_MSK (0x00000003 << CONFIG_COUNTER_ENA_OFST) #define CONFIG_COUNTER_ENA_DEFAULT_VAL ((0x0 << CONFIG_COUNTER_ENA_OFST) & CONFIG_COUNTER_ENA_MSK) @@ -110,6 +111,8 @@ #define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST) #define CONTROL_STP_ACQSTN_OFST (1) #define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST) +#define CONTROL_STRT_PATTERN_OFST (2) +#define CONTROL_STRT_PATTERN_MSK (0x00000001 << CONTROL_STRT_PATTERN_OFST) #define CONTROL_CRE_RST_OFST (10) #define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST) #define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10? diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 7c86e19f8..4152325b3 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -716,10 +716,8 @@ int setTrimbits(int *trimbits) { int start = 0, nloop = 0; setPatternLoop(-1, &start, &iaddr, &nloop); } - // load the trimbits -#ifndef VIRTUAL - startStateMachine(); -#endif + // send pattern to the chips + startPattern(); } // copy trimbits locally @@ -1186,6 +1184,11 @@ int *getDetectorPosition() { return detPos; } /* pattern */ +void startPattern() { + LOG(logINFOBLUE, ("Starting Pattern\n")); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_PATTERN_MSK); +} + uint64_t readPatternWord(int addr) { // error (handled in tcp) if (addr < 0 || addr >= MAX_PATTERN_LENGTH) { diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 7fe2f46de..25cfed686 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -449,6 +449,7 @@ int getActivate(int *retval); int setPhase(enum CLKINDEX ind, int val, int degrees); #elif MYTHEN3D +void startPattern(); uint64_t readPatternWord(int addr); uint64_t writePatternWord(int addr, uint64_t word); int setPatternWaitAddress(int level, int addr); diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h index b53b08bfd..dd5cd16d7 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorServer_funcs.h @@ -217,3 +217,4 @@ int set_timing_source(int); int get_num_channels(int); int update_rate_correction(int); int get_receiver_parameters(int); +int start_pattern(int); diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index 04d646c13..8f0596109 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -329,6 +329,7 @@ void function_table() { flist[F_GET_NUM_CHANNELS] = &get_num_channels; flist[F_UPDATE_RATE_CORRECTION] = &update_rate_correction; flist[F_GET_RECEIVER_PARAMETERS] = &get_receiver_parameters; + flist[F_START_PATTERN] = &start_pattern; // check if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { @@ -7009,4 +7010,20 @@ int get_receiver_parameters(int file_des) { LOG(logINFO, ("Sent %d bytes for receiver parameters\n", n)); return OK; +} + +int start_pattern(int file_des) { + ret = OK; + memset(mess, 0, sizeof(mess)); + + LOG(logDEBUG1, ("Starting Pattern\n")); +#ifndef MYTHEN3D + functionNotImplemented(); +#else + // only set + if (Server_VerifyLock() == OK) { + startPattern(); + } +#endif + return Server_SendResult(file_des, INT32, NULL, 0); } \ No newline at end of file diff --git a/slsDetectorSoftware/include/Detector.h b/slsDetectorSoftware/include/Detector.h index 47e4c8a7e..0f8b1fb3e 100644 --- a/slsDetectorSoftware/include/Detector.h +++ b/slsDetectorSoftware/include/Detector.h @@ -1210,6 +1210,9 @@ class Detector { */ void setPatternBitMask(uint64_t mask, Positions pos = {}); + /** [Mythen3] */ + void startPattern(Positions pos = {}); + /************************************************** * * * Moench * diff --git a/slsDetectorSoftware/src/CmdProxy.h b/slsDetectorSoftware/src/CmdProxy.h index cd4b4db3f..cb71f1360 100644 --- a/slsDetectorSoftware/src/CmdProxy.h +++ b/slsDetectorSoftware/src/CmdProxy.h @@ -860,6 +860,7 @@ class CmdProxy { {"patwaittime2", &CmdProxy::PatternWaitTime}, {"patmask", &CmdProxy::patmask}, {"patsetbit", &CmdProxy::patsetbit}, + {"patternstart", &CmdProxy::patternstart}, /* Moench */ {"rx_jsonaddheader", &CmdProxy::AdditionalJsonHeader}, @@ -2031,6 +2032,9 @@ class CmdProxy { "[64 bit mask]\n\t[Ctb][Moench][Mythen3] 64 bit values " "applied to the selected patmask for every pattern."); + EXECUTE_SET_COMMAND(patternstart, startPattern, + "\n\t[Mythen3] Starts Pattern"); + /* Moench */ INTEGER_COMMAND(framemode, getFrameMode, setFrameMode, diff --git a/slsDetectorSoftware/src/Detector.cpp b/slsDetectorSoftware/src/Detector.cpp index 3422cde97..d3648b0d2 100644 --- a/slsDetectorSoftware/src/Detector.cpp +++ b/slsDetectorSoftware/src/Detector.cpp @@ -1574,6 +1574,10 @@ void Detector::setPatternBitMask(uint64_t mask, Positions pos) { pimpl->Parallel(&Module::setPatternBitMask, pos, mask); } +void Detector::startPattern(Positions pos) { + pimpl->Parallel(&Module::startPattern, pos); +} + // Moench Result> diff --git a/slsDetectorSoftware/src/Module.cpp b/slsDetectorSoftware/src/Module.cpp index 780e9c8b4..43f74bd50 100644 --- a/slsDetectorSoftware/src/Module.cpp +++ b/slsDetectorSoftware/src/Module.cpp @@ -4,8 +4,8 @@ #include "ToString.h" #include "file_utils.h" #include "network_utils.h" -#include "sls_detector_funcs.h" #include "sls_detector_exceptions.h" +#include "sls_detector_funcs.h" #include "string_utils.h" #include "versionAPI.h" @@ -139,16 +139,14 @@ void Module::sendToDetector(int fnum, std::nullptr_t, Ret &retval) { void Module::sendToDetector(int fnum) { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << "]"; sendToDetector(fnum, nullptr, 0, nullptr, 0); } template Ret Module::sendToDetector(int fnum) { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]"; Ret retval{}; @@ -160,8 +158,7 @@ template Ret Module::sendToDetector(int fnum) { template Ret Module::sendToDetector(int fnum, const Arg &args) { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]"; Ret retval{}; @@ -216,8 +213,7 @@ void Module::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) const { void Module::sendToDetectorStop(int fnum) { LOG(logDEBUG1) << "Sending to detector stop: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << "]"; sendToDetectorStop(fnum, nullptr, 0, nullptr, 0); } @@ -237,8 +233,7 @@ void Module::sendToReceiver(int fnum, const void *args, size_t args_size, if (!shm()->useReceiverFlag) { std::ostringstream oss; oss << "Set rx_hostname first to use receiver parameters, "; - oss << getFunctionNameFromEnum( - static_cast(fnum)); + oss << getFunctionNameFromEnum(static_cast(fnum)); throw RuntimeError(oss.str()); } auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort); @@ -278,8 +273,7 @@ void Module::sendToReceiver(int fnum, std::nullptr_t, Ret &retval) const { template Ret Module::sendToReceiver(int fnum) { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]"; Ret retval{}; @@ -290,8 +284,7 @@ template Ret Module::sendToReceiver(int fnum) { template Ret Module::sendToReceiver(int fnum) const { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << ", nullptr, 0, " << typeid(Ret).name() << ", " << sizeof(Ret) << "]"; Ret retval{}; @@ -303,8 +296,7 @@ template Ret Module::sendToReceiver(int fnum) const { template Ret Module::sendToReceiver(int fnum, const Arg &args) { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]"; Ret retval{}; @@ -316,8 +308,7 @@ Ret Module::sendToReceiver(int fnum, const Arg &args) { template Ret Module::sendToReceiver(int fnum, const Arg &args) const { LOG(logDEBUG1) << "Sending: [" - << getFunctionNameFromEnum( - static_cast(fnum)) + << getFunctionNameFromEnum(static_cast(fnum)) << ", " << args << ", " << sizeof(args) << ", " << typeid(Ret).name() << ", " << sizeof(Ret) << "]"; Ret retval{}; @@ -2877,6 +2868,8 @@ uint64_t Module::getPatternBitMask() { return sendToDetector(F_GET_PATTERN_BIT_MASK); } +void Module::startPattern() { sendToDetector(F_START_PATTERN); } + int Module::setLEDEnable(int enable) { return sendToDetector(F_LED, enable); } diff --git a/slsDetectorSoftware/src/Module.h b/slsDetectorSoftware/src/Module.h index b8cccfd93..bdd81d651 100644 --- a/slsDetectorSoftware/src/Module.h +++ b/slsDetectorSoftware/src/Module.h @@ -1500,6 +1500,9 @@ class Module : public virtual slsDetectorDefs { */ uint64_t getPatternBitMask(); + /** [Mythen3] */ + void startPattern(); + /** * Set LED Enable (Moench, CTB only) * @param enable 1 to switch on, 0 to switch off, -1 gets diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h index c8b2dede7..4df1aab5c 100755 --- a/slsSupportLib/include/sls_detector_funcs.h +++ b/slsSupportLib/include/sls_detector_funcs.h @@ -197,6 +197,7 @@ enum detFuncs { F_GET_NUM_CHANNELS, F_UPDATE_RATE_CORRECTION, F_GET_RECEIVER_PARAMETERS, + F_START_PATTERN, NUM_DET_FUNCTIONS, RECEIVER_ENUM_START = 256, /**< detector function should not exceed this @@ -490,6 +491,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS"; case F_UPDATE_RATE_CORRECTION: return "F_UPDATE_RATE_CORRECTION"; case F_GET_RECEIVER_PARAMETERS: return "F_GET_RECEIVER_PARAMETERS"; + case F_START_PATTERN: return "F_START_PATTERN"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; @@ -590,4 +592,3 @@ const char* getFunctionNameFromEnum(enum detFuncs func) { // clang-format on } -