mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
bottom is defined as flippeddatax in config file, not anymore as argument for receiver
This commit is contained in:
@ -50,6 +50,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
char *getDetectorHostname() const;
|
||||
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
int getFlippedData(int axis=0) const;
|
||||
|
||||
|
||||
//***file parameters***
|
||||
/**
|
||||
@ -234,11 +240,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void configure(map<string, string> config_map);
|
||||
|
||||
/**
|
||||
* Set Bottom Enable (eiger specific, should be moved to configure, and later from client via TCPIP)
|
||||
* @param b is true for bottom enabled or false for bottom disabled
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
void setBottomEnable(const bool b);
|
||||
void setFlippedData(int axis=0, int enable=-1);
|
||||
|
||||
|
||||
//***file parameters***
|
||||
@ -532,8 +538,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
bool tengigaEnable;
|
||||
/** Fifo Depth */
|
||||
uint32_t fifoDepth;
|
||||
/** Bottom Half Module Enable */
|
||||
bool bottomEnable;
|
||||
/** enable for flipping data across both axes */
|
||||
bool flippedData[2];
|
||||
|
||||
//***receiver parameters***
|
||||
/** Maximum Number of Listening Threads/ UDP Ports */
|
||||
|
@ -103,13 +103,19 @@ class UDPInterface {
|
||||
* They access local cache of configuration or detector parameters *******
|
||||
*************************************************************************/
|
||||
|
||||
//**initial parameters***
|
||||
//**initial/detector parameters***
|
||||
/*
|
||||
* Get detector hostname
|
||||
* @return hostname or NULL if uninitialized, must be released by calling function (max of 1000 characters)
|
||||
*/
|
||||
virtual char *getDetectorHostname() const = 0;
|
||||
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
virtual int getFlippedData(int axis=0) const = 0;
|
||||
|
||||
|
||||
//***file parameters***
|
||||
/**
|
||||
@ -292,11 +298,11 @@ class UDPInterface {
|
||||
*/
|
||||
virtual void configure(map<string, string> config_map) = 0;
|
||||
|
||||
/**
|
||||
* Set Bottom Enable (eiger specific, should be moved to configure, and later from client via TCPIP)
|
||||
* @param b is true for bottom enabled or false for bottom disabled
|
||||
/*
|
||||
* Get flipped data across 'axis'
|
||||
* @return if data is flipped across 'axis'
|
||||
*/
|
||||
virtual void setBottomEnable(const bool b)= 0;
|
||||
virtual void setFlippedData(int axis=0, int enable=-1) = 0;
|
||||
|
||||
|
||||
//***file parameters***
|
||||
|
@ -61,14 +61,6 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
*************************************************************************/
|
||||
|
||||
//**initial parameters***
|
||||
|
||||
/**
|
||||
* Overridden method
|
||||
* Configure command line parameters
|
||||
* @param config_map mapping of config parameters passed from command line arguments
|
||||
*/
|
||||
void configure(map<string, string> config_map);
|
||||
|
||||
//*** file parameters***
|
||||
/**
|
||||
* Set File Name Prefix (without frame index, file index and extension (_d0_f000000000000_8.raw))
|
||||
|
@ -26,10 +26,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
* @param succecc socket creation was successfull
|
||||
* @param rbase pointer to the receiver base
|
||||
* @param pn port number (defaults to default port number)
|
||||
* @param bot mode is bottom if true, else its a top half module
|
||||
*/
|
||||
|
||||
slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn=-1, bool bot=false);
|
||||
slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn=-1);
|
||||
|
||||
/**
|
||||
* Sets the port number to listen to.
|
||||
@ -216,6 +215,9 @@ private:
|
||||
/** activate/ deactivate */
|
||||
int set_activate();
|
||||
|
||||
/** enable flipped data */
|
||||
int set_flipped_data();
|
||||
|
||||
|
||||
//General Functions
|
||||
/** Locks Receiver */
|
||||
@ -284,9 +286,6 @@ private:
|
||||
/** port number */
|
||||
int portNumber;
|
||||
|
||||
/** true if bottom half module for eiger */
|
||||
bool bottom;
|
||||
|
||||
/** Receiver not setup error message */
|
||||
char SET_RECEIVER_ERR_MESSAGE[MAX_STR_LENGTH];
|
||||
|
||||
|
@ -54,8 +54,9 @@ enum {
|
||||
F_ACTIVATE, /** < activate/deactivate readout */
|
||||
F_STREAM_DATA_FROM_RECEIVER, /**< stream data from receiver to client */
|
||||
|
||||
F_READ_RECEIVER_TIMER /** < sets the timer between each data stream in receiver */
|
||||
F_READ_RECEIVER_TIMER, /** < sets the timer between each data stream in receiver */
|
||||
|
||||
F_SET_FLIPPED_DATA_RECEIVER /** < sets the enable to flip data across x/y axis (bottom/top) */
|
||||
|
||||
/* Always append functions hereafter!!! */
|
||||
};
|
||||
|
@ -46,7 +46,8 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
dynamicRange = 16;
|
||||
tengigaEnable = false;
|
||||
fifoDepth = 0;
|
||||
bottomEnable = false;
|
||||
flippedData[0] = false;
|
||||
flippedData[1] = false;
|
||||
|
||||
//***receiver parameters***
|
||||
status = IDLE;
|
||||
@ -104,6 +105,12 @@ char *UDPBaseImplementation::getDetectorHostname() const{
|
||||
return output;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::getFlippedData(int axis) const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
if(axis<0 || axis > 1) return -1;
|
||||
return flippedData[axis];
|
||||
}
|
||||
|
||||
|
||||
/***file parameters***/
|
||||
char *UDPBaseImplementation::getFileName() const{
|
||||
@ -211,11 +218,11 @@ void UDPBaseImplementation::configure(map<string, string> config_map){
|
||||
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setBottomEnable(const bool b){
|
||||
void UDPBaseImplementation::setFlippedData(int axis, int enable){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
bottomEnable = b;
|
||||
FILE_LOG(logINFO) << "Bottom - " << stringEnable(bottomEnable);
|
||||
if(axis<0 || axis>1) return;
|
||||
flippedData[axis] = enable;
|
||||
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
|
||||
}
|
||||
|
||||
|
||||
|
@ -416,23 +416,6 @@ int UDPStandardImplementation::setupFifoStructure(){
|
||||
|
||||
|
||||
|
||||
void UDPStandardImplementation::configure(map<string, string> config_map){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
map<string, string>::const_iterator pos;
|
||||
pos = config_map.find("mode");
|
||||
if (pos != config_map.end() ){
|
||||
int b;
|
||||
if(!sscanf(pos->second.c_str(), "%d", &b)){
|
||||
cout << "Warning: Could not parse mode. Assuming top mode." << endl;
|
||||
b = 0;
|
||||
}
|
||||
bottomEnable = b!= 0;
|
||||
FILE_LOG(logINFO) << "Bottom: " << stringEnable(bottomEnable);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void UDPStandardImplementation::setFileName(const char c[]){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
@ -1489,11 +1472,7 @@ int UDPStandardImplementation::createUDPSockets(){
|
||||
uint32_t port[2];
|
||||
port[0]= udpPortNum[0];
|
||||
port[1]= udpPortNum[1];
|
||||
//port = udpPortNum;
|
||||
if(bottomEnable){
|
||||
port[0] = udpPortNum[1];
|
||||
port[1] = udpPortNum[0];
|
||||
}
|
||||
|
||||
|
||||
//if eth is mistaken with ip address
|
||||
if (strchr(eth,'.') != NULL)
|
||||
@ -2420,10 +2399,8 @@ uint32_t UDPStandardImplementation::processListeningBuffer(int ithread, int &cSi
|
||||
|
||||
int lastPacketOffset; //the offset of the last packet
|
||||
uint32_t lastFrameHeader; //frame number of last packet in buffer
|
||||
uint64_t lastFrameHeader64; //frame number of last packet in buffer
|
||||
uint32_t packetCount = (rc/onePacketSize);//(packetsPerFrame/numberofListeningThreads) * numberofJobsPerBuffer; //packets received
|
||||
cSize = 0; //reset size
|
||||
jfrau_packet_header_t* header;
|
||||
|
||||
switch(myDetectorType){
|
||||
case GOTTHARD:
|
||||
@ -2510,7 +2487,6 @@ void UDPStandardImplementation::startWriting(){
|
||||
char* wbuf = NULL; //buffer popped from FIFO
|
||||
sfilefd[ithread] = 0; //file pointer
|
||||
uint64_t nf = 0; //for compression, number of frames
|
||||
int listenfifoIndex = ithread;
|
||||
|
||||
|
||||
/* outer loop - loops once for each acquisition */
|
||||
@ -2532,14 +2508,14 @@ void UDPStandardImplementation::startWriting(){
|
||||
fifo[0]->pop(wbuf);
|
||||
uint32_t numPackets = (uint32_t)(*((uint32_t*)wbuf));
|
||||
#ifdef DEBUG4
|
||||
cprintf(GREEN,"Writing_Thread %d: Number of Packets: %d for FIFO %d\n", ithread, numPackets, listenfifoIndex);
|
||||
cprintf(GREEN,"Writing_Thread %d: Number of Packets: %d for FIFO %d\n", ithread, numPackets, dataCompressionEnable?0:ithread);
|
||||
#endif
|
||||
|
||||
|
||||
//end of acquisition
|
||||
if(numPackets == dummyPacketValue){
|
||||
#ifdef DEBUG4
|
||||
cprintf(GREEN,"Writing_Thread %d: Dummy frame popped out of FIFO %d",ithread, listenfifoIndex);
|
||||
cprintf(GREEN,"Writing_Thread %d: Dummy frame popped out of FIFO %d",ithread, dataCompressionEnable?0:ithread);
|
||||
#endif
|
||||
stopWriting(ithread,wbuf);
|
||||
continue;
|
||||
@ -3108,8 +3084,8 @@ void UDPStandardImplementation::updateFileHeader(int ithread){
|
||||
"Top\t\t: %d\n"
|
||||
"Left\t\t: %d\n"
|
||||
"Active\t\t: %d\n"
|
||||
"Frames Caught\t: %d\n"
|
||||
"Frames Lost\t: %d\n"
|
||||
"Frames Caught\t: %lld\n"
|
||||
"Frames Lost\t: %lld\n"
|
||||
"Dynamic Range\t: %d\n"
|
||||
"Ten Giga\t: %d\n"
|
||||
"Image Size\t: %d bytes\n"
|
||||
@ -3124,7 +3100,7 @@ void UDPStandardImplementation::updateFileHeader(int ithread){
|
||||
"Frame Number\t: 8 bytes\n"
|
||||
"Bunch ID\t: 8 bytes\n",
|
||||
FILE_HEADER_SIZE,
|
||||
(bottomEnable?0:1),
|
||||
(flippedData[0]?0:1),
|
||||
(ithread?0:1),
|
||||
activated,
|
||||
(long long int)(totalPacketsInFile[ithread]/packetsPerFrame),
|
||||
|
@ -41,14 +41,12 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
string rest_hostname = "localhost:8081";
|
||||
udp_interface = NULL;
|
||||
|
||||
bool bottom = false; //TODO: properly set new parameter -> mode?
|
||||
//parse command line for config
|
||||
static struct option long_options[] = {
|
||||
/* These options set a flag. */
|
||||
//{"verbose", no_argument, &verbose_flag, 1},
|
||||
/* These options don’t set a flag.
|
||||
We distinguish them by their indices. */
|
||||
{"mode", required_argument, 0, 'm'},
|
||||
{"type", required_argument, 0, 't'},
|
||||
{"config", required_argument, 0, 'f'},
|
||||
{"rx_tcpport", required_argument, 0, 'b'},
|
||||
@ -62,7 +60,7 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
optind = 1;
|
||||
|
||||
while ( c != -1 ){
|
||||
c = getopt_long (argc, argv, "mbfhtr", long_options, &option_index);
|
||||
c = getopt_long (argc, argv, "bfhtr", long_options, &option_index);
|
||||
|
||||
/* Detect the end of the options. */
|
||||
if (c == -1)
|
||||
@ -70,13 +68,6 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
|
||||
switch(c){
|
||||
|
||||
case 'm':
|
||||
int b;
|
||||
sscanf(optarg, "%d", &b);
|
||||
bottom = b != 0;
|
||||
configuration_map["mode"] = optarg;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
fname = optarg;
|
||||
//cout << long_options[option_index].name << " " << optarg << endl;
|
||||
@ -98,7 +89,6 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
string help_message = """\nSLS Receiver Server\n\n""";
|
||||
help_message += """usage: slsReceiver --config config_fname [--rx_tcpport port]\n\n""";
|
||||
help_message += """\t--config:\t configuration filename for SLS Detector receiver\n""";
|
||||
help_message += """\t--mode:\t 1 for bottom and 0 for top\n""";
|
||||
help_message += """\t--rx_tcpport:\t TCP Communication Port with the client. Default: 1954.\n\n""";
|
||||
help_message += """\t--rest_hostname:\t Receiver hostname:port. It applies only to REST receivers, and indicates the hostname of the REST backend. Default: localhost:8081.\n\n""";
|
||||
|
||||
@ -132,12 +122,12 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
||||
}
|
||||
|
||||
if (success==OK){
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << " with mode " << bottom << endl;
|
||||
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << endl;
|
||||
#ifdef REST
|
||||
udp_interface = UDPInterface::create(udp_interface_type);
|
||||
udp_interface->configure(configuration_map);
|
||||
#endif
|
||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no, bottom);
|
||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||
if(mySock) {delete mySock; mySock=NULL;}
|
||||
}
|
||||
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn, bool bot):
|
||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
||||
myDetectorType(GOTTHARD),
|
||||
receiverBase(rbase),
|
||||
ret(OK),
|
||||
@ -38,7 +38,6 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
|
||||
killTCPServerThread(0),
|
||||
tenGigaEnable(0),
|
||||
portNumber(DEFAULT_PORTNO+2),
|
||||
bottom(bot),
|
||||
mySock(NULL){
|
||||
|
||||
strcpy(SET_RECEIVER_ERR_MESSAGE,"Receiver not set up. Please use rx_hostname first.\n");
|
||||
@ -265,7 +264,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_ACTIVATE] = &slsReceiverTCPIPInterface::set_activate;
|
||||
flist[F_STREAM_DATA_FROM_RECEIVER] = &slsReceiverTCPIPInterface::set_data_stream_enable;
|
||||
flist[F_READ_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_read_receiver_timer;
|
||||
|
||||
flist[F_SET_FLIPPED_DATA_RECEIVER] = &slsReceiverTCPIPInterface::set_flipped_data;
|
||||
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i=0;i<numberOfFunctions;i++)
|
||||
@ -390,9 +389,6 @@ int slsReceiverTCPIPInterface::set_detector_type(){
|
||||
myDetectorType = dr;
|
||||
ret=receiverBase->setDetectorType(myDetectorType);
|
||||
retval = myDetectorType;
|
||||
#ifndef REST
|
||||
receiverBase->setBottomEnable(bottom);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
@ -1652,7 +1648,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
|
||||
|
||||
int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
ret=OK;
|
||||
|
||||
/*
|
||||
char fName[MAX_STR_LENGTH]="";
|
||||
int acquisitionIndex = -1;
|
||||
int frameIndex= -1;
|
||||
@ -1905,7 +1901,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
||||
delete [] retval;
|
||||
delete [] origVal;
|
||||
delete [] raw;
|
||||
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -3013,6 +3009,68 @@ int slsReceiverTCPIPInterface::set_activate() {
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_flipped_data(){
|
||||
ret=OK;
|
||||
int retval = -1;
|
||||
int args[2]={0,-1};
|
||||
strcpy(mess,"Could not set flipped data in receiver\n");
|
||||
|
||||
|
||||
// receive arguments
|
||||
if(mySock->ReceiveDataOnly(args,sizeof(args)) < 0 ){
|
||||
strcpy(mess,"Error reading from socket\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
// execute action if the arguments correctly arrived
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
if (ret==OK) {
|
||||
if (lockStatus==1 && mySock->differentClients==1){
|
||||
sprintf(mess,"Receiver locked by %s\n", mySock->lastClientIP);
|
||||
ret=FAIL;
|
||||
}
|
||||
else if (receiverBase == NULL){
|
||||
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
|
||||
ret=FAIL;
|
||||
}
|
||||
else if(receiverBase->getStatus()==RUNNING || receiverBase->getStatus()==TRANSMITTING){
|
||||
strcpy(mess,"Can not set flipped data while receiver not idle\n");
|
||||
ret = FAIL;
|
||||
}
|
||||
else{
|
||||
if(args[1] > -1)
|
||||
receiverBase->setFlippedData(args[0],args[1]);
|
||||
retval=receiverBase->getFlippedData(args[0]);
|
||||
}
|
||||
}
|
||||
#ifdef VERYVERBOSE
|
||||
if(ret!=FAIL){
|
||||
cout << "Flipped Data:" << retval << endl;
|
||||
}else
|
||||
cout << mess << endl;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(ret==OK && mySock->differentClients){
|
||||
FILE_LOG(logDEBUG) << "Force update";
|
||||
ret=FORCE_UPDATE;
|
||||
}
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if(ret==FAIL){
|
||||
cprintf(RED,"%s\n",mess);
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
}
|
||||
mySock->SendDataOnly(&retval,sizeof(retval));
|
||||
|
||||
//return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user