Merge branch 'developer' into testing

This commit is contained in:
maliakal_d 2020-04-06 10:55:41 +02:00
commit 47b0e46f15
33 changed files with 594 additions and 489 deletions

View File

@ -59,11 +59,9 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
private slots: private slots:
void SetSaveFileName(QString val); void SetSaveFileName(QString val);
void AcquireThread();
void UpdatePlot(); void UpdatePlot();
signals: signals:
void StartAcquireSignal();
void AcquireFinishedSignal(); void AcquireFinishedSignal();
void AbortSignal(); void AbortSignal();
void UpdateSignal(); void UpdateSignal();
@ -74,6 +72,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
void SetupPlots(); void SetupPlots();
void GetStatistics(double &min, double &max, double &sum); void GetStatistics(double &min, double &max, double &sum);
void DetachHists(); void DetachHists();
void AcquireThread();
static void GetAcquisitionFinishedCallBack(double currentProgress, static void GetAcquisitionFinishedCallBack(double currentProgress,
int detectorStatus, int detectorStatus,
void *this_pointer); void *this_pointer);

View File

@ -87,7 +87,6 @@ void qDrawPlot::SetupWidgetWindow() {
void qDrawPlot::Initialization() { void qDrawPlot::Initialization() {
connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot())); connect(this, SIGNAL(UpdateSignal()), this, SLOT(UpdatePlot()));
connect(this, SIGNAL(StartAcquireSignal()), this, SLOT(AcquireThread()));
} }
void qDrawPlot::SetupPlots() { void qDrawPlot::SetupPlots() {
@ -657,7 +656,8 @@ void qDrawPlot::StartAcquisition() {
xyRangeChanged = true; xyRangeChanged = true;
} }
emit StartAcquireSignal(); QtConcurrent::run(this, &qDrawPlot::AcquireThread);
LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot"; LOG(logDEBUG) << "End of Starting Acquisition in qDrawPlot";
} }

View File

