mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-19 08:17:13 +02:00
ratecorrectiosn addded to master file
This commit is contained in:
@ -771,6 +771,7 @@ Result<std::string> Detector::getRxHostname(Positions pos) const {
|
||||
|
||||
void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
||||
updateRxRateCorrections();
|
||||
}
|
||||
|
||||
void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
@ -788,6 +789,7 @@ void Detector::setRxHostname(const std::vector<std::string> &name) {
|
||||
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);
|
||||
}
|
||||
}
|
||||
updateRxRateCorrections();
|
||||
}
|
||||
|
||||
Result<int> Detector::getRxPort(Positions pos) const {
|
||||
@ -1109,6 +1111,20 @@ void Detector::setDefaultRateCorrection(Positions pos) {
|
||||
|
||||
void Detector::setRateCorrection(ns dead_time, Positions pos) {
|
||||
pimpl->Parallel(&Module::setRateCorrection, pos, dead_time.count());
|
||||
updateRxRateCorrections();
|
||||
}
|
||||
|
||||
void Detector::updateRxRateCorrections() {
|
||||
// get tau from all modules and send to Rx index 0
|
||||
if (getUseReceiverFlag().squash(false)) {
|
||||
// convert Result<ns> to std::vector<in64_t>
|
||||
auto retval = getRateCorrection();
|
||||
std::vector<int64_t> t(retval.size());
|
||||
for (int i = 0; i < (int)retval.size(); ++i) {
|
||||
t[i] = retval[i].count();
|
||||
}
|
||||
pimpl->Parallel(&Module::sendReceiverRateCorrections, {0}, t);
|
||||
}
|
||||
}
|
||||
|
||||
Result<int> Detector::getPartialReadout(Positions pos) const {
|
||||
|
@ -1163,6 +1163,21 @@ void Module::setRateCorrection(int64_t t) {
|
||||
sendToDetector(F_SET_RATE_CORRECT, t, nullptr);
|
||||
}
|
||||
|
||||
void Module::sendReceiverRateCorrections(const std::vector<int64_t> &t) {
|
||||
LOG(logDEBUG) << "Sending to detector [rate corrections: " << ToString(t)
|
||||
<< ']';
|
||||
auto receiver = ReceiverSocket(shm()->rxHostname, shm()->rxTCPPort);
|
||||
receiver.Send(F_SET_RECEIVER_RATE_CORRECT);
|
||||
// TODO: use overload for vector
|
||||
int size = t.size();
|
||||
receiver.Send(size);
|
||||
receiver.Send(t.data(), t.size() * sizeof(t[0]));
|
||||
if (receiver.Receive<int>() == FAIL) {
|
||||
throw RuntimeError("Receiver " + std::to_string(moduleId) +
|
||||
" returned error: " + receiver.readErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
int Module::getReadNLines() const {
|
||||
return sendToDetector<int>(F_GET_READ_N_LINES);
|
||||
}
|
||||
|
@ -312,6 +312,7 @@ class Module : public virtual slsDetectorDefs {
|
||||
int64_t getRateCorrection() const;
|
||||
void setDefaultRateCorrection();
|
||||
void setRateCorrection(int64_t t = 0);
|
||||
void sendReceiverRateCorrections(const std::vector<int64_t> &t);
|
||||
int getReadNLines() const;
|
||||
void setReadNLines(const int value);
|
||||
bool getInterruptSubframe() const;
|
||||
@ -371,8 +372,9 @@ class Module : public virtual slsDetectorDefs {
|
||||
void setBurstPeriod(int64_t value);
|
||||
std::array<int, 2> getInjectChannel() const;
|
||||
void setInjectChannel(const int offsetChannel, const int incrementChannel);
|
||||
void sendVetoPhoton(const int chipIndex, const std::vector<int>& gainIndices,
|
||||
const std::vector<int>& values);
|
||||
void sendVetoPhoton(const int chipIndex,
|
||||
const std::vector<int> &gainIndices,
|
||||
const std::vector<int> &values);
|
||||
void getVetoPhoton(const int chipIndex, const std::string &fname) const;
|
||||
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||
const int energy, const std::string &fname);
|
||||
|
Reference in New Issue
Block a user