slsReceiver:trying to get deactivate to work

This commit is contained in:
maliakal_d 2018-08-14 15:06:06 +02:00
parent fa175ac934
commit f0ac49190a
18 changed files with 348 additions and 90 deletions

View File

@ -3556,6 +3556,10 @@ int multiSlsDetector::activate(int const enable) {
return callDetectorMember(&slsDetector::activate, enable); return callDetectorMember(&slsDetector::activate, enable);
} }
int multiSlsDetector::setDeactivatedRxrPaddingMode(int padding) {
return callDetectorMember(&slsDetector::setDeactivatedRxrPaddingMode, padding);
}
int multiSlsDetector::getFlippedData(dimension d) { int multiSlsDetector::getFlippedData(dimension d) {
return callDetectorMember(&slsDetector::getFlippedData, d); return callDetectorMember(&slsDetector::getFlippedData, d);
} }

View File

@ -1241,11 +1241,18 @@ public:
int writeAdcRegister(int addr, int val); int writeAdcRegister(int addr, int val);
/** /**
* Activates the detector (Eiger only) * Activates/Deactivates the detector (Eiger only)
* @param enable active (1) or inactive (0), -1 gets * @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active) * @returns 0 (inactive) or 1 (active)for activate mode
*/ */
int activate(int const enable=GET_ONLINE_FLAG); int activate(int const enable=-1);
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
int setDeactivatedRxrPaddingMode(int padding=-1);
/** /**
* Returns the enable if data will be flipped across x or y axis (Eiger) * Returns the enable if data will be flipped across x or y axis (Eiger)

View File

@ -749,7 +749,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
thisDetector->receiverAPIVersion = 0; thisDetector->receiverAPIVersion = 0;
thisDetector->receiver_frameDiscardMode = NO_DISCARD; thisDetector->receiver_frameDiscardMode = NO_DISCARD;
thisDetector->receiver_framePadding = 1; thisDetector->receiver_framePadding = 1;
thisDetector->activated = true;
thisDetector->receiver_deactivatedPaddingEnable = true;
// get the detector parameters based on type // get the detector parameters based on type
detParameterList detlist; detParameterList detlist;
@ -5272,6 +5273,10 @@ string slsDetector::setReceiver(string receiverIP) {
std::cout << "sub period:" << thisDetector->timerValue[SUBFRAME_PERIOD] << endl; std::cout << "sub period:" << thisDetector->timerValue[SUBFRAME_PERIOD] << endl;
std::cout << "dynamic range:" << thisDetector->dynamicRange << endl; std::cout << "dynamic range:" << thisDetector->dynamicRange << endl;
std::cout << "flippeddatax:" << thisDetector->flippedData[X] << endl; std::cout << "flippeddatax:" << thisDetector->flippedData[X] << endl;
if (thisDetector->myDetectorType == EIGER) {
std::cout << "activated: " << thisDetector->activated << endl;
std::cout << "receiver deactivated padding: " << thisDetector->receiver_deactivatedPaddingEnable << endl;
}
std::cout << "10GbE:" << thisDetector->tenGigaEnable << endl; std::cout << "10GbE:" << thisDetector->tenGigaEnable << endl;
std::cout << "Gap pixels: " << thisDetector->gappixels << endl; std::cout << "Gap pixels: " << thisDetector->gappixels << endl;
std::cout << "rx streaming source ip:" << thisDetector->receiver_zmqip << endl; std::cout << "rx streaming source ip:" << thisDetector->receiver_zmqip << endl;
@ -5319,6 +5324,7 @@ string slsDetector::setReceiver(string receiverIP) {
if(thisDetector->myDetectorType == EIGER){ if(thisDetector->myDetectorType == EIGER){
setFlippedData(X,-1); setFlippedData(X,-1);
activate(-1); activate(-1);
setDeactivatedRxrPaddingMode(thisDetector->receiver_deactivatedPaddingEnable);
} }
if(thisDetector->myDetectorType == EIGER) if(thisDetector->myDetectorType == EIGER)
@ -6211,7 +6217,7 @@ int slsDetector::activate(int const enable) {
int retval = -1; int retval = -1;
int arg = enable; int arg = enable;
char mess[MAX_STR_LENGTH]=""; char mess[MAX_STR_LENGTH]="";
int ret = OK; int ret = FAIL;
if(thisDetector->myDetectorType != EIGER){ if(thisDetector->myDetectorType != EIGER){
std::cout<< "Not implemented for this detector" << std::endl; std::cout<< "Not implemented for this detector" << std::endl;
@ -6238,6 +6244,7 @@ int slsDetector::activate(int const enable) {
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE)); setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
} else { } else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
thisDetector->activated = retval;
} }
disconnectControl(); disconnectControl();
if (ret==FORCE_UPDATE) if (ret==FORCE_UPDATE)
@ -6254,12 +6261,13 @@ int slsDetector::activate(int const enable) {
#endif #endif
if(ret!=FAIL){ if(ret!=FAIL){
int arg = thisDetector->activated;
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){ if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE #ifdef VERBOSE
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl; std::cout << "Activating/Deactivating Receiver: " << arg << std::endl;
#endif #endif
if (connectData() == OK){ if (connectData() == OK){
ret=thisReceiver->sendInt(fnum2,retval,retval); ret=thisReceiver->sendInt(fnum2,retval,arg);
disconnectData(); disconnectData();
} }
if(ret==FAIL) if(ret==FAIL)
@ -6276,12 +6284,44 @@ int slsDetector::activate(int const enable) {
#endif #endif
return retval; return thisDetector->activated;
} }
int slsDetector::setDeactivatedRxrPaddingMode(int padding) {
int fnum = F_RECEIVER_DEACTIVATED_PADDING_ENABLE;
int retval = -1;
int arg = padding;
int ret = OK;
if(thisDetector->myDetectorType != EIGER){
std::cout<< "Not implemented for this detector" << std::endl;
setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE));
return -1;
}
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
std::cout << "Deactivated Receiver Padding Enable: " << arg << std::endl;
#endif
if (connectData() == OK){
ret=thisReceiver->sendInt(fnum,retval,arg);
disconnectData();
}
if(ret==FAIL)
setErrorMask((getErrorMask())|(RECEIVER_ACTIVATE));
else
thisDetector->receiver_deactivatedPaddingEnable = retval;
}
return thisDetector->receiver_deactivatedPaddingEnable;
}
int slsDetector::getFlippedData(dimension d) { int slsDetector::getFlippedData(dimension d) {
return thisDetector->flippedData[d]; return thisDetector->flippedData[d];
} }
@ -8570,7 +8610,13 @@ int slsDetector::updateReceiverNoWait() {
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind)); n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->receiver_upstream = ind; thisDetector->receiver_upstream = ind;
// activate
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->activated = ind;
// deactivated padding enable
n += dataSocket->ReceiveDataOnly(&ind,sizeof(ind));
thisDetector->receiver_deactivatedPaddingEnable = ind;
if (!n) printf("n: %d\n", n); if (!n) printf("n: %d\n", n);

View File

@ -375,6 +375,12 @@ private:
/** receiver partial frames padding enable */ /** receiver partial frames padding enable */
bool receiver_framePadding; bool receiver_framePadding;
/** activated receiver */
bool activated;
/** padding enable in deactivated receiver */
bool receiver_deactivatedPaddingEnable;
} sharedSlsDetector; } sharedSlsDetector;
@ -1525,11 +1531,18 @@ public:
int writeAdcRegister(int addr, int val); int writeAdcRegister(int addr, int val);
/** /**
* Activates the detector (Eiger only) * Activates/Deactivates the detector (Eiger only)
* @param enable active (1) or inactive (0), -1 gets * @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active) * @returns 0 (inactive) or 1 (active)for activate mode
*/ */
int activate(int const enable=GET_ONLINE_FLAG); int activate(int const enable=-1);
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
int setDeactivatedRxrPaddingMode(int padding=-1);
/** /**
* Returns the enable if data will be flipped across x or y axis (Eiger) * Returns the enable if data will be flipped across x or y axis (Eiger)

View File

@ -481,12 +481,19 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
*/ */
virtual int setOnline(int const online=-1)=0; virtual int setOnline(int const online=-1)=0;
/** @short activates the detector (detector specific) /**
\param enable can be: -1 returns wether the detector is in active (1) or inactive (0) state * Activates/Deactivates the detector (Eiger only)
\returns 0 (inactive) or 1 (active) * @param enable active (1) or inactive (0), -1 gets
* @returns 0 (inactive) or 1 (active)for activate mode
*/ */
virtual int activate(int const enable=GET_ONLINE_FLAG)=0; virtual int activate(int const enable=-1)=0;
/**
* Set deactivated Receiver padding mode (Eiger only)
* @param padding padding option for deactivated receiver. Can be 1 (padding), 0 (no padding), -1 (gets)
* @returns 1 (padding), 0 (no padding), -1 (inconsistent values) for padding option
*/
virtual int setDeactivatedRxrPaddingMode(int padding=-1)=0;
/** /**
@short set detector settings @short set detector settings

View File

@ -324,7 +324,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
++i; ++i;
/*! \page config /*! \page config
- <b>activate</b> Activates/Deactivates the detector. Deactivated detector does not send data. Used for EIGER only. \c Returns \c (int) - <b>activate [b] [p]</b> Activates/Deactivates the detector. \c b is 1 for activate, 0 for deactivate. Deactivated detector does not send data. \c p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Used for EIGER only. \c Returns \c (int) (string)
*/ */
descrToFuncMap[i].m_pFuncName="activate"; // descrToFuncMap[i].m_pFuncName="activate"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline; descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
@ -4363,11 +4363,20 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
if (!sscanf(args[1],"%d",&ival)) if (!sscanf(args[1],"%d",&ival))
return string("Could not scan activate mode ")+string(args[1]); return string("Could not scan activate mode ")+string(args[1]);
/* if(dynamic_cast<slsDetector*>(myDet) != NULL)
return string("Can only set it from the multiDetector mode");*/
myDet->activate(ival); myDet->activate(ival);
bool padding = true;
if (narg > 2) {
if (string(args[2]) == "padding")
padding = true;
else if (string(args[2]) == "nopadding")
padding = false;
else
return string ("Could not scan activate mode's padding option " + string(args[2]));
myDet->setDeactivatedRxrPaddingMode(padding);
} }
sprintf(ans,"%d",myDet->activate()); }
int ret = myDet->setDeactivatedRxrPaddingMode();
sprintf(ans,"%d %s", myDet->activate(), ret == 1 ? "padding" : (ret == 0 ? "nopadding" : "unknown"));
} }
else if(cmd=="r_online"){ else if(cmd=="r_online"){
if (action==PUT_ACTION) { if (action==PUT_ACTION) {
@ -4398,14 +4407,14 @@ string slsDetectorCommand::helpOnline(int narg, char *args[], int action) {
if (action==PUT_ACTION || action==HELP_ACTION) { if (action==PUT_ACTION || action==HELP_ACTION) {
os << "online i \n sets the detector in online (1) or offline (0) mode"<< std::endl; os << "online i \n sets the detector in online (1) or offline (0) mode"<< std::endl;
os << "r_online i \n sets the receiver in online (1) or offline (0) mode"<< std::endl; os << "r_online i \n sets the receiver in online (1) or offline (0) mode"<< std::endl;
os << "activate i \n sets the detector in activated (1) or deactivated (0) mode (does not send data). Only for Eiger."<< std::endl; os << "activate i [p]\n sets the detector in activated (1) or deactivated (0) mode (does not send data). p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Only for Eiger."<< std::endl;
} }
if (action==GET_ACTION || action==HELP_ACTION) { if (action==GET_ACTION || action==HELP_ACTION) {
os << "online \n gets the detector online (1) or offline (0) mode"<< std::endl; os << "online \n gets the detector online (1) or offline (0) mode"<< std::endl;
os << "checkonline \n returns the hostnames of all detectors in offline mode"<< std::endl; os << "checkonline \n returns the hostnames of all detectors in offline mode"<< std::endl;
os << "r_online \n gets the receiver online (1) or offline (0) mode"<< std::endl; os << "r_online \n gets the receiver online (1) or offline (0) mode"<< std::endl;
os << "r_checkonline \n returns the hostnames of all receiver in offline mode"<< std::endl; os << "r_checkonline \n returns the hostnames of all receiver in offline mode"<< std::endl;
os << "activate \n gets the detector activated (1) or deactivated (0) mode. Only for Eiger."<< std::endl; os << "activate \n gets the detector activated (1) or deactivated (0) mode. And padding or nonpadding for the deactivated receiver. Only for Eiger."<< std::endl;
} }
return os.str(); return os.str();

View File

@ -35,6 +35,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
* @param freq pointer to streaming frequency * @param freq pointer to streaming frequency
* @param timer pointer to timer if streaming frequency is random * @param timer pointer to timer if streaming frequency is random
* @param fp pointer to frame padding enable * @param fp pointer to frame padding enable
* @param act pointer to activated
* @param depaden pointer to deactivated padding enable
* @param dataReadycb pointer to data ready call back function * @param dataReadycb pointer to data ready call back function
* @param dataModifyReadycb pointer to data ready call back function with modified * @param dataModifyReadycb pointer to data ready call back function with modified
* @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed). * @param pDataReadycb pointer to arguments of data ready call back function. To write/stream a smaller size of processed data, change this value (only smaller value is allowed).
@ -42,7 +44,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype, DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype,
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr, bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer, uint32_t* freq, uint32_t* timer,
bool* fp, bool* fp, bool* act, bool* depaden,
void (*dataReadycb)(char*, char*, uint32_t, void*), void (*dataReadycb)(char*, char*, uint32_t, void*),
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
void *pDataReadycb); void *pDataReadycb);
@ -336,6 +338,12 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
/** x coord hardcoded ad 1D, if detector does not send them yet **/ /** x coord hardcoded ad 1D, if detector does not send them yet **/
uint16_t xcoordin1D; uint16_t xcoordin1D;
/** Activated/Deactivated */
bool* activated;
/** Deactivated padding enable */
bool* deactivatedPaddingEnable;
//acquisition start //acquisition start

View File

@ -203,23 +203,24 @@ public:
sls_detector_header header = rheader->detHeader; sls_detector_header header = rheader->detHeader;
hsize_t count[1] = {1}; hsize_t count[1] = {1};
hsize_t start[1] = {fnum}; hsize_t start[1] = {fnum};
int i = 0;
try{ try{
Exception::dontPrint(); //to handle errors Exception::dontPrint(); //to handle errors
dspace_para->selectHyperslab( H5S_SELECT_SET, count, start); dspace_para->selectHyperslab( H5S_SELECT_SET, count, start);
DataSpace memspace(H5S_SCALAR); DataSpace memspace(H5S_SCALAR);
dset_para[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para); dset_para[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para);i=1;
dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para); dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para);i=2;
dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para); dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para);i=3;
dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para); dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);i=4;
dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para); dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);i=5;
dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para); dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);i=6;
dset_para[6]->write(&header.xCoord, parameterDataTypes[6], memspace, *dspace_para); dset_para[6]->write(&header.xCoord, parameterDataTypes[6], memspace, *dspace_para);i=7;
dset_para[7]->write(&header.yCoord, parameterDataTypes[7], memspace, *dspace_para); dset_para[7]->write(&header.yCoord, parameterDataTypes[7], memspace, *dspace_para);i=8;
dset_para[8]->write(&header.zCoord, parameterDataTypes[8], memspace, *dspace_para); dset_para[8]->write(&header.zCoord, parameterDataTypes[8], memspace, *dspace_para);i=9;
dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para); dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);i=10;
dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para); dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);i=11;
dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para); dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);i=12;
dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para); dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para);i=13;
// contiguous bitset // contiguous bitset
if (sizeof(sls_bitset) == sizeof(bitset_storage)) { if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
@ -236,10 +237,10 @@ public:
storage[i >> 3] |= (bits[i] << (i & 7)); storage[i >> 3] |= (bits[i] << (i & 7));
// write bitmask // write bitmask
dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para); dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para);
} }i=14;
} }
catch(Exception error){ catch(Exception error){
cprintf(RED,"Error in writing parameters to file in object %d\n",ind); cprintf(RED,"Error in writing parameters (parameter index %d) to file in object %d\n", i, ind);
error.printErrorStack(); error.printErrorStack();
return 1; return 1;
} }

