bottom is defined as flippeddatax in config file, not anymore as argument for receiver

This commit is contained in:
Dhanya Maliakal
2016-11-30 10:36:46 +01:00
parent 0c8ca874e4
commit 09645cbba8
9 changed files with 116 additions and 81 deletions

View File

@ -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];
}

View File

@ -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),

View File

@ -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 dont 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);
}
}

View File

@ -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;
}