Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer

This commit is contained in:
Erik Frojdh
2020-08-04 15:38:45 +02:00
14 changed files with 181 additions and 52 deletions

View File

@ -190,7 +190,7 @@ int ClientInterface::functionTable(){
flist[F_SET_RECEIVER_UDP_PORT2] = &ClientInterface::set_udp_port2;
flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces;
flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g;
flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters;
flist[F_RECEIVER_SET_COUNTER_MASK] = &ClientInterface::set_counter_mask;
flist[F_INCREMENT_FILE_INDEX] = &ClientInterface::increment_file_index;
flist[F_SET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::set_additional_json_parameter;
flist[F_GET_ADDITIONAL_JSON_PARAMETER] = &ClientInterface::get_additional_json_parameter;
@ -445,8 +445,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
}
}
if (myDetectorType == MYTHEN3) {
int ncounters = __builtin_popcount(arg.countermask);
impl()->setNumberofCounters(ncounters);
impl()->setCounterMask(arg.countermask);
impl()->setAcquisitionTime1(arg.expTime1Ns);
impl()->setAcquisitionTime2(arg.expTime2Ns);
impl()->setAcquisitionTime3(arg.expTime3Ns);
@ -1587,11 +1586,11 @@ int ClientInterface::set_adc_mask_10g(Interface &socket) {
return socket.sendResult(retval);
}
int ClientInterface::set_num_counters(Interface &socket) {
auto arg = socket.Receive<int>();
int ClientInterface::set_counter_mask(Interface &socket) {
auto arg = socket.Receive<uint32_t>();
verifyIdle(socket);
LOG(logDEBUG1) << "Setting counters: " << arg;
impl()->setNumberofCounters(arg);
impl()->setCounterMask(arg);
return socket.Send(OK);
}

View File

@ -146,7 +146,7 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_udp_port2(sls::ServerInterface &socket);
int set_num_interfaces(sls::ServerInterface &socket);
int set_adc_mask_10g(sls::ServerInterface &socket);
int set_num_counters(sls::ServerInterface &socket);
int set_counter_mask(sls::ServerInterface &socket);
int increment_file_index(sls::ServerInterface &socket);
int set_additional_json_parameter(sls::ServerInterface &socket);
int get_additional_json_parameter(sls::ServerInterface &socket);

View File

@ -157,8 +157,9 @@ class GeneralData {
* set number of counters (mythen3)
* @param n number of counters
* @param dr dynamic range
* @param tgEnable ten giga enable
*/
virtual void SetNumberofCounters(const int n, const int dr) {
virtual void SetNumberofCounters(const int n, const int dr, bool tgEnable) {
LOG(logERROR) << "SetNumberofCounters is a generic function that "
"should be overloaded by a derived class";
}
@ -440,17 +441,33 @@ class Mythen3Data : public GeneralData {
* set number of counters (mythen3)
* @param n number of counters
* @param dr dynamic range
* @param tgEnable ten giga enable
*/
virtual void SetNumberofCounters(const int n, const int dr) {
if (n < 1 || n > 3) {
throw sls::RuntimeError("Invalid number of counters " +
std::to_string(n));
}
virtual void SetNumberofCounters(const int n, const int dr, bool tgEnable) {
ncounters = n;
nPixelsX = NCHAN * ncounters;
LOG(logINFO) << "nPixelsX: " << nPixelsX;
imageSize = nPixelsX * nPixelsY * ((double)dr / 8.00);
dataSize = imageSize / packetsPerFrame;
// 10g
if (tgEnable) {
if (dr == 32 && n > 1) {
packetsPerFrame = 2;
} else {
packetsPerFrame = 1;
}
dataSize = imageSize / packetsPerFrame;
}
// 1g
else {
if (n == 3) {
dataSize = 768;
} else {
dataSize = 1280;
}
packetsPerFrame = imageSize / dataSize;
}
LOG(logINFO) << "Packets Per Frame: " << packetsPerFrame;
packetSize = headerSizeinPacket + dataSize;
LOG(logINFO) << "PacketSize: " << packetSize;
}
@ -462,6 +479,7 @@ class Mythen3Data : public GeneralData {
*/
void SetDynamicRange(int dr, bool tgEnable) {
imageSize = nPixelsX * nPixelsY * ((double)dr / 8.00);
packetsPerFrame = tgEnable ? 2 : 20;
dataSize = imageSize / packetsPerFrame;
packetSize = headerSizeinPacket + dataSize;

View File

@ -120,7 +120,7 @@ void Implementation::InitializeMembers() {
subPeriod = 0;
numberOfAnalogSamples = 0;
numberOfDigitalSamples = 0;
numberOfCounters = 0;
counterMask = 0;
dynamicRange = 16;
roi.xmin = -1;
roi.xmax = -1;
@ -962,6 +962,7 @@ void Implementation::SetupWriter() {
masterAttributes->dbitlist |= (1 << i);
}
masterAttributes->roi = roi;
masterAttributes->counterMask = counterMask;
masterAttributes->exptime1 = std::chrono::nanoseconds(acquisitionTime1);
masterAttributes->exptime2 = std::chrono::nanoseconds(acquisitionTime2);
masterAttributes->exptime3 = std::chrono::nanoseconds(acquisitionTime3);
@ -1616,24 +1617,30 @@ void Implementation::setNumberofDigitalSamples(const uint32_t i) {
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
}
int Implementation::getNumberofCounters() const {
uint32_t Implementation::getCounterMask() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return numberOfCounters;
return counterMask;
}
void Implementation::setNumberofCounters(const int i) {
if (numberOfCounters != i) {
numberOfCounters = i;
if (myDetectorType == MYTHEN3) {
generalData->SetNumberofCounters(i, dynamicRange);
// to update npixelsx, npixelsy in file writer
for (const auto &it : dataProcessor)
it->SetPixelDimension();
SetupFifoStructure();
void Implementation::setCounterMask(const uint32_t i) {
if (counterMask != i) {
int ncounters = __builtin_popcount(i);
if (ncounters < 1 || ncounters > 3) {
throw sls::RuntimeError("Invalid number of counters " +
std::to_string(ncounters) +
". Expected 1-3.");
}
counterMask = i;
generalData->SetNumberofCounters(ncounters, dynamicRange,
tengigaEnable);
// to update npixelsx, npixelsy in file writer
for (const auto &it : dataProcessor)
it->SetPixelDimension();
SetupFifoStructure();
}
LOG(logINFO) << "Number of Counters: " << numberOfCounters;
LOG(logINFO) << "Counter mask: " << sls::ToStringHex(counterMask);
int ncounters = __builtin_popcount(counterMask);
LOG(logINFO) << "Number of counters: " << ncounters;
}
uint32_t Implementation::getDynamicRange() const {
@ -1647,7 +1654,14 @@ void Implementation::setDynamicRange(const uint32_t i) {
dynamicRange = i;
if (myDetectorType == EIGER || myDetectorType == MYTHEN3) {
generalData->SetDynamicRange(i, tengigaEnable);
if (myDetectorType == EIGER) {
generalData->SetDynamicRange(i, tengigaEnable);
} else {
int ncounters = __builtin_popcount(counterMask);
generalData->SetNumberofCounters(ncounters, i, tengigaEnable);
}
// to update npixelsx, npixelsy in file writer
for (const auto &it : dataProcessor)
it->SetPixelDimension();
@ -1689,13 +1703,14 @@ bool Implementation::getTenGigaEnable() const {
void Implementation::setTenGigaEnable(const bool b) {
if (tengigaEnable != b) {
tengigaEnable = b;
int ncounters = __builtin_popcount(counterMask);
// side effects
switch (myDetectorType) {
case EIGER:
generalData->SetTenGigaEnable(b, dynamicRange);
break;
case MYTHEN3:
generalData->SetDynamicRange(dynamicRange, b);
generalData->SetNumberofCounters(ncounters, dynamicRange, b);
break;
case MOENCH:
case CHIPTESTBOARD:

View File

@ -186,8 +186,9 @@ class Implementation : private virtual slsDetectorDefs {
uint32_t getNumberofDigitalSamples() const;
/**[Ctb] */
void setNumberofDigitalSamples(const uint32_t i);
int getNumberofCounters() const;
void setNumberofCounters(const int i);
uint32_t getCounterMask() const;
/** [Mythen3] */
void setCounterMask(const uint32_t i);
uint32_t getDynamicRange() const;
void setDynamicRange(const uint32_t i);
ROI getROI() const;
@ -329,7 +330,7 @@ class Implementation : private virtual slsDetectorDefs {
uint64_t subPeriod;
uint64_t numberOfAnalogSamples;
uint64_t numberOfDigitalSamples;
int numberOfCounters;
uint32_t counterMask;
uint32_t dynamicRange;
ROI roi;
bool tengigaEnable;

View File

@ -40,6 +40,7 @@ struct MasterAttributes {
uint32_t dbitoffset{0};
uint64_t dbitlist{0};
slsDetectorDefs::ROI roi{};
uint32_t counterMask{0};
ns exptime1{0};
ns exptime2{0};
ns exptime3{0};
@ -344,7 +345,7 @@ class EigerMasterAttributes : public MasterAttributes {
// Rate corrections
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset = group->createDataSet("rate corrections",
strdatatype, dataspace);
dataset.write(sls::ToString(ratecorr), strdatatype);
@ -363,6 +364,8 @@ class Mythen3MasterAttributes : public MasterAttributes {
<< "Dynamic Range : " << dynamicRange << '\n'
<< "Ten Giga : " << tenGiga << '\n'
<< "Period : " << sls::ToString(period) << '\n'
<< "Counter Mask : " << sls::ToStringHex(counterMask)
<< '\n'
<< "Exptime1 : " << sls::ToString(exptime1)
<< '\n'
<< "Exptime2 : " << sls::ToString(exptime2)
@ -386,6 +389,13 @@ class Mythen3MasterAttributes : public MasterAttributes {
MasterAttributes::WriteHDF5DynamicRange(fd, group);
MasterAttributes::WriteHDF5TenGiga(fd, group);
MasterAttributes::WriteHDF5Period(fd, group);
// Counter Mask
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet(
"counter mask", PredType::STD_U32LE, dataspace);
dataset.write(&counterMask, PredType::STD_U32LE);
}
// Exptime1
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
@ -439,7 +449,7 @@ class Mythen3MasterAttributes : public MasterAttributes {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("gates", PredType::STD_U32LE, dataspace);
dataset.write(&gates, PredType::STD_U64LE);
dataset.write(&gates, PredType::STD_U32LE);
}
};
#endif