created detector dependant master file attributes

This commit is contained in:
2020-07-31 12:15:28 +02:00
parent bd221fefe5
commit 4eaa9588ba
8 changed files with 76 additions and 236 deletions

View File

@@ -6,6 +6,7 @@
#include "BinaryFile.h"
#include "Fifo.h"
#include "MasterAttributes.h"
#include "receiver_defs.h"
#include <iomanip>
@@ -133,7 +134,7 @@ void BinaryFile::WriteToFile(char *buffer, int buffersize,
}
void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
masterAttributes &masterFileAttributes) {
MasterAttributes *attr) {
// beginning of every acquisition
numFramesInFile = 0;
numActualPacketsInFile = 0;
@@ -147,7 +148,6 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
if (!(*silentMode)) {
LOG(logINFO) << "Master File: " << masterFileName;
}
masterFileAttributes.version = BINARY_WRITER_VERSION;
// create master file
if (!(*overWriteEnable)) {
@@ -167,84 +167,10 @@ void BinaryFile::CreateMasterFile(bool masterFileWriteEnable,
masterFileName);
}
// create master file data
time_t t = time(nullptr);
std::string strAttributes = attr->GetBinaryMasterAttributes();
char message[maxMasterFileSize];
sprintf(message,
"Version : %.1f\n"
"Detector Type : %d\n"
"Dynamic Range : %d\n"
"Ten Giga : %d\n"
"Image Size : %d bytes\n"
"nPixelsX : %d pixels\n"
"nPixelsY : %d pixels\n"
"Max Frames Per File : %u\n"
"Total Frames : %lld\n"
"Exptime (ns) : %lld\n"
"SubExptime (ns) : %lld\n"
"SubPeriod (ns) : %lld\n"
"Period (ns) : %lld\n"
"Quad Enable : %d\n"
"Analog Flag : %d\n"
"Digital Flag : %d\n"
"ADC Mask : %d\n"
"Dbit Offset : %d\n"
"Dbit Bitset : %lld\n"
"Roi (xmin, xmax) : %d %d\n"
"Exptime1 (ns) : %lld\n"
"Exptime2 (ns) : %lld\n"
"Exptime3 (ns) : %lld\n"
"GateDelay1 (ns) : %lld\n"
"GateDelay2 (ns) : %lld\n"
"GateDelay3 (ns) : %lld\n"
"Gates : %d\n"
"Timestamp : %s\n\n"
"#Frame Header\n"
"Frame Number : 8 bytes\n"
"SubFrame Number/ExpLength : 4 bytes\n"
"Packet Number : 4 bytes\n"
"Bunch ID : 8 bytes\n"
"Timestamp : 8 bytes\n"
"Module Id : 2 bytes\n"
"Row : 2 bytes\n"
"Column : 2 bytes\n"
"Reserved : 2 bytes\n"
"Debug : 4 bytes\n"
"Round Robin Number : 2 bytes\n"
"Detector Type : 1 byte\n"
"Header Version : 1 byte\n"
"Packets Caught Mask : 64 bytes\n",
masterFileAttributes.version, masterFileAttributes.detectorType,
masterFileAttributes.dynamicRange, masterFileAttributes.tenGiga,
masterFileAttributes.imageSize, masterFileAttributes.nPixelsX,
masterFileAttributes.nPixelsY,
masterFileAttributes.maxFramesPerFile,
(long long int)masterFileAttributes.totalFrames,
(long long int)masterFileAttributes.exptimeNs,
(long long int)masterFileAttributes.subExptimeNs,
(long long int)masterFileAttributes.subPeriodNs,
(long long int)masterFileAttributes.periodNs,
masterFileAttributes.quadEnable,
masterFileAttributes.analogFlag,
masterFileAttributes.digitalFlag, masterFileAttributes.adcmask,
masterFileAttributes.dbitoffset,
(long long int)masterFileAttributes.dbitlist,
masterFileAttributes.roiXmin, masterFileAttributes.roiXmax,
(long long int)masterFileAttributes.exptime1Ns,
(long long int)masterFileAttributes.exptime2Ns,
(long long int)masterFileAttributes.exptime3Ns,
(long long int)masterFileAttributes.gateDelay1Ns,
(long long int)masterFileAttributes.gateDelay2Ns,
(long long int)masterFileAttributes.gateDelay3Ns,
masterFileAttributes.gates, ctime(&t));
//TODO! snprintf? This would already have been a buffer overflow
if (strlen(message) > maxMasterFileSize) {
throw sls::RuntimeError("Master File Size " +
std::to_string(strlen(message)) +
" is greater than max str size " +
std::to_string(maxMasterFileSize));
}
memset(message, 0, maxMasterFileSize);
sls::strcpy_safe(message, strAttributes.c_str());
// write and close file
if (fwrite((void *)message, 1, strlen(message), masterfd) !=
strlen(message)) {