@ -33,6 +33,7 @@ target_compile_definitions(ctbDetectorServer_virtual
target_link_libraries(ctbDetectorServer_virtual target_link_libraries(ctbDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings PUBLIC pthread rt slsProjectCWarnings
m
) )
set_target_properties(ctbDetectorServer_virtual PROPERTIES set_target_properties(ctbDetectorServer_virtual PROPERTIES

View File

@ -67,6 +67,7 @@ int eiger_extgating = 0;
int eiger_extgatingpolarity = 0; int eiger_extgatingpolarity = 0;
int eiger_nexposures = 1; int eiger_nexposures = 1;
int eiger_ntriggers = 1; int eiger_ntriggers = 1;
int eiger_tau_ns = 0;
#ifdef VIRTUAL #ifdef VIRTUAL
@ -477,6 +478,7 @@ void setupDetector() {
getSubExpTime(DEFAULT_SUBFRAME_DEADTIME); getSubExpTime(DEFAULT_SUBFRAME_DEADTIME);
setPeriod(DEFAULT_PERIOD); setPeriod(DEFAULT_PERIOD);
setNumTriggers(DEFAULT_NUM_CYCLES); setNumTriggers(DEFAULT_NUM_CYCLES);
eiger_dynamicrange = DEFAULT_DYNAMIC_RANGE;
setDynamicRange(DEFAULT_DYNAMIC_RANGE); setDynamicRange(DEFAULT_DYNAMIC_RANGE);
eiger_photonenergy = DEFAULT_PHOTON_ENERGY; eiger_photonenergy = DEFAULT_PHOTON_ENERGY;
setParallelMode(DEFAULT_PARALLEL_MODE); setParallelMode(DEFAULT_PARALLEL_MODE);
@ -488,6 +490,7 @@ void setupDetector() {
setStartingFrameNumber(DEFAULT_STARTING_FRAME_NUMBER); setStartingFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
setReadNLines(MAX_ROWS_PER_READOUT); setReadNLines(MAX_ROWS_PER_READOUT);
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15); //SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
eiger_tau_ns = DEFAULT_RATE_CORRECTION;
setRateCorrection(DEFAULT_RATE_CORRECTION); setRateCorrection(DEFAULT_RATE_CORRECTION);
int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY}; int enable[2] = {DEFAULT_EXT_GATING_ENABLE, DEFAULT_EXT_GATING_POLARITY};
setExternalGating(enable);//disable external gating setExternalGating(enable);//disable external gating
@ -532,31 +535,27 @@ int readRegister(uint32_t offset, uint32_t* retval) {
int setDynamicRange(int dr) { int setDynamicRange(int dr) {
#ifdef VIRTUAL // setting dr
if (dr > 0) {
LOG(logINFO, ("Setting dynamic range: %d\n", dr));
eiger_dynamicrange = dr;
}
return eiger_dynamicrange;
#else
if (dr > 0) { if (dr > 0) {
LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr)); LOG(logDEBUG1, ("Setting dynamic range: %d\n", dr));
#ifndef VIRTUAL
if (Feb_Control_SetDynamicRange(dr)) { if (Feb_Control_SetDynamicRange(dr)) {
//EigerSetBitMode(dr);
on_dst = 0; on_dst = 0;
int i; int i;
for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested for(i=0;i<32;i++) dst_requested[i] = 0; //clear dst requested
if (Beb_SetUpTransferParameters(dr)) if (!Beb_SetUpTransferParameters(dr)) {
eiger_dynamicrange = dr; LOG(logERROR, ("Could not set bit mode in the back end\n"));
else LOG(logERROR, ("Could not set bit mode in the back end\n")); return eiger_dynamicrange;
}
} }
}
//make sure back end and front end have the same bit mode
dr= Feb_Control_GetDynamicRange();
return dr;
#endif #endif
eiger_dynamicrange = dr;
}
// getting dr
#ifndef VIRTUAL
eiger_dynamicrange = Feb_Control_GetDynamicRange();
#endif
return eiger_dynamicrange;
} }
@ -842,8 +841,9 @@ int setModule(sls_detector_module myMod, char* mess) {
} }
} }
} }
// trimbits
#ifndef VIRTUAL #ifndef VIRTUAL
// trimbits
if (myMod.nchan == 0) { if (myMod.nchan == 0) {
LOG(logINFO, ("Setting module without trimbits\n")); LOG(logINFO, ("Setting module without trimbits\n"));
} else { } else {
@ -872,6 +872,7 @@ int setModule(sls_detector_module myMod, char* mess) {
return FAIL; return FAIL;
} }
} }
#endif
//rate correction //rate correction
@ -891,17 +892,24 @@ int setModule(sls_detector_module myMod, char* mess) {
else { else {
setDefaultSettingsTau_in_nsec(myMod.tau); setDefaultSettingsTau_in_nsec(myMod.tau);
if (getRateCorrectionEnable()) { if (getRateCorrectionEnable()) {
int64_t retvalTau = setRateCorrection(myMod.tau); if (setRateCorrection(myMod.tau) == FAIL) {
if (myMod.tau != retvalTau) { sprintf(mess, "Cannot set module. Rate correction failed.\n");
sprintf(mess, "Cannot set module. Could not set rate correction\n");
LOG(logERROR, (mess)); LOG(logERROR, (mess));
setSettings(UNDEFINED); setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n")); LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
return FAIL; return FAIL;
} else {
int64_t retvalTau = getCurrentTau();
if (myMod.tau != retvalTau) {
sprintf(mess, "Cannot set module. Could not set rate correction\n");
LOG(logERROR, (mess));
setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined (random trim file)\n"));
return FAIL;
}
} }
} }
} }
#endif
return OK; return OK;
} }
@ -1449,12 +1457,59 @@ int pulseChip(int n) {
return OK; return OK;
} }
int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never be -1) int updateRateCorrection(char* mess) {
int ret = OK;
// recalculates rate correction table, or switches off in wrong bit mode
if (eiger_tau_ns != 0) {
switch (eiger_dynamicrange) {
case 16:
case 32:
ret = setRateCorrection(eiger_tau_ns);
break;
default:
setRateCorrection(0);
strcpy(mess, "Rate correction Deactivated, must be in 32 or 16 bit mode");
ret = FAIL;
break;
}
}
getCurrentTau(); // update eiger_tau_ns
return ret;
}
int validateAndSetRateCorrection(int64_t tau_ns, char* mess) {
// switching on in wrong bit mode
if ((tau_ns != 0) &&
(eiger_dynamicrange != 32) && (eiger_dynamicrange != 16)) {
strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n");
LOG(logERROR,(mess));
return FAIL;
}
// default tau (-1, get proper value)
if (tau_ns < 0) {
tau_ns = getDefaultSettingsTau_in_nsec();
if (tau_ns < 0) {
strcpy(mess,"Default settings file not loaded. No default tau yet\n");
LOG(logERROR,(mess));
return FAIL;
}
eiger_tau_ns = -1;
}
// user defined value (settings become undefined)
else if (tau_ns > 0) {
setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined (tau changed)\n"));
eiger_tau_ns = tau_ns;
}
return setRateCorrection(tau_ns);
}
int setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never be -1)
#ifdef VIRTUAL #ifdef VIRTUAL
//deactivating rate correction //deactivating rate correction
if (custom_tau_in_nsec==0) { if (custom_tau_in_nsec==0) {
eiger_virtual_ratecorrection_variable = 0; eiger_virtual_ratecorrection_variable = 0;
return 0; return OK;
} }
//when dynamic range changes, use old tau //when dynamic range changes, use old tau
@ -1484,22 +1539,21 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
//different setting, calculate table //different setting, calculate table
else { else {
eiger_virtual_ratetable_tau_in_ns = custom_tau_in_nsec; eiger_virtual_ratetable_tau_in_ns = custom_tau_in_nsec;
double period_in_sec = (double)(eiger_virtual_subexptime*10)/(double)1e9; eiger_virtual_ratetable_period_in_ns = eiger_virtual_subexptime*10;
if (eiger_dynamicrange == 16) if (eiger_dynamicrange == 16)
period_in_sec = eiger_virtual_exptime; eiger_virtual_ratetable_period_in_ns = eiger_virtual_exptime;
eiger_virtual_ratetable_period_in_ns = period_in_sec*1e9;
} }
//activating rate correction //activating rate correction
eiger_virtual_ratecorrection_variable = 1; eiger_virtual_ratecorrection_variable = 1;
LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns)); LOG(logINFO, ("Rate Correction Value set to %lld ns\n",(long long int)eiger_virtual_ratetable_tau_in_ns));
return eiger_virtual_ratetable_tau_in_ns; return OK;
#else #else
//deactivating rate correction //deactivating rate correction
if (custom_tau_in_nsec==0) { if (custom_tau_in_nsec==0) {
Feb_Control_SetRateCorrectionVariable(0); Feb_Control_SetRateCorrectionVariable(0);
return 0; return OK;
} }
//when dynamic range changes, use old tau //when dynamic range changes, use old tau
@ -1533,7 +1587,7 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
if (ret<=0) { if (ret<=0) {
LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n")); LOG(logERROR, ("Rate correction failed. Deactivating rate correction\n"));
Feb_Control_SetRateCorrectionVariable(0); Feb_Control_SetRateCorrectionVariable(0);
return ret; return FAIL;
} }
} }
//activating rate correction //activating rate correction
@ -1541,7 +1595,7 @@ int64_t setRateCorrection(int64_t custom_tau_in_nsec) {//in nanosec (will never
LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec())); LOG(logINFO, ("Rate Correction Value set to %lld ns\n", (long long int)Feb_Control_Get_RateTable_Tau_in_nsec()));
Feb_Control_PrintCorrectedValues(); Feb_Control_PrintCorrectedValues();
return Feb_Control_Get_RateTable_Tau_in_nsec(); return OK;
#endif #endif
} }
@ -1559,18 +1613,22 @@ int getDefaultSettingsTau_in_nsec() {
void setDefaultSettingsTau_in_nsec(int t) { void setDefaultSettingsTau_in_nsec(int t) {
default_tau_from_file = t; default_tau_from_file = t;
LOG(logINFO, ("Default tau set to %d\n", default_tau_from_file)); LOG(logINFOBLUE, ("Default tau set to %d\n", default_tau_from_file));
} }
int64_t getCurrentTau() { int64_t getCurrentTau() {
if (!getRateCorrectionEnable()) if (!getRateCorrectionEnable()) {
eiger_tau_ns = 0;
return 0; return 0;
else }
else {
#ifndef VIRTUAL #ifndef VIRTUAL
return Feb_Control_Get_RateTable_Tau_in_nsec(); eiger_tau_ns = Feb_Control_Get_RateTable_Tau_in_nsec();
#else #else
return eiger_virtual_ratetable_tau_in_ns; eiger_tau_ns = eiger_virtual_ratetable_tau_in_ns;
#endif #endif
return eiger_tau_ns;
}
} }
void setExternalGating(int enable[]) { void setExternalGating(int enable[]) {

View File

@ -31,6 +31,7 @@ target_compile_definitions(moenchDetectorServer_virtual
target_link_libraries(moenchDetectorServer_virtual target_link_libraries(moenchDetectorServer_virtual
PUBLIC pthread rt slsProjectCWarnings PUBLIC pthread rt slsProjectCWarnings
m
) )
set_target_properties(moenchDetectorServer_virtual PROPERTIES set_target_properties(moenchDetectorServer_virtual PROPERTIES

View File

@ -413,7 +413,9 @@ int setCounterBit(int val);
int pulsePixel(int n, int x, int y); int pulsePixel(int n, int x, int y);
int pulsePixelNMove(int n, int x, int y); int pulsePixelNMove(int n, int x, int y);
int pulseChip(int n); int pulseChip(int n);
int64_t setRateCorrection(int64_t custom_tau_in_nsec); int updateRateCorrection(char* mess);
int validateAndSetRateCorrection(int64_t tau_ns, char* mess);
int setRateCorrection(int64_t custom_tau_in_nsec);
int getRateCorrectionEnable(); int getRateCorrectionEnable();
int getDefaultSettingsTau_in_nsec(); int getDefaultSettingsTau_in_nsec();
void setDefaultSettingsTau_in_nsec(int t); void setDefaultSettingsTau_in_nsec(int t);

View File

@ -217,3 +217,5 @@ int set_current_source(int);
int get_timing_source(int); int get_timing_source(int);
int set_timing_source(int); int set_timing_source(int);
int get_num_channels(int); int get_num_channels(int);
int update_rate_correction(int);

View File

@ -317,6 +317,7 @@ const char* getFunctionName(enum detFuncs func) {
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE"; case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE"; case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS"; case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS";
case F_UPDATE_RATE_CORRECTION: return "F_UPDATE_RATE_CORRECTION";
default: return "Unknown Function"; default: return "Unknown Function";
} }
@ -510,6 +511,7 @@ void function_table() {
flist[F_GET_TIMING_SOURCE] = &get_timing_source; flist[F_GET_TIMING_SOURCE] = &get_timing_source;
flist[F_SET_TIMING_SOURCE] = &set_timing_source; flist[F_SET_TIMING_SOURCE] = &set_timing_source;
flist[F_GET_NUM_CHANNELS] = &get_num_channels; flist[F_GET_NUM_CHANNELS] = &get_num_channels;
flist[F_UPDATE_RATE_CORRECTION] = &update_rate_correction;
// check // check
if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) { if (NUM_DET_FUNCTIONS >= RECEIVER_ENUM_START) {
@ -2844,61 +2846,12 @@ int send_update(int file_des) {
ret = OK; ret = OK;
int n = 0; int n = 0;
int i32 = -1; int i32 = -1;
int64_t i64 = -1;
i32 = lastClientIP; i32 = lastClientIP;
i32 = __builtin_bswap32(i32); i32 = __builtin_bswap32(i32);
n = sendData(file_des, &i32,sizeof(i32),INT32); n = sendData(file_des, &i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
// dr
i32 = setDynamicRange(GET_FLAG);
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// settings
#if defined(EIGERD) || defined(JUNGFRAUD) || defined(GOTTHARDD) || defined(GOTTHARD2D)|| defined(MOENCHD)
i32 = (int)getSettings();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// #frames
i64 = getNumFrames();
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
// #storage cell
#ifdef JUNGFRAUD
i64 = getNumAdditionalStorageCells();
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#endif
// #triggers
i64 = getNumTriggers();
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
// #bursts
#ifdef GOTTHARD2D
i64 = getNumBursts();
n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError();
#endif
// timing mode
i32 = (int)getTiming();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
// burst mode
#ifdef GOTTHARD2D
i32 = (int)getBurstMode();
n = sendData(file_des,&i32,sizeof(i32),INT32);
if (n < 0) return printSocketReadError();
#endif
// number of channels // number of channels
#if defined(MOENCHD) || defined(CHIPTESTBOARDD) #if defined(MOENCHD) || defined(CHIPTESTBOARDD)
{ {
@ -3498,35 +3451,13 @@ int set_rate_correct(int file_des) {
#else #else
// only set // only set
if (Server_VerifyLock() == OK) { if (Server_VerifyLock() == OK) {
ret = validateAndSetRateCorrection(tau_ns, mess);
int dr = setDynamicRange(-1); int64_t retval = getCurrentTau(); // to update eiger_tau_ns (for update rate correction)
if (ret == FAIL) {
// switching on in wrong bit mode strcpy(mess, "Rate correction failed\n");
if ((tau_ns != 0) && (dr != 32) && (dr != 16)) { LOG(logERROR, (mess));
ret = FAIL; } else {
strcpy(mess,"Rate correction Deactivated, must be in 32 or 16 bit mode\n"); validate64(tau_ns, retval, "set rate correction", DEC);
LOG(logERROR,(mess));
}
// switching on in right mode
else {
if (tau_ns < 0) {
tau_ns = getDefaultSettingsTau_in_nsec();
if (tau_ns < 0) {
ret = FAIL;
strcpy(mess,"Default settings file not loaded. No default tau yet\n");
LOG(logERROR,(mess));
}
}
else if (tau_ns > 0) {
//changing tau to a user defined value changes settings to undefined
setSettings(UNDEFINED);
LOG(logERROR, ("Settings has been changed to undefined (tau changed)\n"));
}
if (ret == OK) {
int64_t retval = setRateCorrection(tau_ns);
validate64(tau_ns, retval, "set rate correction", DEC);
}
} }
} }
#endif #endif
@ -6930,4 +6861,22 @@ int get_num_channels(int file_des) {
LOG(logDEBUG1, ("Get number of channels sretval:[%d, %d]\n", retvals[0], retvals[1])); LOG(logDEBUG1, ("Get number of channels sretval:[%d, %d]\n", retvals[0], retvals[1]));
#endif #endif
return Server_SendResult(file_des, INT32, UPDATE, retvals, sizeof(retvals)); return Server_SendResult(file_des, INT32, UPDATE, retvals, sizeof(retvals));
}
int update_rate_correction(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
#ifndef EIGERD
functionNotImplemented();
#else
LOG(logINFO, ("Update Rate Correction\n"));
// only set
if (Server_VerifyLock() == OK) {
ret = updateRateCorrection(mess);
}
#endif
return Server_SendResult(file_des, INT32, UPDATE, NULL, 0);
} }

View File

@ -785,6 +785,47 @@ std::vector<std::string> CmdProxy::DacCommands() {
} }
/* acquisition */ /* acquisition */
std::string CmdProxy::ReceiverStatus(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "running, idle]\n\tReceiver listener status."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getReceiverStatus({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
throw sls::RuntimeError("Cannot put. Did you mean to use command 'rx_start' or 'rx_stop'?");
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
std::string CmdProxy::DetectorStatus(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
os << "[running, error, transmitting, finished, waiting, idle]\n\tDetector status."
<< '\n';
} else if (action == defs::GET_ACTION) {
if (args.size() != 0) {
WrongNumberOfParameters(0);
}
auto t = det->getDetectorStatus({det_id});
os << OutString(t) << '\n';
} else if (action == defs::PUT_ACTION) {
throw sls::RuntimeError("Cannot put. Did you mean to use command 'start' or 'stop'?");
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */
std::string CmdProxy::UDPDestinationIP(int action) { std::string CmdProxy::UDPDestinationIP(int action) {

View File

@ -691,8 +691,8 @@ class CmdProxy {
{"rx_stop", &CmdProxy::rx_stop}, {"rx_stop", &CmdProxy::rx_stop},
{"start", &CmdProxy::start}, {"start", &CmdProxy::start},
{"stop", &CmdProxy::stop}, {"stop", &CmdProxy::stop},
{"rx_status", &CmdProxy::rx_status}, {"rx_status", &CmdProxy::ReceiverStatus},
{"status", &CmdProxy::status}, {"status", &CmdProxy::DetectorStatus},
{"rx_framescaught", &CmdProxy::rx_framescaught}, {"rx_framescaught", &CmdProxy::rx_framescaught},
{"rx_missingpackets", &CmdProxy::rx_missingpackets}, {"rx_missingpackets", &CmdProxy::rx_missingpackets},
{"startingfnum", &CmdProxy::startingfnum}, {"startingfnum", &CmdProxy::startingfnum},
@ -934,6 +934,8 @@ class CmdProxy {
std::string DacValues(int action); std::string DacValues(int action);
std::vector<std::string> DacCommands(); std::vector<std::string> DacCommands();
/* acquisition */ /* acquisition */
std::string ReceiverStatus(int action);
std::string DetectorStatus(int action);
/* Network Configuration (Detector<->Receiver) */ /* Network Configuration (Detector<->Receiver) */
std::string UDPDestinationIP(int action); std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action); std::string UDPDestinationIP2(int action);
@ -1363,12 +1365,6 @@ class CmdProxy {
EXECUTE_SET_COMMAND_NOID(stop, stopDetector, EXECUTE_SET_COMMAND_NOID(stop, stopDetector,
"\n\tStops detector state machine."); "\n\tStops detector state machine.");
GET_COMMAND(rx_status, getReceiverStatus,
"running, idle]\n\tReceiver listener status.");
GET_COMMAND(status, getDetectorStatus,
"[running, error, transmitting, finished, waiting, idle]\n\tDetector status.");
GET_COMMAND(rx_framescaught, getFramesCaught, GET_COMMAND(rx_framescaught, getFramesCaught,
"\n\tNumber of frames caught by receiver."); "\n\tNumber of frames caught by receiver.");

View File

@ -234,8 +234,7 @@ Result<ns> Detector::getPeriodLeft(Positions pos) const {
} }
Result<defs::timingMode> Detector::getTimingMode(Positions pos) const { Result<defs::timingMode> Detector::getTimingMode(Positions pos) const {
return pimpl->Parallel(&Module::setTimingMode, pos, return pimpl->Parallel(&Module::getTimingMode, pos);
defs::GET_TIMING_MODE);
} }
void Detector::setTimingMode(defs::timingMode value, Positions pos) { void Detector::setTimingMode(defs::timingMode value, Positions pos) {
@ -923,7 +922,7 @@ void Detector::setClientZmqIp(const IpAddr ip, Positions pos) {
// Eiger Specific // Eiger Specific
Result<int> Detector::getDynamicRange(Positions pos) const { Result<int> Detector::getDynamicRange(Positions pos) const {
return pimpl->Parallel(&Module::setDynamicRange, pos, -1); return pimpl->Parallel(&Module::getDynamicRange, pos);
} }
void Detector::setDynamicRange(int value) { void Detector::setDynamicRange(int value) {

View File

@ -462,6 +462,7 @@ void DetectorImpl::readFrameFromReceiver() {
std::string currentFileName; std::string currentFileName;
uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1, uint64_t currentAcquisitionIndex = -1, currentFrameIndex = -1,
currentFileIndex = -1; currentFileIndex = -1;
int currentProgress = -1;
uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1, uint32_t currentSubFrameIndex = -1, coordX = -1, coordY = -1,
flippedDataX = -1; flippedDataX = -1;
@ -540,6 +541,7 @@ void DetectorImpl::readFrameFromReceiver() {
currentFileName = zHeader.fname; currentFileName = zHeader.fname;
currentAcquisitionIndex = zHeader.acqIndex; currentAcquisitionIndex = zHeader.acqIndex;
currentFrameIndex = zHeader.frameIndex; currentFrameIndex = zHeader.frameIndex;
currentProgress = zHeader.progress;
currentFileIndex = zHeader.fileIndex; currentFileIndex = zHeader.fileIndex;
currentSubFrameIndex = zHeader.expLength; currentSubFrameIndex = zHeader.expLength;
coordY = zHeader.row; coordY = zHeader.row;
@ -559,6 +561,7 @@ void DetectorImpl::readFrameFromReceiver() {
<< "\n\tcurrentFrameIndex: " << currentFrameIndex << "\n\tcurrentFrameIndex: " << currentFrameIndex
<< "\n\tcurrentFileIndex: " << currentFileIndex << "\n\tcurrentFileIndex: " << currentFileIndex
<< "\n\tcurrentSubFrameIndex: " << currentSubFrameIndex << "\n\tcurrentSubFrameIndex: " << currentSubFrameIndex
<< "\n\tcurrentProgress: " << currentProgress
<< "\n\tcoordX: " << coordX << "\n\tcoordY: " << coordY << "\n\tcoordX: " << coordX << "\n\tcoordY: " << coordY
<< "\n\tflippedDataX: " << flippedDataX << "\n\tflippedDataX: " << flippedDataX
<< "\n\tcompleteImage: " << completeImage; << "\n\tcompleteImage: " << completeImage;
@ -613,7 +616,6 @@ void DetectorImpl::readFrameFromReceiver() {
// send data to callback // send data to callback
if (data) { if (data) {
setCurrentProgress(currentFrameIndex + 1);
char* image = multiframe; char* image = multiframe;
int imagesize = multisize; int imagesize = multisize;
@ -630,7 +632,7 @@ void DetectorImpl::readFrameFromReceiver() {
<< "\n\timagesize: " << imagesize << "\n\timagesize: " << imagesize
<< "\n\tdynamicRange: " << dynamicRange; << "\n\tdynamicRange: " << dynamicRange;
thisData = new detectorData(getCurrentProgress(), thisData = new detectorData(currentProgress,
currentFileName, nDetPixelsX, nDetPixelsY, image, currentFileName, nDetPixelsX, nDetPixelsY, image,
imagesize, dynamicRange, currentFileIndex, completeImage); imagesize, dynamicRange, currentFileIndex, completeImage);
@ -1004,38 +1006,6 @@ void DetectorImpl::registerDataCallback(void (*userCallback)(detectorData *,
enableDataStreamingToClient(dataReady == nullptr ? 0 : 1); enableDataStreamingToClient(dataReady == nullptr ? 0 : 1);
} }
double DetectorImpl::setTotalProgress() {
int64_t tot = Parallel(&Module::getTotalNumFramesToReceive, {})
.tsquash("Inconsistent number of total frames (#frames x #triggers(or bursts) x #storage cells)");
if (tot == 0) {
throw RuntimeError("Invalid Total Number of frames (0)");
}
totalProgress = tot;
LOG(logDEBUG1) << "Set total progress " << totalProgress << std::endl;
return totalProgress;
}
double DetectorImpl::getCurrentProgress() {
std::lock_guard<std::mutex> lock(mp);
return 100. * progressIndex / totalProgress;
}
void DetectorImpl::incrementProgress() {
std::lock_guard<std::mutex> lock(mp);
progressIndex += 1;
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
<< 100. * progressIndex / totalProgress << " \%";
std::cout << '\r' << std::flush;
}
void DetectorImpl::setCurrentProgress(int64_t i) {
std::lock_guard<std::mutex> lock(mp);
progressIndex = (double)i;
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
<< 100. * progressIndex / totalProgress << " \%";
std::cout << '\r' << std::flush;
}
int DetectorImpl::acquire() { int DetectorImpl::acquire() {
// ensure acquire isnt started multiple times by same client // ensure acquire isnt started multiple times by same client
if (!isAcquireReady()) { if (!isAcquireReady()) {
@ -1056,7 +1026,7 @@ int DetectorImpl::acquire() {
bool receiver = bool receiver =
Parallel(&Module::getUseReceiverFlag, {}).squash(false); Parallel(&Module::getUseReceiverFlag, {}).squash(false);
progressIndex = 0;
setJoinThreadFlag(false); setJoinThreadFlag(false);
// verify receiver is idle // verify receiver is idle
@ -1066,7 +1036,6 @@ int DetectorImpl::acquire() {
Parallel(&Module::stopReceiver, {}); Parallel(&Module::stopReceiver, {});
} }
} }
setTotalProgress();
startProcessingThread(); startProcessingThread();
@ -1106,12 +1075,10 @@ int DetectorImpl::acquire() {
dataProcessingThread.join(); dataProcessingThread.join();
if (acquisition_finished != nullptr) { if (acquisition_finished != nullptr) {
// same status for all, else error int status = Parallel(&Module::getRunStatus, {}).squash(ERROR);
int status = static_cast<int>(ERROR); auto a = Parallel(&Module::getReceiverProgress, {});
auto t = Parallel(&Module::getRunStatus, {}); int progress = (*std::min_element (a.begin(), a.end()));
if (t.equal()) acquisition_finished((double)progress, status, acqFinished_p);
status = t.front();
acquisition_finished(getCurrentProgress(), status, acqFinished_p);
} }
sem_destroy(&sem_newRTAcquisition); sem_destroy(&sem_newRTAcquisition);
@ -1130,8 +1097,14 @@ int DetectorImpl::acquire() {
return OK; return OK;
} }
void DetectorImpl::printProgress(double progress) {
std::cout << std::fixed << std::setprecision(2) << std::setw(6)
<< progress << " \%";
std::cout << '\r' << std::flush;
}
void DetectorImpl::startProcessingThread() { void DetectorImpl::startProcessingThread() {
setTotalProgress();
dataProcessingThread = std::thread(&DetectorImpl::processData, this); dataProcessingThread = std::thread(&DetectorImpl::processData, this);
} }
@ -1142,7 +1115,9 @@ void DetectorImpl::processData() {
} }
// only update progress // only update progress
else { else {
int64_t caught = -1; double progress = 0;
printProgress(progress);
while (true) { while (true) {
// to exit acquire by typing q // to exit acquire by typing q
if (kbhit() != 0) { if (kbhit() != 0) {
@ -1152,16 +1127,18 @@ void DetectorImpl::processData() {
Parallel(&Module::stopAcquisition, {}); Parallel(&Module::stopAcquisition, {});
} }
} }
// get progress // get and print progress
caught = Parallel(&Module::getFramesCaughtByReceiver, {0}) double temp = (double)Parallel(&Module::getReceiverProgress, {0}).squash();
.squash(); if (temp != progress) {
printProgress(progress);
// updating progress progress = temp;
if (caught != -1) {
setCurrentProgress(caught);
} }
// exiting loop // exiting loop
if (getJoinThreadFlag()) { if (getJoinThreadFlag()) {
// print progress one final time before exiting
progress = (double)Parallel(&Module::getReceiverProgress, {0}).squash();
printProgress(progress);
break; break;
} }
// otherwise error when connecting to the receiver too fast // otherwise error when connecting to the receiver too fast

View File

@ -354,13 +354,7 @@ class DetectorImpl : public virtual slsDetectorDefs {
int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr, int InsertGapPixels(char *image, char *&gpImage, bool quadEnable, int dr,
int &nPixelsx, int &nPixelsy); int &nPixelsx, int &nPixelsy);
double setTotalProgress(); void printProgress(double progress);
double getCurrentProgress();
void incrementProgress();
void setCurrentProgress(int64_t i = 0);
void startProcessingThread(); void startProcessingThread();
@ -405,12 +399,6 @@ class DetectorImpl : public virtual slsDetectorDefs {
* from ext. process) */ * from ext. process) */
sem_t sem_endRTAcquisition; sem_t sem_endRTAcquisition;
/** Total number of frames/images for next acquisition */
double totalProgress{0};
/** Current progress or frames/images processed in current acquisition */
double progressIndex{0};
/** mutex to synchronize main and data processing threads */ /** mutex to synchronize main and data processing threads */
mutable std::mutex mp; mutable std::mutex mp;

View File

@ -396,14 +396,6 @@ void Module::initializeDetectorStructure(detectorType type) {
shm()->controlPort = DEFAULT_PORTNO; shm()->controlPort = DEFAULT_PORTNO;
shm()->stopPort = DEFAULT_PORTNO + 1; shm()->stopPort = DEFAULT_PORTNO + 1;
sls::strcpy_safe(shm()->settingsDir, getenv("HOME")); sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
shm()->currentSettings = UNINITIALIZED;
shm()->nFrames = 1;
shm()->nTriggers = 1;
shm()->nBursts = 1;
shm()->nAddStorageCells = 0;
shm()->timingMode = AUTO_TIMING;
shm()->burstMode = BURST_INTERNAL;
shm()->deadTime = 0;
sls::strcpy_safe(shm()->rxHostname, "none"); sls::strcpy_safe(shm()->rxHostname, "none");
shm()->rxTCPPort = DEFAULT_PORTNO + 2; shm()->rxTCPPort = DEFAULT_PORTNO + 2;
shm()->useReceiverFlag = false; shm()->useReceiverFlag = false;
@ -420,7 +412,6 @@ void Module::initializeDetectorStructure(detectorType type) {
shm()->nChip.x = parameters.nChipX; shm()->nChip.x = parameters.nChipX;
shm()->nChip.y = parameters.nChipY; shm()->nChip.y = parameters.nChipY;
shm()->nDacs = parameters.nDacs; shm()->nDacs = parameters.nDacs;
shm()->dynamicRange = parameters.dynamicRange;
} }
int Module::sendModule(sls_detector_module *myMod, int Module::sendModule(sls_detector_module *myMod,
@ -719,54 +710,11 @@ void Module::updateCachedDetectorVariables() {
if (client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0) == if (client.sendCommandThenRead(fnum, nullptr, 0, nullptr, 0) ==
FORCE_UPDATE) { FORCE_UPDATE) {
int n = 0, i32 = 0; int n = 0, i32 = 0;
int64_t i64 = 0;
sls::IpAddr lastClientIP; sls::IpAddr lastClientIP;
n += client.Receive(&lastClientIP, sizeof(lastClientIP)); n += client.Receive(&lastClientIP, sizeof(lastClientIP));
LOG(logDEBUG1) LOG(logDEBUG1)
<< "Updating detector last modified by " << lastClientIP; << "Updating detector last modified by " << lastClientIP;
// dr
n += client.Receive(&i32, sizeof(i32));
shm()->dynamicRange = i32;
// settings
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == JUNGFRAU ||
shm()->myDetectorType == GOTTHARD || shm()->myDetectorType == GOTTHARD2 ||
shm()->myDetectorType == MOENCH) {
n += client.Receive(&i32, sizeof(i32));
shm()->currentSettings = static_cast<detectorSettings>(i32);
}
// frame number
n += client.Receive(&i64, sizeof(i64));
shm()->nFrames = i64;
// storage cell
if (shm()->myDetectorType == JUNGFRAU) {
n += client.Receive(&i64, sizeof(i64));
shm()->nAddStorageCells = i64;
}
// triggers
n += client.Receive(&i64, sizeof(i64));
shm()->nTriggers = i64;
// bursts
if (shm()->myDetectorType == GOTTHARD2) {
n += client.Receive(&i64, sizeof(i64));
shm()->nBursts = i64;
}
// timing mode
n += client.Receive(&i32, sizeof(i32));
shm()->timingMode = static_cast<timingMode>(i32);
// burst mode
if (shm()->myDetectorType == GOTTHARD2) {
n += client.Receive(&i32, sizeof(i32));
shm()->burstMode = static_cast<burstMode>(i32);
}
// number of channels (depends on #samples, adcmask) // number of channels (depends on #samples, adcmask)
if (shm()->myDetectorType == CHIPTESTBOARD || if (shm()->myDetectorType == CHIPTESTBOARD ||
shm()->myDetectorType == MOENCH) { shm()->myDetectorType == MOENCH) {
@ -863,49 +811,21 @@ std::vector<std::string> Module::getConfigFileCommands() {
} }
slsDetectorDefs::detectorSettings Module::getSettings() { slsDetectorDefs::detectorSettings Module::getSettings() {
return sendSettingsOnly(GET_SETTINGS); int arg = -1;
int retval = -1;
sendToDetector(F_SET_SETTINGS, arg, retval);
LOG(logDEBUG1) << "Settings: " << retval;
return static_cast<detectorSettings>(retval);
} }
slsDetectorDefs::detectorSettings void Module::setSettings(detectorSettings isettings) {
Module::setSettings(detectorSettings isettings) {
LOG(logDEBUG1) << "Module setSettings " << isettings;
if (isettings == -1) {
return getSettings();
}
// eiger: only set shm, setting threshold loads the module data
if (shm()->myDetectorType == EIGER) { if (shm()->myDetectorType == EIGER) {
switch (isettings) { throw RuntimeError("Cannot set settings for Eiger. Use threshold energy.");
case STANDARD:
case HIGHGAIN:
case LOWGAIN:
case VERYHIGHGAIN:
case VERYLOWGAIN:
shm()->currentSettings = isettings;
return shm()->currentSettings;
default:
std::ostringstream ss;
ss << "Unknown settings " << ToString(isettings)
<< " for this detector!";
throw RuntimeError(ss.str());
}
} }
// others: send only the settings, detector server will update dac values
// already in server
return sendSettingsOnly(isettings);
}
slsDetectorDefs::detectorSettings
Module::sendSettingsOnly(detectorSettings isettings) {
int arg = static_cast<int>(isettings); int arg = static_cast<int>(isettings);
int retval = -1; int retval = -1;
LOG(logDEBUG1) << "Setting settings to " << arg; LOG(logDEBUG1) << "Setting settings to " << arg;
sendToDetector(F_SET_SETTINGS, arg, retval); sendToDetector(F_SET_SETTINGS, arg, retval);
LOG(logDEBUG1) << "Settings: " << retval;
shm()->currentSettings = static_cast<detectorSettings>(retval);
return shm()->currentSettings;
} }
int Module::getThresholdEnergy() { int Module::getThresholdEnergy() {
@ -944,8 +864,11 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
else if (shm()->myDetectorType == MOENCH) { else if (shm()->myDetectorType == MOENCH) {
setAdditionalJsonParameter("threshold", std::to_string(e_eV)); setAdditionalJsonParameter("threshold", std::to_string(e_eV));
} }
throw RuntimeError(
else {
throw RuntimeError(
"Set threshold energy not implemented for this detector"); "Set threshold energy not implemented for this detector");
}
} }
void Module::setThresholdEnergyAndSettings(int e_eV, void Module::setThresholdEnergyAndSettings(int e_eV,
@ -954,7 +877,7 @@ void Module::setThresholdEnergyAndSettings(int e_eV,
// if settings provided, use that, else use the shared memory variable // if settings provided, use that, else use the shared memory variable
detectorSettings is = detectorSettings is =
((isettings != GET_SETTINGS) ? isettings : shm()->currentSettings); ((isettings != GET_SETTINGS) ? isettings : getSettings());
// verify e_eV exists in trimEneregies[] // verify e_eV exists in trimEneregies[]
if (shm()->trimEnergies.empty() || (e_eV < shm()->trimEnergies.front()) || if (shm()->trimEnergies.empty() || (e_eV < shm()->trimEnergies.front()) ||
@ -999,8 +922,7 @@ void Module::setThresholdEnergyAndSettings(int e_eV,
linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau); linearInterpolation(e_eV, trim1, trim2, myMod1.tau, myMod2.tau);
} }
shm()->currentSettings = is; myMod.reg = is;
myMod.reg = shm()->currentSettings;
myMod.eV = e_eV; myMod.eV = e_eV;
setModule(myMod, tb); setModule(myMod, tb);
if (getSettings() != is) { if (getSettings() != is) {
@ -1161,101 +1083,64 @@ uint64_t Module::getStartingFrameNumber() {
return retval; return retval;
} }
int64_t Module::getTotalNumFramesToReceive() {
int64_t repeats = shm()->nTriggers;
// gotthard2 & auto & burst mode, use nBursts instead of nTriggers
if (shm()->myDetectorType == GOTTHARD2) {
// auto mode (either bursts or no repeats)
if (shm()->timingMode == AUTO_TIMING) {
if (shm()->burstMode != BURST_OFF) {
repeats = shm()->nBursts;
} else {
repeats = 1;
}
}
}
return (shm()->nFrames * repeats * (int64_t)(shm()->nAddStorageCells + 1));
}
void Module::sendTotalNumFramestoReceiver() {
if (shm()->useReceiverFlag) {
int64_t arg = getTotalNumFramesToReceive();
LOG(logDEBUG1) << "Sending total number of frames (#f x #t x #s) to Receiver: " << arg;
sendToReceiver(F_RECEIVER_SET_NUM_FRAMES, arg, nullptr);
}
}
int64_t Module::getNumberOfFrames() { int64_t Module::getNumberOfFrames() {
int64_t retval = -1; int64_t retval = -1;
sendToDetector(F_GET_NUM_FRAMES, nullptr, retval); sendToDetector(F_GET_NUM_FRAMES, nullptr, retval);
LOG(logDEBUG1) << "number of frames :" << retval; LOG(logDEBUG1) << "number of frames :" << retval;
if (shm()->nFrames != retval) { return retval;
shm()->nFrames = retval;
sendTotalNumFramestoReceiver();
}
return shm()->nFrames;
} }
void Module::setNumberOfFrames(int64_t value) { void Module::setNumberOfFrames(int64_t value) {
LOG(logDEBUG1) << "Setting number of frames to " << value; LOG(logDEBUG1) << "Setting number of frames to " << value;
sendToDetector(F_SET_NUM_FRAMES, value, nullptr); sendToDetector(F_SET_NUM_FRAMES, value, nullptr);
shm()->nFrames = value; if (shm()->useReceiverFlag) {
sendTotalNumFramestoReceiver(); LOG(logDEBUG1) << "Sending number of frames to Receiver: " << value;
sendToReceiver(F_RECEIVER_SET_NUM_FRAMES, value, nullptr);
}
} }
int64_t Module::getNumberOfTriggers() { int64_t Module::getNumberOfTriggers() {
int64_t retval = -1; int64_t retval = -1;
sendToDetector(F_GET_NUM_TRIGGERS, nullptr, retval); sendToDetector(F_GET_NUM_TRIGGERS, nullptr, retval);
LOG(logDEBUG1) << "number of triggers :" << retval; LOG(logDEBUG1) << "number of triggers :" << retval;
if (shm()->nTriggers != retval) { return retval;
shm()->nTriggers = retval;
sendTotalNumFramestoReceiver();
}
return shm()->nTriggers;
} }
void Module::setNumberOfTriggers(int64_t value) { void Module::setNumberOfTriggers(int64_t value) {
LOG(logDEBUG1) << "Setting number of triggers to " << value; LOG(logDEBUG1) << "Setting number of triggers to " << value;
sendToDetector(F_SET_NUM_TRIGGERS, value, nullptr); sendToDetector(F_SET_NUM_TRIGGERS, value, nullptr);
shm()->nTriggers = value; if (shm()->useReceiverFlag) {
sendTotalNumFramestoReceiver(); LOG(logDEBUG1) << "Sending number of triggers to Receiver: " << value;
sendToReceiver(F_SET_RECEIVER_NUM_TRIGGERS, value, nullptr);
}
} }
int64_t Module::getNumberOfBursts() { int64_t Module::getNumberOfBursts() {
int64_t retval = -1; int64_t retval = -1;
sendToDetector(F_GET_NUM_BURSTS, nullptr, retval); sendToDetector(F_GET_NUM_BURSTS, nullptr, retval);
LOG(logDEBUG1) << "number of bursts :" << retval; LOG(logDEBUG1) << "number of bursts :" << retval;
if (shm()->nBursts != retval) { return retval;
shm()->nBursts = retval;
sendTotalNumFramestoReceiver();
}
return shm()->nBursts;
} }
void Module::setNumberOfBursts(int64_t value) { void Module::setNumberOfBursts(int64_t value) {
LOG(logDEBUG1) << "Setting number of bursts to " << value; LOG(logDEBUG1) << "Setting number of bursts to " << value;
sendToDetector(F_SET_NUM_BURSTS, value, nullptr); sendToDetector(F_SET_NUM_BURSTS, value, nullptr);
shm()->nBursts = value; if (shm()->useReceiverFlag) {
sendTotalNumFramestoReceiver(); LOG(logDEBUG1) << "Sending number of bursts to Receiver: " << value;
sendToReceiver(F_SET_RECEIVER_NUM_BURSTS, value, nullptr);
}
} }
int Module::getNumberOfAdditionalStorageCells() { int Module::getNumberOfAdditionalStorageCells() {
int prevVal = shm()->nAddStorageCells;
int retval = -1; int retval = -1;
sendToDetector(F_GET_NUM_ADDITIONAL_STORAGE_CELLS, nullptr, retval); sendToDetector(F_GET_NUM_ADDITIONAL_STORAGE_CELLS, nullptr, retval);
LOG(logDEBUG1) << "number of storage cells :" << retval; LOG(logDEBUG1) << "number of storage cells :" << retval;
shm()->nAddStorageCells = retval; return retval;
if (prevVal != retval) {
sendTotalNumFramestoReceiver();
}
return shm()->nAddStorageCells;
} }
void Module::setNumberOfAdditionalStorageCells(int value) { void Module::setNumberOfAdditionalStorageCells(int value) {
LOG(logDEBUG1) << "Setting number of storage cells to " << value; LOG(logDEBUG1) << "Setting number of storage cells to " << value;
sendToDetector(F_SET_NUM_ADDITIONAL_STORAGE_CELLS, value, nullptr); sendToDetector(F_SET_NUM_ADDITIONAL_STORAGE_CELLS, value, nullptr);
shm()->nAddStorageCells = value;
sendTotalNumFramestoReceiver();
} }
int Module::getNumberOfAnalogSamples() { int Module::getNumberOfAnalogSamples() {
@ -1305,16 +1190,13 @@ void Module::setExptime(int64_t value) {
} }
LOG(logDEBUG1) << "Setting exptime to " << value << "ns"; LOG(logDEBUG1) << "Setting exptime to " << value << "ns";
sendToDetector(F_SET_EXPTIME, value, nullptr); 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) { if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending exptime to Receiver: " << value; LOG(logDEBUG1) << "Sending exptime to Receiver: " << value;
sendToReceiver(F_RECEIVER_SET_EXPTIME, value, nullptr); sendToReceiver(F_RECEIVER_SET_EXPTIME, value, nullptr);
} }
if (prevVal != value) {
updateRateCorrection();
}
} }
int64_t Module::getPeriod() { int64_t Module::getPeriod() {
@ -1358,17 +1240,14 @@ void Module::setSubExptime(int64_t value) {
prevVal = getSubExptime(); prevVal = getSubExptime();
} }
LOG(logDEBUG1) << "Setting sub exptime to " << value << "ns"; LOG(logDEBUG1) << "Setting sub exptime to " << value << "ns";
sendToDetector(F_SET_SUB_EXPTIME, value, nullptr); 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) { if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending sub exptime to Receiver: " << value; LOG(logDEBUG1) << "Sending sub exptime to Receiver: " << value;
sendToReceiver(F_RECEIVER_SET_SUB_EXPTIME, value, nullptr); sendToReceiver(F_RECEIVER_SET_SUB_EXPTIME, value, nullptr);
} }
if (prevVal != value) {
updateRateCorrection();
}
} }
int64_t Module::getSubDeadTime() { int64_t Module::getSubDeadTime() {
@ -1466,48 +1345,68 @@ int64_t Module::getMeasurementTime() const {
return retval; return retval;
} }
slsDetectorDefs::timingMode Module::setTimingMode(timingMode value) { slsDetectorDefs::timingMode Module::getTimingMode() {
int fnum = F_SET_TIMING_MODE; int arg = -1;
//auto arg = static_cast<int>(pol);
timingMode retval = GET_TIMING_MODE; timingMode retval = GET_TIMING_MODE;
LOG(logDEBUG1) << "Setting communication to mode " << value; sendToDetector(F_SET_TIMING_MODE, arg, retval);
sendToDetector(fnum, static_cast<int>(value), retval);
LOG(logDEBUG1) << "Timing Mode: " << retval; LOG(logDEBUG1) << "Timing Mode: " << retval;
shm()->timingMode = retval;
return retval; return retval;
} }
int Module::setDynamicRange(int n) { void Module::setTimingMode(timingMode value) {
// TODO! Properly handle fail timingMode retval = GET_TIMING_MODE;
int prevDr = shm()->dynamicRange; LOG(logDEBUG1) << "Setting timing mode to " << value;
sendToDetector(F_SET_TIMING_MODE, static_cast<int>(value), retval);
if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending timing mode to Receiver: " << value;
sendToReceiver(F_SET_RECEIVER_TIMING_MODE, value, nullptr);
}
}
int Module::getDynamicRange() {
int arg = -1;
int retval = -1;
sendToDetector(F_SET_DYNAMIC_RANGE, arg, retval);
LOG(logDEBUG1) << "Dynamic Range: " << retval;
return retval;
}
void Module::setDynamicRange(int n) {
int prev_val = n;
if (shm()->myDetectorType == EIGER) {
prev_val = getDynamicRange();
}
int retval = -1; int retval = -1;
LOG(logDEBUG1) << "Setting dynamic range to " << n; LOG(logDEBUG1) << "Setting dynamic range to " << n;
sendToDetector(F_SET_DYNAMIC_RANGE, n, retval); sendToDetector(F_SET_DYNAMIC_RANGE, n, retval);
LOG(logDEBUG1) << "Dynamic Range: " << retval; LOG(logDEBUG1) << "Dynamic Range: " << retval;
shm()->dynamicRange = retval;
if (shm()->useReceiverFlag) { if (shm()->useReceiverFlag) {
n = shm()->dynamicRange; int arg = retval;
retval = -1; retval = -1;
LOG(logDEBUG1) << "Sending dynamic range to receiver: " << n; LOG(logDEBUG1) << "Sending dynamic range to receiver: " << arg;
sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, n, retval); sendToReceiver(F_SET_RECEIVER_DYNAMIC_RANGE, arg, retval);
LOG(logDEBUG1) << "Receiver Dynamic range: " << retval; LOG(logDEBUG1) << "Receiver Dynamic range: " << retval;
} }
// changes in dr // changes in dr
int dr = shm()->dynamicRange; if (n != prev_val) {
if (prevDr != dr && shm()->myDetectorType == EIGER) {
updateRateCorrection();
// update speed for usability // update speed for usability
if (dr == 32) { switch (n) {
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32"; setClockDivider(RUN_CLOCK, 2); case 32:
} else { LOG(logINFO) << "Setting Clock to Quarter Speed to cope with Dynamic Range of 32";
LOG(logINFO) << "Setting Clock to Full Speed to cope with Dynamic Range of " << dr; setClockDivider(RUN_CLOCK, 0); setClockDivider(RUN_CLOCK, 2);
break;
case 16:
LOG(logINFO) << "Setting Clock to Full Speed to cope with Dynamic Range of " << n;
setClockDivider(RUN_CLOCK, 0);
break;
default:
break;
} }
updateRateCorrection();
} }
return shm()->dynamicRange;
} }
int Module::setDAC(int val, dacIndex index, int mV) { int Module::setDAC(int val, dacIndex index, int mV) {
@ -1701,7 +1600,9 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
LOG(logDEBUG1) << printReceiverConfiguration(); LOG(logDEBUG1) << printReceiverConfiguration();
setReceiverUDPSocketBufferSize(0); setReceiverUDPSocketBufferSize(0);
sendTotalNumFramestoReceiver(); setNumberOfFrames(getNumberOfFrames());
setNumberOfTriggers(getNumberOfTriggers());
setTimingMode(getTimingMode());
setExptime(getExptime()); setExptime(getExptime());
setPeriod(getPeriod()); setPeriod(getPeriod());
@ -1711,7 +1612,7 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
case EIGER: case EIGER:
setSubExptime(getSubExptime()); setSubExptime(getSubExptime());
setSubDeadTime(getSubDeadTime()); setSubDeadTime(getSubDeadTime());
setDynamicRange(shm()->dynamicRange); setDynamicRange(getDynamicRange());
activate(-1); activate(-1);
enableTenGigabitEthernet(-1); enableTenGigabitEthernet(-1);
setQuad(getQuad()); setQuad(getQuad());
@ -1739,7 +1640,12 @@ std::string Module::setReceiverHostname(const std::string &receiverIP) {
case MYTHEN3: case MYTHEN3:
sendNumberofCounterstoReceiver(getCounterMask()); sendNumberofCounterstoReceiver(getCounterMask());
setDynamicRange(shm()->dynamicRange); setDynamicRange(getDynamicRange());
break;
case GOTTHARD2:
setNumberOfBursts(getNumberOfBursts());
setBurstMode(getBurstMode());
break; break;
default: default:
@ -2374,15 +2280,17 @@ slsDetectorDefs::burstMode Module::getBurstMode() {
int retval = -1; int retval = -1;
sendToDetector(F_GET_BURST_MODE, nullptr, retval); sendToDetector(F_GET_BURST_MODE, nullptr, retval);
LOG(logDEBUG1) << "Burst mode:" << retval; LOG(logDEBUG1) << "Burst mode:" << retval;
shm()->burstMode = static_cast<slsDetectorDefs::burstMode>(retval); return static_cast<slsDetectorDefs::burstMode>(retval);
return shm()->burstMode;
} }
void Module::setBurstMode(slsDetectorDefs::burstMode value) { void Module::setBurstMode(slsDetectorDefs::burstMode value) {
int arg = static_cast<int>(value); int arg = static_cast<int>(value);
LOG(logDEBUG1) << "Setting burst mode to " << arg; LOG(logDEBUG1) << "Setting burst mode to " << arg;
sendToDetector(F_SET_BURST_MODE, arg, nullptr); sendToDetector(F_SET_BURST_MODE, arg, nullptr);
shm()->burstMode = value; if (shm()->useReceiverFlag) {
LOG(logDEBUG1) << "Sending burst mode to Receiver: " << value;
sendToReceiver(F_SET_RECEIVER_BURST_MODE, value, nullptr);
}
} }
bool Module::getCurrentSource() { bool Module::getCurrentSource() {
@ -2950,37 +2858,23 @@ void Module::setDefaultRateCorrection() {
LOG(logDEBUG1) << "Setting Default Rate Correction"; LOG(logDEBUG1) << "Setting Default Rate Correction";
int64_t arg = -1; int64_t arg = -1;
sendToDetector(F_SET_RATE_CORRECT, arg, nullptr); sendToDetector(F_SET_RATE_CORRECT, arg, nullptr);
shm()->deadTime = -1;
} }
void Module::setRateCorrection(int64_t t) { void Module::setRateCorrection(int64_t t) {
LOG(logDEBUG1) << "Setting Rate Correction to " << t; LOG(logDEBUG1) << "Setting Rate Correction to " << t;
sendToDetector(F_SET_RATE_CORRECT, t, nullptr); sendToDetector(F_SET_RATE_CORRECT, t, nullptr);
shm()->deadTime = t;
} }
int64_t Module::getRateCorrection() { int64_t Module::getRateCorrection() {
int64_t retval = -1; int64_t retval = -1;
LOG(logDEBUG1) << "Getting rate correction";
sendToDetector(F_GET_RATE_CORRECT, nullptr, retval); sendToDetector(F_GET_RATE_CORRECT, nullptr, retval);
shm()->deadTime = retval;
LOG(logDEBUG1) << "Rate correction: " << retval; LOG(logDEBUG1) << "Rate correction: " << retval;
return retval; return retval;
} }
void Module::updateRateCorrection() { void Module::updateRateCorrection() {
if (shm()->deadTime != 0) { LOG(logDEBUG1) << "Updating rate correction";
switch (shm()->dynamicRange) { sendToDetector(F_UPDATE_RATE_CORRECTION);
case 16:
case 32:
setRateCorrection(shm()->deadTime);
break;
default:
setRateCorrection(0);
throw sls::RuntimeError(
"Rate correction Deactivated, must be in 32 or 16 bit mode");
}
}
} }
std::string Module::printReceiverConfiguration() { std::string Module::printReceiverConfiguration() {
@ -3281,6 +3175,15 @@ uint64_t Module::getReceiverCurrentFrameIndex() const {
return retval; return retval;
} }
int Module::getReceiverProgress() const {
int retval = -1;
if (shm()->useReceiverFlag) {
sendToReceiver(F_GET_RECEIVER_PROGRESS, nullptr, retval);
LOG(logDEBUG1) << "Current Progress of Receiver: " << retval;
}
return retval;
}
void Module::setFileWrite(bool value) { void Module::setFileWrite(bool value) {
if (!shm()->useReceiverFlag) { if (!shm()->useReceiverFlag) {
throw RuntimeError("Set rx_hostname first to use receiver parameters (file write enable)"); throw RuntimeError("Set rx_hostname first to use receiver parameters (file write enable)");

View File

@ -14,7 +14,7 @@
class ServerInterface; class ServerInterface;
#define SLS_SHMAPIVERSION 0x190726 #define SLS_SHMAPIVERSION 0x190726
#define SLS_SHMVERSION 0x200324 #define SLS_SHMVERSION 0x200402
namespace sls{ namespace sls{
@ -62,33 +62,6 @@ struct sharedSlsDetector {
/** number of dacs per module*/ /** number of dacs per module*/
int nDacs; int nDacs;
/** dynamic range of the detector data */
int dynamicRange;
/** detector settings (standard, fast, etc.) */
slsDetectorDefs::detectorSettings currentSettings;
/** number of frames */
int64_t nFrames;
/** number of triggers */
int64_t nTriggers;
/** number of bursts */
int64_t nBursts;
/** number of additional storage cells */
int nAddStorageCells;
/** timing mode */
slsDetectorDefs::timingMode timingMode;
/** burst mode */
slsDetectorDefs::burstMode burstMode;
/** rate correction in ns (needed for default -1) */
int64_t deadTime;
/** ip address/hostname of the receiver for client control via TCP */ /** ip address/hostname of the receiver for client control via TCP */
char rxHostname[MAX_STR_LENGTH]; char rxHostname[MAX_STR_LENGTH];
@ -309,10 +282,6 @@ class Module : public virtual slsDetectorDefs {
*/ */
std::vector<std::string> getConfigFileCommands(); std::vector<std::string> getConfigFileCommands();
/**
* Get detector settings
* @returns current settings
*/
detectorSettings getSettings(); detectorSettings getSettings();
/** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2 /** [Jungfrau] Options:DYNAMICGAIN, DYNAMICHG0, FIXGAIN1, FIXGAIN2, FORCESWITCHG1, FORCESWITCHG2
@ -320,18 +289,8 @@ class Module : public virtual slsDetectorDefs {
* [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2 * [Gotthard2] Options: DYNAMICGAIN, FIXGAIN1, FIXGAIN2
* [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN, * [Moench] Options: G1_HIGHGAIN, G1_LOWGAIN, G2_HIGHCAP_HIGHGAIN, G2_HIGHCAP_LOWGAIN,
* G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN * G2_LOWCAP_HIGHGAIN, G2_LOWCAP_LOWGAIN, G4_HIGHGAIN, G4_LOWGAIN
* [Eiger] Only stores them locally in shm Options: STANDARD, HIGHGAIN, LOWGAIN, VERYHIGHGAIN, VERYLOWGAIN
*/ */
detectorSettings setSettings(detectorSettings isettings); void setSettings(detectorSettings isettings);
/**
* Send detector settings only (set only for Jungfrau, Gotthard, Moench, get
* for all) Only the settings enum is sent to the detector, where it will
* initialize al the dacs already hard coded in the detector server
* @param isettings settings
* @returns current settings
*/
detectorSettings sendSettingsOnly(detectorSettings isettings);
/** /**
* Get threshold energy (Mythen and Eiger) * Get threshold energy (Mythen and Eiger)
@ -445,10 +404,6 @@ class Module : public virtual slsDetectorDefs {
*/ */
uint64_t getStartingFrameNumber(); uint64_t getStartingFrameNumber();
int64_t getTotalNumFramesToReceive();
void sendTotalNumFramestoReceiver();
int64_t getNumberOfFrames(); int64_t getNumberOfFrames();
void setNumberOfFrames(int64_t value); void setNumberOfFrames(int64_t value);
@ -556,22 +511,17 @@ class Module : public virtual slsDetectorDefs {
* [Gotthard2] only in continuous mode */ * [Gotthard2] only in continuous mode */
int64_t getMeasurementTime() const; int64_t getMeasurementTime() const;
/**
* Set/get timing mode
* @param value timing mode (-1 gets)
* @returns current timing mode
*/
timingMode setTimingMode(timingMode value = GET_TIMING_MODE);
timingMode getTimingMode();
void setTimingMode(timingMode value);
int getDynamicRange();
/** /**
* Set/get dynamic range * Set/get dynamic range
* (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to * (Eiger: If i is 32, also sets clkdivider to 2, if 16, sets clkdivider to
* 1) * 1)
* @param i dynamic range (-1 get)
* @returns current dynamic range
* \sa sharedSlsDetector
*/ */
int setDynamicRange(int n = -1); void setDynamicRange(int n);
/** /**
* Set/get dacs value * Set/get dacs value
@ -1467,6 +1417,7 @@ class Module : public virtual slsDetectorDefs {
* @returns current frame index of receiver * @returns current frame index of receiver
*/ */
uint64_t getReceiverCurrentFrameIndex() const; uint64_t getReceiverCurrentFrameIndex() const;
int getReceiverProgress() const;
void setFileWrite(bool value); void setFileWrite(bool value);

View File

@ -118,7 +118,12 @@ int ClientInterface::functionTable(){
flist[F_GET_RECEIVER_TYPE] = &ClientInterface::set_detector_type; flist[F_GET_RECEIVER_TYPE] = &ClientInterface::set_detector_type;
flist[F_SEND_RECEIVER_DETHOSTNAME] = &ClientInterface::set_detector_hostname; flist[F_SEND_RECEIVER_DETHOSTNAME] = &ClientInterface::set_detector_hostname;
flist[F_RECEIVER_SET_ROI] = &ClientInterface::set_roi; flist[F_RECEIVER_SET_ROI] = &ClientInterface::set_roi;
flist[F_RECEIVER_SET_NUM_FRAMES] = &ClientInterface::set_num_frames; flist[F_RECEIVER_SET_NUM_FRAMES] = &ClientInterface::set_num_frames;
flist[F_SET_RECEIVER_NUM_TRIGGERS] = &ClientInterface::set_num_triggers;
flist[F_SET_RECEIVER_NUM_BURSTS] = &ClientInterface::set_num_bursts;
flist[F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS] = &ClientInterface::set_num_add_storage_cells;
flist[F_SET_RECEIVER_TIMING_MODE] = &ClientInterface::set_timing_mode;
flist[F_SET_RECEIVER_BURST_MODE] = &ClientInterface::set_burst_mode;
flist[F_RECEIVER_SET_NUM_ANALOG_SAMPLES]= &ClientInterface::set_num_analog_samples; flist[F_RECEIVER_SET_NUM_ANALOG_SAMPLES]= &ClientInterface::set_num_analog_samples;
flist[F_RECEIVER_SET_NUM_DIGITAL_SAMPLES]= &ClientInterface::set_num_digital_samples; flist[F_RECEIVER_SET_NUM_DIGITAL_SAMPLES]= &ClientInterface::set_num_digital_samples;
flist[F_RECEIVER_SET_EXPTIME] = &ClientInterface::set_exptime; flist[F_RECEIVER_SET_EXPTIME] = &ClientInterface::set_exptime;
@ -195,7 +200,8 @@ int ClientInterface::functionTable(){
flist[F_INCREMENT_FILE_INDEX] = &ClientInterface::increment_file_index; flist[F_INCREMENT_FILE_INDEX] = &ClientInterface::increment_file_index;
flist[F_SET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::set_additional_json_parameter; flist[F_SET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::set_additional_json_parameter;
flist[F_GET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::get_additional_json_parameter; flist[F_GET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::get_additional_json_parameter;
flist[F_GET_RECEIVER_PROGRESS] = &ClientInterface::get_progress;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) { for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" << LOG(logDEBUG1) << "function fnum: " << i << " (" <<
getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i]; getFunctionNameFromEnum((enum detFuncs)i) << ") located at " << flist[i];
@ -415,8 +421,85 @@ int ClientInterface::set_roi(Interface &socket) {
int ClientInterface::set_num_frames(Interface &socket) { int ClientInterface::set_num_frames(Interface &socket) {
auto value = socket.Receive<int64_t>(); auto value = socket.Receive<int64_t>();
if (value <= 0) {
throw RuntimeError("Invalid number of frames " +
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num frames to " << value; LOG(logDEBUG1) << "Setting num frames to " << value;
impl()->setNumberOfFrames(value); impl()->setNumberOfFrames(value);
int64_t retval = impl()->getNumberOfFrames();
validate(value, retval, "set number of frames", DEC);
return socket.Send(OK);
}
int ClientInterface::set_num_triggers(Interface &socket) {
auto value = socket.Receive<int64_t>();
if (value <= 0) {
throw RuntimeError("Invalid number of triggers " +
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num triggers to " << value;
impl()->setNumberOfTriggers(value);
int64_t retval = impl()->getNumberOfTriggers();
validate(value, retval, "set number of triggers", DEC);
return socket.Send(OK);
}
int ClientInterface::set_num_bursts(Interface &socket) {
auto value = socket.Receive<int64_t>();
if (value <= 0) {
throw RuntimeError("Invalid number of bursts " +
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num bursts to " << value;
impl()->setNumberOfBursts(value);
int64_t retval = impl()->getNumberOfBursts();
validate(value, retval, "set number of bursts", DEC);
return socket.Send(OK);
}
int ClientInterface::set_num_add_storage_cells(Interface &socket) {
auto value = socket.Receive<int>();
if (value < 0) {
throw RuntimeError("Invalid number of additional storage cells " +
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting num additional storage cells to " << value;
impl()->setNumberOfAdditionalStorageCells(value);
int retval = impl()->getNumberOfAdditionalStorageCells();
validate(value, retval, "set number of additional storage cells", DEC);
return socket.Send(OK);
}
int ClientInterface::set_timing_mode(Interface &socket) {
auto value = socket.Receive<int>();
if (value < 0 || value >= NUM_TIMING_MODES) {
throw RuntimeError("Invalid timing mode " +
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting timing mode to " << value;
impl()->setTimingMode(static_cast<timingMode>(value));
int retval = impl()->getTimingMode();
validate(value, retval, "set timing mode", DEC);
return socket.Send(OK);
}
int ClientInterface::set_burst_mode(Interface &socket) {
auto value = socket.Receive<int>();
if (value < 0 || value >= NUM_BURST_MODES) {
throw RuntimeError("Invalid burst mode " +
std::to_string(value));
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting burst mode to " << value;
impl()->setBurstMode(static_cast<burstMode>(value));
int retval = impl()->getBurstMode();
validate(value, retval, "set burst mode", DEC);
return socket.Send(OK); return socket.Send(OK);
} }
@ -1425,3 +1508,9 @@ int ClientInterface::get_additional_json_parameter(Interface &socket) {
LOG(logDEBUG1) << "additional json parameter (" << arg << "):" << retval; LOG(logDEBUG1) << "additional json parameter (" << arg << "):" << retval;
return socket.sendResult(retval); return socket.sendResult(retval);
} }
int ClientInterface::get_progress(Interface &socket) {
int retval = impl()->getProgress();
LOG(logDEBUG1) << "progress retval: " << retval;
return socket.sendResult(retval);
}

View File

@ -60,6 +60,11 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_detector_hostname(sls::ServerInterface &socket); int set_detector_hostname(sls::ServerInterface &socket);
int set_roi(sls::ServerInterface &socket); int set_roi(sls::ServerInterface &socket);
int set_num_frames(sls::ServerInterface &socket); int set_num_frames(sls::ServerInterface &socket);
int set_num_triggers(sls::ServerInterface &socket);
int set_num_bursts(sls::ServerInterface &socket);
int set_num_add_storage_cells(sls::ServerInterface &socket);
int set_timing_mode(sls::ServerInterface &socket);
int set_burst_mode(sls::ServerInterface &socket);
int set_num_analog_samples(sls::ServerInterface &socket); int set_num_analog_samples(sls::ServerInterface &socket);
int set_num_digital_samples(sls::ServerInterface &socket); int set_num_digital_samples(sls::ServerInterface &socket);
int set_exptime(sls::ServerInterface &socket); int set_exptime(sls::ServerInterface &socket);
@ -137,6 +142,8 @@ class ClientInterface : private virtual slsDetectorDefs {
int increment_file_index(sls::ServerInterface &socket); int increment_file_index(sls::ServerInterface &socket);
int set_additional_json_parameter(sls::ServerInterface &socket); int set_additional_json_parameter(sls::ServerInterface &socket);
int get_additional_json_parameter(sls::ServerInterface &socket); int get_additional_json_parameter(sls::ServerInterface &socket);
int get_progress(sls::ServerInterface &socket);
Implementation *impl() { Implementation *impl() {
if (receiver != nullptr) { if (receiver != nullptr) {

View File

@ -17,7 +17,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r, DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, int* nd, bool* qe) : uint64_t* fi, int fd, int* nd, bool* qe, uint64_t* tot) :
ThreadObject(ind, TypeName), ThreadObject(ind, TypeName),
runningFlag(0), runningFlag(0),
generalData(nullptr), generalData(nullptr),
@ -31,7 +31,8 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
startedFlag(false), startedFlag(false),
firstIndex(0), firstIndex(0),
completeBuffer(nullptr), completeBuffer(nullptr),
quadEnable(qe) quadEnable(qe),
totalNumFrames(tot)
{ {
numDet[0] = nd[0]; numDet[0] = nd[0];
numDet[1] = nd[1]; numDet[1] = nd[1];
@ -241,6 +242,7 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
zHeader.imageSize = size; zHeader.imageSize = size;
zHeader.acqIndex = acquisitionIndex; zHeader.acqIndex = acquisitionIndex;
zHeader.frameIndex = frameIndex; zHeader.frameIndex = frameIndex;
zHeader.progress = 100 * ((double)(frameIndex + 1) / (double)(*totalNumFrames));
zHeader.fname = fileNametoStream; zHeader.fname = fileNametoStream;
zHeader.frameNumber = header.frameNumber; zHeader.frameNumber = header.frameNumber;
zHeader.expLength = header.expLength; zHeader.expLength = header.expLength;

View File

@ -31,9 +31,10 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param fd flipped data enable for x dimension * @param fd flipped data enable for x dimension
* @param nd pointer to number of detectors in each dimension * @param nd pointer to number of detectors in each dimension
* @param qe pointer to quad Enable * @param qe pointer to quad Enable
* @param tot pointer to total number of frames
*/ */
DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r, DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, int* nd, bool* qe); uint64_t* fi, int fd, int* nd, bool* qe, uint64_t* tot);
/** /**
* Destructor * Destructor
@ -207,5 +208,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
/** Quad Enable */ /** Quad Enable */
bool* quadEnable; bool* quadEnable;
/** Total number of frames */
uint64_t* totalNumFrames;
}; };

View File

@ -95,7 +95,13 @@ void Implementation::InitializeMembers() {
streamingSrcIP = sls::IpAddr{}; streamingSrcIP = sls::IpAddr{};
// detector parameters // detector parameters
numberOfFrames = 0; numberOfTotalFrames = 0;
numberOfFrames = 1;
numberOfTriggers = 1;
numberOfBursts = 1;
numberOfAdditionalStorageCells = 0;
timingMode = AUTO_TIMING;
burstMode = BURST_OFF;
acquisitionPeriod = SAMPLE_TIME_IN_NS; acquisitionPeriod = SAMPLE_TIME_IN_NS;
acquisitionTime = 0; acquisitionTime = 0;
subExpTime = 0; subExpTime = 0;
@ -267,7 +273,7 @@ void Implementation::setDetectorType(const detectorType d) {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, myDetectorType, fifo_ptr, &status, &udpPortNum[i], &eth[i], i, myDetectorType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&numberOfFrames, &dynamicRange, &udpSocketBufferSize, &numberOfTotalFrames, &dynamicRange, &udpSocketBufferSize,
&actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode, &actualUDPSocketBufferSize, &framesPerFile, &frameDiscardMode,
&activated, &deactivatedPaddingEnable, &silentMode)); &activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>( dataProcessor.push_back(sls::make_unique<DataProcessor>(
@ -347,7 +353,7 @@ void Implementation::setDetectorPositionId(const int id) {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) { for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
dataProcessor[i]->SetupFileWriter( dataProcessor[i]->SetupFileWriter(
fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, &filePath, fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, &filePath,
&fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfFrames, &fileIndex, &overwriteEnable, &detID, &numThreads, &numberOfTotalFrames,
&dynamicRange, &udpPortNum[i], generalData); &dynamicRange, &udpPortNum[i], generalData);
} }
assert(numDet[1] != 0); assert(numDet[1] != 0);
@ -508,7 +514,7 @@ void Implementation::setFileWriteEnable(const bool b) {
dataProcessor[i]->SetupFileWriter( dataProcessor[i]->SetupFileWriter(
fileWriteEnable, (int *)numDet, &framesPerFile, &fileName, fileWriteEnable, (int *)numDet, &framesPerFile, &fileName,
&filePath, &fileIndex, &overwriteEnable, &detID, &numThreads, &filePath, &fileIndex, &overwriteEnable, &detID, &numThreads,
&numberOfFrames, &dynamicRange, &udpPortNum[i], generalData); &numberOfTotalFrames, &dynamicRange, &udpPortNum[i], generalData);
} }
} }
@ -594,6 +600,24 @@ uint64_t Implementation::getAcquisitionIndex() const {
return min; return min;
} }
int Implementation::getProgress() const {
// get minimum of processed frame indices
uint64_t currentFrameIndex = -1;
uint32_t flagsum = 0;
for (const auto &it : dataProcessor) {
flagsum += it->GetStartedFlag();
uint64_t curr = it->GetProcessedIndex();
currentFrameIndex = curr < currentFrameIndex ? curr : currentFrameIndex;
}
// no data processed
if (flagsum != dataProcessor.size()) {
currentFrameIndex = -1;
}
return (100.00 * ((double)(currentFrameIndex + 1) / (double)numberOfTotalFrames));
}
std::vector<uint64_t> Implementation::getNumMissingPackets() const { std::vector<uint64_t> Implementation::getNumMissingPackets() const {
std::vector<uint64_t> mp(numThreads); std::vector<uint64_t> mp(numThreads);
for (int i = 0; i < numThreads; i++) { for (int i = 0; i < numThreads; i++) {
@ -603,7 +627,7 @@ std::vector<uint64_t> Implementation::getNumMissingPackets() const {
if (numLinesReadout != MAX_EIGER_ROWS_PER_READOUT) { if (numLinesReadout != MAX_EIGER_ROWS_PER_READOUT) {
totnp = ((numLinesReadout * np) / MAX_EIGER_ROWS_PER_READOUT); totnp = ((numLinesReadout * np) / MAX_EIGER_ROWS_PER_READOUT);
} }
totnp *= numberOfFrames; totnp *= numberOfTotalFrames;
mp[i] = listener[i]->GetNumMissingPacket(stoppedFlag, totnp); mp[i] = listener[i]->GetNumMissingPacket(stoppedFlag, totnp);
} }
return mp; return mp;
@ -745,7 +769,7 @@ void Implementation::startReadout() {
// wait for all packets // wait for all packets
const int numPacketsToReceive = const int numPacketsToReceive =
numberOfFrames * generalData->packetsPerFrame * listener.size(); numberOfTotalFrames * generalData->packetsPerFrame * listener.size();
if (totalPacketsReceived != numPacketsToReceive) { if (totalPacketsReceived != numPacketsToReceive) {
while (totalPacketsReceived != previousValue) { while (totalPacketsReceived != previousValue) {
LOG(logDEBUG3) LOG(logDEBUG3)
@ -842,7 +866,7 @@ void Implementation::SetupWriter() {
attr.nPixelsX = generalData->nPixelsX; attr.nPixelsX = generalData->nPixelsX;
attr.nPixelsY = generalData->nPixelsY; attr.nPixelsY = generalData->nPixelsY;
attr.maxFramesPerFile = framesPerFile; attr.maxFramesPerFile = framesPerFile;
attr.totalFrames = numberOfFrames; attr.totalFrames = numberOfTotalFrames;
attr.exptimeNs = acquisitionTime; attr.exptimeNs = acquisitionTime;
attr.subExptimeNs = subExpTime; attr.subExptimeNs = subExpTime;
attr.subPeriodNs = subPeriod; attr.subPeriodNs = subPeriod;
@ -932,7 +956,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
auto fifo_ptr = fifo[i].get(); auto fifo_ptr = fifo[i].get();
listener.push_back(sls::make_unique<Listener>( listener.push_back(sls::make_unique<Listener>(
i, myDetectorType, fifo_ptr, &status, &udpPortNum[i], i, myDetectorType, fifo_ptr, &status, &udpPortNum[i],
&eth[i], &numberOfFrames, &dynamicRange, &eth[i], &numberOfTotalFrames, &dynamicRange,
&udpSocketBufferSize, &actualUDPSocketBufferSize, &udpSocketBufferSize, &actualUDPSocketBufferSize,
&framesPerFile, &frameDiscardMode, &activated, &framesPerFile, &frameDiscardMode, &activated,
&deactivatedPaddingEnable, &silentMode)); &deactivatedPaddingEnable, &silentMode));
@ -963,7 +987,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
} }
dataStreamer.push_back(sls::make_unique<DataStreamer>( dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
fd, (int*)nd, &quadEnable)); fd, (int*)nd, &quadEnable, &numberOfTotalFrames));
dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets( dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP); &numThreads, streamingPort, streamingSrcIP);
@ -1107,7 +1131,7 @@ void Implementation::setDataStreamEnable(const bool enable) {
} }
dataStreamer.push_back(sls::make_unique<DataStreamer>( dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
fd, (int*)nd, &quadEnable)); fd, (int*)nd, &quadEnable, &numberOfTotalFrames));
dataStreamer[i]->SetGeneralData(generalData); dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets( dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP); &numThreads, streamingPort, streamingSrcIP);
@ -1225,6 +1249,26 @@ void Implementation::setAdditionalJsonParameter(const std::string &key, const st
* Detector Parameters * * Detector Parameters *
* * * *
* ************************************************/ * ************************************************/
void Implementation::updateTotalNumberOfFrames() {
int64_t repeats = numberOfTriggers;
// gotthard2: auto mode
// burst mode: (bursts instead of triggers)
// non burst mode: no bursts or triggers
if (myDetectorType == GOTTHARD2 &&timingMode == AUTO_TIMING) {
if (burstMode == BURST_OFF) {
repeats = numberOfBursts;
} else {
repeats = 1;
}
}
numberOfTotalFrames = numberOfFrames * repeats *
(int64_t)(numberOfAdditionalStorageCells + 1);
if (numberOfTotalFrames == 0) {
throw sls::RuntimeError("Invalid total number of frames to receive: 0");
}
LOG(logINFO) << "Total Number of Frames: " << numberOfTotalFrames;
}
uint64_t Implementation::getNumberOfFrames() const { uint64_t Implementation::getNumberOfFrames() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called"; LOG(logDEBUG3) << __SHORT_AT__ << " called";
return numberOfFrames; return numberOfFrames;
@ -1232,9 +1276,69 @@ uint64_t Implementation::getNumberOfFrames() const {
void Implementation::setNumberOfFrames(const uint64_t i) { void Implementation::setNumberOfFrames(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called"; LOG(logDEBUG3) << __SHORT_AT__ << " called";
numberOfFrames = i; numberOfFrames = i;
LOG(logINFO) << "Number of Frames: " << numberOfFrames; LOG(logINFO) << "Number of Frames: " << numberOfFrames;
updateTotalNumberOfFrames();
}
uint64_t Implementation::getNumberOfTriggers() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return numberOfTriggers;
}
void Implementation::setNumberOfTriggers(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
numberOfTriggers = i;
LOG(logINFO) << "Number of Triggers: " << numberOfTriggers;
updateTotalNumberOfFrames();
}
uint64_t Implementation::getNumberOfBursts() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return numberOfBursts;
}
void Implementation::setNumberOfBursts(const uint64_t i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
numberOfBursts = i;
LOG(logINFO) << "Number of Bursts: " << numberOfBursts;
updateTotalNumberOfFrames();
}
int Implementation::getNumberOfAdditionalStorageCells() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return numberOfAdditionalStorageCells;
}
void Implementation::setNumberOfAdditionalStorageCells(const int i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
numberOfAdditionalStorageCells = i;
LOG(logINFO) << "Number of Additional Storage Cells: " << numberOfAdditionalStorageCells;
updateTotalNumberOfFrames();
}
slsDetectorDefs::timingMode Implementation::getTimingMode() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return timingMode;
}
void Implementation::setTimingMode(const slsDetectorDefs::timingMode i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
timingMode = i;
LOG(logINFO) << "Timing Mode: " << timingMode;
updateTotalNumberOfFrames();
}
slsDetectorDefs::burstMode Implementation::getBurstMode() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return burstMode;
}
void Implementation::setBurstMode(const slsDetectorDefs::burstMode i) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
burstMode = i;
LOG(logINFO) << "Burst Mode: " << burstMode;
updateTotalNumberOfFrames();
} }
uint64_t Implementation::getAcquisitionPeriod() const { uint64_t Implementation::getAcquisitionPeriod() const {

View File

@ -75,6 +75,7 @@ class Implementation : private virtual slsDetectorDefs {
runStatus getStatus() const; runStatus getStatus() const;
uint64_t getFramesCaught() const; uint64_t getFramesCaught() const;
uint64_t getAcquisitionIndex() const; uint64_t getAcquisitionIndex() const;
int getProgress() const;
std::vector<uint64_t> getNumMissingPackets() const; std::vector<uint64_t> getNumMissingPackets() const;
void startReceiver(); void startReceiver();
void setStoppedFlag(bool stopped); void setStoppedFlag(bool stopped);
@ -134,8 +135,19 @@ class Implementation : private virtual slsDetectorDefs {
* Detector Parameters * * Detector Parameters *
* * * *
* ************************************************/ * ************************************************/
void updateTotalNumberOfFrames();
uint64_t getNumberOfFrames() const; uint64_t getNumberOfFrames() const;
void setNumberOfFrames(const uint64_t i); void setNumberOfFrames(const uint64_t i);
uint64_t getNumberOfTriggers() const;
void setNumberOfTriggers(const uint64_t i);
uint64_t getNumberOfBursts() const;
void setNumberOfBursts(const uint64_t i);
int getNumberOfAdditionalStorageCells() const;
void setNumberOfAdditionalStorageCells(const int i);
timingMode getTimingMode() const;
void setTimingMode(const timingMode i);
burstMode getBurstMode() const;
void setBurstMode(const burstMode i);
uint64_t getAcquisitionTime() const; uint64_t getAcquisitionTime() const;
void setAcquisitionTime(const uint64_t i); void setAcquisitionTime(const uint64_t i);
uint64_t getAcquisitionPeriod() const; uint64_t getAcquisitionPeriod() const;
@ -266,7 +278,13 @@ class Implementation : private virtual slsDetectorDefs {
std::map<std::string, std::string> additionalJsonHeader; std::map<std::string, std::string> additionalJsonHeader;
// detector parameters // detector parameters
uint64_t numberOfTotalFrames;
uint64_t numberOfFrames; uint64_t numberOfFrames;
uint64_t numberOfTriggers;
uint64_t numberOfBursts;
int numberOfAdditionalStorageCells;
timingMode timingMode;
burstMode burstMode;
uint64_t acquisitionPeriod; uint64_t acquisitionPeriod;
uint64_t acquisitionTime; uint64_t acquisitionTime;
uint64_t subExpTime; uint64_t subExpTime;

View File

@ -40,6 +40,8 @@ struct zmqHeader {
uint64_t acqIndex{0}; uint64_t acqIndex{0};
/** frame index (starting at 0 for each acquisition) */ /** frame index (starting at 0 for each acquisition) */
uint64_t frameIndex{0}; uint64_t frameIndex{0};
/** progress in percentage */
int progress{0};
/** file name prefix */ /** file name prefix */
std::string fname{""}; std::string fname{""};
/** header from detector */ /** header from detector */

View File

@ -245,7 +245,8 @@ class slsDetectorDefs {
AUTO_TIMING, /**< internal timing */ AUTO_TIMING, /**< internal timing */
TRIGGER_EXPOSURE, /**< trigger mode i.e. exposure is triggered */ TRIGGER_EXPOSURE, /**< trigger mode i.e. exposure is triggered */
GATED, /**< gated */ GATED, /**< gated */
BURST_TRIGGER /**< trigger a burst of frames */ BURST_TRIGGER, /**< trigger a burst of frames */
NUM_TIMING_MODES
}; };
/** /**
@ -448,7 +449,8 @@ class slsDetectorDefs {
enum burstMode { enum burstMode {
BURST_OFF, BURST_OFF,
BURST_INTERNAL, BURST_INTERNAL,
BURST_EXTERNAL BURST_EXTERNAL,
NUM_BURST_MODES
}; };
/** /**
@ -480,7 +482,6 @@ struct detParameters {
int nChipX{0}; int nChipX{0};
int nChipY{0}; int nChipY{0};
int nDacs{0}; int nDacs{0};
int dynamicRange{0};
detParameters() = default; detParameters() = default;
explicit detParameters(slsDetectorDefs::detectorType type) { explicit detParameters(slsDetectorDefs::detectorType type) {
@ -491,7 +492,6 @@ struct detParameters {
nChipX = 10; nChipX = 10;
nChipY = 1; nChipY = 1;
nDacs = 8; nDacs = 8;
dynamicRange = 16;
break; break;
case slsDetectorDefs::detectorType::JUNGFRAU: case slsDetectorDefs::detectorType::JUNGFRAU:
nChanX = 256; nChanX = 256;
@ -499,7 +499,6 @@ struct detParameters {
nChipX = 4; nChipX = 4;
nChipY = 2; nChipY = 2;
nDacs = 8; nDacs = 8;
dynamicRange = 16;
break; break;
case slsDetectorDefs::detectorType::CHIPTESTBOARD: case slsDetectorDefs::detectorType::CHIPTESTBOARD:
nChanX = 36; nChanX = 36;
@ -507,7 +506,6 @@ struct detParameters {
nChipX = 1; nChipX = 1;
nChipY = 1; nChipY = 1;
nDacs = 24; nDacs = 24;
dynamicRange = 16;
break; break;
case slsDetectorDefs::detectorType::MOENCH: case slsDetectorDefs::detectorType::MOENCH:
nChanX = 32; nChanX = 32;
@ -515,7 +513,6 @@ struct detParameters {
nChipX = 1; nChipX = 1;
nChipY = 1; nChipY = 1;
nDacs = 8; nDacs = 8;
dynamicRange = 16;
break; break;
case slsDetectorDefs::detectorType::EIGER: case slsDetectorDefs::detectorType::EIGER:
nChanX = 256; nChanX = 256;
@ -523,7 +520,6 @@ struct detParameters {
nChipX = 4; nChipX = 4;
nChipY = 1; nChipY = 1;
nDacs = 16; nDacs = 16;
dynamicRange = 16;
break; break;
case slsDetectorDefs::detectorType::MYTHEN3: case slsDetectorDefs::detectorType::MYTHEN3:
nChanX = 128 * 3; nChanX = 128 * 3;
@ -531,7 +527,6 @@ struct detParameters {
nChipX = 10; nChipX = 10;
nChipY = 1; nChipY = 1;
nDacs = 16; nDacs = 16;
dynamicRange = 32;
break; break;
case slsDetectorDefs::detectorType::GOTTHARD2: case slsDetectorDefs::detectorType::GOTTHARD2:
nChanX = 128; nChanX = 128;
@ -539,7 +534,6 @@ struct detParameters {
nChipX = 10; nChipX = 10;
nChipY = 1; nChipY = 1;
nDacs = 14; nDacs = 14;
dynamicRange = 16;
break; break;
default: default:
throw sls::RuntimeError("Unknown detector type! " + std::to_string(type)); throw sls::RuntimeError("Unknown detector type! " + std::to_string(type));

View File

@ -197,6 +197,7 @@ enum detFuncs{
F_GET_TIMING_SOURCE, F_GET_TIMING_SOURCE,
F_SET_TIMING_SOURCE, F_SET_TIMING_SOURCE,
F_GET_NUM_CHANNELS, F_GET_NUM_CHANNELS,
F_UPDATE_RATE_CORRECTION,
NUM_DET_FUNCTIONS, NUM_DET_FUNCTIONS,
RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */ RECEIVER_ENUM_START = 256, /**< detector function should not exceed this (detector server should not compile anyway) */
@ -211,6 +212,11 @@ enum detFuncs{
F_SEND_RECEIVER_DETHOSTNAME, F_SEND_RECEIVER_DETHOSTNAME,
F_RECEIVER_SET_ROI, F_RECEIVER_SET_ROI,
F_RECEIVER_SET_NUM_FRAMES, F_RECEIVER_SET_NUM_FRAMES,
F_SET_RECEIVER_NUM_TRIGGERS,
F_SET_RECEIVER_NUM_BURSTS,
F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS,
F_SET_RECEIVER_TIMING_MODE,
F_SET_RECEIVER_BURST_MODE,
F_RECEIVER_SET_NUM_ANALOG_SAMPLES, F_RECEIVER_SET_NUM_ANALOG_SAMPLES,
F_RECEIVER_SET_NUM_DIGITAL_SAMPLES, F_RECEIVER_SET_NUM_DIGITAL_SAMPLES,
F_RECEIVER_SET_EXPTIME, F_RECEIVER_SET_EXPTIME,
@ -287,6 +293,8 @@ enum detFuncs{
F_INCREMENT_FILE_INDEX, F_INCREMENT_FILE_INDEX,
F_SET_ADDITIONAL_JSON_PARAMETER, F_SET_ADDITIONAL_JSON_PARAMETER,
F_GET_ADDITIONAL_JSON_PARAMETER, F_GET_ADDITIONAL_JSON_PARAMETER,
F_GET_RECEIVER_PROGRESS,
NUM_REC_FUNCTIONS NUM_REC_FUNCTIONS
}; };
@ -480,6 +488,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE"; case F_GET_TIMING_SOURCE: return "F_GET_TIMING_SOURCE";
case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE"; case F_SET_TIMING_SOURCE: return "F_SET_TIMING_SOURCE";
case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS"; case F_GET_NUM_CHANNELS: return "F_GET_NUM_CHANNELS";
case F_UPDATE_RATE_CORRECTION: return "F_UPDATE_RATE_CORRECTION";
case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS"; case NUM_DET_FUNCTIONS: return "NUM_DET_FUNCTIONS";
case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START"; case RECEIVER_ENUM_START: return "RECEIVER_ENUM_START";
@ -494,6 +503,11 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME"; case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME";
case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI"; case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
case F_RECEIVER_SET_NUM_FRAMES: return "F_RECEIVER_SET_NUM_FRAMES"; case F_RECEIVER_SET_NUM_FRAMES: return "F_RECEIVER_SET_NUM_FRAMES";
case F_SET_RECEIVER_NUM_TRIGGERS: return "F_SET_RECEIVER_NUM_TRIGGERS";
case F_SET_RECEIVER_NUM_BURSTS: return "F_SET_RECEIVER_NUM_BURSTS";
case F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS: return "F_SET_RECEIVER_NUM_ADD_STORAGE_CELLS";
case F_SET_RECEIVER_TIMING_MODE: return "F_SET_RECEIVER_TIMING_MODE";
case F_SET_RECEIVER_BURST_MODE: return "F_SET_RECEIVER_BURST_MODE";
case F_RECEIVER_SET_NUM_ANALOG_SAMPLES: return "F_RECEIVER_SET_NUM_ANALOG_SAMPLES"; case F_RECEIVER_SET_NUM_ANALOG_SAMPLES: return "F_RECEIVER_SET_NUM_ANALOG_SAMPLES";
case F_RECEIVER_SET_NUM_DIGITAL_SAMPLES:return "F_RECEIVER_SET_NUM_DIGITAL_SAMPLES"; case F_RECEIVER_SET_NUM_DIGITAL_SAMPLES:return "F_RECEIVER_SET_NUM_DIGITAL_SAMPLES";
case F_RECEIVER_SET_EXPTIME: return "F_RECEIVER_SET_EXPTIME"; case F_RECEIVER_SET_EXPTIME: return "F_RECEIVER_SET_EXPTIME";
@ -570,6 +584,7 @@ static const char* getFunctionNameFromEnum(enum detFuncs func) {
case F_INCREMENT_FILE_INDEX: return "F_INCREMENT_FILE_INDEX"; case F_INCREMENT_FILE_INDEX: return "F_INCREMENT_FILE_INDEX";
case F_SET_ADDITIONAL_JSON_PARAMETER: return "F_SET_ADDITIONAL_JSON_PARAMETER"; case F_SET_ADDITIONAL_JSON_PARAMETER: return "F_SET_ADDITIONAL_JSON_PARAMETER";
case F_GET_ADDITIONAL_JSON_PARAMETER: return "F_GET_ADDITIONAL_JSON_PARAMETER"; case F_GET_ADDITIONAL_JSON_PARAMETER: return "F_GET_ADDITIONAL_JSON_PARAMETER";
case F_GET_RECEIVER_PROGRESS: return "F_GET_RECEIVER_PROGRESS";
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS"; case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
default: return "Unknown Function"; default: return "Unknown Function";

View File

@ -1,12 +1,12 @@
/** API versions */ /** API versions */
#define GITBRANCH "developer" #define GITBRANCH "removeshm"
#define APILIB 0x200227 #define APICTB 0x200402
#define APIRECEIVER 0x200227 #define APIGOTTHARD 0x200402
#define APIGUI 0x200227 #define APIGOTTHARD2 0x200402
#define APICTB 0x200331 #define APIJUNGFRAU 0x200402
#define APIGOTTHARD 0x200331 #define APIMYTHEN3 0x200402
#define APIGOTTHARD2 0x200331
#define APIJUNGFRAU 0x200331
#define APIMYTHEN3 0x200331
#define APIMOENCH 0x200331 #define APIMOENCH 0x200331
#define APIEIGER 0x200331 #define APIEIGER 0x200402
#define APILIB 0x200402
#define APIRECEIVER 0x200402
#define APIGUI 0x200331

View File

@ -158,6 +158,7 @@ int ZmqSocket::SendHeader(
"\"size\":%u, " "\"size\":%u, "
"\"acqIndex\":%lu, " "\"acqIndex\":%lu, "
"\"frameIndex\":%lu, " "\"frameIndex\":%lu, "
"\"progress\":%u, "
"\"fname\":\"%s\", " "\"fname\":\"%s\", "
"\"data\": %d, " "\"data\": %d, "
"\"completeImage\": %d, " "\"completeImage\": %d, "
@ -193,6 +194,7 @@ int ZmqSocket::SendHeader(
header.imageSize, header.imageSize,
header.acqIndex, header.acqIndex,
header.frameIndex, header.frameIndex,
header.progress,
header.fname.c_str(), header.fname.c_str(),
header.data ? 1 : 0, header.data ? 1 : 0,
header.completeImage ? 1 : 0, header.completeImage ? 1 : 0,
@ -324,6 +326,7 @@ int ZmqSocket::ParseHeader(const int index, int length, char *buff,
zHeader.imageSize = document["size"].GetUint(); zHeader.imageSize = document["size"].GetUint();
zHeader.acqIndex = document["acqIndex"].GetUint64(); zHeader.acqIndex = document["acqIndex"].GetUint64();
zHeader.frameIndex = document["frameIndex"].GetUint64(); zHeader.frameIndex = document["frameIndex"].GetUint64();
zHeader.progress = document["progress"].GetUint();
zHeader.fname = document["fname"].GetString(); zHeader.fname = document["fname"].GetString();
zHeader.frameNumber = document["frameNumber"].GetUint64(); zHeader.frameNumber = document["frameNumber"].GetUint64();