removed unused multi functions

This commit is contained in:
maliakal_d 2019-10-30 18:20:16 +01:00
parent ba3bc9c408
commit ba9a0c7917
15 changed files with 157 additions and 3737 deletions

View File

@ -1167,12 +1167,12 @@ int set_dac(int file_des) {
if (val != -1) {
//changing dac changes settings to undefined
switch(serverDacIndex) {
case VCMP_LL:
case VCMP_LR:
case VCMP_RL:
case VCMP_RR:
case VRF:
case VCP:
case E_VCMP_LL:
case E_VCMP_LR:
case E_VCMP_RL:
case E_VCMP_RR:
case E_VRF:
case E_VCP:
setSettings(UNDEFINED);
FILE_LOG(logERROR, ("Settings has been changed "
"to undefined (changed specific dacs)\n"));
@ -2495,6 +2495,13 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
#endif
// num udp interfaces
#ifdef JUNGFRAUD
i32 = getNumberofUDPInterfaces();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
if (lockStatus == 0) {
lastClientIP = thisClientIP;
}

File diff suppressed because it is too large Load Diff

View File

@ -169,6 +169,9 @@ struct sharedSlsDetector {
/** reciever dbit offset */
int rxDbitOffset;
/** num udp interfaces */
int numUDPInterfaces;
};
class slsDetector : public virtual slsDetectorDefs {
@ -258,13 +261,7 @@ class slsDetector : public virtual slsDetectorDefs {
* Get Detector type from shared memory variable
* @returns detector type from shared memory variable
*/
detectorType getDetectorTypeAsEnum() const;
/**
* Gets string version of detector type from shared memory variable
* @returns string version of detector type from shared memory variable
*/
std::string getDetectorTypeAsString() const;
detectorType getDetectorType() const;
/**
* Gets detector type from detector and set it in receiver
@ -554,8 +551,6 @@ class slsDetector : public virtual slsDetectorDefs {
*/
int setDynamicRange(int n = -1);
int getDynamicRangeFromShm();
/**
* Set/get dacs value
* @param val value (in V)
@ -848,6 +843,9 @@ class slsDetector : public virtual slsDetectorDefs {
*/
void setNumberofUDPInterfaces(int n);
/** Returns the number of udp interfaces from shared memory */
int getNumberofUDPInterfacesFromShm();
/**
* Returns the number of UDP interfaces to stream data from detector
* (Jungfrau only)

View File

@ -33,16 +33,7 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
std::vector<std::string> getAllCommands();
/* /\** */
/* returns the help for the executeLine command */
/* \param os output stream to return the help to */
/* \param action can be PUT_ACTION or GET_ACTION (from text client even READOUT_ACTION for acquisition) */
/* *\/ */
std::string helpLine(int narg, const char * const args[], int action=HELP_ACTION, int detPos = -1);
static std::string helpAcquire(int action);
static std::string helpFree(int action);
static std::string helpSN(int action);
static std::string helpConfiguration(int action);
@ -51,9 +42,6 @@ class slsDetectorCommand : public virtual slsDetectorDefs {
std::string cmdUnknown(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdAcquire(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdFree(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdHelp(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdSN(int narg, const char * const args[], int action, int detPos = -1);
std::string cmdConfiguration(int narg, const char * const args[], int action, int detPos = -1);

View File

@ -67,7 +67,7 @@ Result<int64_t> Detector::getReceiverVersion(Positions pos) const {
}
Result<defs::detectorType> Detector::getDetectorType(Positions pos) const {
return pimpl->Parallel(&slsDetector::getDetectorTypeAsEnum, pos);
return pimpl->Parallel(&slsDetector::getDetectorType, pos);
}
int Detector::size() const { return pimpl->size(); }
@ -173,7 +173,7 @@ Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
auto res = pimpl->Parallel(&slsDetector::setSpeed, pos, defs::CLOCK_DIVIDER, -1,
0);
Result<defs::speedLevel> speedResult(res.size());
for (size_t i = 0; i < res.size(); ++i) {
for (unsigned int i = 0; i < res.size(); ++i) {
speedResult[i] = static_cast<defs::speedLevel>(res[i]);
}
return speedResult;
@ -314,7 +314,7 @@ void Detector::stopReceiver() {
}
void Detector::startDetector() {
if (getDetectorType({}).squash() == defs::EIGER) {
if (getDetectorType().squash() == defs::EIGER) {
pimpl->Parallel(&slsDetector::prepareAcquisition, {});
}
pimpl->Parallel(&slsDetector::startAcquisition, {});
@ -782,7 +782,9 @@ Result<int> Detector::getDynamicRange(Positions pos) const {
return pimpl->Parallel(&slsDetector::setDynamicRange, pos, -1);
}
void Detector::setDynamicRange(int value) { pimpl->setDynamicRange(value); }
void Detector::setDynamicRange(int value) {
pimpl->Parallel(&slsDetector::setDynamicRange, {}, value);
}
Result<ns> Detector::getSubExptime(Positions pos) const {
return pimpl->Parallel(&slsDetector::setTimer, pos,
@ -832,7 +834,7 @@ Result<bool> Detector::getRxAddGapPixels(Positions pos) const {
}
void Detector::setRxAddGapPixels(bool enable) {
pimpl->setGapPixelsEnable(enable, {});
pimpl->setGapPixelsinReceiver(enable);
}
Result<bool> Detector::getParallelMode(Positions pos) const {
@ -968,7 +970,13 @@ Result<bool> Detector::getQuad(Positions pos) const {
return pimpl->Parallel(&slsDetector::getQuad, pos);
}
void Detector::setQuad(const bool value) { pimpl->setQuad(value); }
void Detector::setQuad(const bool value) {
if (value && size() > 1) {
throw RuntimeError("Cannot set Quad type as it is available only for 1 "
"Eiger Quad Half module.");
}
pimpl->Parallel(&slsDetector::setQuad, {}, value);
}
// Jungfrau Specific
@ -1007,8 +1015,8 @@ Result<bool> Detector::getPowerChip(Positions pos) const {
void Detector::setPowerChip(bool on, Positions pos) {
if ((pos.empty() || pos[0] == -1) && on && pimpl->size() > 3) {
for (unsigned int i = 0; i != pimpl->size(); ++i) {
pimpl->powerChip(static_cast<int>(on), i);
for (int i = 0; i != pimpl->size(); ++i) {
pimpl->Parallel(&slsDetector::powerChip, {i}, static_cast<int>(on));
usleep(1000 * 1000);
}
} else {
@ -1618,12 +1626,12 @@ Result<uint64_t> Detector::getRxCurrentFrameIndex(Positions pos) const {
std::vector<int> Detector::getPortNumbers(int start_port) {
int num_sockets_per_detector = 1;
switch (getDetectorType({}).squash()) {
switch (getDetectorType().squash()) {
case defs::EIGER:
num_sockets_per_detector *= 2;
break;
case defs::JUNGFRAU:
if (getNumberofUDPInterfaces({}).squash() == 2) {
if (getNumberofUDPInterfaces().squash() == 2) {
num_sockets_per_detector *= 2;
}
break;

File diff suppressed because it is too large Load Diff

View File

@ -391,6 +391,7 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->rxMasterFileWrite = true;
shm()->rxFileOverWrite = true;
shm()->rxDbitOffset = 0;
shm()->numUDPInterfaces = 1;
// get the detector parameters based on type
detParameters parameters{type};
@ -545,14 +546,10 @@ int slsDetector::setDetectorType(detectorType const type) {
return retval;
}
slsDetectorDefs::detectorType slsDetector::getDetectorTypeAsEnum() const {
slsDetectorDefs::detectorType slsDetector::getDetectorType() const {
return shm()->myDetectorType;
}
std::string slsDetector::getDetectorTypeAsString() const {
return ToString(getDetectorTypeAsEnum());
}
void slsDetector::updateNumberOfChannels() {
if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) {
@ -832,6 +829,12 @@ void slsDetector::updateCachedDetectorVariables() {
updateNumberOfChannels();
}
// num udp interfaces
if (shm()->myDetectorType == JUNGFRAU) {
n += client.Receive(&i32, sizeof(i32));
shm()->numUDPInterfaces = i32;
}
if (n == 0) {
FILE_LOG(logERROR) << "Could not update detector, received 0 bytes";
}
@ -1312,6 +1315,8 @@ int slsDetector::setSpeed(speedVariable sp, int value, int mode) {
int slsDetector::setDynamicRange(int n) {
// TODO! Properly handle fail
int prevDr = shm()->dynamicRange;
int retval = -1;
FILE_LOG(logDEBUG1) << "Setting dynamic range to " << n;
sendToDetector(F_SET_DYNAMIC_RANGE, n, retval);
@ -1325,10 +1330,21 @@ int slsDetector::setDynamicRange(int n) {
sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, n, retval);
FILE_LOG(logDEBUG1) << "Receiver Dynamic range: " << retval;
}
return shm()->dynamicRange;
// changes in dr
int dr = shm()->dynamicRange;
if (prevDr != dr && shm()->myDetectorType == EIGER) {
updateRateCorrection();
// update speed for usability
if (dr == 32) {
FILE_LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32"; setSpeed(CLOCK_DIVIDER, 2);
} else if (dr == 16) {
FILE_LOG(logINFO) << "Setting Clock to Half Speed to cope with Dynamic Range of 16"; setSpeed(CLOCK_DIVIDER, 1);
}
}
int slsDetector::getDynamicRangeFromShm() { return shm()->dynamicRange; }
return shm()->dynamicRange;
}
int slsDetector::setDAC(int val, dacIndex index, int mV) {
int args[]{static_cast<int>(index), mV, val};
@ -1857,17 +1873,24 @@ int slsDetector::getDestinationUDPPort2() {
void slsDetector::setNumberofUDPInterfaces(int n) {
FILE_LOG(logDEBUG1) << "Setting number of udp interfaces to " << n;
sendToDetector(F_SET_NUM_INTERFACES, n, nullptr);
shm()->numUDPInterfaces = n;
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_NUM_INTERFACES, n, nullptr);
}
}
int slsDetector::getNumberofUDPInterfacesFromShm() {
return shm()->numUDPInterfaces;
}
int slsDetector::getNumberofUDPInterfaces() {
int retval = -1;
FILE_LOG(logDEBUG1) << "Getting number of udp interfaces";
sendToDetector(F_GET_NUM_INTERFACES, nullptr, retval);
FILE_LOG(logDEBUG1) << "Number of udp interfaces: " << retval;
return retval;
shm()->numUDPInterfaces = retval;
return shm()->numUDPInterfaces;
}
void slsDetector::selectUDPInterface(int n) {
@ -2380,6 +2403,10 @@ int slsDetector::setAllTrimbits(int val) {
int slsDetector::enableGapPixels(int val) {
if (val >= 0) {
if (shm()->myDetectorType != EIGER) {
throw NotImplementedError(
"Function (enableGapPixels) not implemented for this detector");
}
int fnum = F_ENABLE_GAPPIXELS_IN_RECEIVER;
int retval = -1;
FILE_LOG(logDEBUG1) << "Sending gap pixels enable to receiver: " << val;

View File

@ -1,5 +1,6 @@
#include "slsDetectorCommand.h"
#include "multiSlsDetector.h"
#include "slsDetector.h"
#include "string_utils.h"
#include <cstdlib>
@ -80,16 +81,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/*! \page test
- <b>help</b> Returns a list of possible commands.
*/
descrToFuncMap[i].m_pFuncName = "help";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdHelp;
++i;
/* Acquisition and status commands */
/*! \page acquisition Acquition commands
Commands to control the acquisition
@ -103,28 +94,6 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page config
- \b free Free shared memory on the control PC
*/
descrToFuncMap[i].m_pFuncName = "free";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFree;
++i;
/*! \page config
- <b>checkdetversion</b> Checks the version compatibility with detector server (if hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName = "checkdetversion";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSN;
++i;
/*! \page config
- <b>rx_checkversion</b> Checks the version compatibility with receiver server (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName = "rx_checkversion";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSN;
++i;
/* settings dump/retrieve */
@ -182,40 +151,6 @@ std::vector<std::string> slsDetectorCommand::getAllCommands(){
return commands;
}
std::string slsDetectorCommand::helpLine(int narg, const char * const args[], int action, int detPos) {
std::ostringstream os;
if (action == READOUT_ACTION) {
return helpAcquire(HELP_ACTION);
}
if (narg == 0) {
os << "Command can be: " << std::endl;
for (int i = 0; i < numberOfCommands; ++i) {
os << descrToFuncMap[i].m_pFuncName << "\n";
}
os << std::endl;
return os.str();
}
return executeLine(narg, args, HELP_ACTION, detPos);
}
std::string slsDetectorCommand::cmdHelp(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
std::cout << narg << std::endl;
if (narg >= 1)
return helpLine(narg - 1, args, action, detPos);
else
return helpLine(0, args, action, detPos);
}
std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[], int action, int detPos) {
@ -237,10 +172,11 @@ std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[],
if (myDet->acquire() == FAIL)
return std::string("acquire failed");
if (myDet->getUseReceiverFlag(detPos)) {
char answer[100];
sprintf(answer, "\nAcquired %d", myDet->getFramesCaughtByReceiver(detPos));
return std::string(answer);
if (myDet->Parallel(&slsDetector::getUseReceiverFlag, {}).squash(false)) {
std::ostringstream os;
os << "\nAcquired ";
os << sls::ToString(myDet->Parallel(&slsDetector::getFramesCaughtByReceiver, {}));
return os.str();
}
return std::string();
@ -260,61 +196,6 @@ std::string slsDetectorCommand::helpAcquire(int action) {
std::string slsDetectorCommand::cmdFree(int narg, const char * const args[], int action, int detPos) {
#ifdef VERBOSE
std::cout << std::string("Executing command ") + std::string(args[0]) + std::string(" ( ") + cmd + std::string(" )\n");
#endif
if (action == HELP_ACTION) {
return helpFree(HELP_ACTION);
}
return ("Error: Should have been freed before creating constructor\n");
}
std::string slsDetectorCommand::helpFree(int action) {
return std::string("free \t frees the shared memory\n");
}
std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int action, int detPos) {
if (action == PUT_ACTION)
return std::string("cannot set");
if (action == HELP_ACTION)
return helpSN(action);
if (cmd == "checkdetversion") {
myDet->checkDetectorVersionCompatibility(detPos);
return std::string("compatible");
}
if (cmd == "rx_checkversion") {
myDet->checkReceiverVersionCompatibility(detPos);
return std::string("compatible");
}
return std::string("unknown id mode ") + cmd;
}
std::string slsDetectorCommand::helpSN(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION) {
os << "checkdetversion \n gets the version compatibility with detector server (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl;
os << "rx_checkversion \n gets the version compatibility with receiver server (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl;
}
return os.str();
}
std::string slsDetectorCommand::cmdConfiguration(int narg, const char * const args[], int action, int detPos) {

View File

@ -3076,14 +3076,14 @@ TEST_CASE("zmqport", "[.cmd]") {
}
int port = 3500;
REQUIRE_NOTHROW(multiSlsDetectorClient("zmqport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":zmqport", GET, nullptr, oss));
REQUIRE(oss.str() == "zmqport " + std::to_string(port + i * socketsperdetector) + '\n');
}
port = 1954;
REQUIRE_NOTHROW(multiSlsDetectorClient("zmqport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":zmqport", GET, nullptr, oss));
REQUIRE(oss.str() == "zmqport " + std::to_string(port + i * socketsperdetector) + '\n');
@ -3104,14 +3104,14 @@ TEST_CASE("rx_zmqport", "[.cmd]") {
}
int port = 3500;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_zmqport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_zmqport", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_zmqport " + std::to_string(port + i * socketsperdetector) + '\n');
}
port = 30001;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_zmqport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_zmqport", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_zmqport " + std::to_string(port + i * socketsperdetector) + '\n');
@ -3337,14 +3337,14 @@ TEST_CASE("network", "[.cmd]") {
}
int port = 5500;
REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":udp_dstport", GET, nullptr, oss));
REQUIRE(oss.str() == "udp_dstport " + std::to_string(port + i * socketsperdetector) + '\n');
}
port = 50001;
REQUIRE_NOTHROW(multiSlsDetectorClient("udp_dstport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":udp_dstport", GET, nullptr, oss));
REQUIRE(oss.str() == "udp_dstport " + std::to_string(port + i * socketsperdetector) + '\n');
@ -4235,7 +4235,7 @@ TEST_CASE("rx_tcpport", "[.cmd]") {
multiSlsDetector d;
int port = 3500;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_tcpport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_tcpport", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');
@ -4243,7 +4243,7 @@ TEST_CASE("rx_tcpport", "[.cmd]") {
REQUIRE_THROWS(multiSlsDetectorClient("rx_tcpport 15", PUT));
port = 1954;
REQUIRE_NOTHROW(multiSlsDetectorClient("rx_tcpport " + std::to_string(port), PUT));
for (size_t i = 0; i != d.size(); ++i) {
for (int i = 0; i != d.size(); ++i) {
std::ostringstream oss;
REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + ":rx_tcpport", GET, nullptr, oss));
REQUIRE(oss.str() == "rx_tcpport " + std::to_string(port + i) + '\n');

View File

@ -4,9 +4,9 @@
#define APIRECEIVER 0x190722
#define APIGUI 0x190723
#define APIMOENCH 0x190820
#define APICTB 0x191029
#define APIGOTTHARD 0x191029
#define APIGOTTHARD2 0x191029
#define APIEIGER 0x191029
#define APIMYTHEN3 0x191030
#define APIJUNGFRAU 0x191030
#define APIEIGER 0x191030
#define APIGOTTHARD 0x191030
#define APIGOTTHARD2 0x191030
#define APIMYTHEN3 0x191030
#define APICTB 0x191030