Stoppedflag (#44)

* removed stopped flag from multi and sls shm, since its removed from fixed pattern in sls, slsshmversion api also added to get hostname and type

* clang format
This commit is contained in:
Dhanya Thattil 2019-07-29 11:35:21 +02:00 committed by Erik Fröjdh
parent b524e0c95f
commit 64a8dd2def
4 changed files with 553 additions and 574 deletions

View File

@ -50,10 +50,6 @@ struct sharedMultiSlsDetector {
/** Number of detectors operated at once */ /** Number of detectors operated at once */
int numberOfDetector[2]; int numberOfDetector[2];
/** stopped flag - is set if an acquisition error occurs or the detector
* is stopped manually. Is reset to 0 at the start of the acquisition */
int stoppedFlag;
/** size of the data that are transfered from all detectors */ /** size of the data that are transfered from all detectors */
int dataBytes; int dataBytes;

View File

@ -12,6 +12,7 @@
class ServerInterface; class ServerInterface;
#define SLS_SHMAPIVERSION 0x190726
#define SLS_SHMVERSION 0x190726 #define SLS_SHMVERSION 0x190726
/** /**
@ -24,13 +25,6 @@ struct sharedSlsDetector {
/** shared memory version */ /** shared memory version */
int shmversion; int shmversion;
/** is the port used for control functions */
int controlPort;
/** stopped flag - is set if an acquisition error occurs or the detector
* is stopped manually. Is reset to 0 at the start of the acquisition */
int stoppedFlag;
/** is the hostname (or IP address) of the detector. needs to be set /** is the hostname (or IP address) of the detector. needs to be set
* before starting the communication */ * before starting the communication */
char hostname[MAX_STR_LENGTH]; char hostname[MAX_STR_LENGTH];
@ -47,6 +41,9 @@ struct sharedSlsDetector {
/** Number of detectors in multi list in x dir and y dir */ /** Number of detectors in multi list in x dir and y dir */
int multiSize[2]; int multiSize[2];
/** is the port used for control functions */
int controlPort;
/** is the port used to stop the acquisition */ /** is the port used to stop the acquisition */
int stopPort; int stopPort;
@ -259,6 +256,11 @@ class slsDetector : public virtual slsDetectorDefs{
*/ */
virtual ~slsDetector(); virtual ~slsDetector();
/**
* Returns false if it cannot get fixed pattern from an old version of shm (hostname, type), else true
*/
bool isFixedPatternSharedMemoryCompatible();
/** /**
* Check version compatibility with receiver software * Check version compatibility with receiver software
*/ */

View File

@ -274,10 +274,13 @@ std::string multiSlsDetector::getUserDetails() {
} }
std::ostringstream sstream; std::ostringstream sstream;
sstream << "\nHostname: " << getHostname(); sstream << "\nHostname: ";
for (auto &d : detectors) {
sstream << (d->isFixedPatternSharedMemoryCompatible() ? d->getHostname() : "Unknown") << "+";
}
sstream << "\nType: "; sstream << "\nType: ";
for (auto &d : detectors) { for (auto &d : detectors) {
sstream << d->getDetectorTypeAsString() << "+"; sstream << (d->isFixedPatternSharedMemoryCompatible() ? d->getDetectorTypeAsString() : "Unknown") << "+";
} }
sstream << "\nPID: " << multi_shm()->lastPID sstream << "\nPID: " << multi_shm()->lastPID
@ -310,7 +313,6 @@ void multiSlsDetector::initializeDetectorStructure() {
multi_shm()->numberOfDetectors = 0; multi_shm()->numberOfDetectors = 0;
multi_shm()->numberOfDetector[X] = 0; multi_shm()->numberOfDetector[X] = 0;
multi_shm()->numberOfDetector[Y] = 0; multi_shm()->numberOfDetector[Y] = 0;
multi_shm()->stoppedFlag = 0;
multi_shm()->dataBytes = 0; multi_shm()->dataBytes = 0;
multi_shm()->dataBytesInclGapPixels = 0; multi_shm()->dataBytesInclGapPixels = 0;
multi_shm()->numberOfChannels = 0; multi_shm()->numberOfChannels = 0;
@ -992,14 +994,8 @@ void multiSlsDetector::stopAcquisition(int detPos) {
// thread) // thread)
std::lock_guard<std::mutex> lock(mg); std::lock_guard<std::mutex> lock(mg);
if (detPos >= 0) { if (detPos >= 0) {
// if only 1 detector, set flag to stop current acquisition
if (detectors.size() == 1) {
multi_shm()->stoppedFlag = 1;
}
detectors[detPos]->stopAcquisition(); detectors[detPos]->stopAcquisition();
} else { } else {
multi_shm()->stoppedFlag = 1;
parallelCall(&slsDetector::stopAcquisition); parallelCall(&slsDetector::stopAcquisition);
} }
} }
@ -4188,7 +4184,6 @@ int multiSlsDetector::acquire() {
bool receiver = getUseReceiverFlag(); bool receiver = getUseReceiverFlag();
progressIndex = 0; progressIndex = 0;
multi_shm()->stoppedFlag = 0;
setJoinThreadFlag(false); setJoinThreadFlag(false);
// verify receiver is idle // verify receiver is idle
@ -4202,21 +4197,19 @@ int multiSlsDetector::acquire() {
startProcessingThread(); startProcessingThread();
// resets frames caught in receiver // resets frames caught in receiver
if (receiver && multi_shm()->stoppedFlag == 0) { if (receiver) {
std::lock_guard<std::mutex> lock(mg); std::lock_guard<std::mutex> lock(mg);
resetFramesCaught(); resetFramesCaught();
} }
// start receiver // start receiver
if (receiver && multi_shm()->stoppedFlag == 0) { if (receiver) {
std::lock_guard<std::mutex> lock(mg); std::lock_guard<std::mutex> lock(mg);
startReceiver(); startReceiver();
// let processing thread listen to these packets // let processing thread listen to these packets
if (multi_shm()->stoppedFlag == 0)
sem_post(&sem_newRTAcquisition); sem_post(&sem_newRTAcquisition);
} }
if (multi_shm()->stoppedFlag == 0)
startAndReadAll(); startAndReadAll();
// stop receiver // stop receiver

View File

@ -54,6 +54,10 @@ slsDetector::slsDetector(int multi_id, int det_id, bool verify)
slsDetector::~slsDetector() = default; slsDetector::~slsDetector() = default;
bool slsDetector::isFixedPatternSharedMemoryCompatible() {
return (shm()->shmversion >= SLS_SHMAPIVERSION);
}
void slsDetector::checkDetectorVersionCompatibility() { void slsDetector::checkDetectorVersionCompatibility() {
int fnum = F_CHECK_VERSION; int fnum = F_CHECK_VERSION;
int64_t arg = 0; int64_t arg = 0;
@ -107,8 +111,8 @@ int64_t slsDetector::getId(idMode mode) {
int64_t retval = -1; int64_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting id type " << mode; FILE_LOG(logDEBUG1) << "Getting id type " << mode;
sendToDetector(F_GET_ID, arg, retval); sendToDetector(F_GET_ID, arg, retval);
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1) << "Id (" << mode << "): 0x" << std::hex << retval
<< "Id (" << mode << "): 0x" << std::hex << retval << std::dec; << std::dec;
return retval; return retval;
} }
@ -161,12 +165,12 @@ void slsDetector::sendToDetectorStop(int fnum, const void *args,
template <typename Arg, typename Ret> template <typename Arg, typename Ret>
void slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) { void slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) {
sendToDetectorStop(fnum, &args, sizeof(args), &retval, sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
sizeof(retval));
} }
template <typename Arg> template <typename Arg>
void slsDetector::sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t) { void slsDetector::sendToDetectorStop(int fnum, const Arg &args,
std::nullptr_t) {
sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0); sendToDetectorStop(fnum, &args, sizeof(args), nullptr, 0);
} }
@ -252,7 +256,6 @@ void slsDetector::initSharedMemory(detectorType type, int multi_id,
void slsDetector::initializeDetectorStructure(detectorType type) { void slsDetector::initializeDetectorStructure(detectorType type) {
shm()->shmversion = SLS_SHMVERSION; shm()->shmversion = SLS_SHMVERSION;
shm()->controlPort = DEFAULT_PORTNO; shm()->controlPort = DEFAULT_PORTNO;
shm()->stoppedFlag = 0;
sls::strcpy_safe(shm()->hostname, DEFAULT_HOSTNAME); sls::strcpy_safe(shm()->hostname, DEFAULT_HOSTNAME);
shm()->myDetectorType = type; shm()->myDetectorType = type;
shm()->offset[X] = 0; shm()->offset[X] = 0;
@ -704,8 +707,7 @@ void slsDetector::execCommand(const std::string &cmd) {
FILE_LOG(logDEBUG1) << "Sending command to detector " << arg; FILE_LOG(logDEBUG1) << "Sending command to detector " << arg;
sendToDetector(F_EXEC_COMMAND, arg, retval); sendToDetector(F_EXEC_COMMAND, arg, retval);
if (strlen(retval) != 0u) { if (strlen(retval) != 0u) {
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
<< retval;
} }
} }
@ -713,13 +715,14 @@ void slsDetector::updateCachedDetectorVariables() {
int fnum = F_UPDATE_CLIENT; int fnum = F_UPDATE_CLIENT;
FILE_LOG(logDEBUG1) << "Sending update client to detector server"; FILE_LOG(logDEBUG1) << "Sending update client to detector server";
auto client = DetectorSocket(shm()->hostname, shm()->controlPort); auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
if (client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0) == FORCE_UPDATE) { if (client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0) ==
FORCE_UPDATE) {
int n = 0, i32 = 0; int n = 0, i32 = 0;
int64_t i64 = 0; int64_t i64 = 0;
char lastClientIP[INET_ADDRSTRLEN] = {0}; char lastClientIP[INET_ADDRSTRLEN] = {0};
n += client.Receive(lastClientIP, sizeof(lastClientIP)); n += client.Receive(lastClientIP, sizeof(lastClientIP));
FILE_LOG(logDEBUG1) << "Updating detector last modified by " FILE_LOG(logDEBUG1)
<< lastClientIP; << "Updating detector last modified by " << lastClientIP;
// dr // dr
n += client.Receive(&i32, sizeof(i32)); n += client.Receive(&i32, sizeof(i32));
@ -838,7 +841,6 @@ void slsDetector::updateCachedDetectorVariables() {
} }
} }
std::vector<std::string> slsDetector::getConfigFileCommands() { std::vector<std::string> slsDetector::getConfigFileCommands() {
std::vector<std::string> base{"hostname", "port", "stopport", std::vector<std::string> base{"hostname", "port", "stopport",
"settingsdir", "fpath", "lock", "settingsdir", "fpath", "lock",
@ -1161,7 +1163,6 @@ void slsDetector::prepareAcquisition() {
void slsDetector::startAcquisition() { void slsDetector::startAcquisition() {
FILE_LOG(logDEBUG1) << "Starting Acquisition"; FILE_LOG(logDEBUG1) << "Starting Acquisition";
shm()->stoppedFlag = 0;
sendToDetector(F_START_ACQUISITION); sendToDetector(F_START_ACQUISITION);
FILE_LOG(logDEBUG1) << "Starting Acquisition successful"; FILE_LOG(logDEBUG1) << "Starting Acquisition successful";
} }
@ -1176,7 +1177,6 @@ void slsDetector::stopAcquisition() {
FILE_LOG(logDEBUG1) << "Stopping Acquisition"; FILE_LOG(logDEBUG1) << "Stopping Acquisition";
sendToDetectorStop(F_STOP_ACQUISITION); sendToDetectorStop(F_STOP_ACQUISITION);
FILE_LOG(logDEBUG1) << "Stopping Acquisition successful"; FILE_LOG(logDEBUG1) << "Stopping Acquisition successful";
shm()->stoppedFlag = 1;
// if rxr streaming and acquisition finished, restream dummy stop packet // if rxr streaming and acquisition finished, restream dummy stop packet
if ((shm()->rxUpstream) && (s == IDLE) && (r == IDLE)) { if ((shm()->rxUpstream) && (s == IDLE) && (r == IDLE)) {
restreamStopFromReceiver(); restreamStopFromReceiver();
@ -1185,14 +1185,12 @@ void slsDetector::stopAcquisition() {
void slsDetector::sendSoftwareTrigger() { void slsDetector::sendSoftwareTrigger() {
FILE_LOG(logDEBUG1) << "Sending software trigger"; FILE_LOG(logDEBUG1) << "Sending software trigger";
shm()->stoppedFlag = 0;
sendToDetector(F_SOFTWARE_TRIGGER); sendToDetector(F_SOFTWARE_TRIGGER);
FILE_LOG(logDEBUG1) << "Sending software trigger successful"; FILE_LOG(logDEBUG1) << "Sending software trigger successful";
} }
void slsDetector::startAndReadAll() { void slsDetector::startAndReadAll() {
FILE_LOG(logDEBUG1) << "Starting and reading all frames"; FILE_LOG(logDEBUG1) << "Starting and reading all frames";
shm()->stoppedFlag = 0;
sendToDetector(F_START_AND_READ_ALL); sendToDetector(F_START_AND_READ_ALL);
FILE_LOG(logDEBUG1) << "Detector successfully finished acquisition"; FILE_LOG(logDEBUG1) << "Detector successfully finished acquisition";
} }
@ -1206,8 +1204,7 @@ void slsDetector::startReadOut() {
void slsDetector::readAll() { void slsDetector::readAll() {
FILE_LOG(logDEBUG1) << "Reading all frames"; FILE_LOG(logDEBUG1) << "Reading all frames";
sendToDetector(F_READ_ALL); sendToDetector(F_READ_ALL);
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1) << "Detector successfully finished reading all frames";
<< "Detector successfully finished reading all frames";
} }
void slsDetector::configureMAC() { void slsDetector::configureMAC() {
@ -1304,14 +1301,14 @@ void slsDetector::configureMAC() {
if (shm()->detectorMAC != detector_mac) { if (shm()->detectorMAC != detector_mac) {
shm()->detectorMAC = detector_mac; shm()->detectorMAC = detector_mac;
FILE_LOG(logINFO) FILE_LOG(logINFO) << detId << ": Detector MAC updated to "
<< detId << ": Detector MAC updated to " << getDetectorMAC(); << getDetectorMAC();
} }
if (shm()->detectorIP != detector_ip) { if (shm()->detectorIP != detector_ip) {
shm()->detectorIP = detector_ip; shm()->detectorIP = detector_ip;
FILE_LOG(logINFO) FILE_LOG(logINFO) << detId << ": Detector IP updated to "
<< detId << ": Detector IP updated to " << getDetectorIP(); << getDetectorIP();
} }
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {
updateCachedDetectorVariables(); updateCachedDetectorVariables();
@ -1535,8 +1532,8 @@ uint32_t slsDetector::writeRegister(uint32_t addr, uint32_t val) {
FILE_LOG(logDEBUG1) << "Writing to reg 0x" << std::hex << addr << "data: 0x" FILE_LOG(logDEBUG1) << "Writing to reg 0x" << std::hex << addr << "data: 0x"
<< std::hex << val << std::dec; << std::hex << val << std::dec;
sendToDetector(F_WRITE_REGISTER, args, retval); sendToDetector(F_WRITE_REGISTER, args, retval);
FILE_LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" FILE_LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex
<< std::hex << retval << std::dec; << retval << std::dec;
return retval; return retval;
} }
@ -1544,8 +1541,8 @@ uint32_t slsDetector::readRegister(uint32_t addr) {
uint32_t retval = -1; uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Reading reg 0x" << std::hex << addr << std::dec; FILE_LOG(logDEBUG1) << "Reading reg 0x" << std::hex << addr << std::dec;
sendToDetector(F_READ_REGISTER, addr, retval); sendToDetector(F_READ_REGISTER, addr, retval);
FILE_LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" FILE_LOG(logDEBUG1) << "Reg 0x" << std::hex << addr << ": 0x" << std::hex
<< std::hex << retval << std::dec; << retval << std::dec;
return retval; return retval;
} }
@ -1659,8 +1656,6 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
shm()->useReceiverFlag = true; shm()->useReceiverFlag = true;
checkReceiverVersionCompatibility(); checkReceiverVersionCompatibility();
FILE_LOG(logDEBUG) FILE_LOG(logDEBUG)
<< "detector type:" << "detector type:"
<< (slsDetectorDefs::detectorTypeToString(shm()->myDetectorType)) << (slsDetectorDefs::detectorTypeToString(shm()->myDetectorType))
@ -1681,16 +1676,14 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
shm()->timerValue[CYCLES_NUMBER]) > 1) shm()->timerValue[CYCLES_NUMBER]) > 1)
<< "\nframe period:" << (shm()->timerValue[FRAME_PERIOD]) << "\nframe period:" << (shm()->timerValue[FRAME_PERIOD])
<< "\nframe number:" << (shm()->timerValue[FRAME_NUMBER]) << "\nframe number:" << (shm()->timerValue[FRAME_NUMBER])
<< "\nsub exp time:" << "\nsub exp time:" << (shm()->timerValue[SUBFRAME_ACQUISITION_TIME])
<< (shm()->timerValue[SUBFRAME_ACQUISITION_TIME])
<< "\nsub dead time:" << (shm()->timerValue[SUBFRAME_DEADTIME]) << "\nsub dead time:" << (shm()->timerValue[SUBFRAME_DEADTIME])
<< "\nasamples:" << (shm()->timerValue[ANALOG_SAMPLES]) << "\nasamples:" << (shm()->timerValue[ANALOG_SAMPLES])
<< "\ndsamples:" << (shm()->timerValue[DIGITAL_SAMPLES]) << "\ndsamples:" << (shm()->timerValue[DIGITAL_SAMPLES])
<< "\ndynamic range:" << shm()->dynamicRange << "\ndynamic range:" << shm()->dynamicRange
<< "\nflippeddatax:" << (shm()->flippedData[X]) << "\nflippeddatax:" << (shm()->flippedData[X])
<< "\nactivated: " << shm()->activated << "\nactivated: " << shm()->activated
<< "\nreceiver deactivated padding: " << "\nreceiver deactivated padding: " << shm()->rxPadDeactivatedModules
<< shm()->rxPadDeactivatedModules
<< "\nsilent Mode:" << shm()->rxSilentMode << "\nsilent Mode:" << shm()->rxSilentMode
<< "\n10GbE:" << shm()->tenGigaEnable << "\n10GbE:" << shm()->tenGigaEnable
<< "\nGap pixels: " << shm()->gappixels << "\nGap pixels: " << shm()->gappixels
@ -1728,8 +1721,7 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
case EIGER: case EIGER:
setTimer(SUBFRAME_ACQUISITION_TIME, setTimer(SUBFRAME_ACQUISITION_TIME,
shm()->timerValue[SUBFRAME_ACQUISITION_TIME]); shm()->timerValue[SUBFRAME_ACQUISITION_TIME]);
setTimer(SUBFRAME_DEADTIME, setTimer(SUBFRAME_DEADTIME, shm()->timerValue[SUBFRAME_DEADTIME]);
shm()->timerValue[SUBFRAME_DEADTIME]);
setDynamicRange(shm()->dynamicRange); setDynamicRange(shm()->dynamicRange);
setFlippedData(X, -1); setFlippedData(X, -1);
activate(-1); activate(-1);
@ -1954,7 +1946,7 @@ void slsDetector::setReceiverStreamingIP(std::string sourceIP) {
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
char retvals[MAX_STR_LENGTH]{}; char retvals[MAX_STR_LENGTH]{};
char args[MAX_STR_LENGTH]{}; char args[MAX_STR_LENGTH]{};
sls::strcpy_safe(args, shm()->rxZmqip.str()); //TODO send int sls::strcpy_safe(args, shm()->rxZmqip.str()); // TODO send int
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1)
<< "Sending receiver streaming IP to receiver: " << args; << "Sending receiver streaming IP to receiver: " << args;
sendToReceiver(F_RECEIVER_STREAMING_SRC_IP, args, retvals); sendToReceiver(F_RECEIVER_STREAMING_SRC_IP, args, retvals);
@ -1974,8 +1966,7 @@ int slsDetector::setDetectorNetworkParameter(networkParameter index,
FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to " FILE_LOG(logDEBUG1) << "Setting network parameter index " << index << " to "
<< delay; << delay;
sendToDetector(F_SET_NETWORK_PARAMETER, args, retval); sendToDetector(F_SET_NETWORK_PARAMETER, args, retval);
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1) << "Network Parameter (" << index << "): " << retval;
<< "Network Parameter (" << index << "): " << retval;
return retval; return retval;
} }
@ -2127,7 +2118,8 @@ void slsDetector::setUDPConnection() {
// called before set up // called before set up
if (strcmp(shm()->rxHostname, "none") == 0) { if (strcmp(shm()->rxHostname, "none") == 0) {
throw RuntimeError("Cannot set udp connection. Receiver hostname not set yet."); throw RuntimeError(
"Cannot set udp connection. Receiver hostname not set yet.");
} }
if (shm()->rxUDPIP == 0) { if (shm()->rxUDPIP == 0) {
@ -2220,7 +2212,8 @@ void slsDetector::sendImageToDetector(imageType index, int16_t imageVals[]) {
} }
} }
void slsDetector::writeCounterBlockFile(const std::string &fname, int startACQ) { void slsDetector::writeCounterBlockFile(const std::string &fname,
int startACQ) {
int nChan = getTotalNumberOfChannels(); int nChan = getTotalNumberOfChannels();
int16_t retvals[nChan]; int16_t retvals[nChan];
FILE_LOG(logDEBUG1) << "Reading Counter to " << fname FILE_LOG(logDEBUG1) << "Reading Counter to " << fname
@ -2235,8 +2228,7 @@ void slsDetector::getCounterBlock(int16_t image[], int startACQ) {
int nChan = getTotalNumberOfChannels(); int nChan = getTotalNumberOfChannels();
int args[] = {startACQ, nChan}; int args[] = {startACQ, nChan};
FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ; FILE_LOG(logDEBUG1) << "Reading Counter block with startacq: " << startACQ;
sendToDetector(fnum, args, sizeof(args), image, sendToDetector(fnum, args, sizeof(args), image, nChan * sizeof(int16_t));
nChan * sizeof(int16_t));
} }
void slsDetector::resetCounterBlock(int startACQ) { void slsDetector::resetCounterBlock(int startACQ) {
@ -2311,9 +2303,8 @@ void slsDetector::sendROI(int n, ROI roiLimits[]) {
shm()->roiLimits[i] = retval[i]; shm()->roiLimits[i] = retval[i];
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1)
<< "ROI [" << i << "] (" << shm()->roiLimits[i].xmin << "," << "ROI [" << i << "] (" << shm()->roiLimits[i].xmin << ","
<< shm()->roiLimits[i].xmax << "," << shm()->roiLimits[i].xmax << "," << shm()->roiLimits[i].ymin
<< shm()->roiLimits[i].ymin << "," << "," << shm()->roiLimits[i].ymax << ")";
<< shm()->roiLimits[i].ymax << ")";
} }
} }
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {
@ -2386,11 +2377,10 @@ void slsDetector::setADCEnableMask(uint32_t mask) {
uint32_t slsDetector::getADCEnableMask() { uint32_t slsDetector::getADCEnableMask() {
uint32_t retval = -1; uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting ADC Enable mask"; FILE_LOG(logDEBUG1) << "Getting ADC Enable mask";
sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sendToDetector(F_GET_ADC_ENABLE_MASK, nullptr, 0, &retval, sizeof(retval));
sizeof(retval));
shm()->adcEnableMask = retval; shm()->adcEnableMask = retval;
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1) << "ADC Enable Mask: 0x" << std::hex << retval
<< "ADC Enable Mask: 0x" << std::hex << retval << std::dec; << std::dec;
return shm()->adcEnableMask; return shm()->adcEnableMask;
} }
@ -2404,8 +2394,7 @@ uint32_t slsDetector::getADCInvert() {
uint32_t retval = -1; uint32_t retval = -1;
FILE_LOG(logDEBUG1) << "Getting ADC Invert"; FILE_LOG(logDEBUG1) << "Getting ADC Invert";
sendToDetector(F_GET_ADC_INVERT, nullptr, retval); sendToDetector(F_GET_ADC_INVERT, nullptr, retval);
FILE_LOG(logDEBUG1) FILE_LOG(logDEBUG1) << "ADC Invert: 0x" << std::hex << retval << std::dec;
<< "ADC Invert: 0x" << std::hex << retval << std::dec;
return retval; return retval;
} }
@ -2685,15 +2674,15 @@ void slsDetector::programFPGA(std::vector<char> buffer) {
while (count > 0) { while (count > 0) {
usleep(1 * 1000 * 1000); usleep(1 * 1000 * 1000);
--count; --count;
printf("%d%%\r", static_cast<int>( printf("%d%%\r",
(static_cast<double>(ERASE_TIME - count) / static_cast<int>(
ERASE_TIME) * (static_cast<double>(ERASE_TIME - count) / ERASE_TIME) *
100)); 100));
std::cout << std::flush; std::cout << std::flush;
} }
printf("\n"); printf("\n");
FILE_LOG(logINFO) << "Writing to Flash to detector " << detId FILE_LOG(logINFO) << "Writing to Flash to detector " << detId << " ("
<< " (" << shm()->hostname << ")"; << shm()->hostname << ")";
printf("%d%%\r", 0); printf("%d%%\r", 0);
std::cout << std::flush; std::cout << std::flush;
} }
@ -2724,9 +2713,9 @@ void slsDetector::programFPGA(std::vector<char> buffer) {
currentPointer += unitprogramsize; currentPointer += unitprogramsize;
// print progress // print progress
printf("%d%%\r", static_cast<int>((static_cast<double>( printf("%d%%\r",
totalsize - filesize) / static_cast<int>(
totalsize) * (static_cast<double>(totalsize - filesize) / totalsize) *
100)); 100));
std::cout << std::flush; std::cout << std::flush;
} }
@ -2871,7 +2860,6 @@ void slsDetector::printReceiverConfiguration(TLogLevel level) {
<< "\nReceiver UDP Port2:\t" << getReceiverUDPPort2(); << "\nReceiver UDP Port2:\t" << getReceiverUDPPort2();
} }
bool slsDetector::getUseReceiverFlag() const { return shm()->useReceiverFlag; } bool slsDetector::getUseReceiverFlag() const { return shm()->useReceiverFlag; }
std::string slsDetector::checkReceiverOnline() { std::string slsDetector::checkReceiverOnline() {
@ -3025,8 +3013,8 @@ void slsDetector::updateCachedReceiverVariables() const {
shm()->rxDbitOffset = i32; shm()->rxDbitOffset = i32;
if (n == 0) { if (n == 0) {
throw RuntimeError("Could not update receiver: " + throw RuntimeError(
std::string(shm()->rxHostname) + "Could not update receiver: " + std::string(shm()->rxHostname) +
", received 0 bytes\n"); ", received 0 bytes\n");
} }
} }
@ -3413,8 +3401,8 @@ std::array<int, 3> slsDetector::setPatternLoops(int level, int start, int stop,
<< ", start: " << start << ", stop: " << stop << ", start: " << start << ", stop: " << stop
<< ", nloops: " << n; << ", nloops: " << n;
sendToDetector(F_SET_PATTERN_LOOP, args, retvals); sendToDetector(F_SET_PATTERN_LOOP, args, retvals);
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", " FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", " << retvals[1]
<< retvals[1] << ", " << retvals[2]; << ", " << retvals[2];
return retvals; return retvals;
} }