mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-24 23:30:03 +02:00
slsReceiver:trying to get deactivate to work
This commit is contained in:
parent
fa175ac934
commit
f0ac49190a
@ -3556,6 +3556,10 @@ int multiSlsDetector::activate(int const enable) {
|
||||
return callDetectorMember(&slsDetector::activate, enable);
|
||||
}
|
||||
|
||||
int multiSlsDetector::setDeactivatedRxrPaddingMode(int padding) {
|
||||
return callDetectorMember(&slsDetector::setDeactivatedRxrPaddingMode, padding);
|
||||
}
|
||||
|
||||
int multiSlsDetector::getFlippedData(dimension d) {
|
||||
return callDetectorMember(&slsDetector::getFlippedData, d);
|
||||
}
|
||||
|
@ -1241,11 +1241,18 @@ public:
|
||||
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
|
||||
* @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)
|
||||
|
@ -749,7 +749,8 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
|
||||
thisDetector->receiverAPIVersion = 0;
|
||||
thisDetector->receiver_frameDiscardMode = NO_DISCARD;
|
||||
thisDetector->receiver_framePadding = 1;
|
||||
|
||||
thisDetector->activated = true;
|
||||
thisDetector->receiver_deactivatedPaddingEnable = true;
|
||||
|
||||
// get the detector parameters based on type
|
||||
detParameterList detlist;
|
||||
@ -5272,6 +5273,10 @@ string slsDetector::setReceiver(string receiverIP) {
|
||||
std::cout << "sub period:" << thisDetector->timerValue[SUBFRAME_PERIOD] << endl;
|
||||
std::cout << "dynamic range:" << thisDetector->dynamicRange << 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 << "Gap pixels: " << thisDetector->gappixels << endl;
|
||||
std::cout << "rx streaming source ip:" << thisDetector->receiver_zmqip << endl;
|
||||
@ -5319,6 +5324,7 @@ string slsDetector::setReceiver(string receiverIP) {
|
||||
if(thisDetector->myDetectorType == EIGER){
|
||||
setFlippedData(X,-1);
|
||||
activate(-1);
|
||||
setDeactivatedRxrPaddingMode(thisDetector->receiver_deactivatedPaddingEnable);
|
||||
}
|
||||
|
||||
if(thisDetector->myDetectorType == EIGER)
|
||||
@ -6211,7 +6217,7 @@ int slsDetector::activate(int const enable) {
|
||||
int retval = -1;
|
||||
int arg = enable;
|
||||
char mess[MAX_STR_LENGTH]="";
|
||||
int ret = OK;
|
||||
int ret = FAIL;
|
||||
|
||||
if(thisDetector->myDetectorType != EIGER){
|
||||
std::cout<< "Not implemented for this detector" << std::endl;
|
||||
@ -6238,6 +6244,7 @@ int slsDetector::activate(int const enable) {
|
||||
setErrorMask((getErrorMask())|(DETECTOR_ACTIVATE));
|
||||
} else {
|
||||
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
|
||||
thisDetector->activated = retval;
|
||||
}
|
||||
disconnectControl();
|
||||
if (ret==FORCE_UPDATE)
|
||||
@ -6254,12 +6261,13 @@ int slsDetector::activate(int const enable) {
|
||||
#endif
|
||||
|
||||
if(ret!=FAIL){
|
||||
int arg = thisDetector->activated;
|
||||
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
|
||||
#ifdef VERBOSE
|
||||
std::cout << "Activating/Deactivating Receiver: " << retval << std::endl;
|
||||
std::cout << "Activating/Deactivating Receiver: " << arg << std::endl;
|
||||
#endif
|
||||
if (connectData() == OK){
|
||||
ret=thisReceiver->sendInt(fnum2,retval,retval);
|
||||
ret=thisReceiver->sendInt(fnum2,retval,arg);
|
||||
disconnectData();
|
||||
}
|
||||
if(ret==FAIL)
|
||||
@ -6276,12 +6284,44 @@ int slsDetector::activate(int const enable) {
|
||||
#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) {
|
||||
return thisDetector->flippedData[d];
|
||||
}
|
||||
@ -8570,7 +8610,13 @@ int slsDetector::updateReceiverNoWait() {
|
||||
n += dataSocket->ReceiveDataOnly(&ind,sizeof(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);
|
||||
|
||||
|
@ -375,6 +375,12 @@ private:
|
||||
/** receiver partial frames padding enable */
|
||||
bool receiver_framePadding;
|
||||
|
||||
/** activated receiver */
|
||||
bool activated;
|
||||
|
||||
/** padding enable in deactivated receiver */
|
||||
bool receiver_deactivatedPaddingEnable;
|
||||
|
||||
} sharedSlsDetector;
|
||||
|
||||
|
||||
@ -1525,11 +1531,18 @@ public:
|
||||
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
|
||||
* @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)
|
||||
|
@ -481,12 +481,19 @@ class slsDetectorBase : public virtual slsDetectorDefs, public virtual errorDef
|
||||
*/
|
||||
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
|
||||
\returns 0 (inactive) or 1 (active)
|
||||
/**
|
||||
* Activates/Deactivates the detector (Eiger only)
|
||||
* @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
|
||||
|
@ -324,7 +324,7 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
|
||||
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdOnline;
|
||||
++i;
|
||||
/*! \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_pFuncPtr=&slsDetectorCommand::cmdOnline;
|
||||
@ -4363,11 +4363,20 @@ string slsDetectorCommand::cmdOnline(int narg, char *args[], int action) {
|
||||
if (action==PUT_ACTION) {
|
||||
if (!sscanf(args[1],"%d",&ival))
|
||||
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);
|
||||
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"){
|
||||
if (action==PUT_ACTION) {
|
||||
@ -4398,14 +4407,14 @@ string slsDetectorCommand::helpOnline(int narg, char *args[], int 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 << "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) {
|
||||
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 << "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 << "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();
|
||||
|
||||
|
@ -35,6 +35,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param freq pointer to streaming frequency
|
||||
* @param timer pointer to timer if streaming frequency is random
|
||||
* @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 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).
|
||||
@ -42,7 +44,7 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||
DataProcessor(int ind, detectorType dtype, Fifo*& f, fileFormat* ftype,
|
||||
bool fwenable, bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
bool* fp,
|
||||
bool* fp, bool* act, bool* depaden,
|
||||
void (*dataReadycb)(char*, char*, uint32_t, void*),
|
||||
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
|
||||
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 **/
|
||||
uint16_t xcoordin1D;
|
||||
|
||||
/** Activated/Deactivated */
|
||||
bool* activated;
|
||||
|
||||
/** Deactivated padding enable */
|
||||
bool* deactivatedPaddingEnable;
|
||||
|
||||
|
||||
|
||||
//acquisition start
|
||||
|
@ -203,23 +203,24 @@ public:
|
||||
sls_detector_header header = rheader->detHeader;
|
||||
hsize_t count[1] = {1};
|
||||
hsize_t start[1] = {fnum};
|
||||
int i = 0;
|
||||
try{
|
||||
Exception::dontPrint(); //to handle errors
|
||||
dspace_para->selectHyperslab( H5S_SELECT_SET, count, start);
|
||||
DataSpace memspace(H5S_SCALAR);
|
||||
dset_para[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para);
|
||||
dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para);
|
||||
dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para);
|
||||
dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);
|
||||
dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);
|
||||
dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);
|
||||
dset_para[6]->write(&header.xCoord, parameterDataTypes[6], memspace, *dspace_para);
|
||||
dset_para[7]->write(&header.yCoord, parameterDataTypes[7], memspace, *dspace_para);
|
||||
dset_para[8]->write(&header.zCoord, parameterDataTypes[8], memspace, *dspace_para);
|
||||
dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);
|
||||
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[0]->write(&header.frameNumber, parameterDataTypes[0], memspace, *dspace_para);i=1;
|
||||
dset_para[1]->write(&header.expLength, parameterDataTypes[1], memspace, *dspace_para);i=2;
|
||||
dset_para[2]->write(&header.packetNumber, parameterDataTypes[2], memspace, *dspace_para);i=3;
|
||||
dset_para[3]->write(&header.bunchId, parameterDataTypes[3], memspace, *dspace_para);i=4;
|
||||
dset_para[4]->write(&header.timestamp, parameterDataTypes[4], memspace, *dspace_para);i=5;
|
||||
dset_para[5]->write(&header.modId, parameterDataTypes[5], memspace, *dspace_para);i=6;
|
||||
dset_para[6]->write(&header.xCoord, parameterDataTypes[6], memspace, *dspace_para);i=7;
|
||||
dset_para[7]->write(&header.yCoord, parameterDataTypes[7], memspace, *dspace_para);i=8;
|
||||
dset_para[8]->write(&header.zCoord, parameterDataTypes[8], memspace, *dspace_para);i=9;
|
||||
dset_para[9]->write(&header.debug, parameterDataTypes[9], memspace, *dspace_para);i=10;
|
||||
dset_para[10]->write(&header.roundRNumber, parameterDataTypes[10], memspace, *dspace_para);i=11;
|
||||
dset_para[11]->write(&header.detType, parameterDataTypes[11], memspace, *dspace_para);i=12;
|
||||
dset_para[12]->write(&header.version, parameterDataTypes[12], memspace, *dspace_para);i=13;
|
||||
|
||||
// contiguous bitset
|
||||
if (sizeof(sls_bitset) == sizeof(bitset_storage)) {
|
||||
@ -236,10 +237,10 @@ public:
|
||||
storage[i >> 3] |= (bits[i] << (i & 7));
|
||||
// write bitmask
|
||||
dset_para[13]->write((char*)storage, parameterDataTypes[13], memspace, *dspace_para);
|
||||
}
|
||||
}i=14;
|
||||
}
|
||||
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();
|
||||
return 1;
|
||||
}
|
||||
|
@ -33,11 +33,13 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* @param as pointer to actual udp socket buffer size
|
||||
* @param fpf pointer to frames per file
|
||||
* @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,
|
||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||
frameDiscardPolicy* fdp);
|
||||
frameDiscardPolicy* fdp, bool* act, bool* depaden);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -236,6 +238,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
||||
/** frame discard policy */
|
||||
frameDiscardPolicy* frameDiscardMode;
|
||||
|
||||
/** Activated/Deactivated */
|
||||
bool* activated;
|
||||
|
||||
/** Deactivated padding enable */
|
||||
bool* deactivatedPaddingEnable;
|
||||
|
||||
|
||||
// acquisition start
|
||||
/** Aquisition Started flag */
|
||||
|
@ -277,11 +277,19 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @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
|
||||
@ -605,10 +613,21 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @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
|
||||
@ -727,7 +746,9 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
/** Receiver Status */
|
||||
runStatus status;
|
||||
/** Activated/Deactivated */
|
||||
int activated;
|
||||
bool activated;
|
||||
/** Deactivated padding enable */
|
||||
bool deactivatedPaddingEnable;
|
||||
/** frame discard policy */
|
||||
frameDiscardPolicy frameDiscardMode;
|
||||
/** frame padding */
|
||||
|
@ -47,6 +47,7 @@ class UDPInterface {
|
||||
* -setDynamicRange
|
||||
* -setFlippedData (if eiger)
|
||||
* -setActivate (if eiger)
|
||||
* -setDeactivatedPadding (if eiger)
|
||||
* -setTenGigaEnable (if eiger)
|
||||
* -setGapPixelsEnable
|
||||
* -setStreamingPort
|
||||
@ -364,11 +365,19 @@ class UDPInterface {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @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
|
||||
@ -694,10 +703,21 @@ class UDPInterface {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @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
|
||||
|
@ -281,6 +281,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** set partial frame padding enable*/
|
||||
int set_padding_enable();
|
||||
|
||||
/** set deactivated receiver padding enable */
|
||||
int set_deactivated_receiver_padding_enable();
|
||||
|
||||
|
||||
/** detector type */
|
||||
detectorType myDetectorType;
|
||||
|
@ -70,6 +70,7 @@ enum recFuncs{
|
||||
F_RECEIVER_CHECK_VERSION, /** < check receiver version compatibility */
|
||||
F_RECEIVER_DISCARD_POLICY, /** < frames discard policy */
|
||||
F_RECEIVER_PADDING_ENABLE, /** < partial frames padding enable */
|
||||
F_RECEIVER_DEACTIVATED_PADDING_ENABLE, /** < deactivated receiver padding enable */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
|
||||
fileFormat* ftype, bool fwenable,
|
||||
bool* dsEnable, bool* gpEnable, uint32_t* dr,
|
||||
uint32_t* freq, uint32_t* timer,
|
||||
bool* fp,
|
||||
bool* fp, bool* act, bool* depaden,
|
||||
void (*dataReadycb)(char*, char*, uint32_t, void*),
|
||||
void (*dataModifyReadycb)(char*, char*, uint32_t &, void*),
|
||||
void *pDataReadycb) :
|
||||
@ -48,6 +48,8 @@ DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
|
||||
currentFreqCount(0),
|
||||
tempBuffer(0),
|
||||
xcoordin1D(0),
|
||||
activated(act),
|
||||
deactivatedPaddingEnable(depaden),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -374,8 +376,10 @@ void DataProcessor::ProcessAnImage(char* buf) {
|
||||
header.xCoord = xcoordin1D;
|
||||
}
|
||||
|
||||
// deactivated and padding enabled
|
||||
if ((!(*activated) && *deactivatedPaddingEnable) ||
|
||||
// frame padding
|
||||
if (*framePadding && nump < generalData->packetsPerFrame)
|
||||
(*framePadding && nump < generalData->packetsPerFrame))
|
||||
PadMissingPackets(buf);
|
||||
|
||||
// normal call back
|
||||
|
@ -22,7 +22,7 @@ const string Listener::TypeName = "Listener";
|
||||
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
uint32_t* portno, char* e, uint64_t* nf, uint32_t* dr,
|
||||
uint32_t* us, uint32_t* as, uint32_t* fpf,
|
||||
frameDiscardPolicy* fdp) :
|
||||
frameDiscardPolicy* fdp, bool* act, bool* depaden) :
|
||||
ThreadObject(ind),
|
||||
runningFlag(0),
|
||||
generalData(0),
|
||||
@ -38,6 +38,8 @@ Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
|
||||
actualUDPSocketBufferSize(as),
|
||||
framesPerFile(fpf),
|
||||
frameDiscardMode(fdp),
|
||||
activated(act),
|
||||
deactivatedPaddingEnable(depaden),
|
||||
acquisitionStartedFlag(false),
|
||||
measurementStartedFlag(false),
|
||||
firstAcquisitionIndex(0),
|
||||
@ -183,6 +185,10 @@ int Listener::SetThreadPriority(int priority) {
|
||||
|
||||
int Listener::CreateUDPSockets() {
|
||||
|
||||
if (!(*activated)) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
//if eth is mistaken with ip address
|
||||
if (strchr(eth,'.') != NULL){
|
||||
memset(eth, 0, MAX_STR_LENGTH);
|
||||
@ -236,6 +242,12 @@ void Listener::SetSilentMode(bool mode) {
|
||||
|
||||
int Listener::CreateDummySocketForUDPSocketBufferSize(uint32_t s) {
|
||||
FILE_LOG(logINFO) << "Testing UDP Socket Buffer size with test port " << *udpPortNumber;
|
||||
|
||||
if (!(*activated)) {
|
||||
*actualUDPSocketBufferSize = (s*2);
|
||||
return OK;
|
||||
}
|
||||
|
||||
uint32_t temp = *udpSocketBufferSize;
|
||||
*udpSocketBufferSize = s;
|
||||
|
||||
@ -291,7 +303,7 @@ void Listener::ThreadExecution() {
|
||||
#endif
|
||||
|
||||
//udpsocket doesnt exist
|
||||
if (!udpSocketAlive && !carryOverFlag) {
|
||||
if (*activated && !udpSocketAlive && !carryOverFlag) {
|
||||
//FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
||||
(*((uint32_t*)buffer)) = 0;
|
||||
StopListening(buffer);
|
||||
@ -299,7 +311,7 @@ void Listener::ThreadExecution() {
|
||||
}
|
||||
|
||||
//get data
|
||||
if ((*status != TRANSMITTING && udpSocketAlive) || carryOverFlag) {
|
||||
if ((*status != TRANSMITTING && (!(*activated) || udpSocketAlive)) || carryOverFlag) {
|
||||
rc = ListenToAnImage(buffer);
|
||||
}
|
||||
|
||||
@ -357,6 +369,7 @@ void Listener::StopListening(char* buf) {
|
||||
|
||||
/* buf includes the fifo header and packet header */
|
||||
uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
|
||||
int rc = 0;
|
||||
uint64_t fnum = 0, bid = 0;
|
||||
uint32_t pnum = 0, snum = 0;
|
||||
@ -378,6 +391,20 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
/*memset(buf + fifohsize, 0xFF, generalData->imageSize);*/
|
||||
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
|
||||
|
@ -58,6 +58,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
//***receiver parameters***
|
||||
status = IDLE;
|
||||
activated = true;
|
||||
deactivatedPaddingEnable = true;
|
||||
frameDiscardMode = NO_DISCARD;
|
||||
framePadding = false;
|
||||
|
||||
@ -322,11 +323,16 @@ uint32_t UDPBaseImplementation::getSilentMode() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return silentMode;}
|
||||
|
||||
int UDPBaseImplementation::getActivate() const{
|
||||
bool UDPBaseImplementation::getActivate() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return activated;
|
||||
}
|
||||
|
||||
bool UDPBaseImplementation::getDeactivatedPadding() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return deactivatedPaddingEnable;
|
||||
}
|
||||
|
||||
uint32_t UDPBaseImplementation::getStreamingPort() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
return streamingPort;
|
||||
@ -733,15 +739,18 @@ void UDPBaseImplementation::abort(){
|
||||
}
|
||||
|
||||
|
||||
int UDPBaseImplementation::setActivate(int enable){
|
||||
bool UDPBaseImplementation::setActivate(bool enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
if(enable != -1){
|
||||
activated = enable;
|
||||
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) {
|
||||
|
@ -375,13 +375,13 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
||||
Listener* l = new Listener(i, myDetectorType, fifo[i], &status,
|
||||
&udpPortNum[i], eth, &numberOfFrames, &dynamicRange,
|
||||
&udpSocketBufferSize, &actualUDPSocketBufferSize, &framesPerFile,
|
||||
&frameDiscardMode);
|
||||
&frameDiscardMode, &activated, &deactivatedPaddingEnable);
|
||||
listener.push_back(l);
|
||||
|
||||
DataProcessor* p = new DataProcessor(i, myDetectorType, fifo[i], &fileFormatType,
|
||||
fileWriteEnable, &dataStreamEnable, &gapPixelsEnable,
|
||||
&dynamicRange, &frameToGuiFrequency, &frameToGuiTimerinMS,
|
||||
&framePadding,
|
||||
&framePadding, &activated, &deactivatedPaddingEnable,
|
||||
rawDataReadyCallBack, rawDataModifyReadyCallBack, pRawDataReady);
|
||||
dataProcessor.push_back(p);
|
||||
}
|
||||
@ -573,9 +573,7 @@ void UDPStandardImplementation::stopReceiver(){
|
||||
void UDPStandardImplementation::startReadout(){
|
||||
if(status == RUNNING){
|
||||
|
||||
//needs to wait for packets only if activated
|
||||
if(activated){
|
||||
|
||||
// wait for incoming delayed packets
|
||||
//current packets caught
|
||||
volatile int totalP = 0,prev=-1;
|
||||
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||
@ -604,7 +602,7 @@ void UDPStandardImplementation::startReadout(){
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//set status
|
||||
status = TRANSMITTING;
|
||||
|
@ -245,6 +245,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
|
||||
case F_RECEIVER_CHECK_VERSION: return "F_RECEIVER_CHECK_VERSION";
|
||||
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";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
@ -301,6 +302,8 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_RECEIVER_CHECK_VERSION] = &slsReceiverTCPIPInterface::check_version_compatibility;
|
||||
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;
|
||||
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
@ -706,6 +709,19 @@ int slsReceiverTCPIPInterface::send_update() {
|
||||
#endif
|
||||
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)
|
||||
strcpy(mySock->lastClientIP,mySock->thisClientIP);
|
||||
|
||||
@ -1931,11 +1947,11 @@ int slsReceiverTCPIPInterface::set_activate() {
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setActivate(enable);
|
||||
receiverBase->setActivate(enable > 0 ? true : false);
|
||||
}
|
||||
}
|
||||
//get
|
||||
retval = receiverBase->getActivate();
|
||||
retval = (int)receiverBase->getActivate();
|
||||
if(enable >= 0 && retval != enable){
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set activate to %d, returned %d\n",enable,retval);
|
||||
@ -2485,7 +2501,7 @@ int slsReceiverTCPIPInterface::enable_gap_pixels() {
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "Activate: " << retval;
|
||||
FILE_LOG(logDEBUG1) << "Gap Pixels Enable: " << retval;
|
||||
#endif
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user