Gappixels (#89)

* WIP

* WIP virtual delays, imagetest for saturation

* WIP, vertical and horizontal

* WIP

* gap pixels work, fixed 32 bit data out (10gbe=0) for virtual servers

* quad works (also in virtual), handling gappixels and quad

* jungfrau gapppixels work

* jungfrau: done

* complete image or missing packets given in json header and gui

* eiger virtual 4 bit mode bug fix

* working version of zmq add json header, except printout

* printout bug

* fix for json para

* to map WIP

* map done

* map print , mapwith result left

* json result works, testing added

* updated server binaries

* compiling on rhels7, variable size char array iniitalization

* zmqsocket parsing didnt need Document

* const to map, json para is strings not map

* json add header: mapping cleaner without insert make_pair
This commit is contained in:
Dhanya Thattil
2020-03-30 14:54:35 +02:00
committed by GitHub
parent 6a6af528ef
commit d58eb1dc6e
52 changed files with 1879 additions and 1398 deletions

View File

@ -128,7 +128,6 @@ class BinaryFileStatic {
"SubExptime (ns) : %lld\n"
"SubPeriod(ns) : %lld\n"
"Period (ns) : %lld\n"
"Gap Pixels Enable : %d\n"
"Quad Enable : %d\n"
"Analog Flag : %d\n"
"Digital Flag : %d\n"
@ -167,7 +166,6 @@ class BinaryFileStatic {
(long long int)attr.subExptimeNs,
(long long int)attr.subPeriodNs,
(long long int)attr.periodNs,
attr.gapPixelsEnable,
attr.quadEnable,
attr.analogFlag,
attr.digitalFlag,

View File

@ -16,6 +16,7 @@
#include <vector>
#include <sys/syscall.h>
#include <unistd.h>
#include <map>
using sls::RuntimeError;
using sls::SocketError;
@ -113,7 +114,6 @@ int ClientInterface::functionTable(){
flist[F_LOCK_RECEIVER] = &ClientInterface::lock_receiver;
flist[F_GET_LAST_RECEIVER_CLIENT_IP] = &ClientInterface::get_last_client_ip;
flist[F_SET_RECEIVER_PORT] = &ClientInterface::set_port;
flist[F_UPDATE_RECEIVER_CLIENT] = &ClientInterface::update_client;
flist[F_GET_RECEIVER_VERSION] = &ClientInterface::get_version;
flist[F_GET_RECEIVER_TYPE] = &ClientInterface::set_detector_type;
flist[F_SEND_RECEIVER_DETHOSTNAME] = &ClientInterface::set_detector_hostname;
@ -163,7 +163,6 @@ int ClientInterface::functionTable(){
flist[F_GET_RECEIVER_STREAMING_SRC_IP] = &ClientInterface::get_streaming_source_ip;
flist[F_SET_RECEIVER_SILENT_MODE] = &ClientInterface::set_silent_mode;
flist[F_GET_RECEIVER_SILENT_MODE] = &ClientInterface::get_silent_mode;
flist[F_ENABLE_GAPPIXELS_IN_RECEIVER] = &ClientInterface::enable_gap_pixels;
flist[F_RESTREAM_STOP_FROM_RECEIVER] = &ClientInterface::restream_stop;
flist[F_SET_ADDITIONAL_JSON_HEADER] = &ClientInterface::set_additional_json_header;
flist[F_GET_ADDITIONAL_JSON_HEADER] = &ClientInterface::get_additional_json_header;
@ -194,6 +193,8 @@ int ClientInterface::functionTable(){
flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g;
flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters;
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;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@ -325,29 +326,6 @@ int ClientInterface::set_port(Interface &socket) {
return OK;
}
int ClientInterface::update_client(Interface &socket) {
if (receiver == nullptr)
throw sls::SocketError(
"Receiver not set up. Please use rx_hostname first.\n");
socket.Send(OK);
return send_update(socket);
}
int ClientInterface::send_update(Interface &socket) {
int n = 0;
int i32 = -1;
sls::IpAddr ip;
ip = server->getLastClient();
n += socket.Send(&ip, sizeof(ip));
// gap pixels
i32 = (int)receiver->getGapPixelsEnable();
n += socket.Send(&i32, sizeof(i32));
return OK;
}
int ClientInterface::get_version(Interface &socket) {
return socket.sendResult(getReceiverVersion());
}
@ -989,26 +967,6 @@ int ClientInterface::get_silent_mode(Interface &socket) {
return socket.sendResult(retval);
}
int ClientInterface::enable_gap_pixels(Interface &socket) {
auto enable = socket.Receive<int>();
if (myDetectorType != EIGER)
functionNotImplemented();
if (enable >= 0) {
verifyIdle(socket);
LOG(logDEBUG1) << "Setting gap pixels enable:" << enable;
try {
impl()->setGapPixelsEnable(static_cast<bool>(enable));
} catch(const RuntimeError &e) {
throw RuntimeError("Could not set gap pixels enable to " + std::to_string(enable));
}
}
auto retval = static_cast<int>(impl()->getGapPixelsEnable());
validate(enable, retval, "set gap pixels enable", DEC);
LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
return socket.sendResult(retval);
}
int ClientInterface::restream_stop(Interface &socket) {
verifyIdle(socket);
if (!impl()->getDataStreamEnable()) {
@ -1022,19 +980,39 @@ int ClientInterface::restream_stop(Interface &socket) {
}
int ClientInterface::set_additional_json_header(Interface &socket) {
char arg[MAX_STR_LENGTH]{};
socket.Receive(arg);
std::map<std::string, std::string> json;
int size = socket.Receive<int>();
if (size > 0) {
char args[size * 2][SHORT_STR_LENGTH];
memset(args, 0, sizeof(args));
socket.Receive(args, sizeof(args));
for (int i = 0; i < size; ++i) {
json[args[2 * i]] = args[2 * i + 1];
}
}
verifyIdle(socket);
LOG(logDEBUG1) << "Setting additional json header: " << arg;
impl()->setAdditionalJsonHeader(arg);
LOG(logDEBUG1) << "Setting additional json header: " << sls::ToString(json);
impl()->setAdditionalJsonHeader(json);
return socket.Send(OK);
}
int ClientInterface::get_additional_json_header(Interface &socket) {
char retval[MAX_STR_LENGTH]{};
sls::strcpy_safe(retval, impl()->getAdditionalJsonHeader().c_str());
LOG(logDEBUG1) << "additional json header:" << retval;
return socket.sendResult(retval);
std::map<std::string, std::string> json = impl()->getAdditionalJsonHeader();
LOG(logDEBUG1) << "additional json header:" << sls::ToString(json);
int size = json.size();
socket.sendResult(size);
if (size > 0) {
char retvals[size * 2][SHORT_STR_LENGTH];
memset(retvals, 0, sizeof(retvals));
int iarg = 0;
for (auto & it : json) {
sls::strcpy_safe(retvals[iarg], it.first.c_str());
sls::strcpy_safe(retvals[iarg + 1], it.second.c_str());
iarg += 2;
}
socket.Send(retvals, sizeof(retvals));
}
return OK;
}
int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
@ -1427,4 +1405,23 @@ int ClientInterface::increment_file_index(Interface &socket) {
impl()->setFileIndex(impl()->getFileIndex() + 1);
}
return socket.Send(OK);
}
}
int ClientInterface::set_additional_json_parameter(Interface &socket) {
char args[2][SHORT_STR_LENGTH]{};
socket.Receive(args);
verifyIdle(socket);
LOG(logDEBUG1) << "Setting additional json parameter (" << args[0] << "): " << args[1];
impl()->setAdditionalJsonParameter(args[0], args[1]);
return socket.Send(OK);
}
int ClientInterface::get_additional_json_parameter(Interface &socket) {
char arg[SHORT_STR_LENGTH]{};
socket.Receive(arg);
char retval[SHORT_STR_LENGTH]{};
sls::strcpy_safe(retval, impl()->getAdditionalJsonParameter(arg).c_str());
LOG(logDEBUG1) << "additional json parameter (" << arg << "):" << retval;
return socket.sendResult(retval);
}

View File

@ -55,8 +55,6 @@ class ClientInterface : private virtual slsDetectorDefs {
int lock_receiver(sls::ServerInterface &socket);
int get_last_client_ip(sls::ServerInterface &socket);
int set_port(sls::ServerInterface &socket);
int update_client(sls::ServerInterface &socket);
int send_update(sls::ServerInterface &socket);
int get_version(sls::ServerInterface &socket);
int set_detector_type(sls::ServerInterface &socket);
int set_detector_hostname(sls::ServerInterface &socket);
@ -107,7 +105,6 @@ class ClientInterface : private virtual slsDetectorDefs {
int get_streaming_source_ip(sls::ServerInterface &socket);
int set_silent_mode(sls::ServerInterface &socket);
int get_silent_mode(sls::ServerInterface &socket);
int enable_gap_pixels(sls::ServerInterface &socket);
int restream_stop(sls::ServerInterface &socket);
int set_additional_json_header(sls::ServerInterface &socket);
int get_additional_json_header(sls::ServerInterface &socket);
@ -138,6 +135,8 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_adc_mask_10g(sls::ServerInterface &socket);
int set_num_counters(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);
Implementation *impl() {
if (receiver != nullptr) {

View File

@ -25,7 +25,7 @@ const std::string DataProcessor::TypeName = "DataProcessor";
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
fileFormat* ftype, bool fwenable, bool* mfwenable,
bool* dsEnable, bool* gpEnable, uint32_t* dr,
bool* dsEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer,
bool* fp, bool* act, bool* depaden, bool* sm, bool* qe,
std::vector <int> * cdl, int* cdo, int* cad) :
@ -40,12 +40,10 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
fileFormatType(ftype),
fileWriteEnable(fwenable),
masterFileWriteEnable(mfwenable),
gapPixelsEnable(gpEnable),
dynamicRange(dr),
streamingFrequency(freq),
streamingTimerInMs(timer),
currentFreqCount(0),
tempBuffer(nullptr),
activated(act),
deactivatedPaddingEnable(depaden),
silentMode(sm),
@ -69,7 +67,6 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo* f,
DataProcessor::~DataProcessor() {
delete file;
delete [] tempBuffer;
}
/** getters */
@ -116,15 +113,6 @@ void DataProcessor::ResetParametersforNewAcquisition(){
numFramesCaught = 0;
firstIndex = 0;
currentFrameIndex = 0;
if (tempBuffer != nullptr) {
delete [] tempBuffer;
tempBuffer = nullptr;
}
if (*gapPixelsEnable) {
tempBuffer = new char[generalData->imageSize];
memset(tempBuffer, 0, generalData->imageSize);
}
}
@ -296,11 +284,6 @@ void DataProcessor::ProcessAnImage(char* buf) {
}
}
if (*gapPixelsEnable && (*dynamicRange!=4))
InsertGapPixels(buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
*dynamicRange);
// frame padding
if (*activated && *framePadding && nump < generalData->packetsPerFrame)
PadMissingPackets(buf);
@ -512,103 +495,3 @@ void DataProcessor::RearrangeDbitData(char* buf) {
(*((uint32_t*)buf)) = numResult8Bits * sizeof(uint8_t);
}
/** eiger specific */
void DataProcessor::InsertGapPixels(char* buf, uint32_t dr) {
memset(tempBuffer, 0xFF, generalData->imageSize);
int rightChip = ((*quadEnable) ? 0 : index); // quad enable, then faking both to be left chips
const uint32_t nx = generalData->nPixelsX;
const uint32_t ny = generalData->nPixelsY;
const uint32_t npx = nx * ny;
bool group3 = (*quadEnable) ? false : true; // if quad enabled, no last line for left chips
char* srcptr = nullptr;
char* dstptr = nullptr;
const uint32_t b1px = generalData->imageSize / (npx); // not double as not dealing with 4 bit mode
const uint32_t b2px = 2 * b1px;
const uint32_t b1pxofst = (rightChip == 0 ? 0 : b1px); // left fpga (rightChip 0) has no extra 1px offset, but right fpga has
const uint32_t b1chip = 256 * b1px;
const uint32_t b1line = (nx * b1px);
const uint32_t bgroup3chip = b1chip + (group3 ? b1px : 0);
// copying line by line
srcptr = buf;
dstptr = tempBuffer + b1line + b1pxofst; // left fpga (rightChip 0) has no extra 1px offset, but right fpga has
for (uint32_t i = 0; i < (ny-1); ++i) {
memcpy(dstptr, srcptr, b1chip);
srcptr += b1chip;
dstptr += (b1chip + b2px);
memcpy(dstptr, srcptr, b1chip);
srcptr += b1chip;
dstptr += bgroup3chip;
}
// vertical filling of values
{
char* srcgp1 = nullptr; char* srcgp2 = nullptr; char* srcgp3 = nullptr;
char* dstgp1 = nullptr; char* dstgp2 = nullptr; char* dstgp3 = nullptr;
const uint32_t b3px = 3 * b1px;
srcptr = tempBuffer + b1line;
dstptr = tempBuffer + b1line;
for (uint32_t i = 0; i < (ny-1); ++i) {
srcgp1 = srcptr + b1pxofst + b1chip - b1px;
dstgp1 = srcgp1 + b1px;
srcgp2 = srcgp1 + b3px;
dstgp2 = dstgp1 + b1px;
if (group3) {
if (rightChip == 0u) {
srcgp3 = srcptr + b1line - b2px;
dstgp3 = srcgp3 + b1px;
} else {
srcgp3 = srcptr + b1px;
dstgp3 = srcptr;
}
}
switch (dr) {
case 8:
(*((uint8_t*)srcgp1)) = (*((uint8_t*)srcgp1))/2; (*((uint8_t*)dstgp1)) = (*((uint8_t*)srcgp1));
(*((uint8_t*)srcgp2)) = (*((uint8_t*)srcgp2))/2; (*((uint8_t*)dstgp2)) = (*((uint8_t*)srcgp2));
if (group3) {
(*((uint8_t*)srcgp3)) = (*((uint8_t*)srcgp3))/2; (*((uint8_t*)dstgp3)) = (*((uint8_t*)srcgp3));
}
break;
case 16:
(*((uint16_t*)srcgp1)) = (*((uint16_t*)srcgp1))/2; (*((uint16_t*)dstgp1)) = (*((uint16_t*)srcgp1));
(*((uint16_t*)srcgp2)) = (*((uint16_t*)srcgp2))/2; (*((uint16_t*)dstgp2)) = (*((uint16_t*)srcgp2));
if (group3) {
(*((uint16_t*)srcgp3)) = (*((uint16_t*)srcgp3))/2; (*((uint16_t*)dstgp3)) = (*((uint16_t*)srcgp3));
}
break;
default:
(*((uint32_t*)srcgp1)) = (*((uint32_t*)srcgp1))/2; (*((uint32_t*)dstgp1)) = (*((uint32_t*)srcgp1));
(*((uint32_t*)srcgp2)) = (*((uint32_t*)srcgp2))/2; (*((uint32_t*)dstgp2)) = (*((uint32_t*)srcgp2));
if (group3) {
(*((uint32_t*)srcgp3)) = (*((uint32_t*)srcgp3))/2; (*((uint32_t*)dstgp3)) = (*((uint32_t*)srcgp3));
}
break;
}
srcptr += b1line;
dstptr += b1line;
}
}
// horizontal filling of values
srcptr = tempBuffer + b1line;
dstptr = tempBuffer;
for (uint32_t i = 0; i < nx; ++i) {
switch (dr) {
case 8: (*((uint8_t*)srcptr)) = (*((uint8_t*)srcptr))/2; (*((uint8_t*)dstptr)) = (*((uint8_t*)srcptr)); break;
case 16:(*((uint16_t*)srcptr)) = (*((uint16_t*)srcptr))/2; (*((uint16_t*)dstptr)) = (*((uint16_t*)srcptr)); break;
default:(*((uint32_t*)srcptr)) = (*((uint32_t*)srcptr))/2; (*((uint32_t*)dstptr)) = (*((uint32_t*)srcptr)); break;
}
srcptr += b1px;
dstptr += b1px;
}
memcpy(buf, tempBuffer, generalData->imageSize);
return;
}

View File

@ -33,7 +33,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* @param fwenable file writer enable
* @apram mfwenable pointer to master file write enable
* @param dsEnable pointer to data stream enable
* @param gpEnable pointer to gap pixels enable
* @param dr pointer to dynamic range
* @param freq pointer to streaming frequency
* @param timer pointer to timer if streaming frequency is random
@ -47,7 +46,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
* @param cad pointer to ctb analog databytes
*/
DataProcessor(int ind, detectorType dtype, Fifo* f, fileFormat* ftype,
bool fwenable, bool* mfwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
bool fwenable, bool* mfwenable, bool* dsEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer,
bool* fp, bool* act, bool* depaden, bool* sm, bool* qe,
std::vector <int> * cdl, int* cdo, int* cad);
@ -252,13 +251,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/
void RearrangeDbitData(char* buf);
/**
* Processing Function (inserting gap pixels) eiger specific
* @param buf pointer to image
* @param dr dynamic range
*/
void InsertGapPixels(char* buf, uint32_t dr);
/** type of thread */
static const std::string TypeName;
@ -291,10 +283,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
/** Master File Write Enable */
bool* masterFileWriteEnable;
/** Gap Pixels Enable */
bool* gapPixelsEnable;
/** Dynamic Range */
uint32_t* dynamicRange;
@ -310,9 +298,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
/** timer beginning stamp for random streaming */
struct timespec timerBegin;
/** temporary buffer for processing */
char* tempBuffer;
/** Activated/Deactivated */
bool* activated;

View File

@ -17,7 +17,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, std::string* ajh, int* nd, bool* gpEnable, bool* qe) :
uint64_t* fi, int fd, int* nd, bool* qe) :
ThreadObject(ind, TypeName),
runningFlag(0),
generalData(nullptr),
@ -28,11 +28,9 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
adcConfigured(-1),
fileIndex(fi),
flippedDataX(fd),
additionJsonHeader(ajh),
startedFlag(false),
firstIndex(0),
completeBuffer(nullptr),
gapPixelsEnable(gpEnable),
quadEnable(qe)
{
numDet[0] = nd[0];
@ -108,6 +106,10 @@ void DataStreamer::SetFlippedDataX(int fd) {
flippedDataX = fd;
}
void DataStreamer::SetAdditionalJsonHeader(const std::map<std::string, std::string> &json) {
additionJsonHeader = json;
}
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const sls::IpAddr ip) {
uint32_t portnum = port + index;
std::string sip = ip.str();
@ -217,31 +219,58 @@ void DataStreamer::ProcessAnImage(char* buf) {
int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32_t nx, uint32_t ny, bool dummy) {
if (dummy)
return zmqSocket->SendHeaderData(index, dummy,SLS_DETECTOR_JSON_HEADER_VERSION);
zmqHeader zHeader;
zHeader.data = !dummy;
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
if (dummy) {
return zmqSocket->SendHeader(index, zHeader);
}
sls_detector_header header = rheader->detHeader;
uint64_t frameIndex = header.frameNumber - firstIndex;
uint64_t acquisitionIndex = header.frameNumber;
return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex,
numDet[0], numDet[1], nx, ny, size,
acquisitionIndex, frameIndex, fileNametoStream,
header.frameNumber, header.expLength, header.packetNumber, header.bunchId, header.timestamp,
header.modId, header.row, header.column, header.reserved,
header.debug, header.roundRNumber,
header.detType, header.version,
*gapPixelsEnable ? 1 : 0, flippedDataX, *quadEnable,
additionJsonHeader
);
zHeader.dynamicRange = *dynamicRange;
zHeader.fileIndex = *fileIndex;
zHeader.ndetx = numDet[0];
zHeader.ndety = numDet[1];
zHeader.npixelsx = nx;
zHeader.npixelsy = ny;
zHeader.imageSize = size;
zHeader.acqIndex = acquisitionIndex;
zHeader.frameIndex = frameIndex;
zHeader.fname = fileNametoStream;
zHeader.frameNumber = header.frameNumber;
zHeader.expLength = header.expLength;
zHeader.packetNumber = header.packetNumber;
zHeader.bunchId = header.bunchId;
zHeader.timestamp = header.timestamp;
zHeader.modId = header.modId;
zHeader.row = header.row;
zHeader.column = header.column;
zHeader.reserved = header.reserved;
zHeader.debug = header.debug;
zHeader.roundRNumber = header.roundRNumber;
zHeader.detType = header.detType;
zHeader.version = header.version;
zHeader.flippedDataX = flippedDataX;
zHeader.quad = *quadEnable;
zHeader.completeImage = (header.packetNumber < generalData->packetsPerFrame ? false : true);
zHeader.addJsonHeader = additionJsonHeader;
return zmqSocket->SendHeader(index, zHeader);
}
void DataStreamer::RestreamStop() {
//send dummy header
int ret = zmqSocket->SendHeaderData(index, true, SLS_DETECTOR_JSON_HEADER_VERSION);
zmqHeader zHeader;
zHeader.data = false;
zHeader.jsonversion = SLS_DETECTOR_JSON_HEADER_VERSION;
int ret = zmqSocket->SendHeader(index, zHeader);
if (!ret) {
throw sls::RuntimeError("Could not restream Dummy Header via ZMQ for port " + std::to_string(zmqSocket->GetPortNumber()));
}

View File

@ -15,7 +15,7 @@ class Fifo;
class DataStreamer;
class ZmqSocket;
#include <vector>
#include <map>
class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
@ -29,13 +29,11 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param r roi
* @param fi pointer to file index
* @param fd flipped data enable for x dimension
* @param ajh additional json header
* @param nd pointer to number of detectors in each dimension
* @param gpEnable pointer to gap pixels enable
* @param qe pointer to quad Enable
*/
DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
uint64_t* fi, int fd, std::string* ajh, int* nd, bool* gpEnable, bool* qe);
uint64_t* fi, int fd, int* nd, bool* qe);
/**
* Destructor
@ -90,6 +88,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param flipped data enable in x dimension
*/
void SetFlippedDataX(int fd);
/**
* Set additional json header
* @param json additional json header
*/
void SetAdditionalJsonHeader(const std::map<std::string, std::string> &json);
/**
* Creates Zmq Sockets
@ -183,7 +187,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
int flippedDataX;
/** additional json header */
std::string* additionJsonHeader;
std::map<std::string, std::string> additionJsonHeader;
/** Aquisition Started flag */
bool startedFlag;
@ -200,9 +204,6 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
/** Number of Detectors in X and Y dimension */
int numDet[2];
/** Gap Pixels Enable */
bool* gapPixelsEnable;
/** Quad Enable */
bool* quadEnable;

View File

@ -171,16 +171,6 @@ public:
LOG(logERROR) << "SetTenGigaEnable is a generic function that should be overloaded by a derived class";
};
/**
* Enable Gap Pixels changes member variables
* @param enable true if gap pixels enable, else false
* @param dr dynamic range
* @param q quad enable
*/
virtual void SetGapPixelsEnable(bool b, int dr, bool q) {
LOG(logERROR) << "SetGapPixelsEnable is a generic function that should be overloaded by a derived class";
};
/**
* Set odd starting packet (gotthard)
* @param index thread index for debugging purposes
@ -452,39 +442,6 @@ class EigerData : public GeneralData {
imageSize = dataSize*packetsPerFrame;
};
/**
* Enable Gap Pixels changes member variables
* @param enable true if gap pixels enable, else false
* @param dr dynamic range
* @param q quad enable
*/
void SetGapPixelsEnable(bool b, int dr, bool q) {
if (dr == 4)
b = 0;
switch((int)b) {
case 1:
nPixelsX = (256 * 2) + 3;
if (q) {
nPixelsX = (256 * 2) + 2;
}
nPixelsY = 256 + 1;
imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 1 : // 8 bit
0.5))); // 4 bit
break;
default:
nPixelsX = (256*2);
nPixelsY = 256;
imageSize = nPixelsX * nPixelsY * ((dr > 16) ? 4 : // 32 bit
((dr > 8) ? 2 : // 16 bit
((dr > 4) ? 1 : // 8 bit
0.5))); // 4 bit
break;
}
};
};

