mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
slsReceiverSoftware: bitset storage in case the libarary changes contiguous representation, also changed hdf5 representation from 512 byte (to_string) to just passing char* to keep at 64 bytes
This commit is contained in:
@ -86,10 +86,9 @@ class BinaryFileStatic {
|
||||
* @param fd file pointer
|
||||
* @param buf buffer to write from
|
||||
* @param bsize size of buffer
|
||||
* @param fnum current image number
|
||||
* @returns number of elements written
|
||||
*/
|
||||
static int WriteDataFile(FILE* fd, char* buf, int bsize, uint64_t fnum)
|
||||
static int WriteDataFile(FILE* fd, char* buf, int bsize)
|
||||
{
|
||||
if (!fd)
|
||||
return 0;
|
||||
|
@ -22,6 +22,7 @@ using namespace H5;
|
||||
#include <iomanip>
|
||||
#include <stdlib.h> //malloc
|
||||
#include <sstream>
|
||||
#include <cstring> //memset
|
||||
using namespace std;
|
||||
|
||||
class HDF5FileStatic: public virtual slsReceiverDefs {
|
||||
@ -219,7 +220,23 @@ public:
|
||||
dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);
|
||||
dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);
|
||||
dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para);
|
||||
dset_para[13]->write(rheader->packetsMask.to_string().c_str(), parameterDataTypes[13], memspace, *dspace_para);
|
||||
|
||||
// contiguous bitset
|
||||
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
||||
dset_para[13]->write((char*)&(rheader->packetsMask), parameterDataTypes[13], memspace, *dspace_para);
|
||||
}
|
||||
|
||||
// not contiguous bitset
|
||||
else {
|
||||
// get contiguous representation of bit mask
|
||||
bitset_storage storage;
|
||||
memset(storage, 0 , sizeof(bitset_storage));
|
||||
sls_bitset bits = rheader->packetsMask;
|
||||
for (int i = 0; i < MAX_NUM_PACKETS; ++i)
|
||||
storage[i >> 3] |= (bits[i] << (i & 7));
|
||||
// write bitmask
|
||||
dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para);
|
||||
}
|
||||
}
|
||||
catch(Exception error){
|
||||
cprintf(RED,"Error in writing parameters to file in object %d\n",ind);
|
||||
@ -486,7 +503,7 @@ public:
|
||||
|
||||
// always create chunked dataset as unlimited is only supported with chunked layout
|
||||
DSetCreatPropList paralist;
|
||||
hsize_t chunkpara_dims[3] ={maxchunkedimages};
|
||||
hsize_t chunkpara_dims[3] = {maxchunkedimages};
|
||||
paralist.setChunk(1, chunkpara_dims);
|
||||
|
||||
for (unsigned int i = 0; i < parameterNames.size(); ++i){
|
||||
|
@ -169,11 +169,14 @@ public:
|
||||
#ifdef __cplusplus
|
||||
#define MAX_NUM_PACKETS 512
|
||||
|
||||
typedef std::bitset<MAX_NUM_PACKETS> sls_bitset;
|
||||
|
||||
typedef struct {
|
||||
sls_detector_header detHeader; /**< is the detector header */
|
||||
std::bitset<MAX_NUM_PACKETS> packetsMask; /**< is the packets caught bit mask */
|
||||
sls_detector_header detHeader; /**< is the detector header */
|
||||
sls_bitset packetsMask; /**< is the packets caught bit mask */
|
||||
} sls_receiver_header;
|
||||
|
||||
typedef uint8_t bitset_storage[MAX_NUM_PACKETS/8];
|
||||
|
||||
#endif
|
||||
/**
|
||||
|
Reference in New Issue
Block a user