View File

@ -33,11 +33,13 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
* @param as pointer to actual udp socket buffer size * @param as pointer to actual udp socket buffer size
* @param fpf pointer to frames per file * @param fpf pointer to frames per file
* @param fdp frame discard policy * @param fdp frame discard policy
* @param act pointer to activated
* @param depaden pointer to deactivated padding enable
*/ */
Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr, uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
uint32_t* us, uint32_t* as, uint32_t* fpf, uint32_t* us, uint32_t* as, uint32_t* fpf,
frameDiscardPolicy* fdp); frameDiscardPolicy* fdp, bool* act, bool* depaden);
/** /**
* Destructor * Destructor
@ -236,6 +238,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
/** frame discard policy */ /** frame discard policy */
frameDiscardPolicy* frameDiscardMode; frameDiscardPolicy* frameDiscardMode;
/** Activated/Deactivated */
bool* activated;
/** Deactivated padding enable */
bool* deactivatedPaddingEnable;
// acquisition start // acquisition start
/** Aquisition Started flag */ /** Aquisition Started flag */

View File

@ -277,11 +277,19 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
/** /**
* Get activate * Get activate
* If deactivated, receiver will write dummy packets 0xFF * If deactivated, receiver will create dummy data if deactivated padding is enabled
* (as it will receive nothing from detector) * (as it will receive nothing from detector)
* @return 0 for deactivated, 1 for activated * @return false for deactivated, true for activated
*/ */
int getActivate() const; bool getActivate() const;
/**
* Get deactivated padding enable
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
* (as it will receive nothing from detector)
* @return 0 for disabled, 1 for enabled
*/
bool getDeactivatedPadding() const;
/** /**
* Get Streaming Port * Get Streaming Port
@ -605,10 +613,21 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
/** /**
* Activate / Deactivate Receiver * Activate / Deactivate Receiver
* If deactivated, receiver will write dummy packets 0xFF * If deactivated, receiver will create dummy data if deactivated padding is enabled
* (as it will receive nothing from detector) * (as it will receive nothing from detector)
* @param enable enable
* @return false for disabled, true for enabled
*/ */
int setActivate(int enable = -1); bool setActivate(const bool enable);
/**
* Set deactivated padding enable
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
* (as it will receive nothing from detector)
* @param enable enable
* @return false for disabled, true for enabled
*/
bool setDeactivatedPadding(const bool enable);
/** /**
* Set streaming port * Set streaming port
@ -727,7 +746,9 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
/** Receiver Status */ /** Receiver Status */
runStatus status; runStatus status;
/** Activated/Deactivated */ /** Activated/Deactivated */
int activated; bool activated;
/** Deactivated padding enable */
bool deactivatedPaddingEnable;
/** frame discard policy */ /** frame discard policy */
frameDiscardPolicy frameDiscardMode; frameDiscardPolicy frameDiscardMode;
/** frame padding */ /** frame padding */

