mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
minor
This commit is contained in:
@ -1857,6 +1857,8 @@ class slsDetector : public virtual slsDetectorDefs{
|
|||||||
*/
|
*/
|
||||||
int writeSettingsFile(const std::string &fname, sls_detector_module& mod);
|
int writeSettingsFile(const std::string &fname, sls_detector_module& mod);
|
||||||
|
|
||||||
|
std::vector<std::string> getSettingsFileDacNames();
|
||||||
|
|
||||||
/** slsDetector Id or position in the detectors list */
|
/** slsDetector Id or position in the detectors list */
|
||||||
const int detId;
|
const int detId;
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ int64_t slsDetector::getId(idMode mode) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t slsDetector::getReceiverSoftwareVersion(){
|
int64_t slsDetector::getReceiverSoftwareVersion() {
|
||||||
FILE_LOG(logDEBUG1) << "Getting receiver software version";
|
FILE_LOG(logDEBUG1) << "Getting receiver software version";
|
||||||
int64_t retval = -1;
|
int64_t retval = -1;
|
||||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||||
@ -155,9 +155,9 @@ int64_t slsDetector::getReceiverSoftwareVersion(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void slsDetector::freeSharedMemory(int multi_id, int slsId) {
|
void slsDetector::freeSharedMemory(int multi_id, int slsId) {
|
||||||
SharedMemory<sharedSlsDetector> shm(multi_id, slsId);
|
SharedMemory<sharedSlsDetector> temp_shm(multi_id, slsId);
|
||||||
if (shm.IsExisting()) {
|
if (temp_shm.IsExisting()) {
|
||||||
shm.RemoveSharedMemory();
|
temp_shm.RemoveSharedMemory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,6 @@ std::string slsDetector::getHostname() const {
|
|||||||
|
|
||||||
void slsDetector::initSharedMemory(detectorType type, int multi_id,
|
void slsDetector::initSharedMemory(detectorType type, int multi_id,
|
||||||
bool verify) {
|
bool verify) {
|
||||||
|
|
||||||
detector_shm = SharedMemory<sharedSlsDetector>(multi_id, detId);
|
detector_shm = SharedMemory<sharedSlsDetector>(multi_id, detId);
|
||||||
if (!detector_shm.IsExisting()) {
|
if (!detector_shm.IsExisting()) {
|
||||||
detector_shm.CreateSharedMemory();
|
detector_shm.CreateSharedMemory();
|
||||||
@ -196,7 +195,6 @@ void slsDetector::initSharedMemory(detectorType type, int multi_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void slsDetector::initializeDetectorStructure(detectorType type) {
|
void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||||
detector_shm()->shmversion = SLS_SHMVERSION;
|
detector_shm()->shmversion = SLS_SHMVERSION;
|
||||||
detector_shm()->onlineFlag = OFFLINE_FLAG;
|
detector_shm()->onlineFlag = OFFLINE_FLAG;
|
||||||
@ -339,7 +337,6 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int slsDetector::sendModule(sls_detector_module *myMod,
|
int slsDetector::sendModule(sls_detector_module *myMod,
|
||||||
sls::ClientSocket &client) {
|
sls::ClientSocket &client) {
|
||||||
TLogLevel level = logDEBUG1;
|
TLogLevel level = logDEBUG1;
|
||||||
@ -1091,19 +1088,18 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
|||||||
" not defined for this module!");
|
" not defined for this module!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool interpolate =
|
bool interpolate =
|
||||||
std::all_of(detector_shm()->trimEnergies,
|
std::all_of(detector_shm()->trimEnergies,
|
||||||
detector_shm()->trimEnergies + detector_shm()->nTrimEn,
|
detector_shm()->trimEnergies + detector_shm()->nTrimEn,
|
||||||
[e_eV](const int &e) { return e != e_eV; });
|
[e_eV](const int &e) { return e != e_eV; });
|
||||||
|
|
||||||
sls_detector_module myMod{detector_shm()->myDetectorType};
|
sls_detector_module myMod{detector_shm()->myDetectorType};
|
||||||
|
|
||||||
if (!interpolate) {
|
if (!interpolate) {
|
||||||
std::string settingsfname = getTrimbitFilename(is, e_eV);
|
std::string settingsfname = getTrimbitFilename(is, e_eV);
|
||||||
FILE_LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
FILE_LOG(logDEBUG1) << "Settings File is " << settingsfname;
|
||||||
myMod = readSettingsFile(settingsfname, tb);
|
myMod = readSettingsFile(settingsfname, tb);
|
||||||
}else{
|
} else {
|
||||||
// find the trim values
|
// find the trim values
|
||||||
int trim1 = -1, trim2 = -1;
|
int trim1 = -1, trim2 = -1;
|
||||||
for (int i = 0; i < detector_shm()->nTrimEn; ++i) {
|
for (int i = 0; i < detector_shm()->nTrimEn; ++i) {
|
||||||
@ -1140,7 +1136,7 @@ int slsDetector::setThresholdEnergyAndSettings(int e_eV,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string slsDetector::getTrimbitFilename(detectorSettings s, int e_eV){
|
std::string slsDetector::getTrimbitFilename(detectorSettings s, int e_eV) {
|
||||||
std::string ssettings;
|
std::string ssettings;
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case STANDARD:
|
case STANDARD:
|
||||||
@ -1165,9 +1161,9 @@ std::string slsDetector::getTrimbitFilename(detectorSettings s, int e_eV){
|
|||||||
throw RuntimeError(ss.str());
|
throw RuntimeError(ss.str());
|
||||||
}
|
}
|
||||||
std::ostringstream ostfn;
|
std::ostringstream ostfn;
|
||||||
ostfn << detector_shm()->settingsDir << ssettings << "/" << e_eV << "eV"
|
ostfn << detector_shm()->settingsDir << ssettings << "/" << e_eV << "eV"
|
||||||
<< "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec
|
<< "/noise.sn" << std::setfill('0') << std::setw(3) << std::dec
|
||||||
<< getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10);
|
<< getId(DETECTOR_SERIAL_NUMBER) << std::setbase(10);
|
||||||
return ostfn.str();
|
return ostfn.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1625,7 +1621,7 @@ int slsDetector::sendToDetector(int fnum, const Arg &args, std::nullptr_t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
int slsDetector::sendToDetector(int fnum, std::nullptr_t, Ret& retval) {
|
int slsDetector::sendToDetector(int fnum, std::nullptr_t, Ret &retval) {
|
||||||
return sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
return sendToDetector(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1633,20 +1629,22 @@ int slsDetector::sendToDetector(int fnum) {
|
|||||||
return sendToDetector(fnum, nullptr, 0, nullptr, 0);
|
return sendToDetector(fnum, nullptr, 0, nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::sendToDetectorStop(int fnum, const void *args, size_t args_size,
|
int slsDetector::sendToDetectorStop(int fnum, const void *args,
|
||||||
void *retval, size_t retval_size) {
|
size_t args_size, void *retval,
|
||||||
|
size_t retval_size) {
|
||||||
auto stop =
|
auto stop =
|
||||||
DetectorSocket(detector_shm()->hostname, detector_shm()->stopPort);
|
DetectorSocket(detector_shm()->hostname, detector_shm()->stopPort);
|
||||||
auto ret =
|
auto ret =
|
||||||
stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
stop.sendCommandThenRead(fnum, args, args_size, retval, retval_size);
|
||||||
stop.close();
|
stop.close();
|
||||||
//no update on stop port
|
// no update on stop port
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Arg, typename Ret>
|
template <typename Arg, typename Ret>
|
||||||
int slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) {
|
int slsDetector::sendToDetectorStop(int fnum, const Arg &args, Ret &retval) {
|
||||||
return sendToDetectorStop(fnum, &args, sizeof(args), &retval, sizeof(retval));
|
return sendToDetectorStop(fnum, &args, sizeof(args), &retval,
|
||||||
|
sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Arg>
|
template <typename Arg>
|
||||||
@ -1655,7 +1653,7 @@ int slsDetector::sendToDetectorStop(int fnum, const Arg &args, std::nullptr_t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Ret>
|
template <typename Ret>
|
||||||
int slsDetector::sendToDetectorStop(int fnum, std::nullptr_t, Ret& retval) {
|
int slsDetector::sendToDetectorStop(int fnum, std::nullptr_t, Ret &retval) {
|
||||||
return sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
return sendToDetectorStop(fnum, nullptr, 0, &retval, sizeof(retval));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2188,7 +2186,6 @@ void slsDetector::setReceiverStreamingIP(std::string sourceIP) {
|
|||||||
char args[MAX_STR_LENGTH]{};
|
char args[MAX_STR_LENGTH]{};
|
||||||
char retvals[MAX_STR_LENGTH]{};
|
char retvals[MAX_STR_LENGTH]{};
|
||||||
|
|
||||||
|
|
||||||
// if empty, give rx_hostname
|
// if empty, give rx_hostname
|
||||||
if (sourceIP.empty()) {
|
if (sourceIP.empty()) {
|
||||||
if (strcmp(detector_shm()->receiver_hostname, "none") == 0) {
|
if (strcmp(detector_shm()->receiver_hostname, "none") == 0) {
|
||||||
@ -2755,7 +2752,8 @@ bool slsDetector::setDeactivatedRxrPaddingMode(int padding) {
|
|||||||
int retval = -1;
|
int retval = -1;
|
||||||
FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable: " << padding;
|
FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable: " << padding;
|
||||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||||
sendToReceiver(fnum, &padding, sizeof(padding), &retval, sizeof(retval));
|
sendToReceiver(fnum, &padding, sizeof(padding), &retval,
|
||||||
|
sizeof(retval));
|
||||||
FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable:" << retval;
|
FILE_LOG(logDEBUG1) << "Deactivated Receiver Padding Enable:" << retval;
|
||||||
detector_shm()->rxPadDeactivatedModules = static_cast<bool>(retval);
|
detector_shm()->rxPadDeactivatedModules = static_cast<bool>(retval);
|
||||||
}
|
}
|
||||||
@ -2827,25 +2825,19 @@ int slsDetector::setTrimEn(std::vector<int> energies) {
|
|||||||
if (energies.size() > MAX_TRIMEN) {
|
if (energies.size() > MAX_TRIMEN) {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "Size of trim energies: " << energies.size()
|
os << "Size of trim energies: " << energies.size()
|
||||||
<< " exceeds what can "
|
<< " exceeds what can be stored in shared memory: " << MAX_TRIMEN
|
||||||
<< "be stored in shared memory: " << MAX_TRIMEN << "\n";
|
<< "\n";
|
||||||
throw RuntimeError(os.str());
|
throw RuntimeError(os.str());
|
||||||
}
|
}
|
||||||
|
std::copy(begin(energies), end(energies), detector_shm()->trimEnergies);
|
||||||
for (size_t i = 0; i != energies.size(); ++i) {
|
|
||||||
detector_shm()->trimEnergies[i] = energies[i];
|
|
||||||
}
|
|
||||||
detector_shm()->nTrimEn = energies.size();
|
detector_shm()->nTrimEn = energies.size();
|
||||||
return (detector_shm()->nTrimEn);
|
return detector_shm()->nTrimEn;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> slsDetector::getTrimEn() {
|
std::vector<int> slsDetector::getTrimEn() {
|
||||||
std::vector<int> energies;
|
return std::vector<int>(detector_shm()->trimEnergies,
|
||||||
energies.reserve(detector_shm()->nTrimEn);
|
detector_shm()->trimEnergies +
|
||||||
for (int i = 0; i != detector_shm()->nTrimEn; ++i) {
|
detector_shm()->nTrimEn);
|
||||||
energies.push_back(detector_shm()->trimEnergies[i]);
|
|
||||||
}
|
|
||||||
return energies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::pulsePixel(int n, int x, int y) {
|
int slsDetector::pulsePixel(int n, int x, int y) {
|
||||||
@ -2984,7 +2976,6 @@ int slsDetector::programFPGA(std::vector<char> buffer) {
|
|||||||
int currentPointer = 0;
|
int currentPointer = 0;
|
||||||
size_t totalsize = filesize;
|
size_t totalsize = filesize;
|
||||||
while (ret != FAIL && (filesize > 0)) {
|
while (ret != FAIL && (filesize > 0)) {
|
||||||
|
|
||||||
unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
unitprogramsize = MAX_FPGAPROGRAMSIZE; // 2mb
|
||||||
if (unitprogramsize > filesize) { // less than 2mb
|
if (unitprogramsize > filesize) { // less than 2mb
|
||||||
unitprogramsize = filesize;
|
unitprogramsize = filesize;
|
||||||
@ -3048,13 +3039,12 @@ int slsDetector::rebootController() {
|
|||||||
throw RuntimeError(
|
throw RuntimeError(
|
||||||
"Reboot controller not implemented for this detector");
|
"Reboot controller not implemented for this detector");
|
||||||
}
|
}
|
||||||
|
|
||||||
int fnum = F_REBOOT_CONTROLLER;
|
int fnum = F_REBOOT_CONTROLLER;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
FILE_LOG(logINFO) << "Sending reboot controller to detector " << detId
|
FILE_LOG(logINFO) << "Sending reboot controller to detector " << detId
|
||||||
<< " (" << detector_shm()->hostname << ")";
|
<< " (" << detector_shm()->hostname << ")";
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
//TODO! (Erik) Investigate if we can return a value before reboot
|
// TODO! (Erik) Investigate if we can return a value before reboot
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
auto client = DetectorSocket(detector_shm()->hostname,
|
||||||
detector_shm()->controlPort);
|
detector_shm()->controlPort);
|
||||||
client.sendData(&fnum, sizeof(fnum));
|
client.sendData(&fnum, sizeof(fnum));
|
||||||
@ -3083,7 +3073,7 @@ int slsDetector::setAutoComparatorDisableMode(int ival) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::setModule(sls_detector_module& module, int tb) {
|
int slsDetector::setModule(sls_detector_module &module, int tb) {
|
||||||
int fnum = F_SET_MODULE;
|
int fnum = F_SET_MODULE;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
@ -3093,7 +3083,6 @@ int slsDetector::setModule(sls_detector_module& module, int tb) {
|
|||||||
module.nchan = 0;
|
module.nchan = 0;
|
||||||
module.nchip = 0;
|
module.nchip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
auto client = DetectorSocket(detector_shm()->hostname,
|
||||||
detector_shm()->controlPort);
|
detector_shm()->controlPort);
|
||||||
@ -3112,7 +3101,6 @@ int slsDetector::setModule(sls_detector_module& module, int tb) {
|
|||||||
if (ret == FORCE_UPDATE) {
|
if (ret == FORCE_UPDATE) {
|
||||||
ret = updateDetector();
|
ret = updateDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
// update client structure
|
// update client structure
|
||||||
if (ret == OK) {
|
if (ret == OK) {
|
||||||
if (module.eV != -1) {
|
if (module.eV != -1) {
|
||||||
@ -3126,7 +3114,6 @@ sls_detector_module slsDetector::getModule() {
|
|||||||
int fnum = F_GET_MODULE;
|
int fnum = F_GET_MODULE;
|
||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
FILE_LOG(logDEBUG1) << "Getting module";
|
FILE_LOG(logDEBUG1) << "Getting module";
|
||||||
|
|
||||||
sls_detector_module myMod{detector_shm()->myDetectorType};
|
sls_detector_module myMod{detector_shm()->myDetectorType};
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
auto client = DetectorSocket(detector_shm()->hostname,
|
auto client = DetectorSocket(detector_shm()->hostname,
|
||||||
@ -3167,15 +3154,12 @@ int64_t slsDetector::getRateCorrection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void slsDetector::updateRateCorrection() {
|
void slsDetector::updateRateCorrection() {
|
||||||
// rate correction is enabled
|
|
||||||
if (detector_shm()->deadTime != 0) {
|
if (detector_shm()->deadTime != 0) {
|
||||||
switch (detector_shm()->dynamicRange) {
|
switch (detector_shm()->dynamicRange) {
|
||||||
// rate correction is allowed
|
|
||||||
case 16:
|
case 16:
|
||||||
case 32:
|
case 32:
|
||||||
setRateCorrection(detector_shm()->deadTime);
|
setRateCorrection(detector_shm()->deadTime);
|
||||||
break;
|
break;
|
||||||
// not allowed
|
|
||||||
default:
|
default:
|
||||||
setRateCorrection(0);
|
setRateCorrection(0);
|
||||||
throw sls::NonCriticalError(
|
throw sls::NonCriticalError(
|
||||||
@ -3201,13 +3185,10 @@ void slsDetector::printReceiverConfiguration(TLogLevel level) {
|
|||||||
|
|
||||||
int slsDetector::setReceiverOnline(int value) {
|
int slsDetector::setReceiverOnline(int value) {
|
||||||
if (value != GET_ONLINE_FLAG) {
|
if (value != GET_ONLINE_FLAG) {
|
||||||
// no receiver
|
|
||||||
if (strcmp(detector_shm()->receiver_hostname, "none") == 0) {
|
if (strcmp(detector_shm()->receiver_hostname, "none") == 0) {
|
||||||
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
||||||
} else {
|
} else {
|
||||||
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
||||||
|
|
||||||
// set online
|
|
||||||
if (value == ONLINE_FLAG) {
|
if (value == ONLINE_FLAG) {
|
||||||
// connect and set offline flag
|
// connect and set offline flag
|
||||||
auto receiver =
|
auto receiver =
|
||||||
@ -3229,16 +3210,15 @@ int slsDetector::getReceiverOnline() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string slsDetector::checkReceiverOnline() {
|
std::string slsDetector::checkReceiverOnline() {
|
||||||
std::string retval;
|
|
||||||
try {
|
try {
|
||||||
auto receiver = ReceiverSocket(detector_shm()->receiver_hostname,
|
auto receiver = ReceiverSocket(detector_shm()->receiver_hostname,
|
||||||
detector_shm()->receiverTCPPort);
|
detector_shm()->receiverTCPPort);
|
||||||
detector_shm()->receiverOnlineFlag = ONLINE_FLAG;
|
detector_shm()->receiverOnlineFlag = ONLINE_FLAG;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
||||||
retval = detector_shm()->receiver_hostname;
|
return detector_shm()->receiver_hostname;
|
||||||
}
|
}
|
||||||
return retval;
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
int slsDetector::lockReceiver(int lock) {
|
int slsDetector::lockReceiver(int lock) {
|
||||||
@ -3298,8 +3278,8 @@ int slsDetector::updateCachedReceiverVariables() const {
|
|||||||
throw RuntimeError(msg);
|
throw RuntimeError(msg);
|
||||||
} else {
|
} else {
|
||||||
int n = 0, i32 = 0;
|
int n = 0, i32 = 0;
|
||||||
char cstring[MAX_STR_LENGTH] = {};
|
char cstring[MAX_STR_LENGTH]{};
|
||||||
char lastClientIP[INET_ADDRSTRLEN] = {};
|
char lastClientIP[INET_ADDRSTRLEN]{};
|
||||||
|
|
||||||
n += receiver.receiveData(lastClientIP, sizeof(lastClientIP));
|
n += receiver.receiveData(lastClientIP, sizeof(lastClientIP));
|
||||||
FILE_LOG(logDEBUG1)
|
FILE_LOG(logDEBUG1)
|
||||||
@ -3462,7 +3442,8 @@ std::string slsDetector::setFileName(const std::string &fname) {
|
|||||||
|
|
||||||
int slsDetector::setFramesPerFile(int n_frames) {
|
int slsDetector::setFramesPerFile(int n_frames) {
|
||||||
if (n_frames >= 0) {
|
if (n_frames >= 0) {
|
||||||
FILE_LOG(logDEBUG1) << "Setting receiver frames per file to " << n_frames;
|
FILE_LOG(logDEBUG1)
|
||||||
|
<< "Setting receiver frames per file to " << n_frames;
|
||||||
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->receiverOnlineFlag == ONLINE_FLAG) {
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, retval);
|
sendToReceiver(F_SET_RECEIVER_FRAMES_PER_FILE, n_frames, retval);
|
||||||
@ -3768,13 +3749,13 @@ uint64_t slsDetector::setPatternWord(int addr, uint64_t word) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<int, 3> slsDetector::setPatternLoops(int level, int start, int stop, int n) {
|
std::array<int, 3> slsDetector::setPatternLoops(int level, int start, int stop,
|
||||||
|
int n) {
|
||||||
int args[]{level, start, stop, n};
|
int args[]{level, start, stop, n};
|
||||||
std::array<int, 3> retvals{};
|
std::array<int, 3> retvals{};
|
||||||
FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level
|
FILE_LOG(logDEBUG1) << "Setting Pat Loops, level: " << level
|
||||||
<< ", start: " << start << ", stop: " << stop
|
<< ", start: " << start << ", stop: " << stop
|
||||||
<< ", nloops: " << n;
|
<< ", nloops: " << n;
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
sendToDetector(F_SET_PATTERN_LOOP, args, retvals);
|
sendToDetector(F_SET_PATTERN_LOOP, args, retvals);
|
||||||
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", "
|
FILE_LOG(logDEBUG1) << "Set Pat Loops: " << retvals[0] << ", "
|
||||||
@ -3786,10 +3767,8 @@ std::array<int, 3> slsDetector::setPatternLoops(int level, int start, int stop,
|
|||||||
int slsDetector::setPatternWaitAddr(int level, int addr) {
|
int slsDetector::setPatternWaitAddr(int level, int addr) {
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
int args[]{level, addr};
|
int args[]{level, addr};
|
||||||
FILE_LOG(logDEBUG1) << "Setting Pat Wait Addr, level: "
|
FILE_LOG(logDEBUG1) << "Setting Pat Wait Addr, level: " << level
|
||||||
<< level << ", addr: 0x" << std::hex << addr
|
<< ", addr: 0x" << std::hex << addr << std::dec;
|
||||||
<< std::dec;
|
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
sendToDetector(F_SET_PATTERN_WAIT_ADDR, args, retval);
|
sendToDetector(F_SET_PATTERN_WAIT_ADDR, args, retval);
|
||||||
FILE_LOG(logDEBUG1) << "Set Pat Wait Addr: " << retval;
|
FILE_LOG(logDEBUG1) << "Set Pat Wait Addr: " << retval;
|
||||||
@ -3798,7 +3777,7 @@ int slsDetector::setPatternWaitAddr(int level, int addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t slsDetector::setPatternWaitTime(int level, uint64_t t) {
|
uint64_t slsDetector::setPatternWaitTime(int level, uint64_t t) {
|
||||||
uint64_t retval = -1;
|
uint64_t retval = -1;
|
||||||
uint64_t args[]{static_cast<uint64_t>(level), t};
|
uint64_t args[]{static_cast<uint64_t>(level), t};
|
||||||
FILE_LOG(logDEBUG1) << "Setting Pat Wait Time, level: " << level
|
FILE_LOG(logDEBUG1) << "Setting Pat Wait Time, level: " << level
|
||||||
<< ", t: " << t;
|
<< ", t: " << t;
|
||||||
@ -3867,7 +3846,6 @@ int slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) {
|
|||||||
FILE_LOG(logDEBUG1) << "Sending Digital IO Delay, pin mask: " << std::hex
|
FILE_LOG(logDEBUG1) << "Sending Digital IO Delay, pin mask: " << std::hex
|
||||||
<< args[0] << ", delay: " << std::dec << args[1]
|
<< args[0] << ", delay: " << std::dec << args[1]
|
||||||
<< " ps";
|
<< " ps";
|
||||||
|
|
||||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||||
ret = sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr);
|
ret = sendToDetector(F_DIGITAL_IO_DELAY, args, nullptr);
|
||||||
FILE_LOG(logDEBUG1) << "Digital IO Delay successful";
|
FILE_LOG(logDEBUG1) << "Digital IO Delay successful";
|
||||||
@ -3875,10 +3853,10 @@ int slsDetector::setDigitalIODelay(uint64_t pinMask, int delay) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module
|
sls_detector_module slsDetector::interpolateTrim(sls_detector_module *a,
|
||||||
slsDetector::interpolateTrim(sls_detector_module *a, sls_detector_module *b,
|
sls_detector_module *b,
|
||||||
const int energy, const int e1, const int e2,
|
const int energy, const int e1,
|
||||||
int tb) {
|
const int e2, int tb) {
|
||||||
|
|
||||||
// only implemented for eiger currently (in terms of which dacs)
|
// only implemented for eiger currently (in terms of which dacs)
|
||||||
if (detector_shm()->myDetectorType != EIGER) {
|
if (detector_shm()->myDetectorType != EIGER) {
|
||||||
@ -3918,12 +3896,9 @@ slsDetector::interpolateTrim(sls_detector_module *a, sls_detector_module *b,
|
|||||||
|
|
||||||
// Copy irrelevant dacs (without failing): CAL
|
// Copy irrelevant dacs (without failing): CAL
|
||||||
if (a->dacs[CAL] != b->dacs[CAL]) {
|
if (a->dacs[CAL] != b->dacs[CAL]) {
|
||||||
FILE_LOG(logWARNING) << "DAC CAL differs in both energies "
|
FILE_LOG(logWARNING)
|
||||||
"("
|
<< "DAC CAL differs in both energies (" << a->dacs[CAL] << ","
|
||||||
<< a->dacs[CAL] << "," << b->dacs[CAL]
|
<< b->dacs[CAL] << ")!\nTaking first: " << a->dacs[CAL];
|
||||||
<< ")!\n"
|
|
||||||
"Taking first: "
|
|
||||||
<< a->dacs[CAL];
|
|
||||||
}
|
}
|
||||||
myMod.dacs[CAL] = a->dacs[CAL];
|
myMod.dacs[CAL] = a->dacs[CAL];
|
||||||
|
|
||||||
@ -3937,7 +3912,6 @@ slsDetector::interpolateTrim(sls_detector_module *a, sls_detector_module *b,
|
|||||||
linearInterpolation(energy, e1, e2, a->dacs[dacs_to_interpolate[i]],
|
linearInterpolation(energy, e1, e2, a->dacs[dacs_to_interpolate[i]],
|
||||||
b->dacs[dacs_to_interpolate[i]]);
|
b->dacs[dacs_to_interpolate[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interpolate all trimbits
|
// Interpolate all trimbits
|
||||||
if (tb != 0) {
|
if (tb != 0) {
|
||||||
for (int i = 0; i < myMod.nchan; ++i) {
|
for (int i = 0; i < myMod.nchan; ++i) {
|
||||||
@ -3948,35 +3922,11 @@ slsDetector::interpolateTrim(sls_detector_module *a, sls_detector_module *b,
|
|||||||
return myMod;
|
return myMod;
|
||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module
|
sls_detector_module slsDetector::readSettingsFile(const std::string &fname,
|
||||||
slsDetector::readSettingsFile(const std::string &fname, int tb) {
|
int tb) {
|
||||||
|
|
||||||
FILE_LOG(logDEBUG1) << "Read settings file " << fname;
|
FILE_LOG(logDEBUG1) << "Read settings file " << fname;
|
||||||
sls_detector_module myMod(detector_shm()->myDetectorType);
|
sls_detector_module myMod(detector_shm()->myDetectorType);
|
||||||
|
auto names = getSettingsFileDacNames();
|
||||||
std::vector<std::string> names;
|
|
||||||
switch (detector_shm()->myDetectorType) {
|
|
||||||
case GOTTHARD:
|
|
||||||
names = {"Vref", "VcascN", "VcascP", "Vout",
|
|
||||||
"Vcasc", "Vin", "Vref_comp", "Vib_test"};
|
|
||||||
break;
|
|
||||||
case EIGER:
|
|
||||||
break;
|
|
||||||
case JUNGFRAU:
|
|
||||||
names.emplace_back("VDAC0");
|
|
||||||
names.emplace_back("VDAC1");
|
|
||||||
names.emplace_back("VDAC2");
|
|
||||||
names.emplace_back("VDAC3");
|
|
||||||
names.emplace_back("VDAC4");
|
|
||||||
names.emplace_back("VDAC5");
|
|
||||||
names.emplace_back("VDAC6");
|
|
||||||
names.emplace_back("VDAC7");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw RuntimeError(
|
|
||||||
"Unknown detector type - unknown format for settings file");
|
|
||||||
}
|
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
std::ifstream infile;
|
std::ifstream infile;
|
||||||
if (detector_shm()->myDetectorType == EIGER) {
|
if (detector_shm()->myDetectorType == EIGER) {
|
||||||
@ -3985,8 +3935,7 @@ slsDetector::readSettingsFile(const std::string &fname, int tb) {
|
|||||||
infile.open(fname.c_str(), std::ios_base::in);
|
infile.open(fname.c_str(), std::ios_base::in);
|
||||||
}
|
}
|
||||||
if (!infile.is_open()) {
|
if (!infile.is_open()) {
|
||||||
throw RuntimeError("Could not open settings file for reading: " +
|
throw RuntimeError("Could not open settings file: " + fname);
|
||||||
fname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// eiger
|
// eiger
|
||||||
@ -4071,26 +4020,8 @@ slsDetector::readSettingsFile(const std::string &fname, int tb) {
|
|||||||
|
|
||||||
int slsDetector::writeSettingsFile(const std::string &fname,
|
int slsDetector::writeSettingsFile(const std::string &fname,
|
||||||
sls_detector_module &mod) {
|
sls_detector_module &mod) {
|
||||||
|
|
||||||
FILE_LOG(logDEBUG1) << "Write settings file " << fname;
|
FILE_LOG(logDEBUG1) << "Write settings file " << fname;
|
||||||
|
auto names = getSettingsFileDacNames();
|
||||||
std::vector<std::string> names;
|
|
||||||
switch (detector_shm()->myDetectorType) {
|
|
||||||
case GOTTHARD:
|
|
||||||
names = {"Vref", "VcascN", "VcascP", "Vout",
|
|
||||||
"Vcasc", "Vin", "Vref_comp", "Vib_test"};
|
|
||||||
break;
|
|
||||||
case EIGER:
|
|
||||||
break;
|
|
||||||
case JUNGFRAU:
|
|
||||||
names = {"VDAC0", "VDAC1", "VDAC2", "VDAC3", "VDAC4", "VDAC5",
|
|
||||||
"VDAC6", "VDAC7", "VDAC8", "VDAC9", "VDAC10", "VDAC11",
|
|
||||||
"VDAC12", "VDAC13", "VDAC14", "VDAC15"};
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw RuntimeError(
|
|
||||||
"Unknown detector type - unknown format for settings file");
|
|
||||||
}
|
|
||||||
std::ofstream outfile;
|
std::ofstream outfile;
|
||||||
if (detector_shm()->myDetectorType == EIGER) {
|
if (detector_shm()->myDetectorType == EIGER) {
|
||||||
outfile.open(fname.c_str(), std::ofstream::binary);
|
outfile.open(fname.c_str(), std::ofstream::binary);
|
||||||
@ -4126,3 +4057,24 @@ int slsDetector::writeSettingsFile(const std::string &fname,
|
|||||||
outfile.close();
|
outfile.close();
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string>
|
||||||
|
slsDetector::getSettingsFileDacNames() {
|
||||||
|
switch (detector_shm()->myDetectorType) {
|
||||||
|
case GOTTHARD:
|
||||||
|
return {"Vref", "VcascN", "VcascP", "Vout",
|
||||||
|
"Vcasc", "Vin", "Vref_comp", "Vib_test"};
|
||||||
|
break;
|
||||||
|
case EIGER:
|
||||||
|
break;
|
||||||
|
case JUNGFRAU:
|
||||||
|
return {"VDAC0", "VDAC1", "VDAC2", "VDAC3", "VDAC4", "VDAC5",
|
||||||
|
"VDAC6", "VDAC7", "VDAC8", "VDAC9", "VDAC10", "VDAC11",
|
||||||
|
"VDAC12", "VDAC13", "VDAC14", "VDAC15"};
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw RuntimeError(
|
||||||
|
"Unknown detector type - unknown format for settings file");
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
Reference in New Issue
Block a user