mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-21 09:08:00 +02:00
quad implemented
This commit is contained in:
@ -16,7 +16,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
|
||||
|
||||
|
||||
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
||||
uint64_t* fi, int* fd, char* ajh, bool* sm) :
|
||||
uint64_t* fi, int* fd, char* ajh, bool* sm, int* nd, bool* gpEnable) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
generalData(0),
|
||||
@ -26,14 +26,19 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI>* r,
|
||||
roi(r),
|
||||
adcConfigured(-1),
|
||||
fileIndex(fi),
|
||||
flippedData(fd),
|
||||
additionJsonHeader(ajh),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
firstMeasurementIndex(0),
|
||||
completeBuffer(0)
|
||||
completeBuffer(0),
|
||||
gapPixelsEnable(gpEnable)
|
||||
{
|
||||
flippedData[0] = fd[0];
|
||||
flippedData[1] = fd[1];
|
||||
numDet[0] = nd[0];
|
||||
numDet[1] = nd[1];
|
||||
|
||||
if(ThreadObject::CreateThread() == FAIL)
|
||||
throw std::exception();
|
||||
|
||||
@ -130,6 +135,16 @@ int DataStreamer::SetThreadPriority(int priority) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void DataStreamer::SetNumberofDetectors(int* nd) {
|
||||
numDet[0] = nd[0];
|
||||
numDet[1] = nd[1];
|
||||
}
|
||||
|
||||
void DataStreamer::SetFlippedData(int* fd) {
|
||||
flippedData[0] = fd[0];
|
||||
flippedData[1] = fd[1];
|
||||
}
|
||||
|
||||
|
||||
void DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
|
||||
uint32_t portnum = port + index;
|
||||
@ -261,13 +276,13 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
|
||||
uint64_t acquisitionIndex = header.frameNumber - firstAcquisitionIndex;
|
||||
|
||||
return zmqSocket->SendHeaderData(index, dummy, SLS_DETECTOR_JSON_HEADER_VERSION, *dynamicRange, *fileIndex,
|
||||
nx, ny, size,
|
||||
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,
|
||||
flippedData,
|
||||
gapPixelsEnable ? 1 : 0, flippedData,
|
||||
additionJsonHeader
|
||||
);
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
flippedData[0] = 0;
|
||||
flippedData[1] = 0;
|
||||
gapPixelsEnable = false;
|
||||
quadEnable = false;
|
||||
|
||||
//***receiver parameters***
|
||||
status = IDLE;
|
||||
@ -137,6 +138,11 @@ bool UDPBaseImplementation::getGapPixelsEnable() const {
|
||||
return gapPixelsEnable;
|
||||
}
|
||||
|
||||
bool UDPBaseImplementation::getQuad() const {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return quadEnable;
|
||||
}
|
||||
|
||||
/***file parameters***/
|
||||
slsReceiverDefs::fileFormat UDPBaseImplementation::getFileFormat() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
@ -392,6 +398,8 @@ void UDPBaseImplementation::setMultiDetectorSize(const int* size) {
|
||||
}
|
||||
strcat(message,")");
|
||||
FILE_LOG(logINFO) << message;
|
||||
|
||||
// overridden
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setFlippedData(int axis, int enable){
|
||||
@ -399,6 +407,8 @@ void UDPBaseImplementation::setFlippedData(int axis, int enable){
|
||||
if(axis<0 || axis>1) return;
|
||||
flippedData[axis] = enable==0?0:1;
|
||||
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
||||
|
||||
// overridden
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setGapPixelsEnable(const bool b) {
|
||||
@ -410,6 +420,14 @@ int UDPBaseImplementation::setGapPixelsEnable(const bool b) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setQuad(const bool b) {
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
quadEnable = b;
|
||||
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
|
||||
|
||||
// overridden
|
||||
}
|
||||
|
||||
/***file parameters***/
|
||||
void UDPBaseImplementation::setFileFormat(const fileFormat f){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
@ -111,6 +111,55 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
|
||||
}
|
||||
|
||||
|
||||
void UDPStandardImplementation::setMultiDetectorSize(const int* size) {
|
||||
char message[100];
|
||||
strcpy(message, "Detector Size: (");
|
||||
for (int i = 0; i < MAX_DIMENSIONS; ++i) {
|
||||
if (myDetectorType == EIGER && (!i))
|
||||
numDet[i] = size[i]*2;
|
||||
else
|
||||
numDet[i] = size[i];
|
||||
sprintf(message,"%s%d",message,numDet[i]);
|
||||
if (i < MAX_DIMENSIONS-1 )
|
||||
strcat(message,",");
|
||||
}
|
||||
strcat(message,")");
|
||||
|
||||
int sz[2] = {numDet[0], numDet[1]};
|
||||
if (quadEnable) {
|
||||
sz[0] = 1;
|
||||
sz[1] = 2;
|
||||
}
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
(*it)->SetNumberofDetectors(sz);
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << message;
|
||||
}
|
||||
|
||||
void UDPStandardImplementation::setFlippedData(int axis, int enable){
|
||||
if(axis<0 || axis>1) return;
|
||||
flippedData[axis] = enable==0?0:1;
|
||||
|
||||
if (!quadEnable) {
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
(*it)->SetFlippedData(flippedData);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int fd[2] = {flippedData[0], flippedData[1]};
|
||||
if (dataStreamer.size() == 2) {
|
||||
fd[0] = 0;
|
||||
dataStreamer[0]->SetFlippedData(fd);
|
||||
fd[0] = 1;
|
||||
dataStreamer[1]->SetFlippedData(fd);
|
||||
}
|
||||
}
|
||||
|
||||
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
||||
}
|
||||
|
||||
|
||||
|
||||
int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
|
||||
if (gapPixelsEnable != b) {
|
||||
@ -130,6 +179,32 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
void UDPStandardImplementation::setQuad(const bool b) {
|
||||
if (quadEnable != b) {
|
||||
quadEnable = b;
|
||||
|
||||
if (!quadEnable) {
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
(*it)->SetNumberofDetectors(numDet);
|
||||
(*it)->SetFlippedData(flippedData);
|
||||
}
|
||||
} else {
|
||||
int size[2] = {1, 2};
|
||||
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
|
||||
(*it)->SetNumberofDetectors(size);
|
||||
}
|
||||
int fd[2] = {flippedData[0], flippedData[1]};
|
||||
if (dataStreamer.size() == 2) {
|
||||
fd[0] = 0;
|
||||
dataStreamer[0]->SetFlippedData(fd);
|
||||
fd[0] = 1;
|
||||
dataStreamer[1]->SetFlippedData(fd);
|
||||
}
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Quad Enable: " << quadEnable;
|
||||
}
|
||||
|
||||
|
||||
void UDPStandardImplementation::setFileFormat(const fileFormat f){
|
||||
switch(f){
|
||||
@ -252,7 +327,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
||||
for ( int i = 0; i < numThreads; ++i ) {
|
||||
try {
|
||||
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
|
||||
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
|
||||
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode, (int*)numDet, &gapPixelsEnable);
|
||||
dataStreamer.push_back(s);
|
||||
dataStreamer[i]->SetGeneralData(generalData);
|
||||
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
|
||||
|
@ -246,6 +246,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
|
||||
case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY";
|
||||
case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE";
|
||||
case F_RECEIVER_DEACTIVATED_PADDING_ENABLE: return "F_RECEIVER_DEACTIVATED_PADDING_ENABLE";
|
||||
case F_RECEIVER_QUAD: return "F_RECEIVER_QUAD";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -303,7 +304,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy;
|
||||
flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable;
|
||||
flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable;
|
||||
|
||||
flist[F_RECEIVER_QUAD] = &slsReceiverTCPIPInterface::set_quad_type;
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
@ -2982,3 +2983,53 @@ int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() {
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_quad_type() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
int value = -1;
|
||||
int retval = -1;
|
||||
|
||||
// receive arguments
|
||||
if (mySock->ReceiveDataOnly(&value,sizeof(value)) < 0 )
|
||||
return printSocketReadError();
|
||||
|
||||
// execute action
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
if (receiverBase == NULL)
|
||||
invalidReceiverObject();
|
||||
else {
|
||||
// set
|
||||
if(value >= 0) {
|
||||
if (mySock->differentClients && lockStatus)
|
||||
receiverlocked();
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setQuad(value); // no check required
|
||||
}
|
||||
}
|
||||
//get
|
||||
retval = (int)receiverBase->getQuad(); // no check required
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logINFO) << "Quad mode:" << retval;
|
||||
#endif
|
||||
|
||||
if (ret == OK && mySock->differentClients)
|
||||
ret = FORCE_UPDATE;
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if (ret == FAIL)
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user