View File

@ -47,6 +47,7 @@ class UDPInterface {
* -setDynamicRange * -setDynamicRange
* -setFlippedData (if eiger) * -setFlippedData (if eiger)
* -setActivate (if eiger) * -setActivate (if eiger)
* -setDeactivatedPadding (if eiger)
* -setTenGigaEnable (if eiger) * -setTenGigaEnable (if eiger)
* -setGapPixelsEnable * -setGapPixelsEnable
* -setStreamingPort * -setStreamingPort
@ -364,11 +365,19 @@ class UDPInterface {
/** /**
* Get activate * Get activate
* If deactivated, receiver will write dummy packets 0xFF * If deactivated, receiver will create dummy data if deactivated padding is enabled
* (as it will receive nothing from detector) * (as it will receive nothing from detector)
* @return 0 for deactivated, 1 for activated * @return false for deactivated, true for activated
*/ */
virtual int getActivate() const = 0; virtual bool getActivate() const = 0;
/**
* Get deactivated padding enable
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
* (as it will receive nothing from detector)
* @return false for disabled, true for enabled
*/
virtual bool getDeactivatedPadding() const = 0;
/** /**
* Get Streaming Port * Get Streaming Port
@ -694,10 +703,21 @@ class UDPInterface {
/** /**
* Activate / Deactivate Receiver * Activate / Deactivate Receiver
* If deactivated, receiver will write dummy packets 0xFF * If deactivated, receiver will create dummy data if deactivated padding is enabled
* (as it will receive nothing from detector) * (as it will receive nothing from detector)
* @param enable enable
* @return false for disabled, true for enabled
*/ */
virtual int setActivate(int enable = -1) = 0; virtual bool setActivate(const bool enable) = 0;
/**
* Set deactivated padding enable
* If enabled, receiver will create dummy packets (0xFF), else it will create nothing
* (as it will receive nothing from detector)
* @param enable enable
* @return false for disabled, true for enabled
*/
virtual bool setDeactivatedPadding(const bool enable) = 0;
/** /**
* Set streaming port * Set streaming port

View File

@ -281,6 +281,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
/** set partial frame padding enable*/ /** set partial frame padding enable*/
int set_padding_enable(); int set_padding_enable();
/** set deactivated receiver padding enable */
int set_deactivated_receiver_padding_enable();
/** detector type */ /** detector type */
detectorType myDetectorType; detectorType myDetectorType;

View File

@ -70,6 +70,7 @@ enum recFuncs{
F_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */ F_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */
F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */ F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */
F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */ F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */
F_RECEIVER_DEACTIVATED_PADDING_ENABLE, /** < deactivated receiver padding enable */
/* Always append functions hereafter!!! */ /* Always append functions hereafter!!! */

View File

@ -27,7 +27,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
fileFormat* ftype, bool fwenable, fileFormat* ftype, bool fwenable,
bool* dsEnable, bool* gpEnable, uint32_t* dr, bool* dsEnable, bool* gpEnable, uint32_t* dr,
uint32_t* freq, uint32_t* timer, uint32_t* freq, uint32_t* timer,
bool* fp, bool* fp, bool* act, bool* depaden,
void (*dataReadycb)(char*, char*, uint32_t, void*), void (*dataReadycb)(char*, char*, uint32_t, void*),
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*), void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
void *pDataReadycb) : void *pDataReadycb) :
@ -48,6 +48,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
currentFreqCount(0), currentFreqCount(0),
tempBuffer(0), tempBuffer(0),
xcoordin1D(0), xcoordin1D(0),
activated(act),
deactivatedPaddingEnable(depaden),
acquisitionStartedFlag(false), acquisitionStartedFlag(false),
measurementStartedFlag(false), measurementStartedFlag(false),
firstAcquisitionIndex(0), firstAcquisitionIndex(0),
@ -374,8 +376,10 @@ void DataProcessor::ProcessAnImage(char* buf) {
header.xCoord = xcoordin1D; header.xCoord = xcoordin1D;
} }
// deactivated and padding enabled
if ((!(*activated) && *deactivatedPaddingEnable) ||
// frame padding // frame padding
if (*framePadding && nump < generalData->packetsPerFrame) (*framePadding && nump < generalData->packetsPerFrame))
PadMissingPackets(buf); PadMissingPackets(buf);
// normal call back // normal call back