View File

@ -383,41 +383,29 @@ public:
attribute = dataset.createAttribute("unit",strdatatype, dataspace);
attribute.write(strdatatype, std::string("ns"));
//Gap Pixels Enable
dataset = group5.createDataSet ( "gap pixels enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.gapPixelsEnable), PredType::NATIVE_INT);
//Quad Enable
dataset = group5.createDataSet ( "quad enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.quadEnable), PredType::NATIVE_INT);
//Gap Pixels Enable
dataset = group5.createDataSet ( "gap pixels enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.gapPixelsEnable), PredType::NATIVE_INT);
//Quad Enable
dataset = group5.createDataSet ( "quad enable", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.quadEnable), PredType::NATIVE_INT);
//Analog Flag
dataset = group5.createDataSet ( "analog flag", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.quadEnable), PredType::NATIVE_INT);
dataset.write ( &(attr.analogFlag), PredType::NATIVE_INT);
//Digital Flag
dataset = group5.createDataSet ( "digital flag", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.gapPixelsEnable), PredType::NATIVE_INT);
dataset.write ( &(attr.digitalFlag), PredType::NATIVE_INT);
//ADC Mask
dataset = group5.createDataSet ( "adc mask", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.quadEnable), PredType::NATIVE_INT);
dataset.write ( &(attr.adcmask), PredType::NATIVE_INT);
//Dbit Offset
dataset = group5.createDataSet ( "dbit offset", PredType::NATIVE_INT, dataspace );
dataset.write ( &(attr.gapPixelsEnable), PredType::NATIVE_INT);
dataset.write ( &(attr.dbitoffset), PredType::NATIVE_INT);
// Dbit List
dataset = group5.createDataSet ( "dbit bitset list", PredType::STD_U64LE, dataspace );
dataset.write ( &(attr.periodNs), PredType::STD_U64LE);
dataset.write ( &(attr.dbitlist), PredType::STD_U64LE);
// Roi xmin
dataset = group5.createDataSet ( "roi xmin", PredType::NATIVE_INT, dataspace );

