mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-08 19:10:42 +02:00
ratecorrectiosn addded to master file
This commit is contained in:
parent
bea4ba131a
commit
885b22eca8
@ -1469,6 +1469,7 @@ class Detector {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<int> getPortNumbers(int start_port);
|
std::vector<int> getPortNumbers(int start_port);
|
||||||
|
void updateRxRateCorrections();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
@ -771,6 +771,7 @@ Result<std::string> Detector::getRxHostname(Positions pos) const {
|
|||||||
|
|
||||||
void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
void Detector::setRxHostname(const std::string &receiver, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
pimpl->Parallel(&Module::setReceiverHostname, pos, receiver);
|
||||||
|
updateRxRateCorrections();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Detector::setRxHostname(const std::vector<std::string> &name) {
|
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]);
|
pimpl->Parallel(&Module::setReceiverHostname, {idet}, name[idet]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateRxRateCorrections();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<int> Detector::getRxPort(Positions pos) const {
|
Result<int> Detector::getRxPort(Positions pos) const {
|
||||||
@ -1109,6 +1111,20 @@ void Detector::setDefaultRateCorrection(Positions pos) {
|
|||||||
|
|
||||||
void Detector::setRateCorrection(ns dead_time, Positions pos) {
|
void Detector::setRateCorrection(ns dead_time, Positions pos) {
|
||||||
pimpl->Parallel(&Module::setRateCorrection, pos, dead_time.count());
|
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 {
|
Result<int> Detector::getPartialReadout(Positions pos) const {
|
||||||
|
@ -1163,6 +1163,21 @@ void Module::setRateCorrection(int64_t t) {
|
|||||||
sendToDetector(F_SET_RATE_CORRECT, t, nullptr);
|
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 {
|
int Module::getReadNLines() const {
|
||||||
return sendToDetector<int>(F_GET_READ_N_LINES);
|
return sendToDetector<int>(F_GET_READ_N_LINES);
|
||||||
}
|
}
|
||||||
|
@ -312,6 +312,7 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
int64_t getRateCorrection() const;
|
int64_t getRateCorrection() const;
|
||||||
void setDefaultRateCorrection();
|
void setDefaultRateCorrection();
|
||||||
void setRateCorrection(int64_t t = 0);
|
void setRateCorrection(int64_t t = 0);
|
||||||
|
void sendReceiverRateCorrections(const std::vector<int64_t> &t);
|
||||||
int getReadNLines() const;
|
int getReadNLines() const;
|
||||||
void setReadNLines(const int value);
|
void setReadNLines(const int value);
|
||||||
bool getInterruptSubframe() const;
|
bool getInterruptSubframe() const;
|
||||||
@ -371,8 +372,9 @@ class Module : public virtual slsDetectorDefs {
|
|||||||
void setBurstPeriod(int64_t value);
|
void setBurstPeriod(int64_t value);
|
||||||
std::array<int, 2> getInjectChannel() const;
|
std::array<int, 2> getInjectChannel() const;
|
||||||
void setInjectChannel(const int offsetChannel, const int incrementChannel);
|
void setInjectChannel(const int offsetChannel, const int incrementChannel);
|
||||||
void sendVetoPhoton(const int chipIndex, const std::vector<int>& gainIndices,
|
void sendVetoPhoton(const int chipIndex,
|
||||||
const std::vector<int>& values);
|
const std::vector<int> &gainIndices,
|
||||||
|
const std::vector<int> &values);
|
||||||
void getVetoPhoton(const int chipIndex, const std::string &fname) const;
|
void getVetoPhoton(const int chipIndex, const std::string &fname) const;
|
||||||
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
void setVetoPhoton(const int chipIndex, const int numPhotons,
|
||||||
const int energy, const std::string &fname);
|
const int energy, const std::string &fname);
|
||||||
|
@ -201,6 +201,7 @@ int ClientInterface::functionTable(){
|
|||||||
flist[F_GET_RECEIVER_THREAD_IDS] = &ClientInterface::get_thread_ids;
|
flist[F_GET_RECEIVER_THREAD_IDS] = &ClientInterface::get_thread_ids;
|
||||||
flist[F_GET_RECEIVER_STREAMING_START_FNUM] = &ClientInterface::get_streaming_start_fnum;
|
flist[F_GET_RECEIVER_STREAMING_START_FNUM] = &ClientInterface::get_streaming_start_fnum;
|
||||||
flist[F_SET_RECEIVER_STREAMING_START_FNUM] = &ClientInterface::set_streaming_start_fnum;
|
flist[F_SET_RECEIVER_STREAMING_START_FNUM] = &ClientInterface::set_streaming_start_fnum;
|
||||||
|
flist[F_SET_RECEIVER_RATE_CORRECT] = &ClientInterface::set_rate_correct;
|
||||||
|
|
||||||
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 << " (" <<
|
||||||
@ -906,7 +907,8 @@ int ClientInterface::get_missing_packets(Interface &socket) {
|
|||||||
auto size = static_cast<int>(missing_packets.size());
|
auto size = static_cast<int>(missing_packets.size());
|
||||||
socket.Send(OK);
|
socket.Send(OK);
|
||||||
socket.Send(size);
|
socket.Send(size);
|
||||||
socket.Send(missing_packets.data(), sizeof(missing_packets[0])* missing_packets.size());
|
socket.Send(missing_packets.data(),
|
||||||
|
sizeof(missing_packets[0]) * missing_packets.size());
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1204,7 +1206,7 @@ int ClientInterface::set_additional_json_header(Interface &socket) {
|
|||||||
socket.Receive(&buff[0], buff.size());
|
socket.Receive(&buff[0], buff.size());
|
||||||
std::istringstream iss(buff);
|
std::istringstream iss(buff);
|
||||||
std::string key, value;
|
std::string key, value;
|
||||||
while(iss >> key){
|
while (iss >> key) {
|
||||||
iss >> value;
|
iss >> value;
|
||||||
json[key] = value;
|
json[key] = value;
|
||||||
}
|
}
|
||||||
@ -1219,7 +1221,7 @@ int ClientInterface::get_additional_json_header(Interface &socket) {
|
|||||||
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
|
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
|
||||||
LOG(logDEBUG1) << "additional json header:" << sls::ToString(json);
|
LOG(logDEBUG1) << "additional json header:" << sls::ToString(json);
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for (auto & it : json){
|
for (auto &it : json) {
|
||||||
oss << it.first << ' ' << it.second << ' ';
|
oss << it.first << ' ' << it.second << ' ';
|
||||||
}
|
}
|
||||||
auto buff = oss.str();
|
auto buff = oss.str();
|
||||||
@ -1735,3 +1737,18 @@ int ClientInterface::set_streaming_start_fnum(Interface &socket) {
|
|||||||
validate(index, retval, "set streaming start fnum", DEC);
|
validate(index, retval, "set streaming start fnum", DEC);
|
||||||
return socket.Send(OK);
|
return socket.Send(OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ClientInterface::set_rate_correct(Interface &socket) {
|
||||||
|
auto index = socket.Receive<int>();
|
||||||
|
if (index <= 0) {
|
||||||
|
throw RuntimeError("Invalid number of rate correction values: " +
|
||||||
|
std::to_string(index));
|
||||||
|
}
|
||||||
|
LOG(logDEBUG) << "Number of detectors for rate correction: " << index;
|
||||||
|
std::vector<int64_t> t(index);
|
||||||
|
socket.Receive(t.data(), t.size() * sizeof(t[0]));
|
||||||
|
verifyIdle(socket);
|
||||||
|
LOG(logINFOBLUE) << "Setting rate corrections[" << index << ']';
|
||||||
|
impl()->setRateCorrections(t);
|
||||||
|
return socket.Send(OK);
|
||||||
|
}
|
@ -157,6 +157,7 @@ class ClientInterface : private virtual slsDetectorDefs {
|
|||||||
int get_thread_ids(sls::ServerInterface &socket);
|
int get_thread_ids(sls::ServerInterface &socket);
|
||||||
int get_streaming_start_fnum(sls::ServerInterface &socket);
|
int get_streaming_start_fnum(sls::ServerInterface &socket);
|
||||||
int set_streaming_start_fnum(sls::ServerInterface &socket);
|
int set_streaming_start_fnum(sls::ServerInterface &socket);
|
||||||
|
int set_rate_correct(sls::ServerInterface &socket);
|
||||||
|
|
||||||
Implementation *impl() {
|
Implementation *impl() {
|
||||||
if (receiver != nullptr) {
|
if (receiver != nullptr) {
|
||||||
|
@ -47,6 +47,7 @@ void Implementation::DeleteMembers() {
|
|||||||
fifo.clear();
|
fifo.clear();
|
||||||
eth.clear();
|
eth.clear();
|
||||||
udpPortNum.clear();
|
udpPortNum.clear();
|
||||||
|
rateCorrections.clear();
|
||||||
ctbDbitList.clear();
|
ctbDbitList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,6 +947,7 @@ void Implementation::SetupWriter() {
|
|||||||
masterAttributes->subExptime = std::chrono::nanoseconds(subExpTime);
|
masterAttributes->subExptime = std::chrono::nanoseconds(subExpTime);
|
||||||
masterAttributes->subPeriod = std::chrono::nanoseconds(subPeriod);
|
masterAttributes->subPeriod = std::chrono::nanoseconds(subPeriod);
|
||||||
masterAttributes->quad = quadEnable;
|
masterAttributes->quad = quadEnable;
|
||||||
|
masterAttributes->ratecorr = rateCorrections;
|
||||||
masterAttributes->adcmask =
|
masterAttributes->adcmask =
|
||||||
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
tengigaEnable ? adcEnableMaskTenGiga : adcEnableMaskOneGiga;
|
||||||
masterAttributes->analog =
|
masterAttributes->analog =
|
||||||
@ -1798,6 +1800,11 @@ void Implementation::setReadNLines(const int value) {
|
|||||||
LOG(logINFO) << "Number of Lines to readout: " << numLinesReadout;
|
LOG(logINFO) << "Number of Lines to readout: " << numLinesReadout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Implementation::setRateCorrections(const std::vector<int64_t> &t) {
|
||||||
|
rateCorrections = t;
|
||||||
|
LOG(logINFO) << "Rate Corrections: " << sls::ToString(rateCorrections);
|
||||||
|
}
|
||||||
|
|
||||||
slsDetectorDefs::readoutMode Implementation::getReadoutMode() const {
|
slsDetectorDefs::readoutMode Implementation::getReadoutMode() const {
|
||||||
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
LOG(logDEBUG3) << __SHORT_AT__ << " called";
|
||||||
return readoutType;
|
return readoutType;
|
||||||
|
@ -211,6 +211,8 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
int getReadNLines() const;
|
int getReadNLines() const;
|
||||||
/* [Eiger] */
|
/* [Eiger] */
|
||||||
void setReadNLines(const int value);
|
void setReadNLines(const int value);
|
||||||
|
/* [Eiger] */
|
||||||
|
void setRateCorrections(const std::vector<int64_t> &t);
|
||||||
readoutMode getReadoutMode() const;
|
readoutMode getReadoutMode() const;
|
||||||
/* [Ctb] */
|
/* [Ctb] */
|
||||||
void setReadoutMode(const readoutMode f);
|
void setReadoutMode(const readoutMode f);
|
||||||
@ -336,6 +338,7 @@ class Implementation : private virtual slsDetectorDefs {
|
|||||||
bool activated;
|
bool activated;
|
||||||
bool deactivatedPaddingEnable;
|
bool deactivatedPaddingEnable;
|
||||||
int numLinesReadout;
|
int numLinesReadout;
|
||||||
|
std::vector<int64_t> rateCorrections;
|
||||||
readoutMode readoutType;
|
readoutMode readoutType;
|
||||||
uint32_t adcEnableMaskOneGiga;
|
uint32_t adcEnableMaskOneGiga;
|
||||||
uint32_t adcEnableMaskTenGiga;
|
uint32_t adcEnableMaskTenGiga;
|
||||||
|
@ -34,6 +34,7 @@ class MasterAttributes {
|
|||||||
ns subExptime{0};
|
ns subExptime{0};
|
||||||
ns subPeriod{0};
|
ns subPeriod{0};
|
||||||
uint32_t quad{0};
|
uint32_t quad{0};
|
||||||
|
std::vector<int64_t> ratecorr;
|
||||||
uint32_t adcmask{0};
|
uint32_t adcmask{0};
|
||||||
uint32_t analog{0};
|
uint32_t analog{0};
|
||||||
uint32_t digital{0};
|
uint32_t digital{0};
|
||||||
@ -292,7 +293,9 @@ class EigerMasterAttributes : public MasterAttributes {
|
|||||||
<< '\n'
|
<< '\n'
|
||||||
<< "SubPeriod : " << sls::ToString(subPeriod)
|
<< "SubPeriod : " << sls::ToString(subPeriod)
|
||||||
<< '\n'
|
<< '\n'
|
||||||
<< "Quad : " << quad << '\n';
|
<< "Quad : " << quad << '\n'
|
||||||
|
<< "Rate Corrections : " << sls::ToString(ratecorr)
|
||||||
|
<< '\n';
|
||||||
std::string message = oss.str();
|
std::string message = oss.str();
|
||||||
MasterAttributes::WriteBinaryAttributes(fd, message);
|
MasterAttributes::WriteBinaryAttributes(fd, message);
|
||||||
};
|
};
|
||||||
@ -339,6 +342,14 @@ class EigerMasterAttributes : public MasterAttributes {
|
|||||||
group->createDataSet("quad", PredType::NATIVE_INT, dataspace);
|
group->createDataSet("quad", PredType::NATIVE_INT, dataspace);
|
||||||
dataset.write(&quad, PredType::NATIVE_INT);
|
dataset.write(&quad, PredType::NATIVE_INT);
|
||||||
}
|
}
|
||||||
|
// Rate corrections
|
||||||
|
{
|
||||||
|
DataSpace dataspace = DataSpace(H5S_SCALAR);
|
||||||
|
StrType strdatatype(PredType::C_S1, 256);
|
||||||
|
DataSet dataset = group->createDataSet("rate corrections",
|
||||||
|
strdatatype, dataspace);
|
||||||
|
dataset.write(sls::ToString(ratecorr), strdatatype);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -309,6 +309,7 @@ enum detFuncs {
|
|||||||
F_GET_RECEIVER_THREAD_IDS,
|
F_GET_RECEIVER_THREAD_IDS,
|
||||||
F_GET_RECEIVER_STREAMING_START_FNUM,
|
F_GET_RECEIVER_STREAMING_START_FNUM,
|
||||||
F_SET_RECEIVER_STREAMING_START_FNUM,
|
F_SET_RECEIVER_STREAMING_START_FNUM,
|
||||||
|
F_SET_RECEIVER_RATE_CORRECT,
|
||||||
|
|
||||||
NUM_REC_FUNCTIONS
|
NUM_REC_FUNCTIONS
|
||||||
};
|
};
|
||||||
@ -617,9 +618,9 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
|
|||||||
case F_SET_RECEIVER_NUM_GATES: return "F_SET_RECEIVER_NUM_GATES";
|
case F_SET_RECEIVER_NUM_GATES: return "F_SET_RECEIVER_NUM_GATES";
|
||||||
case F_SET_RECEIVER_GATE_DELAY: return "F_SET_RECEIVER_GATE_DELAY";
|
case F_SET_RECEIVER_GATE_DELAY: return "F_SET_RECEIVER_GATE_DELAY";
|
||||||
case F_GET_RECEIVER_THREAD_IDS: return "F_GET_RECEIVER_THREAD_IDS";
|
case F_GET_RECEIVER_THREAD_IDS: return "F_GET_RECEIVER_THREAD_IDS";
|
||||||
|
|
||||||
case F_GET_RECEIVER_STREAMING_START_FNUM: return "F_GET_RECEIVER_STREAMING_START_FNUM";
|
case F_GET_RECEIVER_STREAMING_START_FNUM: return "F_GET_RECEIVER_STREAMING_START_FNUM";
|
||||||
case F_SET_RECEIVER_STREAMING_START_FNUM: return "F_SET_RECEIVER_STREAMING_START_FNUM";
|
case F_SET_RECEIVER_STREAMING_START_FNUM: return "F_SET_RECEIVER_STREAMING_START_FNUM";
|
||||||
|
case F_SET_RECEIVER_RATE_CORRECT: return "F_SET_RECEIVER_RATE_CORRECT";
|
||||||
|
|
||||||
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
|
||||||
default: return "Unknown Function";
|
default: return "Unknown Function";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user