This commit is contained in:
maliakal_d 2020-09-02 16:15:33 +02:00
parent 42b5ff3a62
commit abe34d573c
6 changed files with 40 additions and 3 deletions

View File

@ -474,6 +474,9 @@ defs::scanParameters Module::getScan() const {
void Module::setScan(const defs::scanParameters t) {
auto retval = sendToDetector<int64_t>(F_SET_SCAN, t);
if (shm()->useReceiverFlag) {
sendToReceiver(F_SET_RECEIVER_SCAN, t, nullptr);
}
// if disabled, retval is 1, else its number of steps
setNumberOfFrames(retval);
}

View File

@ -202,6 +202,8 @@ int ClientInterface::functionTable(){
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_RATE_CORRECT] = &ClientInterface::set_rate_correct;
flist[F_SET_RECEIVER_SCAN] = &ClientInterface::set_scan;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@ -1622,4 +1624,12 @@ int ClientInterface::set_rate_correct(Interface &socket) {
LOG(logINFOBLUE) << "Setting rate corrections[" << index << ']';
impl()->setRateCorrections(t);
return socket.Send(OK);
}
int ClientInterface::set_scan(Interface &socket) {
auto arg = socket.Receive<scanParameters>();
LOG(logDEBUG) << "Scan Mode: " << sls::ToString(arg);
verifyIdle(socket);
impl()->setScan(arg);
return socket.Send(OK);
}

View File

@ -157,6 +157,7 @@ class ClientInterface : private virtual slsDetectorDefs {
int get_streaming_start_fnum(sls::ServerInterface &socket);
int set_streaming_start_fnum(sls::ServerInterface &socket);
int set_rate_correct(sls::ServerInterface &socket);
int set_scan(sls::ServerInterface &socket);
Implementation *impl() {
if (receiver != nullptr) {

View File

@ -754,6 +754,7 @@ void Implementation::SetupWriter() {
masterAttributes->gateDelay2 = gateDelay2;
masterAttributes->gateDelay3 = gateDelay3;
masterAttributes->gates = numberOfGates;
masterAttributes->additionalJsonHeader = additionalJsonHeader;
try {
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {

View File

@ -15,8 +15,8 @@ using namespace H5;
using ns = std::chrono::nanoseconds;
// versions
#define HDF5_WRITER_VERSION (6.1) // 1 decimal places
#define BINARY_WRITER_VERSION (6.1) // 1 decimal places
#define HDF5_WRITER_VERSION (6.2) // 1 decimal places
#define BINARY_WRITER_VERSION (6.2) // 1 decimal places
struct MasterAttributes {
slsDetectorDefs::detectorType detType{slsDetectorDefs::GENERIC};
@ -48,6 +48,7 @@ struct MasterAttributes {
ns gateDelay2{0};
ns gateDelay3{0};
uint32_t gates;
std::map<std::string, std::string> additionalJsonHeader;
MasterAttributes(){};
virtual ~MasterAttributes(){};
@ -74,6 +75,15 @@ struct MasterAttributes {
};
void WriteBinaryAttributes(FILE *fd, std::string message) {
// adding few common parameters to the end
if (!additionalJsonHeader.empty()) {
std::ostringstream oss;
oss << "Additional Json Header : "
<< sls::ToString(additionalJsonHeader) << '\n';
message += oss.str();
}
// adding sls_receiver header format
message += std::string("\n#Frame Header\n"
"Frame Number : 8 bytes\n"
"SubFrame Number/ExpLength : 4 bytes\n"
@ -90,6 +100,7 @@ struct MasterAttributes {
"Header Version : 1 byte\n"
"Packets Caught Mask : 64 bytes\n");
// writing to file
if (fwrite((void *)message.c_str(), 1, message.length(), fd) !=
message.length()) {
throw sls::RuntimeError(
@ -103,7 +114,7 @@ struct MasterAttributes {
"by a child class";
};
void WriteHDF5Attributes(H5File *fd, Group *group){
void WriteHDF5Attributes(H5File *fd, Group *group) {
// clang-format off
// version
{
@ -179,6 +190,15 @@ struct MasterAttributes {
"total frames", PredType::STD_U64LE, dataspace);
dataset.write(&totalFrames, PredType::STD_U64LE);
}
// additional json header
if (!additionalJsonHeader.empty()) {
std::string json = sls::ToString(additionalJsonHeader);
StrType strdatatype(PredType::C_S1, json.length());
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("additional json header", strdatatype, dataspace);
dataset.write(sls::ToString(additionalJsonHeader), strdatatype);
}
};
void WriteHDF5Exptime(H5File *fd, Group *group) {

View File

@ -312,6 +312,7 @@ enum detFuncs {
F_GET_RECEIVER_STREAMING_START_FNUM,
F_SET_RECEIVER_STREAMING_START_FNUM,
F_SET_RECEIVER_RATE_CORRECT,
F_SET_RECEIVER_SCAN,
NUM_REC_FUNCTIONS
};
@ -625,6 +626,7 @@ const char* getFunctionNameFromEnum(enum detFuncs func) {
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_RATE_CORRECT: return "F_SET_RECEIVER_RATE_CORRECT";
case F_SET_RECEIVER_SCAN: return "F_SET_RECEIVER_SCAN";
case NUM_REC_FUNCTIONS: return "NUM_REC_FUNCTIONS";
default: return "Unknown Function";