View File

@ -37,6 +37,7 @@ void Implementation::DeleteMembers() {
generalData = nullptr;
}
additionalJsonHeader.clear();
listener.clear();
dataProcessor.clear();
dataStreamer.clear();
@ -92,7 +93,6 @@ void Implementation::InitializeMembers() {
streamingTimerInMs = DEFAULT_STREAMING_TIMER_IN_MS;
streamingPort = 0;
streamingSrcIP = sls::IpAddr{};
additionalJsonHeader = "";
// detector parameters
numberOfFrames = 0;
@ -108,7 +108,6 @@ void Implementation::InitializeMembers() {
roi.xmax = -1;
tengigaEnable = false;
flippedDataX = 0;
gapPixelsEnable = false;
quadEnable = false;
activated = true;
deactivatedPaddingEnable = true;
@ -273,7 +272,7 @@ void Implementation::setDetectorType(const detectorType d) {
&activated, &deactivatedPaddingEnable, &silentMode));
dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType, fileWriteEnable,
&masterFileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
&masterFileWriteEnable, &dataStreamEnable,
&dynamicRange, &streamingFrequency, &streamingTimerInMs,
&framePadding, &activated, &deactivatedPaddingEnable,
&silentMode, &quadEnable, &ctbDbitList, &ctbDbitOffset,
@ -848,7 +847,6 @@ void Implementation::SetupWriter() {
attr.subExptimeNs = subExpTime;
attr.subPeriodNs = subPeriod;
attr.periodNs = acquisitionPeriod;
attr.gapPixelsEnable = gapPixelsEnable;
attr.quadEnable = quadEnable;
attr.analogFlag = (readoutType == ANALOG_ONLY || readoutType == ANALOG_AND_DIGITAL) ? 1 : 0;
attr.digitalFlag = (readoutType == DIGITAL_ONLY || readoutType == ANALOG_AND_DIGITAL) ? 1 : 0;
@ -943,7 +941,7 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, myDetectorType, fifo_ptr, &fileFormatType,
fileWriteEnable, &masterFileWriteEnable, &dataStreamEnable,
&gapPixelsEnable, &dynamicRange, &streamingFrequency,
&dynamicRange, &streamingFrequency,
&streamingTimerInMs, &framePadding, &activated,
&deactivatedPaddingEnable, &silentMode, &quadEnable, &ctbDbitList,
&ctbDbitOffset, &ctbAnalogDataBytes));
@ -965,10 +963,11 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
fd, &additionalJsonHeader, (int*)nd, &gapPixelsEnable, &quadEnable));
fd, (int*)nd, &quadEnable));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP);
dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader);
} catch (...) {
if (dataStreamEnable) {
@ -1108,10 +1107,11 @@ void Implementation::setDataStreamEnable(const bool enable) {
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex,
fd, &additionalJsonHeader, (int*)nd, &gapPixelsEnable, &quadEnable));
fd, (int*)nd, &quadEnable));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numThreads, streamingPort, streamingSrcIP);
dataStreamer[i]->SetAdditionalJsonHeader(additionalJsonHeader);
} catch (...) {
dataStreamer.clear();
dataStreamEnable = false;
@ -1170,17 +1170,55 @@ void Implementation::setStreamingSourceIP(const sls::IpAddr ip) {
LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
}
std::string Implementation::getAdditionalJsonHeader() const {
std::map<std::string, std::string> Implementation::getAdditionalJsonHeader() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return additionalJsonHeader;
}
void Implementation::setAdditionalJsonHeader(const std::string& c) {
void Implementation::setAdditionalJsonHeader(const std::map<std::string, std::string> &c) {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
additionalJsonHeader = c;
LOG(logINFO) << "Additional JSON Header: " << additionalJsonHeader;
for (const auto &it : dataStreamer) {
it->SetAdditionalJsonHeader(c);
}
LOG(logINFO) << "Additional JSON Header: " << sls::ToString(additionalJsonHeader);
}
std::string Implementation::getAdditionalJsonParameter(const std::string &key) const {
if (additionalJsonHeader.find(key) != additionalJsonHeader.end()) {
return additionalJsonHeader.at(key);
}
throw sls::RuntimeError("No key " + key + " found in additional json header");
}
void Implementation::setAdditionalJsonParameter(const std::string &key, const std::string &value) {
auto pos = additionalJsonHeader.find(key);
// if value is empty, delete
if (value.empty()) {
// doesnt exist
if (pos == additionalJsonHeader.end()) {
LOG(logINFO) << "Additional json parameter (" << key << ") does not exist anyway";
} else {
LOG(logINFO) << "Deleting additional json parameter (" << key << ")";
additionalJsonHeader.erase(pos);
}
}
// if found, set it
else if (pos != additionalJsonHeader.end()) {
additionalJsonHeader[key] = value;
LOG(logINFO) << "Setting additional json parameter (" << key << ") to " << value;
}
// append if not found
else {
additionalJsonHeader[key] = value;
LOG(logINFO) << "Adding additional json parameter (" << key << ") to " << value;
}
for (const auto &it : dataStreamer) {
it->SetAdditionalJsonHeader(additionalJsonHeader);
}
LOG(logINFO) << "Additional JSON Header: " << sls::ToString(additionalJsonHeader);
}
/**************************************************
* *
@ -1330,9 +1368,6 @@ void Implementation::setDynamicRange(const uint32_t i) {
if (myDetectorType == EIGER || myDetectorType == MYTHEN3) {
generalData->SetDynamicRange(i, tengigaEnable);
if (myDetectorType == EIGER) {
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable);
}
// to update npixelsx, npixelsy in file writer
for (const auto &it : dataProcessor)
it->SetPixelDimension();
@ -1377,7 +1412,6 @@ void Implementation::setTenGigaEnable(const bool b) {
switch (myDetectorType) {
case EIGER:
generalData->SetTenGigaEnable(b, dynamicRange);
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, quadEnable);
break;
case MOENCH:
case CHIPTESTBOARD:
@ -1421,24 +1455,6 @@ void Implementation::setFlippedDataX(int enable) {
LOG(logINFO) << "Flipped Data X: " << flippedDataX;
}
bool Implementation::getGapPixelsEnable() const {
LOG(logDEBUG3) << __SHORT_AT__ << " called";
return gapPixelsEnable;
}
void Implementation::setGapPixelsEnable(const bool b) {
if (gapPixelsEnable != b) {
gapPixelsEnable = b;
// side effects
generalData->SetGapPixelsEnable(b, dynamicRange, quadEnable);
for (const auto &it : dataProcessor)
it->SetPixelDimension();
SetupFifoStructure();
}
LOG(logINFO) << "Gap Pixels Enable: " << gapPixelsEnable;
}
bool Implementation::getQuad() const {
LOG(logDEBUG) << __AT__ << " starting";
return quadEnable;
@ -1448,12 +1464,6 @@ void Implementation::setQuad(const bool b) {
if (quadEnable != b) {
quadEnable = b;
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange, b);
// to update npixelsx, npixelsy in file writer
for (const auto &it : dataProcessor)
it->SetPixelDimension();
SetupFifoStructure();
if (!quadEnable) {
for (const auto &it : dataStreamer) {
it->SetNumberofDetectors(numDet);

View File

@ -14,6 +14,7 @@ class slsDetectorDefs;
#include <exception>
#include <memory>
#include <vector>
#include <map>
class Implementation : private virtual slsDetectorDefs {
public:
@ -123,8 +124,10 @@ class Implementation : private virtual slsDetectorDefs {
void setStreamingPort(const uint32_t i);
sls::IpAddr getStreamingSourceIP() const;
void setStreamingSourceIP(const sls::IpAddr ip);
std::string getAdditionalJsonHeader() const;
void setAdditionalJsonHeader(const std::string& c);
std::map<std::string, std::string> getAdditionalJsonHeader() const;
void setAdditionalJsonHeader(const std::map<std::string, std::string> &c);
std::string getAdditionalJsonParameter(const std::string &key) const;
void setAdditionalJsonParameter(const std::string &key, const std::string &value);
/**************************************************
* *
@ -161,9 +164,6 @@ class Implementation : private virtual slsDetectorDefs {
void setTenGigaEnable(const bool b);
int getFlippedDataX() const;
void setFlippedDataX(int enable = -1);
bool getGapPixelsEnable() const;
/* [Eiger] */
void setGapPixelsEnable(const bool b);
bool getQuad() const;
/* [Eiger] */
void setQuad(const bool b);
@ -263,7 +263,7 @@ class Implementation : private virtual slsDetectorDefs {
uint32_t streamingTimerInMs;
uint32_t streamingPort;
sls::IpAddr streamingSrcIP;
std::string additionalJsonHeader;
std::map<std::string, std::string> additionalJsonHeader;
// detector parameters
uint64_t numberOfFrames;
@ -278,7 +278,6 @@ class Implementation : private virtual slsDetectorDefs {
ROI roi;
bool tengigaEnable;
int flippedDataX;
bool gapPixelsEnable;
bool quadEnable;
bool activated;
bool deactivatedPaddingEnable;

View File

@ -74,7 +74,6 @@ struct masterAttributes {
uint64_t subExptimeNs;
uint64_t subPeriodNs;
uint64_t periodNs;
uint32_t gapPixelsEnable;
uint32_t quadEnable;
uint32_t analogFlag;
uint32_t digitalFlag;