View File

@ -22,7 +22,7 @@ const string Listener::TypeName = "Listener";
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s, Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr, uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
uint32_t* us, uint32_t* as, uint32_t* fpf, uint32_t* us, uint32_t* as, uint32_t* fpf,
frameDiscardPolicy* fdp) : frameDiscardPolicy* fdp, bool* act, bool* depaden) :
ThreadObject(ind), ThreadObject(ind),
runningFlag(0), runningFlag(0),
generalData(0), generalData(0),
@ -38,6 +38,8 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
actualUDPSocketBufferSize(as), actualUDPSocketBufferSize(as),
framesPerFile(fpf), framesPerFile(fpf),
frameDiscardMode(fdp), frameDiscardMode(fdp),
activated(act),
deactivatedPaddingEnable(depaden),
acquisitionStartedFlag(false), acquisitionStartedFlag(false),
measurementStartedFlag(false), measurementStartedFlag(false),
firstAcquisitionIndex(0), firstAcquisitionIndex(0),
@ -183,6 +185,10 @@ int Listener::SetThreadPriority(int priority) {
int Listener::CreateUDPSockets() { int Listener::CreateUDPSockets() {
if (!(*activated)) {
return OK;
}
//if eth is mistaken with ip address //if eth is mistaken with ip address
if (strchr(eth,'.') != NULL){ if (strchr(eth,'.') != NULL){
memset(eth, 0, MAX_STR_LENGTH); memset(eth, 0, MAX_STR_LENGTH);
@ -236,6 +242,12 @@ void Listener::SetSilentMode(bool mode) {
int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) { int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber; FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber;
if (!(*activated)) {
*actualUDPSocketBufferSize = (s*2);
return OK;
}
uint32_t temp = *udpSocketBufferSize; uint32_t temp = *udpSocketBufferSize;
*udpSocketBufferSize = s; *udpSocketBufferSize = s;
@ -291,7 +303,7 @@ void Listener::ThreadExecution() {
#endif #endif
//udpsocket doesnt exist //udpsocket doesnt exist
if (!udpSocketAlive && !carryOverFlag) { if (*activated && !udpSocketAlive && !carryOverFlag) {
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier"; //FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
(*((uint32_t*)buffer)) = 0; (*((uint32_t*)buffer)) = 0;
StopListening(buffer); StopListening(buffer);
@ -299,7 +311,7 @@ void Listener::ThreadExecution() {
} }
//get data //get data
if ((*status != TRANSMITTING && udpSocketAlive) || carryOverFlag) { if ((*status != TRANSMITTING && (!(*activated) || udpSocketAlive)) || carryOverFlag) {
rc = ListenToAnImage(buffer); rc = ListenToAnImage(buffer);
} }
@ -357,6 +369,7 @@ void Listener::StopListening(char* buf) {
/* buf includes the fifo header and packet header */ /* buf includes the fifo header and packet header */
uint32_t Listener::ListenToAnImage(char* buf) { uint32_t Listener::ListenToAnImage(char* buf) {
int rc = 0; int rc = 0;
uint64_t fnum = 0, bid = 0; uint64_t fnum = 0, bid = 0;
uint32_t pnum = 0, snum = 0; uint32_t pnum = 0, snum = 0;
@ -378,6 +391,20 @@ uint32_t Listener::ListenToAnImage(char* buf) {
/*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/ /*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/
new_header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES); new_header = (sls_receiver_header*) (buf + FIFO_HEADER_NUMBYTES);
// deactivated (eiger)
if (!(*activated)) {cprintf(RED,"deactivated receiver\n");
// no padding
if (!(*deactivatedPaddingEnable)) {
return 0;}
// padding without setting bitmask (all missing packets padded in dataProcessor)
if (currentFrameIndex >= *numImages)
return 0;
new_header->detHeader.frameNumber = currentFrameIndex+1; //(eiger)
new_header->detHeader.detType = (uint8_t) generalData->myDetectorType;
new_header->detHeader.version = (uint8_t) SLS_DETECTOR_HEADER_VERSION;
return generalData->imageSize;
}
//look for carry over //look for carry over

View File

@ -58,6 +58,7 @@ void UDPBaseImplementation::initializeMembers(){
//***receiver parameters*** //***receiver parameters***
status = IDLE; status = IDLE;
activated = true; activated = true;
deactivatedPaddingEnable = true;
frameDiscardMode = NO_DISCARD; frameDiscardMode = NO_DISCARD;
framePadding = false; framePadding = false;
@ -322,11 +323,16 @@ uint32_t UDPBaseImplementation::getSilentMode() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return silentMode;} return silentMode;}
int UDPBaseImplementation::getActivate() const{ bool UDPBaseImplementation::getActivate() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return activated; return activated;
} }
bool UDPBaseImplementation::getDeactivatedPadding() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
return deactivatedPaddingEnable;
}
uint32_t UDPBaseImplementation::getStreamingPort() const{ uint32_t UDPBaseImplementation::getStreamingPort() const{
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
return streamingPort; return streamingPort;
@ -733,15 +739,18 @@ void UDPBaseImplementation::abort(){
} }
int UDPBaseImplementation::setActivate(int enable){ bool UDPBaseImplementation::setActivate(bool enable){
FILE_LOG(logDEBUG) << __AT__ << " starting"; FILE_LOG(logDEBUG) << __AT__ << " starting";
if(enable != -1){
activated = enable; activated = enable;
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated); FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
return activated;
} }
return activated; bool UDPBaseImplementation::setDeactivatedPadding(bool enable){
FILE_LOG(logDEBUG) << __AT__ << " starting";
deactivatedPaddingEnable = enable;
FILE_LOG(logINFO) << "Deactivated Padding Enable: " << stringEnable(deactivatedPaddingEnable);
return deactivatedPaddingEnable;
} }
void UDPBaseImplementation::setStreamingPort(const uint32_t i) { void UDPBaseImplementation::setStreamingPort(const uint32_t i) {

View File

@ -375,13 +375,13 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
Listener* l = new Listener(i, myDetectorType, fifo[i], &status, Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange, &udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile, &udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
&frameDiscardMode); &frameDiscardMode, &activated, &deactivatedPaddingEnable);
listener.push_back(l); listener.push_back(l);
DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType, DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType,
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable, fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
&dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS, &dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
&framePadding, &framePadding, &activated, &deactivatedPaddingEnable,
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady); rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
dataProcessor.push_back(p); dataProcessor.push_back(p);
} }
@ -573,9 +573,7 @@ void UDPStandardImplementation::stopReceiver(){
void UDPStandardImplementation::startReadout(){ void UDPStandardImplementation::startReadout(){
if(status == RUNNING){ if(status == RUNNING){
//needs to wait for packets only if activated // wait for incoming delayed packets
if(activated){
//current packets caught //current packets caught
volatile int totalP = 0,prev=-1; volatile int totalP = 0,prev=-1;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
@ -604,7 +602,7 @@ void UDPStandardImplementation::startReadout(){
#endif #endif
} }
} }
}
//set status //set status
status = TRANSMITTING; status = TRANSMITTING;

View File

@ -245,6 +245,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION"; case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION";
case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY"; case F_RECEIVER_DISCARD_POLICY: return "F_RECEIVER_DISCARD_POLICY";
case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE"; case F_RECEIVER_PADDING_ENABLE: return "F_RECEIVER_PADDING_ENABLE";
case F_RECEIVER_DEACTIVATED_PADDING_ENABLE: return "F_RECEIVER_DEACTIVATED_PADDING_ENABLE";
default: return "Unknown Function"; default: return "Unknown Function";
} }
@ -301,6 +302,8 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility; flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility;
flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy; flist[F_RECEIVER_DISCARD_POLICY] = &slsReceiverTCPIPInterface::set_discard_policy;
flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable; flist[F_RECEIVER_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_padding_enable;
flist[F_RECEIVER_DEACTIVATED_PADDING_ENABLE] = &slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable;
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) { for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
@ -706,6 +709,19 @@ int slsReceiverTCPIPInterface::send_update() {
#endif #endif
n += mySock->SendDataOnly(&ind,sizeof(ind)); n += mySock->SendDataOnly(&ind,sizeof(ind));
// activate
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getActivate();
#endif
n += mySock->SendDataOnly(&ind,sizeof(ind));
// deactivated padding enable
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
ind=(int)receiverBase->getDeactivatedPadding();
#endif
n += mySock->SendDataOnly(&ind,sizeof(ind));
if (!lockStatus) if (!lockStatus)
strcpy(mySock->lastClientIP,mySock->thisClientIP); strcpy(mySock->lastClientIP,mySock->thisClientIP);
@ -1931,11 +1947,11 @@ int slsReceiverTCPIPInterface::set_activate() {
else if (receiverBase->getStatus() != IDLE) else if (receiverBase->getStatus() != IDLE)
receiverNotIdle(); receiverNotIdle();
else { else {
receiverBase->setActivate(enable); receiverBase->setActivate(enable > 0 ? true : false);
} }
} }
//get //get
retval = receiverBase->getActivate(); retval = (int)receiverBase->getActivate();
if(enable >= 0 && retval != enable){ if(enable >= 0 && retval != enable){
ret = FAIL; ret = FAIL;
sprintf(mess,"Could not set activate to %d, returned %d\n",enable,retval); sprintf(mess,"Could not set activate to %d, returned %d\n",enable,retval);
@ -2485,7 +2501,7 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() {
} }
#endif #endif
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
FILE_LOG(logDEBUG1) << "Activate: " << retval; FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
#endif #endif
if (ret == OK && mySock->differentClients) if (ret == OK && mySock->differentClients)
@ -2895,3 +2911,59 @@ int slsReceiverTCPIPInterface::set_padding_enable() {
int slsReceiverTCPIPInterface::set_deactivated_receiver_padding_enable() {
ret = OK;
memset(mess, 0, sizeof(mess));
int enable = -1;
int retval = -1;
// receive arguments
if (mySock->ReceiveDataOnly(&enable,sizeof(enable)) < 0 )
return printSocketReadError();
if (myDetectorType != EIGER)
functionNotImplemented();
// execute action
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
else {
if (receiverBase == NULL)
invalidReceiverObject();
else {
// set
if(enable >= 0) {
if (mySock->differentClients && lockStatus)
receiverlocked();
else if (receiverBase->getStatus() != IDLE)
receiverNotIdle();
else {
receiverBase->setDeactivatedPadding(enable > 0 ? true : false);
}
}
//get
retval = (int)receiverBase->getDeactivatedPadding();
if(enable >= 0 && retval != enable){
ret = FAIL;
sprintf(mess,"Could not set deactivated padding enable to %d, returned %d\n",enable,retval);
FILE_LOG(logERROR) << mess;
}
}
}
#endif
#ifdef VERYVERBOSE
FILE_LOG(logDEBUG1) << "Deactivated Padding Enable: " << 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;
}