mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 18:17:59 +02:00
timer split up
This commit is contained in:
@ -112,61 +112,60 @@ void Detector::registerDataCallback(void (*func)(detectorData *, uint64_t,
|
||||
|
||||
// Acquisition Parameters
|
||||
|
||||
Result<int64_t> Detector::getNumberOfFrames() const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, {}, defs::FRAME_NUMBER, -1);
|
||||
Result<int64_t> Detector::getNumberOfFrames(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfFrames, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfFrames(int64_t value) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, {}, defs::FRAME_NUMBER, value);
|
||||
pimpl->Parallel(&slsDetector::setNumberOfFrames, {}, value);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfTriggers() const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, {}, defs::TRIGGER_NUMBER, -1);
|
||||
Result<int64_t> Detector::getNumberOfTriggers(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfTriggers, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfTriggers(int64_t value) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, {}, defs::TRIGGER_NUMBER, value);
|
||||
pimpl->Parallel(&slsDetector::setNumberOfTriggers, {}, value);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getExptime(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::ACQUISITION_TIME,
|
||||
-1);
|
||||
return pimpl->Parallel(&slsDetector::getExptime, pos);
|
||||
}
|
||||
|
||||
void Detector::setExptime(ns t, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::ACQUISITION_TIME,
|
||||
t.count());
|
||||
pimpl->Parallel(&slsDetector::setExptime, pos, t.count());
|
||||
}
|
||||
|
||||
Result<ns> Detector::getPeriod(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::FRAME_PERIOD, -1);
|
||||
return pimpl->Parallel(&slsDetector::getPeriod, pos);
|
||||
}
|
||||
|
||||
void Detector::setPeriod(ns t, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::FRAME_PERIOD, t.count());
|
||||
pimpl->Parallel(&slsDetector::setPeriod, pos, t.count());
|
||||
}
|
||||
|
||||
Result<ns> Detector::getDelayAfterTrigger(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::DELAY_AFTER_TRIGGER, -1);
|
||||
return pimpl->Parallel(&slsDetector::getDelayAfterTrigger, pos);
|
||||
}
|
||||
|
||||
void Detector::setDelayAfterTrigger(ns value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::DELAY_AFTER_TRIGGER,
|
||||
value.count());
|
||||
pimpl->Parallel(&slsDetector::setDelayAfterTrigger, pos, value.count());
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfFramesLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::FRAME_NUMBER);
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfFramesLeft, pos);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfTriggersLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::TRIGGER_NUMBER);
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfTriggersLeft, pos);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getDelayAfterTriggerLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos,
|
||||
defs::DELAY_AFTER_TRIGGER);
|
||||
return pimpl->Parallel(&slsDetector::getDelayAfterTriggerLeft, pos);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getPeriodLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getPeriodLeft, pos);
|
||||
}
|
||||
|
||||
Result<defs::speedLevel> Detector::getSpeed(Positions pos) const {
|
||||
@ -332,7 +331,7 @@ Result<defs::runStatus> Detector::getReceiverStatus(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getReceiverStatus, pos);
|
||||
}
|
||||
|
||||
Result<int> Detector::getFramesCaught(Positions pos) const {
|
||||
Result<int64_t> Detector::getFramesCaught(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getFramesCaughtByReceiver, pos);
|
||||
}
|
||||
|
||||
@ -787,23 +786,19 @@ void Detector::setDynamicRange(int value) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getSubExptime(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::SUBFRAME_ACQUISITION_TIME, -1);
|
||||
return pimpl->Parallel(&slsDetector::getSubExptime, pos);
|
||||
}
|
||||
|
||||
void Detector::setSubExptime(ns t, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::SUBFRAME_ACQUISITION_TIME, t.count());
|
||||
pimpl->Parallel(&slsDetector::setSubExptime, pos, t.count());
|
||||
}
|
||||
|
||||
Result<ns> Detector::getSubDeadTime(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::SUBFRAME_DEADTIME,
|
||||
-1);
|
||||
return pimpl->Parallel(&slsDetector::getSubDeadTime, pos);
|
||||
}
|
||||
|
||||
void Detector::setSubDeadTime(ns value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::SUBFRAME_DEADTIME,
|
||||
value.count());
|
||||
pimpl->Parallel(&slsDetector::setSubDeadTime, pos, value.count());
|
||||
}
|
||||
|
||||
Result<int> Detector::getThresholdEnergy(Positions pos) const {
|
||||
@ -915,13 +910,11 @@ void Detector::setInterruptSubframe(const bool enable, Positions pos) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getMeasuredPeriod(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos,
|
||||
defs::MEASURED_PERIOD);
|
||||
return pimpl->Parallel(&slsDetector::getMeasuredPeriod, pos);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getMeasuredSubFramePeriod(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos,
|
||||
defs::MEASURED_SUBPERIOD);
|
||||
return pimpl->Parallel(&slsDetector::getMeasuredSubFramePeriod, pos);
|
||||
}
|
||||
|
||||
Result<bool> Detector::getActive(Positions pos) const {
|
||||
@ -1033,14 +1026,12 @@ void Detector::setAutoCompDisable(bool value, Positions pos) {
|
||||
static_cast<int>(value));
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfAdditionalStorageCells() const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, {},
|
||||
defs::STORAGE_CELL_NUMBER, -1);
|
||||
Result<int> Detector::getNumberOfAdditionalStorageCells(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfAdditionalStorageCells, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfAdditionalStorageCells(int64_t value) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, {}, defs::STORAGE_CELL_NUMBER,
|
||||
value);
|
||||
void Detector::setNumberOfAdditionalStorageCells(int value) {
|
||||
pimpl->Parallel(&slsDetector::setNumberOfAdditionalStorageCells, {}, value);
|
||||
}
|
||||
|
||||
Result<int> Detector::getStorageCellStart(Positions pos) const {
|
||||
@ -1052,13 +1043,11 @@ void Detector::setStoragecellStart(int cell, Positions pos) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getStorageCellDelay(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos,
|
||||
defs::STORAGE_CELL_DELAY, -1);
|
||||
return pimpl->Parallel(&slsDetector::getStorageCellDelay, pos);
|
||||
}
|
||||
|
||||
void Detector::setStorageCellDelay(ns value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::STORAGE_CELL_DELAY,
|
||||
value.count());
|
||||
pimpl->Parallel(&slsDetector::setStorageCellDelay, pos, value.count());
|
||||
}
|
||||
|
||||
// Gotthard Specific
|
||||
@ -1079,12 +1068,7 @@ void Detector::clearROI(Positions pos) {
|
||||
}
|
||||
|
||||
Result<ns> Detector::getExptimeLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos,
|
||||
defs::ACQUISITION_TIME);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getPeriodLeft(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::FRAME_PERIOD);
|
||||
return pimpl->Parallel(&slsDetector::getExptimeLeft, pos);
|
||||
}
|
||||
|
||||
Result<defs::externalSignalFlag>
|
||||
@ -1110,22 +1094,20 @@ Result<int> Detector::setImageTestMode(int value, Positions pos) {
|
||||
|
||||
// CTB Specific
|
||||
|
||||
Result<int64_t> Detector::getNumberOfAnalogSamples(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::ANALOG_SAMPLES,
|
||||
-1);
|
||||
Result<int> Detector::getNumberOfAnalogSamples(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfAnalogSamples, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfAnalogSamples(int64_t value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::ANALOG_SAMPLES, value);
|
||||
void Detector::setNumberOfAnalogSamples(int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setNumberOfAnalogSamples, pos, value);
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfDigitalSamples(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::setTimer, pos, defs::DIGITAL_SAMPLES,
|
||||
-1);
|
||||
Result<int> Detector::getNumberOfDigitalSamples(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfDigitalSamples, pos);
|
||||
}
|
||||
|
||||
void Detector::setNumberOfDigitalSamples(int64_t value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setTimer, pos, defs::DIGITAL_SAMPLES, value);
|
||||
void Detector::setNumberOfDigitalSamples(int value, Positions pos) {
|
||||
pimpl->Parallel(&slsDetector::setNumberOfDigitalSamples, pos, value);
|
||||
}
|
||||
|
||||
Result<defs::readoutMode> Detector::getReadoutMode(Positions pos) const {
|
||||
@ -1605,17 +1587,15 @@ void Detector::executeCommand(const std::string &value, Positions pos) {
|
||||
}
|
||||
|
||||
Result<int64_t> Detector::getNumberOfFramesFromStart(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos,
|
||||
defs::FRAMES_FROM_START);
|
||||
return pimpl->Parallel(&slsDetector::getNumberOfFramesFromStart, pos);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getActualTime(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos, defs::ACTUAL_TIME);
|
||||
return pimpl->Parallel(&slsDetector::getActualTime, pos);
|
||||
}
|
||||
|
||||
Result<ns> Detector::getMeasurementTime(Positions pos) const {
|
||||
return pimpl->Parallel(&slsDetector::getTimeLeft, pos,
|
||||
defs::MEASUREMENT_TIME);
|
||||
return pimpl->Parallel(&slsDetector::getMeasurementTime, pos);
|
||||
}
|
||||
|
||||
std::string Detector::getUserDetails() const { return pimpl->getUserDetails(); }
|
||||
|
@ -1006,10 +1006,10 @@ void multiSlsDetector::registerDataCallback(
|
||||
}
|
||||
}
|
||||
|
||||
int multiSlsDetector::setTotalProgress() {
|
||||
int nf = Parallel(&slsDetector::setTimer, {}, FRAME_NUMBER, -1)
|
||||
double multiSlsDetector::setTotalProgress() {
|
||||
int64_t nf = Parallel(&slsDetector::getNumberOfFramesFromShm, {})
|
||||
.tsquash("Inconsistent number of frames");
|
||||
int nc = Parallel(&slsDetector::setTimer, {}, TRIGGER_NUMBER, -1)
|
||||
int64_t nc = Parallel(&slsDetector::getNumberOfTriggersFromShm, {})
|
||||
.tsquash("Inconsistent number of triggers");
|
||||
if (nf == 0 || nc == 0) {
|
||||
throw RuntimeError("Number of frames or triggers is 0");
|
||||
@ -1017,7 +1017,7 @@ int multiSlsDetector::setTotalProgress() {
|
||||
|
||||
int ns = 1;
|
||||
if (multi_shm()->multiDetectorType == JUNGFRAU) {
|
||||
ns = Parallel(&slsDetector::setTimer, {}, STORAGE_CELL_NUMBER, -1)
|
||||
ns = Parallel(&slsDetector::getNumberOfAdditionalStorageCellsFromShm, {})
|
||||
.tsquash("Inconsistent number of additional storage cells");
|
||||
++ns;
|
||||
}
|
||||
@ -1030,23 +1030,23 @@ int multiSlsDetector::setTotalProgress() {
|
||||
|
||||
double multiSlsDetector::getCurrentProgress() {
|
||||
std::lock_guard<std::mutex> lock(mp);
|
||||
return 100. * ((double)progressIndex) / ((double)totalProgress);
|
||||
return 100. * progressIndex / totalProgress;
|
||||
}
|
||||
|
||||
void multiSlsDetector::incrementProgress() {
|
||||
std::lock_guard<std::mutex> lock(mp);
|
||||
progressIndex++;
|
||||
progressIndex += 1;
|
||||
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
|
||||
<< 100. * ((double)progressIndex) / ((double)totalProgress)
|
||||
<< 100. * progressIndex / totalProgress
|
||||
<< " \%";
|
||||
std::cout << '\r' << std::flush;
|
||||
}
|
||||
|
||||
void multiSlsDetector::setCurrentProgress(int i) {
|
||||
void multiSlsDetector::setCurrentProgress(int64_t i) {
|
||||
std::lock_guard<std::mutex> lock(mp);
|
||||
progressIndex = i;
|
||||
progressIndex = (double)i;
|
||||
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
|
||||
<< 100. * ((double)progressIndex) / ((double)totalProgress)
|
||||
<< 100. * progressIndex / totalProgress
|
||||
<< " \%";
|
||||
std::cout << '\r' << std::flush;
|
||||
}
|
||||
@ -1148,7 +1148,7 @@ void multiSlsDetector::processData() {
|
||||
}
|
||||
// only update progress
|
||||
else {
|
||||
int caught = -1;
|
||||
int64_t caught = -1;
|
||||
while (true) {
|
||||
// to exit acquire by typing q
|
||||
if (kbhit() != 0) {
|
||||
|
@ -322,21 +322,9 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
shm()->roMode = ANALOG_ONLY;
|
||||
shm()->currentSettings = UNINITIALIZED;
|
||||
shm()->currentThresholdEV = -1;
|
||||
shm()->timerValue[FRAME_NUMBER] = 1;
|
||||
shm()->timerValue[ACQUISITION_TIME] = 0;
|
||||
shm()->timerValue[FRAME_PERIOD] = 0;
|
||||
shm()->timerValue[DELAY_AFTER_TRIGGER] = 0;
|
||||
shm()->timerValue[TRIGGER_NUMBER] = 1;
|
||||
shm()->timerValue[ACTUAL_TIME] = 0;
|
||||
shm()->timerValue[MEASUREMENT_TIME] = 0;
|
||||
shm()->timerValue[PROGRESS] = 0;
|
||||
shm()->timerValue[FRAMES_FROM_START] = 0;
|
||||
shm()->timerValue[FRAMES_FROM_START_PG] = 0;
|
||||
shm()->timerValue[ANALOG_SAMPLES] = 1;
|
||||
shm()->timerValue[DIGITAL_SAMPLES] = 1;
|
||||
shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = 0;
|
||||
shm()->timerValue[STORAGE_CELL_NUMBER] = 0;
|
||||
shm()->timerValue[SUBFRAME_DEADTIME] = 0;
|
||||
shm()->nFrames = 1;
|
||||
shm()->nTriggers = 1;
|
||||
shm()->nAddStorageCells = 0;
|
||||
shm()->deadTime = 0;
|
||||
sls::strcpy_safe(shm()->rxHostname, "none");
|
||||
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
|
||||
@ -751,44 +739,17 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
|
||||
// frame number
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[FRAME_NUMBER] = i64;
|
||||
|
||||
// exptime
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[ACQUISITION_TIME] = i64;
|
||||
|
||||
// subexptime, subdeadtime
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[SUBFRAME_ACQUISITION_TIME] = i64;
|
||||
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[SUBFRAME_DEADTIME] = i64;
|
||||
}
|
||||
|
||||
// period
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[FRAME_PERIOD] = i64;
|
||||
|
||||
// delay
|
||||
if (shm()->myDetectorType != EIGER && shm()->myDetectorType != MYTHEN3 && shm()->myDetectorType != GOTTHARD2) {
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[DELAY_AFTER_TRIGGER] = i64;
|
||||
}
|
||||
shm()->nFrames = i64;
|
||||
|
||||
if (shm()->myDetectorType == JUNGFRAU) {
|
||||
// storage cell
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[STORAGE_CELL_NUMBER] = i64;
|
||||
|
||||
// storage cell delay
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[STORAGE_CELL_DELAY] = i64;
|
||||
shm()->nAddStorageCells = i64;
|
||||
}
|
||||
|
||||
// triggers
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
shm()->timerValue[TRIGGER_NUMBER] = i64;
|
||||
shm()->nTriggers = i64;
|
||||
|
||||
// readout mode
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
@ -806,18 +767,6 @@ void slsDetector::updateCachedDetectorVariables() {
|
||||
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
||||
shm()->myDetectorType == MOENCH) {
|
||||
// analog samples
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
if (i64 >= 0) {
|
||||
shm()->timerValue[ANALOG_SAMPLES] = i64;
|
||||
}
|
||||
|
||||
// digital samples
|
||||
n += client.Receive(&i64, sizeof(i64));
|
||||
if (i64 >= 0) {
|
||||
shm()->timerValue[DIGITAL_SAMPLES] = i64;
|
||||
}
|
||||
|
||||
// adcmask
|
||||
uint32_t u32 = 0;
|
||||
n += client.Receive(&u32, sizeof(u32));
|
||||
@ -1220,87 +1169,295 @@ uint64_t slsDetector::getStartingFrameNumber() {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
|
||||
int64_t args[]{static_cast<int64_t>(index), t};
|
||||
int64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Setting " << sls::ToString(index) << " to " << t
|
||||
<< " ns/value";
|
||||
|
||||
// send to detector
|
||||
int64_t oldtimer = shm()->timerValue[index];
|
||||
sendToDetector(F_SET_TIMER, args, retval);
|
||||
FILE_LOG(logDEBUG1) << sls::ToString(index) << ": " << retval;
|
||||
shm()->timerValue[index] = retval;
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
if (index == ANALOG_SAMPLES || index == DIGITAL_SAMPLES) {
|
||||
updateNumberOfChannels();
|
||||
}
|
||||
|
||||
// setting timers consequences (eiger (ratecorr) )
|
||||
// (a get can also change timer value, hence check difference)
|
||||
if (oldtimer != shm()->timerValue[index]) {
|
||||
// eiger: change exptime/subexptime, set rate correction to update table
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
int dr = shm()->dynamicRange;
|
||||
if ((dr == 32 && index == SUBFRAME_ACQUISITION_TIME) ||
|
||||
(dr == 16 && index == ACQUISITION_TIME)) {
|
||||
int r = getRateCorrection();
|
||||
if (r != 0) {
|
||||
setRateCorrection(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// send to reciever
|
||||
void slsDetector::sendTotalNumFramestoReceiver() {
|
||||
if (shm()->useReceiverFlag) {
|
||||
timerIndex rt[]{FRAME_NUMBER,
|
||||
FRAME_PERIOD,
|
||||
TRIGGER_NUMBER,
|
||||
ACQUISITION_TIME,
|
||||
SUBFRAME_ACQUISITION_TIME,
|
||||
SUBFRAME_DEADTIME,
|
||||
ANALOG_SAMPLES,
|
||||
DIGITAL_SAMPLES,
|
||||
STORAGE_CELL_NUMBER};
|
||||
|
||||
// if in list (lambda)
|
||||
if (std::any_of(std::begin(rt), std::end(rt),
|
||||
[index](timerIndex t) { return t == index; })) {
|
||||
args[1] = shm()->timerValue[index];
|
||||
retval = -1;
|
||||
|
||||
// rewrite args
|
||||
if ((index == FRAME_NUMBER) || (index == TRIGGER_NUMBER) ||
|
||||
(index == STORAGE_CELL_NUMBER)) {
|
||||
args[1] = shm()->timerValue[FRAME_NUMBER] *
|
||||
((shm()->timerValue[TRIGGER_NUMBER] > 0)
|
||||
? (shm()->timerValue[TRIGGER_NUMBER])
|
||||
: 1) *
|
||||
((shm()->timerValue[STORAGE_CELL_NUMBER] > 0)
|
||||
? (shm()->timerValue[STORAGE_CELL_NUMBER]) + 1
|
||||
: 1);
|
||||
}
|
||||
FILE_LOG(logDEBUG1)
|
||||
<< "Sending "
|
||||
<< (((index == FRAME_NUMBER) || (index == TRIGGER_NUMBER) ||
|
||||
(index == STORAGE_CELL_NUMBER))
|
||||
? "(#Frames) * (#triggers) * (#storage cells)"
|
||||
: sls::ToString(index))
|
||||
<< " to receiver: " << args[1];
|
||||
|
||||
sendToReceiver(F_SET_RECEIVER_TIMER, args, retval);
|
||||
}
|
||||
int64_t arg = shm()->nFrames * shm()->nTriggers * (shm()->nAddStorageCells + 1);
|
||||
FILE_LOG(logDEBUG1) << "Sending total number of frames (#f x #t x #s) to Receiver: " << arg;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_FRAMES, arg, nullptr);
|
||||
}
|
||||
return shm()->timerValue[index];
|
||||
}
|
||||
|
||||
int64_t slsDetector::getTimeLeft(timerIndex index) const {
|
||||
int64_t slsDetector::getNumberOfFramesFromShm() {
|
||||
return shm()->nFrames;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getNumberOfFrames() {
|
||||
int64_t prevVal = shm()->nFrames;
|
||||
int64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting " << sls::ToString(index) << " left";
|
||||
sendToDetectorStop(F_GET_TIME_LEFT, index, retval);
|
||||
FILE_LOG(logDEBUG1) << sls::ToString(index) << " left: " << retval;
|
||||
return retval;
|
||||
sendToDetector(F_GET_NUM_FRAMES, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of frames :" << retval;
|
||||
shm()->nFrames = retval;
|
||||
if (prevVal != retval) {
|
||||
sendTotalNumFramestoReceiver();
|
||||
}
|
||||
return shm()->nFrames;
|
||||
}
|
||||
|
||||
void slsDetector::setNumberOfFrames(int64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting number of frames to " << value;
|
||||
sendToDetector(F_SET_NUM_FRAMES, value, nullptr);
|
||||
shm()->nFrames = value;
|
||||
sendTotalNumFramestoReceiver();
|
||||
}
|
||||
|
||||
int64_t slsDetector::getNumberOfTriggersFromShm() {
|
||||
return shm()->nTriggers;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getNumberOfTriggers() {
|
||||
int64_t prevVal = shm()->nTriggers;
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_NUM_TRIGGERS, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of triggers :" << retval;
|
||||
shm()->nTriggers = retval;
|
||||
if (prevVal != retval) {
|
||||
sendTotalNumFramestoReceiver();
|
||||
}
|
||||
return shm()->nTriggers;
|
||||
}
|
||||
|
||||
void slsDetector::setNumberOfTriggers(int64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting number of triggers to " << value;
|
||||
sendToDetector(F_SET_NUM_TRIGGERS, value, nullptr);
|
||||
shm()->nTriggers = value;
|
||||
sendTotalNumFramestoReceiver();
|
||||
}
|
||||
|
||||
int slsDetector::getNumberOfAdditionalStorageCellsFromShm() {
|
||||
return shm()->nAddStorageCells;
|
||||
}
|
||||
|
||||
int slsDetector::getNumberOfAdditionalStorageCells() {
|
||||
int prevVal = shm()->nAddStorageCells;
|
||||
int retval = -1;
|
||||
sendToDetector(F_GET_NUM_ADDITIONAL_STORAGE_CELLS, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of storage cells :" << retval;
|
||||
shm()->nAddStorageCells = retval;
|
||||
if (prevVal != retval) {
|
||||
sendTotalNumFramestoReceiver();
|
||||
}
|
||||
return shm()->nAddStorageCells;
|
||||
}
|
||||
|
||||
void slsDetector::setNumberOfAdditionalStorageCells(int value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting number of storage cells to " << value;
|
||||
sendToDetector(F_SET_NUM_ADDITIONAL_STORAGE_CELLS, value, nullptr);
|
||||
shm()->nAddStorageCells = value;
|
||||
sendTotalNumFramestoReceiver();
|
||||
}
|
||||
|
||||
int slsDetector::getNumberOfAnalogSamples() {
|
||||
int retval = -1;
|
||||
sendToDetector(F_GET_NUM_ANALOG_SAMPLES, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of analog samples :" << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setNumberOfAnalogSamples(int value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting number of analog samples to " << value;
|
||||
sendToDetector(F_SET_NUM_ANALOG_SAMPLES, value, nullptr);
|
||||
// update #nchan, as it depends on #samples, adcmask
|
||||
updateNumberOfChannels();
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending number of analog samples to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_ANALOG_SAMPLES, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int slsDetector::getNumberOfDigitalSamples() {
|
||||
int retval = -1;
|
||||
sendToDetector(F_GET_NUM_DIGITAL_SAMPLES, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of digital samples :" << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setNumberOfDigitalSamples(int value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting number of digital samples to " << value;
|
||||
sendToDetector(F_SET_NUM_DIGITAL_SAMPLES, value, nullptr);
|
||||
// update #nchan, as it depends on #samples, adcmask
|
||||
updateNumberOfChannels();
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending number of digital samples to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t slsDetector::getExptime() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_EXPTIME, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "exptime :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setExptime(int64_t value) {
|
||||
int64_t prevVal = value;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
prevVal = getExptime();
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
|
||||
sendToDetector(F_SET_EXPTIME, value, nullptr);
|
||||
if (shm()->myDetectorType == EIGER && prevVal != value && shm()->dynamicRange == 16) {
|
||||
int r = getRateCorrection();
|
||||
if (r != 0) {
|
||||
setRateCorrection(r);
|
||||
}
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending exptime to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_EXPTIME, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t slsDetector::getPeriod() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_PERIOD, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "period :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setPeriod(int64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting period to " << value << "ns";
|
||||
sendToDetector(F_SET_PERIOD, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending period to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_PERIOD, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t slsDetector::getDelayAfterTrigger() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_DELAY_AFTER_TRIGGER, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "delay after trigger :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setDelayAfterTrigger(int64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting delay after trigger to " << value << "ns";
|
||||
sendToDetector(F_SET_DELAY_AFTER_TRIGGER, value, nullptr);
|
||||
}
|
||||
|
||||
int64_t slsDetector::getSubExptime() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_SUB_EXPTIME, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "sub exptime :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setSubExptime(int64_t value) {
|
||||
int64_t prevVal = value;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
prevVal = getSubExptime();
|
||||
}
|
||||
FILE_LOG(logDEBUG1) << "Setting sub exptime to " << value << "ns";
|
||||
sendToDetector(F_SET_SUB_EXPTIME, value, nullptr);
|
||||
if (shm()->myDetectorType == EIGER && prevVal != value && shm()->dynamicRange == 32) {
|
||||
int r = getRateCorrection();
|
||||
if (r != 0) {
|
||||
setRateCorrection(r);
|
||||
}
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending sub exptime to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_SUB_EXPTIME, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t slsDetector::getSubDeadTime() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_SUB_DEADTIME, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "sub deadtime :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setSubDeadTime(int64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting sub deadtime to " << value << "ns";
|
||||
sendToDetector(F_SET_SUB_DEADTIME, value, nullptr);
|
||||
if (shm()->useReceiverFlag) {
|
||||
FILE_LOG(logDEBUG1) << "Sending sub deadtime to Receiver: " << value;
|
||||
sendToReceiver(F_RECEIVER_SET_SUB_DEADTIME, value, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t slsDetector::getStorageCellDelay() {
|
||||
int64_t retval = -1;
|
||||
sendToDetector(F_GET_STORAGE_CELL_DELAY, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "storage cell delay :" << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
void slsDetector::setStorageCellDelay(int64_t value) {
|
||||
FILE_LOG(logDEBUG1) << "Setting storage cell delay to " << value << "ns";
|
||||
sendToDetector(F_SET_STORAGE_CELL_DELAY, value, nullptr);
|
||||
}
|
||||
|
||||
int64_t slsDetector::getNumberOfFramesLeft() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_FRAMES_LEFT, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of frames left :" << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getNumberOfTriggersLeft() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_TRIGGERS_LEFT, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of triggers left :" << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getDelayAfterTriggerLeft() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_DELAY_AFTER_TRIGGER_LEFT, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "delay after trigger left :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getExptimeLeft() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_EXPTIME_LEFT, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "exptime left :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getPeriodLeft() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_PERIOD_LEFT, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "period left :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getMeasuredPeriod() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_MEASURED_PERIOD, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "measured period :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getMeasuredSubFramePeriod() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_MEASURED_SUBPERIOD, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "exptime :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getNumberOfFramesFromStart() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_FRAMES_FROM_START, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "number of frames from start :" << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getActualTime() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_ACTUAL_TIME, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "actual time :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int64_t slsDetector::getMeasurementTime() const {
|
||||
int64_t retval = -1;
|
||||
sendToDetectorStop(F_GET_MEASUREMENT_TIME, nullptr, retval);
|
||||
FILE_LOG(logDEBUG1) << "measurement time :" << retval << "ns";
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::setSpeed(speedVariable sp, int value, int mode) {
|
||||
@ -1551,15 +1708,6 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
<< "\nwrite enable:" << shm()->rxFileWrite
|
||||
<< "\nmaster write enable:" << shm()->rxMasterFileWrite
|
||||
<< "\noverwrite enable:" << shm()->rxFileOverWrite
|
||||
<< "\nframe index needed:"
|
||||
<< ((shm()->timerValue[FRAME_NUMBER] *
|
||||
shm()->timerValue[TRIGGER_NUMBER]) > 1)
|
||||
<< "\nframe period:" << (shm()->timerValue[FRAME_PERIOD])
|
||||
<< "\nframe number:" << (shm()->timerValue[FRAME_NUMBER])
|
||||
<< "\nsub exp time:" << (shm()->timerValue[SUBFRAME_ACQUISITION_TIME])
|
||||
<< "\nsub dead time:" << (shm()->timerValue[SUBFRAME_DEADTIME])
|
||||
<< "\nasamples:" << (shm()->timerValue[ANALOG_SAMPLES])
|
||||
<< "\ndsamples:" << (shm()->timerValue[DIGITAL_SAMPLES])
|
||||
<< "\ndynamic range:" << shm()->dynamicRange
|
||||
<< "\nflippeddatax:" << (shm()->flippedDataX)
|
||||
<< "\nactivated: " << shm()->activated
|
||||
@ -1603,17 +1751,16 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
setFileWrite(shm()->rxFileWrite);
|
||||
setMasterFileWrite(shm()->rxMasterFileWrite);
|
||||
setFileOverWrite(shm()->rxFileOverWrite);
|
||||
setTimer(FRAME_PERIOD, shm()->timerValue[FRAME_PERIOD]);
|
||||
setTimer(FRAME_NUMBER, shm()->timerValue[FRAME_NUMBER]);
|
||||
setTimer(ACQUISITION_TIME, shm()->timerValue[ACQUISITION_TIME]);
|
||||
sendTotalNumFramestoReceiver();
|
||||
setExptime(getExptime());
|
||||
setPeriod(getPeriod());
|
||||
|
||||
// detector specific
|
||||
switch (shm()->myDetectorType) {
|
||||
|
||||
case EIGER:
|
||||
setTimer(SUBFRAME_ACQUISITION_TIME,
|
||||
shm()->timerValue[SUBFRAME_ACQUISITION_TIME]);
|
||||
setTimer(SUBFRAME_DEADTIME, shm()->timerValue[SUBFRAME_DEADTIME]);
|
||||
setSubExptime(getSubExptime());
|
||||
setSubDeadTime(getSubDeadTime());
|
||||
setDynamicRange(shm()->dynamicRange);
|
||||
setFlippedDataX(-1);
|
||||
activate(-1);
|
||||
@ -1625,8 +1772,8 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
break;
|
||||
|
||||
case CHIPTESTBOARD:
|
||||
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
|
||||
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
|
||||
setNumberOfAnalogSamples(getNumberOfAnalogSamples());
|
||||
setNumberOfDigitalSamples(getNumberOfDigitalSamples());
|
||||
enableTenGigabitEthernet(shm()->tenGigaEnable);
|
||||
setReadoutMode(shm()->roMode);
|
||||
setADCEnableMask(shm()->adcEnableMask);
|
||||
@ -1635,8 +1782,8 @@ std::string slsDetector::setReceiverHostname(const std::string &receiverIP) {
|
||||
break;
|
||||
|
||||
case MOENCH:
|
||||
setTimer(ANALOG_SAMPLES, shm()->timerValue[ANALOG_SAMPLES]);
|
||||
setTimer(DIGITAL_SAMPLES, shm()->timerValue[DIGITAL_SAMPLES]);
|
||||
setNumberOfAnalogSamples(getNumberOfAnalogSamples());
|
||||
setNumberOfDigitalSamples(getNumberOfDigitalSamples());
|
||||
enableTenGigabitEthernet(shm()->tenGigaEnable);
|
||||
setADCEnableMask(shm()->adcEnableMask);
|
||||
break;
|
||||
@ -3074,8 +3221,8 @@ slsDetectorDefs::runStatus slsDetector::getReceiverStatus() const {
|
||||
return retval;
|
||||
}
|
||||
|
||||
int slsDetector::getFramesCaughtByReceiver() const {
|
||||
int retval = -1;
|
||||
int64_t slsDetector::getFramesCaughtByReceiver() const {
|
||||
int64_t retval = -1;
|
||||
FILE_LOG(logDEBUG1) << "Getting Frames Caught by Receiver";
|
||||
if (shm()->useReceiverFlag) {
|
||||
sendToReceiver(F_GET_RECEIVER_FRAMES_CAUGHT, nullptr, retval);
|
||||
|
Reference in New Issue
Block a user