just started changin frm ostringstream

This commit is contained in:
Dhanya Maliakal
2017-04-18 15:32:01 +02:00
parent 9468b9ca1e
commit 91b7a87557
12 changed files with 1170 additions and 864 deletions

View File

@@ -19,7 +19,6 @@ using namespace std;
* They access local cache of configuration or detector parameters *******
*************************************************************************/
UDPBaseImplementation::UDPBaseImplementation(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
initializeMembers();
@@ -33,9 +32,7 @@ UDPBaseImplementation::UDPBaseImplementation(){
}
void UDPBaseImplementation::initializeMembers(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
FILE_LOG(logDEBUG) << "Info: Initializing base members";
//**detector parameters***
myDetectorType = GENERIC;
strcpy(detHostname,"");
@@ -93,7 +90,6 @@ UDPBaseImplementation::~UDPBaseImplementation(){}
/**initial parameters***/
char *UDPBaseImplementation::getDetectorHostname() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
//not initialized
if(!strlen(detHostname))
@@ -106,7 +102,6 @@ char *UDPBaseImplementation::getDetectorHostname() const{
}
int UDPBaseImplementation::getFlippedData(int axis) const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(axis<0 || axis > 1) return -1;
return flippedData[axis];
}
@@ -114,7 +109,6 @@ int UDPBaseImplementation::getFlippedData(int axis) const{
/***file parameters***/
char *UDPBaseImplementation::getFileName() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
//not initialized
if(!strlen(fileName))
@@ -127,7 +121,6 @@ char *UDPBaseImplementation::getFileName() const{
}
char *UDPBaseImplementation::getFilePath() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
//not initialized
if(!strlen(filePath))
@@ -139,25 +132,24 @@ char *UDPBaseImplementation::getFilePath() const{
return output;
}
uint64_t UDPBaseImplementation::getFileIndex() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fileIndex;}
uint64_t UDPBaseImplementation::getFileIndex() const{ return fileIndex;}
int UDPBaseImplementation::getScanTag() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return scanTag;}
int UDPBaseImplementation::getScanTag() const{ return scanTag;}
bool UDPBaseImplementation::getFrameIndexEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameIndexEnable;}
bool UDPBaseImplementation::getFrameIndexEnable() const{ return frameIndexEnable;}
bool UDPBaseImplementation::getFileWriteEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fileWriteEnable;}
bool UDPBaseImplementation::getFileWriteEnable() const{ return fileWriteEnable;}
bool UDPBaseImplementation::getOverwriteEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return overwriteEnable;}
bool UDPBaseImplementation::getOverwriteEnable() const{ return overwriteEnable;}
bool UDPBaseImplementation::getDataCompressionEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dataCompressionEnable;}
bool UDPBaseImplementation::getDataCompressionEnable() const{ return dataCompressionEnable;}
/***acquisition count parameters***/
uint64_t UDPBaseImplementation::getTotalFramesCaught() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return (totalPacketsCaught/packetsPerFrame);}
uint64_t UDPBaseImplementation::getTotalFramesCaught() const{ return (totalPacketsCaught/packetsPerFrame);}
uint64_t UDPBaseImplementation::getFramesCaught() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return (packetsCaught/packetsPerFrame);}
uint64_t UDPBaseImplementation::getFramesCaught() const{ return (packetsCaught/packetsPerFrame);}
int64_t UDPBaseImplementation::getAcquisitionIndex() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(!totalPacketsCaught)
return -1;
@@ -166,12 +158,12 @@ int64_t UDPBaseImplementation::getAcquisitionIndex() const{
/***connection parameters***/
uint32_t UDPBaseImplementation::getUDPPortNumber() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return udpPortNum[0];}
uint32_t UDPBaseImplementation::getUDPPortNumber() const{ return udpPortNum[0];}
uint32_t UDPBaseImplementation::getUDPPortNumber2() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return udpPortNum[1];}
uint32_t UDPBaseImplementation::getUDPPortNumber2() const{ return udpPortNum[1];}
char *UDPBaseImplementation::getEthernetInterface() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
char* output = new char[MAX_STR_LENGTH]();
strcpy(output,eth);
@@ -181,30 +173,30 @@ char *UDPBaseImplementation::getEthernetInterface() const{
/***acquisition parameters***/
int UDPBaseImplementation::getShortFrameEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return shortFrameEnable;}
int UDPBaseImplementation::getShortFrameEnable() const{ return shortFrameEnable;}
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameToGuiFrequency;}
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{ return frameToGuiFrequency;}
uint32_t UDPBaseImplementation::getFrameToGuiTimer() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return frameToGuiTimerinMS;}
uint32_t UDPBaseImplementation::getFrameToGuiTimer() const{ return frameToGuiTimerinMS;}
uint32_t UDPBaseImplementation::getDataStreamEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dataStreamEnable;}
uint32_t UDPBaseImplementation::getDataStreamEnable() const{ return dataStreamEnable;}
uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionPeriod;}
uint64_t UDPBaseImplementation::getAcquisitionPeriod() const{ return acquisitionPeriod;}
uint64_t UDPBaseImplementation::getAcquisitionTime() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return acquisitionTime;}
uint64_t UDPBaseImplementation::getAcquisitionTime() const{ return acquisitionTime;}
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfFrames;}
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ return numberOfFrames;}
uint32_t UDPBaseImplementation::getDynamicRange() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dynamicRange;}
uint32_t UDPBaseImplementation::getDynamicRange() const{ return dynamicRange;}
bool UDPBaseImplementation::getTenGigaEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return tengigaEnable;}
bool UDPBaseImplementation::getTenGigaEnable() const{ return tengigaEnable;}
uint32_t UDPBaseImplementation::getFifoDepth() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return fifoDepth;}
uint32_t UDPBaseImplementation::getFifoDepth() const{ return fifoDepth;}
/***receiver status***/
slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return status;}
slsReceiverDefs::runStatus UDPBaseImplementation::getStatus() const{ return status;}
int UDPBaseImplementation::getActivate() const{FILE_LOG(logDEBUG) << __AT__ << " starting"; return activated;}
int UDPBaseImplementation::getActivate() const{ return activated;}
/*************************************************************************
@@ -214,29 +206,35 @@ int UDPBaseImplementation::getActivate() const{FILE_LOG(logDEBUG) << __AT__ << "
/**initial parameters***/
void UDPBaseImplementation::configure(map<string, string> config_map){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
}
void UDPBaseImplementation::setFlippedData(int axis, int enable){
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(axis<0 || axis>1) return;
flippedData[axis] = enable==0?0:1;
FILE_LOG(logINFO) << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
ostringstream os;
os << "Flipped Data: " << flippedData[0] << " , " << flippedData[1];
string message(os.str()); FILE_LOG(logINFO, message);
}
/***file parameters***/
void UDPBaseImplementation::setFileName(const char c[]){
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(strlen(c))
strcpy(fileName, c);
FILE_LOG(logINFO) << "File name:" << fileName;
ostringstream os;
os << "File name:" << fileName;
string message(os.str()); FILE_LOG(logINFO, message);
}
void UDPBaseImplementation::setFilePath(const char c[]){
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(strlen(c)){
//check if filepath exists
@@ -245,55 +243,69 @@ void UDPBaseImplementation::setFilePath(const char c[]){
strcpy(filePath,c);
else{
strcpy(filePath,"");
FILE_LOG(logWARNING) << "FilePath does not exist:" << filePath;
ostringstream os;
os << "FilePath does not exist:" << filePath;
string message(os.str()); FILE_LOG(logWARNING, message);
}
strcpy(filePath, c);
}
FILE_LOG(logDEBUG) << "Info: File path:" << filePath;
/*FILE_LOG(logDEBUG) << "Info: File path:" << filePath;*/
}
void UDPBaseImplementation::setFileIndex(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
fileIndex = i;
FILE_LOG(logINFO) << "File Index:" << fileIndex;
ostringstream os;
os << "File Index:" << fileIndex;
string message(os.str()); FILE_LOG(logINFO, message);
}
//FIXME: needed?
void UDPBaseImplementation::setScanTag(const int i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
scanTag = i;
FILE_LOG(logINFO) << "Scan Tag:" << scanTag;
ostringstream os;
os << "Scan Tag:" << scanTag;
string message(os.str()); FILE_LOG(logINFO, message);
}
void UDPBaseImplementation::setFrameIndexEnable(const bool b){
FILE_LOG(logDEBUG) << __AT__ << " starting";
frameIndexEnable = b;
FILE_LOG(logINFO) << "Frame Index Enable: " << stringEnable(frameIndexEnable);
ostringstream os;
os << "Frame Index Enable: " << stringEnable(frameIndexEnable);
string message(os.str()); FILE_LOG(logINFO, message);
}
void UDPBaseImplementation::setFileWriteEnable(const bool b){
FILE_LOG(logDEBUG) << __AT__ << " starting";
fileWriteEnable = b;
FILE_LOG(logINFO) << "File Write Enable: " << stringEnable(fileWriteEnable);
ostringstream os;
os << "File Write Enable: " << stringEnable(fileWriteEnable);
string message(os.str()); FILE_LOG(logINFO, message);
}
void UDPBaseImplementation::setOverwriteEnable(const bool b){
FILE_LOG(logDEBUG) << __AT__ << " starting";
overwriteEnable = b;
FILE_LOG(logINFO) << "Overwrite Enable: " << stringEnable(overwriteEnable);
ostringstream os;
os << "Overwrite Enable: " << stringEnable(overwriteEnable);
string message(os.str()); FILE_LOG(logINFO, message);
}
int UDPBaseImplementation::setDataCompressionEnable(const bool b){
FILE_LOG(logDEBUG) << __AT__ << " starting";
dataCompressionEnable = b;
FILE_LOG(logINFO) << "Data Compression : " << stringEnable(dataCompressionEnable);
ostringstream os;
os << "Data Compression : " << stringEnable(dataCompressionEnable);
string message(os.str()); FILE_LOG(logINFO, message);
//overridden methods might return FAIL
return OK;
@@ -302,58 +314,72 @@ int UDPBaseImplementation::setDataCompressionEnable(const bool b){
/***connection parameters***/
void UDPBaseImplementation::setUDPPortNumber(const uint32_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
udpPortNum[0] = i;
FILE_LOG(logINFO) << "UDP Port Number[0]:" << udpPortNum[0];
ostringstream os;
os << "UDP Port Number[0]:" << udpPortNum[0];
string message(os.str()); FILE_LOG(logINFO, message);
}
void UDPBaseImplementation::setUDPPortNumber2(const uint32_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
udpPortNum[1] = i;
FILE_LOG(logINFO) << "UDP Port Number[1]:" << udpPortNum[1];
ostringstream os;
os << "UDP Port Number[1]:" << udpPortNum[1];
string message(os.str()); FILE_LOG(logINFO, message);
}
void UDPBaseImplementation::setEthernetInterface(const char* c){
FILE_LOG(logDEBUG) << __AT__ << " starting";
strcpy(eth, c);
FILE_LOG(logINFO) << "Ethernet Interface: " << eth;
ostringstream os;
os << "Ethernet Interface: " << eth;
string message(os.str()); FILE_LOG(logINFO, message);
}
/***acquisition parameters***/
void UDPBaseImplementation::setShortFrameEnable(const int i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
shortFrameEnable = i;
FILE_LOG(logINFO) << "Short Frame Enable: " << stringEnable(shortFrameEnable);
ostringstream os;
os << "Short Frame Enable: " << stringEnable(shortFrameEnable);
string message(os.str()); FILE_LOG(logINFO, message);
}
int UDPBaseImplementation::setFrameToGuiFrequency(const uint32_t freq){
FILE_LOG(logDEBUG) << __AT__ << " starting";
frameToGuiFrequency = freq;
FILE_LOG(logINFO) << "Frame To Gui Frequency:" << frameToGuiFrequency;
ostringstream os;
os << "Frame To Gui Frequency:" << frameToGuiFrequency;
string message(os.str()); FILE_LOG(logINFO, message);
//overrridden child classes might return FAIL
return OK;
}
void UDPBaseImplementation::setFrameToGuiTimer(const uint32_t time_in_ms){
FILE_LOG(logDEBUG) << __AT__ << " starting";
frameToGuiTimerinMS = time_in_ms;
FILE_LOG(logINFO) << "Frame To Gui Timer:" << frameToGuiTimerinMS;
ostringstream os;
os << "Frame To Gui Timer:" << frameToGuiTimerinMS;
string message(os.str()); FILE_LOG(logINFO, message);
}
uint32_t UDPBaseImplementation::setDataStreamEnable(const uint32_t enable){
FILE_LOG(logDEBUG) << __AT__ << " starting";
dataStreamEnable = enable;
FILE_LOG(logINFO) << "Streaming Data from Receiver:" << dataStreamEnable;
ostringstream os;
os << "Streaming Data from Receiver:" << dataStreamEnable;
string message(os.str()); FILE_LOG(logINFO, message);
//overrridden child classes might return FAIL
return OK;
@@ -361,60 +387,72 @@ uint32_t UDPBaseImplementation::setDataStreamEnable(const uint32_t enable){
int UDPBaseImplementation::setAcquisitionPeriod(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
acquisitionPeriod = i;
FILE_LOG(logINFO) << "Acquisition Period:" << (double)acquisitionPeriod/(1E9) << "s";
ostringstream os;
os << "Acquisition Period:" << (double)acquisitionPeriod/(1E9) << "s";
string message(os.str()); FILE_LOG(logINFO, message);
//overrridden child classes might return FAIL
return OK;
}
int UDPBaseImplementation::setAcquisitionTime(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
acquisitionTime = i;
FILE_LOG(logINFO) << "Acquisition Time:" << (double)acquisitionTime/(1E9) << "s";
ostringstream os;
os << "Acquisition Time:" << (double)acquisitionTime/(1E9) << "s";
string message(os.str()); FILE_LOG(logINFO, message);
//overrridden child classes might return FAIL
return OK;
}
int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
numberOfFrames = i;
FILE_LOG(logINFO) << "Number of Frames:" << numberOfFrames;
ostringstream os;
os << "Number of Frames:" << numberOfFrames;
string message(os.str()); FILE_LOG(logINFO, message);
//overrridden child classes might return FAIL
return OK;
}
int UDPBaseImplementation::setDynamicRange(const uint32_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
dynamicRange = i;
FILE_LOG(logINFO) << "Dynamic Range:" << dynamicRange;
ostringstream os;
os << "Dynamic Range:" << dynamicRange;
string message(os.str()); FILE_LOG(logINFO, message);
//overrridden child classes might return FAIL
return OK;
}
int UDPBaseImplementation::setTenGigaEnable(const bool b){
FILE_LOG(logDEBUG) << __AT__ << " starting";
tengigaEnable = b;
FILE_LOG(logINFO) << "Ten Giga Enable: " << stringEnable(tengigaEnable);
ostringstream os;
os << "Ten Giga Enable: " << stringEnable(tengigaEnable);
string message(os.str()); FILE_LOG(logINFO, message);
//overridden functions might return FAIL
return OK;
}
int UDPBaseImplementation::setFifoDepth(const uint32_t i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
fifoDepth = i;
FILE_LOG(logINFO) << "Fifo Depth: " << i;
ostringstream os;
os << "Fifo Depth: " << i;
string message(os.str()); FILE_LOG(logINFO, message);
//overridden functions might return FAIL
return OK;
@@ -428,79 +466,94 @@ int UDPBaseImplementation::setFifoDepth(const uint32_t i){
/***initial functions***/
int UDPBaseImplementation::setDetectorType(const detectorType d){
FILE_LOG(logDEBUG) << __AT__ << " starting";
myDetectorType = d;
//if eiger, set numberofListeningThreads = 2;
FILE_LOG(logINFO) << "Detector Type:" << getDetectorType(d);
ostringstream os;
os << "Detector Type:" << getDetectorType(d);
string message(os.str()); FILE_LOG(logINFO, message);
return OK;
}
void UDPBaseImplementation::initialize(const char *c){
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(strlen(c))
strcpy(detHostname, c);
FILE_LOG(logINFO) << "Detector Hostname:" << detHostname;
ostringstream os;
os << "Detector Hostname:" << detHostname;
string message(os.str()); FILE_LOG(logINFO, message);
}
/***acquisition functions***/
void UDPBaseImplementation::resetAcquisitionCount(){
FILE_LOG(logDEBUG) << __AT__ << " starting";
totalPacketsCaught = 0;
FILE_LOG(logINFO) << "totalPacketsCaught:" << totalPacketsCaught;
ostringstream os;
os << "totalPacketsCaught:" << totalPacketsCaught;
string message(os.str()); FILE_LOG(logINFO, message);
}
int UDPBaseImplementation::startReceiver(char *c){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
return OK;
}
void UDPBaseImplementation::stopReceiver(){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
}
void UDPBaseImplementation::startReadout(){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
}
int UDPBaseImplementation::shutDownUDPSockets(){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
//overridden functions might return FAIL
return OK;
}
void UDPBaseImplementation::readFrame(int ithread, char* c,char** raw, int64_t &startAcquisitionIndex, int64_t &startFrameIndex){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
}
//FIXME: needed, isnt stopReceiver enough?
void UDPBaseImplementation::abort(){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
}
void UDPBaseImplementation::closeFile(int ithread){
FILE_LOG(logWARNING) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
ostringstream os;
os << " must be overridden by child classes";
string message(os.str()); FILE_LOG(logERROR, message);
}
int UDPBaseImplementation::setActivate(int enable){
FILE_LOG(logDEBUG) << __AT__ << " starting";
if(enable != -1){
activated = enable;
FILE_LOG(logINFO) << "Activation: " << stringEnable(activated);
ostringstream os;
os << "Activation: " << stringEnable(activated);
string message(os.str()); FILE_LOG(logINFO, message);
}
return activated;

View File

@@ -23,17 +23,23 @@ using namespace std;
UDPInterface * UDPInterface::create(string receiver_type){
if (receiver_type == "standard"){
FILE_LOG(logINFO) << "Starting " << receiver_type;
ostringstream os;
os << "Starting " << receiver_type;
string message(os.str()); FILE_LOG(logINFO, message);
return new UDPStandardImplementation();
}
#ifdef REST
else if (receiver_type == "REST"){
FILE_LOG(logINFO) << "Starting " << receiver_type;
ostringstream os;
os << "Starting " << receiver_type;
string message(os.str()); FILE_LOG(logINFO, message);
return new UDPRESTImplementation();
}
#endif
else{
FILE_LOG(logWARNING) << "[ERROR] UDP interface not supported, using standard implementation";
ostringstream os;
os << "[ERROR] UDP interface not supported, using standard implementation";
string message(os.str()); FILE_LOG(logWARNING, message);
return new UDPBaseImplementation();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -104,7 +104,6 @@ int main(int argc, char *argv[]) {
//start tcp server thread
if(receiver->start() == slsReceiverDefs::OK){
FILE_LOG(logDEBUG1) << "DONE!" << endl;
string str;
cin>>str;
//wait and look for an exit keyword

View File

@@ -106,23 +106,31 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
if( !fname.empty() ){
try{
FILE_LOG(logINFO) << "config file name " << fname;
ostringstream os;
os << "config file name " << fname;
string message(os.str()); FILE_LOG(logDEBUG, message);
success = read_config_file(fname, &tcpip_port_no, &configuration_map);
//VERBOSE_PRINT("Read configuration file of " + iline + " lines");
}
catch(...){
FILE_LOG(logERROR) << "Error opening configuration file " << fname ;
success = FAIL;
ostringstream os;
os << "Error opening configuration file " << fname ;
string message(os.str()); FILE_LOG(logERROR, message);
success = FAIL;
}
}
if(success != OK){
FILE_LOG(logERROR) << "Failed: see output above for more information " ;
ostringstream os;
os << "Failed: see output above for more information " ;
string message(os.str()); FILE_LOG(logERROR, message);
}
if (success==OK){
FILE_LOG(logINFO) << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << endl;
ostringstream os;
os << "SLS Receiver starting " << udp_interface_type << " on port " << tcpip_port_no << endl;
string message(os.str()); FILE_LOG(logDEBUG, message);
#ifdef REST
udp_interface = UDPInterface::create(udp_interface_type);
udp_interface->configure(configuration_map);

View File

@@ -28,17 +28,17 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
}
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
myDetectorType(GOTTHARD),
receiverBase(rbase),
ret(OK),
lockStatus(0),
shortFrame(-1),
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
dynamicrange(16),
killTCPServerThread(0),
tenGigaEnable(0),
portNumber(DEFAULT_PORTNO+2),
mySock(NULL){
myDetectorType(GOTTHARD),
receiverBase(rbase),
ret(OK),
lockStatus(0),
shortFrame(-1),
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
dynamicrange(16),
killTCPServerThread(0),
tenGigaEnable(0),
portNumber(DEFAULT_PORTNO+2),
mySock(NULL){
strcpy(SET_RECEIVER_ERR_MESSAGE,"Receiver not set up. Please use rx_hostname first.\n");
@@ -126,14 +126,22 @@ int slsReceiverTCPIPInterface::setPortNumber(int pn){
int slsReceiverTCPIPInterface::start(){
FILE_LOG(logDEBUG) << "Creating TCP Server Thread" << endl;
{
ostringstream os;
os << "Creating TCP Server Thread" << endl;
string message(os.str()); FILE_LOG(logDEBUG, message);
}
killTCPServerThread = 0;
if(pthread_create(&TCPServer_thread, NULL,startTCPServerThread, (void*) this)){
cout << "Could not create TCP Server thread" << endl;
return FAIL;
}
//#ifdef VERYVERBOSE
FILE_LOG(logDEBUG) << "TCP Server thread created successfully." << endl;
{
ostringstream os;
os << "TCP Server thread created successfully." << endl;
string message(os.str()); FILE_LOG(logDEBUG, message);
}
//#endif
return OK;
}
@@ -387,23 +395,27 @@ int slsReceiverTCPIPInterface::set_detector_type(){
receiverBase->registerCallBackRawDataReady(rawDataReadyCallBack,pRawDataReady);
}
#endif
myDetectorType = dr;
ret=receiverBase->setDetectorType(myDetectorType);
retval = myDetectorType;
myDetectorType = dr;
ret=receiverBase->setDetectorType(myDetectorType);
retval = myDetectorType;
}
}
}
//#ifdef VERYVERBOSE
if(ret!=FAIL)
FILE_LOG(logDEBUG) << "detector type " << dr;
{
ostringstream os;
os << "detector type " << dr;
string message(os.str()); FILE_LOG(logDEBUG, message);
}
else
cprintf(RED, "%s\n", mess);
//#endif
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -470,7 +482,7 @@ int slsReceiverTCPIPInterface::set_file_name() {
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -545,7 +557,7 @@ int slsReceiverTCPIPInterface::set_file_dir() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -617,7 +629,7 @@ int slsReceiverTCPIPInterface::set_file_index() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -695,7 +707,7 @@ int slsReceiverTCPIPInterface::set_frame_index() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -759,12 +771,16 @@ int slsReceiverTCPIPInterface::setup_udp(){
receiverBase->setUDPPortNumber2(udpport2);
//setup udpip
//get ethernet interface or IP to listen to
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
{
ostringstream os;
os << "Receiver UDP IP: " << args[0];
string message(os.str()); FILE_LOG(logINFO, message);
}
temp = genericSocket::ipToName(args[0]);
if(temp=="none"){
ret = FAIL;
strcpy(mess, "Failed to get ethernet interface or IP\n");
FILE_LOG(logERROR) << mess;
FILE_LOG(logERROR, string(mess));
}
else{
strcpy(eth,temp.c_str());
@@ -785,7 +801,9 @@ int slsReceiverTCPIPInterface::setup_udp(){
}
else{
strcpy(retval,temp.c_str());
FILE_LOG(logINFO) << "Reciever MAC Address: " << retval;
ostringstream os;
os << "Reciever MAC Address: " << retval;
string message(os.str()); FILE_LOG(logINFO, message);
}
}
}
@@ -793,14 +811,14 @@ int slsReceiverTCPIPInterface::setup_udp(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
// send answer
mySock->SendDataOnly(&ret,sizeof(ret));
if(ret==FAIL){
FILE_LOG(logERROR) << mess;
FILE_LOG(logERROR, string(mess));
mySock->SendDataOnly(mess,sizeof(mess));
}
mySock->SendDataOnly(retval,MAX_STR_LENGTH);
@@ -849,7 +867,7 @@ int slsReceiverTCPIPInterface::start_receiver(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -897,7 +915,7 @@ int slsReceiverTCPIPInterface::stop_receiver(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -928,7 +946,7 @@ int slsReceiverTCPIPInterface::get_status(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -959,7 +977,7 @@ int slsReceiverTCPIPInterface::get_frames_caught(){
}else retval=receiverBase->getTotalFramesCaught();
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -991,7 +1009,7 @@ int slsReceiverTCPIPInterface::get_frame_index(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1036,7 +1054,7 @@ int slsReceiverTCPIPInterface::reset_frames_caught(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1105,7 +1123,7 @@ int slsReceiverTCPIPInterface::set_short_frame() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1287,7 +1305,7 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1468,7 +1486,7 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1622,7 +1640,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1657,7 +1675,7 @@ int slsReceiverTCPIPInterface::propix_read_frame(){
int slsReceiverTCPIPInterface::eiger_read_frame(){
ret=OK;
/*
/*
char fName[MAX_STR_LENGTH]="";
int acquisitionIndex = -1;
int frameIndex= -1;
@@ -1889,7 +1907,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -1910,7 +1928,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
delete [] retval;
delete [] origVal;
delete [] raw;
*/
*/
return ret;
}
@@ -2052,7 +2070,7 @@ int slsReceiverTCPIPInterface::jungfrau_read_frame(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2130,7 +2148,7 @@ int slsReceiverTCPIPInterface::set_read_frequency(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2196,7 +2214,7 @@ int slsReceiverTCPIPInterface::set_read_receiver_timer(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2259,7 +2277,7 @@ int slsReceiverTCPIPInterface::set_data_stream_enable(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2319,7 +2337,7 @@ int slsReceiverTCPIPInterface::enable_file_write(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2347,7 +2365,7 @@ int slsReceiverTCPIPInterface::get_id(){
#endif
if(mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2371,43 +2389,43 @@ int64_t slsReceiverTCPIPInterface::getReceiverVersion(){
int slsReceiverTCPIPInterface::start_readout(){cprintf(BLUE,"In start readout!\n");
ret=OK;
enum runStatus retval;
ret=OK;
enum runStatus retval;
// execute action if the arguments correctly arrived
// execute action if the arguments correctly arrived
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
if (receiverBase == NULL){
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
ret=FAIL;
}
/*else if(receiverBase->getStatus()!= IDLE){
if (receiverBase == NULL){
strcpy(mess,SET_RECEIVER_ERR_MESSAGE);
ret=FAIL;
}
/*else if(receiverBase->getStatus()!= IDLE){
strcpy(mess,"Can not start receiver readout while receiver not idle\n");
ret = FAIL;
}*/
else{
receiverBase->startReadout();
retval = receiverBase->getStatus();
if((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE))
ret = OK;
else
ret = FAIL;
}
else{
receiverBase->startReadout();
retval = receiverBase->getStatus();
if((retval == TRANSMITTING) || (retval == RUN_FINISHED) || (retval == IDLE))
ret = OK;
else
ret = FAIL;
}
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
ret=FORCE_UPDATE;
}
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;
// 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;
}
@@ -2483,7 +2501,7 @@ int slsReceiverTCPIPInterface::set_timer() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2555,7 +2573,7 @@ int slsReceiverTCPIPInterface::enable_compression() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2621,7 +2639,7 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2722,7 +2740,7 @@ int slsReceiverTCPIPInterface::set_dynamic_range() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2790,7 +2808,7 @@ int slsReceiverTCPIPInterface::enable_overwrite() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2860,7 +2878,7 @@ int slsReceiverTCPIPInterface::enable_tengiga() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -2932,7 +2950,7 @@ int slsReceiverTCPIPInterface::set_fifo_depth() {
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -3006,7 +3024,7 @@ int slsReceiverTCPIPInterface::set_activate() {
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}
@@ -3070,7 +3088,7 @@ int slsReceiverTCPIPInterface::set_flipped_data(){
#endif
if(ret==OK && mySock->differentClients){
FILE_LOG(logDEBUG) << "Force update";
FILE_LOG(logDEBUG,"Force update" );
ret=FORCE_UPDATE;
}