mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-31 08:31:18 +01:00
renaming sls and detectors to modules, multis to detector
This commit is contained in:
@@ -59,7 +59,7 @@ void Module::freeSharedMemory() {
|
||||
}
|
||||
|
||||
bool Module::isFixedPatternSharedMemoryCompatible() const {
|
||||
return (shm()->shmversion >= SLS_SHMAPIVERSION);
|
||||
return (shm()->shmversion >= MODULE_SHMAPIVERSION);
|
||||
}
|
||||
|
||||
std::string Module::getHostname() const { return shm()->hostname; }
|
||||
@@ -71,7 +71,7 @@ void Module::setHostname(const std::string &hostname,
|
||||
client.close();
|
||||
try {
|
||||
checkDetectorVersionCompatibility();
|
||||
LOG(logINFO) << "Detector Version Compatibility - Success";
|
||||
LOG(logINFO) << "Module Version Compatibility - Success";
|
||||
} catch (const DetectorError &e) {
|
||||
if (!initialChecks) {
|
||||
LOG(logWARNING) << "Bypassing Initial Checks at your own risk!";
|
||||
@@ -79,7 +79,7 @@ void Module::setHostname(const std::string &hostname,
|
||||
throw;
|
||||
}
|
||||
}
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
setActivate(true);
|
||||
}
|
||||
}
|
||||
@@ -108,22 +108,21 @@ int64_t Module::getReceiverSoftwareVersion() const {
|
||||
// static function
|
||||
slsDetectorDefs::detectorType
|
||||
Module::getTypeFromDetector(const std::string &hostname, int cport) {
|
||||
LOG(logDEBUG1) << "Getting detector type ";
|
||||
LOG(logDEBUG1) << "Getting Module type ";
|
||||
sls::ClientSocket socket("Detector", hostname, cport);
|
||||
socket.Send(F_GET_DETECTOR_TYPE);
|
||||
socket.Receive<int>(); // TODO! Should we look at this OK/FAIL?
|
||||
auto retval = socket.Receive<detectorType>();
|
||||
LOG(logDEBUG1) << "Detector type is " << retval;
|
||||
LOG(logDEBUG1) << "Module type is " << retval;
|
||||
return retval;
|
||||
}
|
||||
|
||||
slsDetectorDefs::detectorType Module::getDetectorType() const {
|
||||
return shm()->myDetectorType;
|
||||
return shm()->detType;
|
||||
}
|
||||
|
||||
void Module::updateNumberOfChannels() {
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD ||
|
||||
shm()->myDetectorType == MOENCH) {
|
||||
if (shm()->detType == CHIPTESTBOARD || shm()->detType == MOENCH) {
|
||||
std::array<int, 2> retvals{};
|
||||
sendToDetector(F_GET_NUM_CHANNELS, nullptr, retvals);
|
||||
shm()->nChan.x = retvals[0];
|
||||
@@ -138,9 +137,9 @@ slsDetectorDefs::xy Module::getNumberOfChannels() const {
|
||||
return coord;
|
||||
}
|
||||
|
||||
void Module::updateNumberOfDetector(slsDetectorDefs::xy det) {
|
||||
shm()->numberOfDetector = det;
|
||||
int args[2] = {shm()->numberOfDetector.y, moduleIndex};
|
||||
void Module::updateNumberOfModule(slsDetectorDefs::xy det) {
|
||||
shm()->numberOfModule = det;
|
||||
int args[2] = {shm()->numberOfModule.y, moduleIndex};
|
||||
sendToDetector(F_SET_POSITION, args, nullptr);
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ slsDetectorDefs::detectorSettings Module::getSettings() const {
|
||||
}
|
||||
|
||||
void Module::setSettings(detectorSettings isettings) {
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
throw RuntimeError(
|
||||
"Cannot set settings for Eiger. Use threshold energy.");
|
||||
}
|
||||
@@ -177,7 +176,7 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
std::all_of(shm()->trimEnergies.begin(), shm()->trimEnergies.end(),
|
||||
[e_eV](const int &e) { return e != e_eV; });
|
||||
|
||||
sls_detector_module myMod{shm()->myDetectorType};
|
||||
sls_detector_module myMod{shm()->detType};
|
||||
|
||||
if (!interpolate) {
|
||||
std::string settingsfname = getTrimbitFilename(isettings, e_eV);
|
||||
@@ -214,7 +213,7 @@ void Module::setThresholdEnergy(int e_eV, detectorSettings isettings,
|
||||
setModule(myMod, trimbits);
|
||||
if (getSettings() != isettings) {
|
||||
throw RuntimeError("setThresholdEnergyAndSettings: Could not set "
|
||||
"settings in detector");
|
||||
"settings in Module");
|
||||
}
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
@@ -249,7 +248,7 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
M_VDCSH
|
||||
};
|
||||
|
||||
std::vector<sls_detector_module> myMods{shm()->myDetectorType};
|
||||
std::vector<sls_detector_module> myMods{shm()->detType};
|
||||
std::vector<int> energy(e_eV.begin(), e_eV.end());
|
||||
// if all energies are same
|
||||
if (allEqualTo(energy, energy[0])) {
|
||||
@@ -307,7 +306,7 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
}
|
||||
}
|
||||
|
||||
sls_detector_module myMod{shm()->myDetectorType};
|
||||
sls_detector_module myMod{shm()->detType};
|
||||
myMod = myMods[0];
|
||||
|
||||
// if multiple thresholds, combine
|
||||
@@ -392,7 +391,7 @@ void Module::setAllThresholdEnergy(std::array<int, 3> e_eV,
|
||||
setModule(myMod, trimbits);
|
||||
if (getSettings() != isettings) {
|
||||
throw RuntimeError("setThresholdEnergyAndSettings: Could not set "
|
||||
"settings in detector");
|
||||
"settings in Module");
|
||||
}
|
||||
|
||||
if (shm()->useReceiverFlag) {
|
||||
@@ -411,11 +410,11 @@ std::string Module::setSettingsDir(const std::string &dir) {
|
||||
|
||||
void Module::loadTrimbits(const std::string &fname) {
|
||||
// find specific file if it has detid in file name (.snxxx)
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
if (shm()->detType == EIGER || shm()->detType == MYTHEN3) {
|
||||
std::ostringstream ostfn;
|
||||
ostfn << fname;
|
||||
int moduleIdWidth = 3;
|
||||
if (shm()->myDetectorType == MYTHEN3) {
|
||||
if (shm()->detType == MYTHEN3) {
|
||||
moduleIdWidth = 4;
|
||||
}
|
||||
if ((fname.find(".sn") == std::string::npos) &&
|
||||
@@ -439,7 +438,7 @@ void Module::setAllTrimbits(int val) {
|
||||
}
|
||||
|
||||
std::vector<int> Module::getTrimEn() const {
|
||||
if (shm()->myDetectorType != EIGER && shm()->myDetectorType != MYTHEN3) {
|
||||
if (shm()->detType != EIGER && shm()->detType != MYTHEN3) {
|
||||
throw RuntimeError("getTrimEn not implemented for this detector.");
|
||||
}
|
||||
return std::vector<int>(shm()->trimEnergies.begin(),
|
||||
@@ -447,7 +446,7 @@ std::vector<int> Module::getTrimEn() const {
|
||||
}
|
||||
|
||||
int Module::setTrimEn(const std::vector<int> &energies) {
|
||||
if (shm()->myDetectorType != EIGER && shm()->myDetectorType != MYTHEN3) {
|
||||
if (shm()->detType != EIGER && shm()->detType != MYTHEN3) {
|
||||
throw RuntimeError("setTrimEn not implemented for this detector.");
|
||||
}
|
||||
if (energies.size() > MAX_TRIMEN) {
|
||||
@@ -463,14 +462,14 @@ int Module::setTrimEn(const std::vector<int> &energies) {
|
||||
}
|
||||
|
||||
bool Module::getFlipRows() const {
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
return sendToReceiver<int>(F_GET_FLIP_ROWS_RECEIVER);
|
||||
}
|
||||
return sendToDetector<int>(F_GET_FLIP_ROWS);
|
||||
}
|
||||
|
||||
void Module::setFlipRows(bool value) {
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
sendToReceiver<int>(F_SET_FLIP_ROWS_RECEIVER, static_cast<int>(value));
|
||||
} else {
|
||||
sendToDetector(F_SET_FLIP_ROWS, static_cast<int>(value), nullptr);
|
||||
@@ -509,7 +508,7 @@ int64_t Module::getExptime(int gateIndex) const {
|
||||
|
||||
void Module::setExptime(int gateIndex, int64_t value) {
|
||||
int64_t prevVal = value;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
prevVal = getExptime(-1);
|
||||
}
|
||||
int64_t args[]{static_cast<int64_t>(gateIndex), value};
|
||||
@@ -563,7 +562,7 @@ int Module::getDynamicRange() const {
|
||||
|
||||
void Module::setDynamicRange(int dr) {
|
||||
int prev_val = dr;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
prev_val = getDynamicRange();
|
||||
}
|
||||
|
||||
@@ -573,7 +572,7 @@ void Module::setDynamicRange(int dr) {
|
||||
}
|
||||
|
||||
// update speed
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
if (dr == 32) {
|
||||
LOG(logINFO) << "Setting Clock to Quarter Speed to cope with "
|
||||
"Dynamic Range of 32";
|
||||
@@ -995,7 +994,7 @@ void Module::setDestinationUDPIP(const IpAddr ip) {
|
||||
if (shm()->useReceiverFlag) {
|
||||
sls::MacAddr retval(0LU);
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_IP, ip, retval);
|
||||
LOG(logINFO) << "Setting destination udp mac of detector " << moduleIndex
|
||||
LOG(logINFO) << "Setting destination udp mac of Module " << moduleIndex
|
||||
<< " to " << retval;
|
||||
sendToDetector(F_SET_DEST_UDP_MAC, retval, nullptr);
|
||||
}
|
||||
@@ -1015,7 +1014,7 @@ void Module::setDestinationUDPIP2(const IpAddr ip) {
|
||||
if (shm()->useReceiverFlag) {
|
||||
sls::MacAddr retval(0LU);
|
||||
sendToReceiver(F_SET_RECEIVER_UDP_IP2, ip, retval);
|
||||
LOG(logINFO) << "Setting destination udp mac2 of detector " << moduleIndex
|
||||
LOG(logINFO) << "Setting destination udp mac2 of Module " << moduleIndex
|
||||
<< " to " << retval;
|
||||
sendToDetector(F_SET_DEST_UDP_MAC2, retval, nullptr);
|
||||
}
|
||||
@@ -1073,27 +1072,28 @@ void Module::validateUDPConfiguration() {
|
||||
|
||||
std::string Module::printReceiverConfiguration() {
|
||||
std::ostringstream os;
|
||||
os << "\n\nDetector " << moduleIndex << "\nReceiver Hostname:\t"
|
||||
os << "\n\nModule " << moduleIndex << "\nReceiver Hostname:\t"
|
||||
<< getReceiverHostname();
|
||||
|
||||
if (shm()->myDetectorType == JUNGFRAU) {
|
||||
if (shm()->detType == JUNGFRAU) {
|
||||
os << "\nNumber of Interfaces:\t" << getNumberofUDPInterfaces()
|
||||
<< "\nSelected Interface:\t" << getSelectedUDPInterface();
|
||||
}
|
||||
|
||||
os << "\nDetector UDP IP:\t" << getSourceUDPIP() << "\nDetector UDP MAC:\t"
|
||||
<< getSourceUDPMAC() << "\nReceiver UDP IP:\t" << getDestinationUDPIP()
|
||||
<< "\nReceiver UDP MAC:\t" << getDestinationUDPMAC();
|
||||
os << "\nSource UDP IP:\t" << getSourceUDPIP() << "\nSource UDP MAC:\t"
|
||||
<< getSourceUDPMAC() << "\nDestination UDP IP:\t"
|
||||
<< getDestinationUDPIP() << "\nReceiver UDP MAC:\t"
|
||||
<< getDestinationUDPMAC();
|
||||
|
||||
if (shm()->myDetectorType == JUNGFRAU) {
|
||||
os << "\nDetector UDP IP2:\t" << getSourceUDPIP2()
|
||||
<< "\nDetector UDP MAC2:\t" << getSourceUDPMAC2()
|
||||
<< "\nReceiver UDP IP2:\t" << getDestinationUDPIP2()
|
||||
<< "\nReceiver UDP MAC2:\t" << getDestinationUDPMAC2();
|
||||
if (shm()->detType == JUNGFRAU) {
|
||||
os << "\nSource UDP IP2:\t" << getSourceUDPIP2()
|
||||
<< "\nSource UDP MAC2:\t" << getSourceUDPMAC2()
|
||||
<< "\nDestination UDP IP2:\t" << getDestinationUDPIP2()
|
||||
<< "\nDestination UDP MAC2:\t" << getDestinationUDPMAC2();
|
||||
}
|
||||
os << "\nReceiver UDP Port:\t" << getDestinationUDPPort();
|
||||
if (shm()->myDetectorType == JUNGFRAU || shm()->myDetectorType == EIGER) {
|
||||
os << "\nReceiver UDP Port2:\t" << getDestinationUDPPort2();
|
||||
os << "\nDestination UDP Port:\t" << getDestinationUDPPort();
|
||||
if (shm()->detType == JUNGFRAU || shm()->detType == EIGER) {
|
||||
os << "\nDestination UDP Port2:\t" << getDestinationUDPPort2();
|
||||
}
|
||||
os << "\n";
|
||||
return os.str();
|
||||
@@ -1184,25 +1184,25 @@ void Module::setReceiverHostname(const std::string &receiverIP) {
|
||||
sendToDetector(F_GET_RECEIVER_PARAMETERS, nullptr, retval);
|
||||
|
||||
// populate from shared memory
|
||||
retval.detType = shm()->myDetectorType;
|
||||
retval.numberOfDetector.x = shm()->numberOfDetector.x;
|
||||
retval.numberOfDetector.y = shm()->numberOfDetector.y;
|
||||
retval.detType = shm()->detType;
|
||||
retval.numberOfModule.x = shm()->numberOfModule.x;
|
||||
retval.numberOfModule.y = shm()->numberOfModule.y;
|
||||
retval.moduleIndex = moduleIndex;
|
||||
memset(retval.hostname, 0, sizeof(retval.hostname));
|
||||
strcpy_safe(retval.hostname, shm()->hostname);
|
||||
|
||||
sls::MacAddr retvals[2];
|
||||
sendToReceiver(F_SETUP_RECEIVER, retval, retvals);
|
||||
// update detectors with dest mac
|
||||
// update Modules with dest mac
|
||||
if (retval.udp_dstmac == 0 && retvals[0] != 0) {
|
||||
LOG(logINFO) << "Setting destination udp mac of "
|
||||
"detector "
|
||||
"Module "
|
||||
<< moduleIndex << " to " << retvals[0];
|
||||
sendToDetector(F_SET_DEST_UDP_MAC, retvals[0], nullptr);
|
||||
}
|
||||
if (retval.udp_dstmac2 == 0 && retvals[1] != 0) {
|
||||
LOG(logINFO) << "Setting destination udp mac2 of "
|
||||
"detector "
|
||||
"Module "
|
||||
<< moduleIndex << " to " << retvals[1];
|
||||
sendToDetector(F_SET_DEST_UDP_MAC2, retvals[1], nullptr);
|
||||
}
|
||||
@@ -1467,7 +1467,7 @@ int64_t Module::getSubExptime() const {
|
||||
|
||||
void Module::setSubExptime(int64_t value) {
|
||||
int64_t prevVal = value;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
prevVal = getSubExptime();
|
||||
}
|
||||
sendToDetector(F_SET_SUB_EXPTIME, value, nullptr);
|
||||
@@ -1512,7 +1512,7 @@ void Module::setRateCorrection(int64_t t) {
|
||||
}
|
||||
|
||||
void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
|
||||
LOG(logDEBUG) << "Sending to detector [rate corrections: " << ToString(t)
|
||||
LOG(logDEBUG) << "Sending to Module [rate corrections: " << ToString(t)
|
||||
<< ']';
|
||||
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.Send(F_SET_RECEIVER_RATE_CORRECT);
|
||||
@@ -1824,7 +1824,7 @@ void Module::getVetoPhoton(const int chipIndex,
|
||||
|
||||
void Module::setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||
const int energy, const std::string &fname) {
|
||||
if (shm()->myDetectorType != GOTTHARD2) {
|
||||
if (shm()->detType != GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"Set Veto reference is not implemented for this detector");
|
||||
}
|
||||
@@ -1905,7 +1905,7 @@ void Module::setVetoReference(const int gainIndex, const int value) {
|
||||
}
|
||||
|
||||
void Module::setVetoFile(const int chipIndex, const std::string &fname) {
|
||||
if (shm()->myDetectorType != GOTTHARD2) {
|
||||
if (shm()->detType != GOTTHARD2) {
|
||||
throw RuntimeError(
|
||||
"Set Veto file is not implemented for this detector");
|
||||
}
|
||||
@@ -2225,7 +2225,7 @@ void Module::setReadoutMode(const slsDetectorDefs::readoutMode mode) {
|
||||
auto arg = static_cast<uint32_t>(mode); // TODO! unit?
|
||||
sendToDetector(F_SET_READOUT_MODE, arg, nullptr);
|
||||
// update #nchan, as it depends on #samples, adcmask,
|
||||
if (shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
if (shm()->detType == CHIPTESTBOARD) {
|
||||
updateNumberOfChannels();
|
||||
}
|
||||
if (shm()->useReceiverFlag) {
|
||||
@@ -2481,7 +2481,7 @@ void Module::setAdditionalJsonParameter(const std::string &key,
|
||||
|
||||
// Advanced
|
||||
void Module::programFPGA(std::vector<char> buffer) {
|
||||
switch (shm()->myDetectorType) {
|
||||
switch (shm()->detType) {
|
||||
case JUNGFRAU:
|
||||
case CHIPTESTBOARD:
|
||||
case MOENCH:
|
||||
@@ -3003,42 +3003,42 @@ slsDetectorDefs::detectorType Module::getDetectorTypeFromShm(int det_id,
|
||||
}
|
||||
|
||||
shm.OpenSharedMemory();
|
||||
if (verify && shm()->shmversion != SLS_SHMVERSION) {
|
||||
if (verify && shm()->shmversion != MODULE_SHMVERSION) {
|
||||
std::ostringstream ss;
|
||||
ss << "Single shared memory (" << det_id << "-" << moduleIndex
|
||||
<< ":)version mismatch (expected 0x" << std::hex << SLS_SHMVERSION
|
||||
<< ":)version mismatch (expected 0x" << std::hex << MODULE_SHMVERSION
|
||||
<< " but got 0x" << shm()->shmversion << ")" << std::dec
|
||||
<< ". Clear Shared memory to continue.";
|
||||
shm.UnmapSharedMemory();
|
||||
throw SharedMemoryError(ss.str());
|
||||
}
|
||||
return shm()->myDetectorType;
|
||||
return shm()->detType;
|
||||
}
|
||||
|
||||
void Module::initSharedMemory(detectorType type, int det_id, bool verify) {
|
||||
shm = SharedMemory<sharedSlsDetector>(det_id, moduleIndex);
|
||||
shm = SharedMemory<sharedModule>(det_id, moduleIndex);
|
||||
if (!shm.IsExisting()) {
|
||||
shm.CreateSharedMemory();
|
||||
initializeDetectorStructure(type);
|
||||
initializeModuleStructure(type);
|
||||
} else {
|
||||
shm.OpenSharedMemory();
|
||||
if (verify && shm()->shmversion != SLS_SHMVERSION) {
|
||||
if (verify && shm()->shmversion != MODULE_SHMVERSION) {
|
||||
std::ostringstream ss;
|
||||
ss << "Single shared memory (" << det_id << "-" << moduleIndex
|
||||
<< ":) version mismatch (expected 0x" << std::hex
|
||||
<< SLS_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
|
||||
<< MODULE_SHMVERSION << " but got 0x" << shm()->shmversion << ")"
|
||||
<< std::dec << ". Clear Shared memory to continue.";
|
||||
throw SharedMemoryError(ss.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Module::initializeDetectorStructure(detectorType type) {
|
||||
shm()->shmversion = SLS_SHMVERSION;
|
||||
void Module::initializeModuleStructure(detectorType type) {
|
||||
shm()->shmversion = MODULE_SHMVERSION;
|
||||
memset(shm()->hostname, 0, MAX_STR_LENGTH);
|
||||
shm()->myDetectorType = type;
|
||||
shm()->numberOfDetector.x = 0;
|
||||
shm()->numberOfDetector.y = 0;
|
||||
shm()->detType = type;
|
||||
shm()->numberOfModule.x = 0;
|
||||
shm()->numberOfModule.y = 0;
|
||||
shm()->controlPort = DEFAULT_PORTNO;
|
||||
shm()->stopPort = DEFAULT_PORTNO + 1;
|
||||
sls::strcpy_safe(shm()->settingsDir, getenv("HOME"));
|
||||
@@ -3046,12 +3046,12 @@ void Module::initializeDetectorStructure(detectorType type) {
|
||||
shm()->rxTCPPort = DEFAULT_PORTNO + 2;
|
||||
shm()->useReceiverFlag = false;
|
||||
shm()->zmqport = DEFAULT_ZMQ_CL_PORTNO +
|
||||
(moduleIndex * ((shm()->myDetectorType == EIGER) ? 2 : 1));
|
||||
(moduleIndex * ((shm()->detType == EIGER) ? 2 : 1));
|
||||
shm()->zmqip = IpAddr{};
|
||||
shm()->numUDPInterfaces = 1;
|
||||
shm()->stoppedFlag = false;
|
||||
|
||||
// get the detector parameters based on type
|
||||
// get the Module parameters based on type
|
||||
detParameters parameters{type};
|
||||
shm()->nChan.x = parameters.nChanX;
|
||||
shm()->nChan.y = parameters.nChanY;
|
||||
@@ -3062,7 +3062,7 @@ void Module::initializeDetectorStructure(detectorType type) {
|
||||
|
||||
void Module::checkDetectorVersionCompatibility() {
|
||||
int64_t arg = 0;
|
||||
switch (shm()->myDetectorType) {
|
||||
switch (shm()->detType) {
|
||||
case EIGER:
|
||||
arg = APIEIGER;
|
||||
break;
|
||||
@@ -3140,7 +3140,7 @@ int Module::sendModule(sls_detector_module *myMod, sls::ClientSocket &client) {
|
||||
ts += n;
|
||||
LOG(level) << "dacs sent. " << n << " bytes";
|
||||
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
if (shm()->detType == EIGER || shm()->detType == MYTHEN3) {
|
||||
n = client.Send(myMod->chanregs, sizeof(int) * (myMod->nchan));
|
||||
ts += n;
|
||||
LOG(level) << "channels sent. " << n << " bytes";
|
||||
@@ -3187,12 +3187,12 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
|
||||
const int energy, const int e1,
|
||||
const int e2, bool trimbits) {
|
||||
// dacs specified only for eiger and mythen3
|
||||
if (shm()->myDetectorType != EIGER && shm()->myDetectorType != MYTHEN3) {
|
||||
if (shm()->detType != EIGER && shm()->detType != MYTHEN3) {
|
||||
throw NotImplementedError(
|
||||
"Interpolation of Trim values not implemented for this detector!");
|
||||
}
|
||||
|
||||
sls_detector_module myMod{shm()->myDetectorType};
|
||||
sls_detector_module myMod{shm()->detType};
|
||||
enum eiger_DacIndex {
|
||||
E_SVP,
|
||||
E_VTR,
|
||||
@@ -3232,7 +3232,7 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
|
||||
|
||||
// create copy and interpolate dac lists
|
||||
std::vector<int> dacs_to_copy, dacs_to_interpolate;
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
dacs_to_copy.insert(
|
||||
dacs_to_copy.end(),
|
||||
{E_SVP, E_VTR, E_SVN, E_VTGSTV, E_RXB_RB, E_RXB_LB, E_VCN, E_VIS});
|
||||
@@ -3267,7 +3267,7 @@ sls_detector_module Module::interpolateTrim(sls_detector_module *a,
|
||||
}
|
||||
|
||||
// Copy irrelevant dacs (without failing)
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
// CAL
|
||||
if (a->dacs[E_CAL] != b->dacs[E_CAL]) {
|
||||
LOG(logWARNING)
|
||||
@@ -3315,16 +3315,16 @@ std::string Module::getTrimbitFilename(detectorSettings s, int e_eV) {
|
||||
}
|
||||
std::ostringstream ostfn;
|
||||
ostfn << shm()->settingsDir << ssettings << "/" << e_eV << "eV";
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
ostfn << "/noise.sn";
|
||||
} else if (shm()->myDetectorType == MYTHEN3) {
|
||||
} else if (shm()->detType == MYTHEN3) {
|
||||
ostfn << "/trim.sn";
|
||||
} else {
|
||||
throw RuntimeError(
|
||||
"Settings or trimbit files not defined for this detector.");
|
||||
}
|
||||
int moduleIdWidth = 3;
|
||||
if (shm()->myDetectorType == MYTHEN3) {
|
||||
if (shm()->detType == MYTHEN3) {
|
||||
moduleIdWidth = 4;
|
||||
}
|
||||
ostfn << std::setfill('0') << std::setw(moduleIdWidth) << std::dec
|
||||
@@ -3335,10 +3335,10 @@ std::string Module::getTrimbitFilename(detectorSettings s, int e_eV) {
|
||||
sls_detector_module Module::readSettingsFile(const std::string &fname,
|
||||
bool trimbits) {
|
||||
LOG(logDEBUG1) << "Read settings file " << fname;
|
||||
sls_detector_module myMod(shm()->myDetectorType);
|
||||
sls_detector_module myMod(shm()->detType);
|
||||
// open file
|
||||
std::ifstream infile;
|
||||
if (shm()->myDetectorType == EIGER || shm()->myDetectorType == MYTHEN3) {
|
||||
if (shm()->detType == EIGER || shm()->detType == MYTHEN3) {
|
||||
infile.open(fname.c_str(), std::ifstream::binary);
|
||||
} else {
|
||||
infile.open(fname.c_str(), std::ios_base::in);
|
||||
@@ -3350,7 +3350,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
||||
auto file_size = getFileSize(infile);
|
||||
|
||||
// eiger
|
||||
if (shm()->myDetectorType == EIGER) {
|
||||
if (shm()->detType == EIGER) {
|
||||
infile.read(reinterpret_cast<char *>(myMod.dacs),
|
||||
sizeof(int) * (myMod.ndac));
|
||||
infile.read(reinterpret_cast<char *>(&myMod.iodelay),
|
||||
@@ -3373,7 +3373,7 @@ sls_detector_module Module::readSettingsFile(const std::string &fname,
|
||||
}
|
||||
|
||||
// mythen3 (dacs, trimbits)
|
||||
else if (shm()->myDetectorType == MYTHEN3) {
|
||||
else if (shm()->detType == MYTHEN3) {
|
||||
int expected_size = sizeof(int) * myMod.ndac +
|
||||
sizeof(int) * myMod.nchan + sizeof(myMod.reg);
|
||||
if (file_size != expected_size) {
|
||||
@@ -3439,7 +3439,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::cout << '\n';
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
@@ -3459,7 +3459,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::cout << '\n';
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
@@ -3470,7 +3470,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
// checksum
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
@@ -3522,7 +3522,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
@@ -3535,7 +3535,7 @@ void Module::programFPGAviaBlackfin(std::vector<char> buffer) {
|
||||
}
|
||||
|
||||
void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
LOG(logINFO) << "Sending programming binary (from rbf) to detector "
|
||||
LOG(logINFO) << "Sending programming binary (from rbf) to Module "
|
||||
<< moduleIndex << " (" << shm()->hostname << ")";
|
||||
|
||||
auto client = DetectorSocket(shm()->hostname, shm()->controlPort);
|
||||
@@ -3554,7 +3554,7 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
// validate file size before sending program
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
@@ -3604,7 +3604,7 @@ void Module::programFPGAviaNios(std::vector<char> buffer) {
|
||||
}
|
||||
if (client.Receive<int>() == FAIL) {
|
||||
std::ostringstream os;
|
||||
os << "Detector " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
os << "Module " << moduleIndex << " (" << shm()->hostname << ")"
|
||||
<< " returned error: " << client.readErrorMessage();
|
||||
throw RuntimeError(os.str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user