mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-17 16:43:45 +01:00
Added status resetting for REST
This commit is contained in:
@@ -21,19 +21,15 @@
|
|||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
/*
|
|
||||||
void print_not_implemented(string method_name){
|
|
||||||
std::cout << "[WARNING] Method " << method_name << " not implemented!" << std::endl;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
class UDPInterface {
|
class UDPInterface {
|
||||||
|
|
||||||
/* abstract class that defines the public interface of an sls detector data receiver.
|
/* abstract class that defines the public interface of an sls detector data receiver UDP part.
|
||||||
*
|
*
|
||||||
* Use the factory method slsReceiverBase::create() to get an instance:
|
* Use the factory method slsReceiverBase::create() to get an instance:
|
||||||
*
|
*
|
||||||
* slsReceiverBase *receiver = slsReceiverBase::create()
|
* UDPInterface *receiver = UDPInterface::create()
|
||||||
*
|
*
|
||||||
* supported sequence of method-calls:
|
* supported sequence of method-calls:
|
||||||
*
|
*
|
||||||
@@ -64,11 +60,6 @@ class UDPInterface {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* constructor
|
|
||||||
*/
|
|
||||||
//UDPInterface(){};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
*/
|
*/
|
||||||
@@ -80,11 +71,10 @@ class UDPInterface {
|
|||||||
static UDPInterface *create(string receiver_type = "standard");
|
static UDPInterface *create(string receiver_type = "standard");
|
||||||
|
|
||||||
virtual void configure(map<string, string> config_map) = 0;
|
virtual void configure(map<string, string> config_map) = 0;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Receiver
|
* Initialize the Receiver
|
||||||
@param detectorHostName detector hostname
|
@param detectorHostName detector hostname
|
||||||
@@ -94,10 +84,10 @@ class UDPInterface {
|
|||||||
|
|
||||||
|
|
||||||
/* Returns detector hostname
|
/* Returns detector hostname
|
||||||
/returns hostname
|
/returns hostname
|
||||||
* caller needs to deallocate the returned char array.
|
* caller needs to deallocate the returned char array.
|
||||||
* if uninitialized, it must return NULL
|
* if uninitialized, it must return NULL
|
||||||
*/
|
*/
|
||||||
virtual char *getDetectorHostname() const = 0;
|
virtual char *getDetectorHostname() const = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -48,8 +48,10 @@ class UDPRESTImplementation : protected virtual slsReceiverDefs, public UDPBaseI
|
|||||||
virtual ~UDPRESTImplementation();
|
virtual ~UDPRESTImplementation();
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
void initialize_REST();
|
void initialize_REST();
|
||||||
|
|
||||||
|
public:
|
||||||
void configure(map<string, string> config_map);
|
void configure(map<string, string> config_map);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2121,12 +2121,24 @@ int UDPBaseImplementation::enableTenGiga(int enable){
|
|||||||
createWriterThreads(true);
|
createWriterThreads(true);
|
||||||
}
|
}
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
if(mem0[i]) {free(mem0[i]); mem0[i] = NULL;}
|
if(mem0[i]){
|
||||||
if(fifo[i]) {delete fifo[i]; fifo[i] = NULL;}
|
free(mem0[i]);
|
||||||
if(fifoFree[i]) {delete fifoFree[i]; fifoFree[i] = NULL;}
|
mem0[i] = NULL;
|
||||||
|
}
|
||||||
|
if(fifo[i]){
|
||||||
|
delete fifo[i];
|
||||||
|
fifo[i] = NULL;
|
||||||
|
}
|
||||||
|
if(fifoFree[i]) {
|
||||||
|
delete fifoFree[i];
|
||||||
|
fifoFree[i] = NULL;
|
||||||
|
}
|
||||||
buffer[i] = NULL;
|
buffer[i] = NULL;
|
||||||
}
|
}
|
||||||
if(latestData) {delete [] latestData; latestData = NULL;}
|
if(latestData){
|
||||||
|
delete [] latestData;
|
||||||
|
latestData = NULL;
|
||||||
|
}
|
||||||
latestData = new char[frameSize];
|
latestData = new char[frameSize];
|
||||||
|
|
||||||
numJobsPerThread = -1;
|
numJobsPerThread = -1;
|
||||||
|
|||||||
@@ -6,16 +6,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
#include <signal.h> // SIGINT
|
|
||||||
#include <sys/stat.h> // stat
|
|
||||||
#include <sys/socket.h> // socket(), bind(), listen(), accept(), shut down
|
|
||||||
#include <arpa/inet.h> // sock_addr_in, htonl, INADDR_ANY
|
|
||||||
#include <stdlib.h> // exit()
|
|
||||||
#include <iomanip> //set precision
|
|
||||||
#include <sys/mman.h> //munmap
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -35,7 +25,6 @@ UDPInterface * UDPInterface::create(string receiver_type){
|
|||||||
cout << "Starting " << receiver_type << endl;
|
cout << "Starting " << receiver_type << endl;
|
||||||
return new UDPStandardImplementation();
|
return new UDPStandardImplementation();
|
||||||
}
|
}
|
||||||
|
|
||||||
//#ifdef REST
|
//#ifdef REST
|
||||||
else if (receiver_type == "REST"){
|
else if (receiver_type == "REST"){
|
||||||
return new UDPRESTImplementation();
|
return new UDPRESTImplementation();
|
||||||
|
|||||||
@@ -31,12 +31,14 @@ using namespace std;
|
|||||||
/*
|
/*
|
||||||
TODO
|
TODO
|
||||||
+ filePath != getFilePath
|
+ filePath != getFilePath
|
||||||
|
+ better state handling. Now it is only IDLE - RUNNING - IDLE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
UDPRESTImplementation::UDPRESTImplementation(){
|
UDPRESTImplementation::UDPRESTImplementation(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
// Default values
|
||||||
rest_hostname = "localhost";
|
rest_hostname = "localhost";
|
||||||
rest_port = 8081;
|
rest_port = 8081;
|
||||||
}
|
}
|
||||||
@@ -57,20 +59,21 @@ void UDPRESTImplementation::configure(map<string, string> config_map){
|
|||||||
if(pos != string::npos){
|
if(pos != string::npos){
|
||||||
istringstream (host_port_str.substr (pos)) >> rest_port;
|
istringstream (host_port_str.substr (pos)) >> rest_port;
|
||||||
rest_hostname = host_port_str.substr(0, pos);
|
rest_hostname = host_port_str.substr(0, pos);
|
||||||
cout << rest_hostname << " " << rest_port << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
for(map<string, string>::const_iterator i=config_map.begin(); i != config_map.end(); i++){
|
for(map<string, string>::const_iterator i=config_map.begin(); i != config_map.end(); i++){
|
||||||
std::cout << i->first << " " << i->second<< std::endl;
|
std::cout << i->first << " " << i->second<< std::endl;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::initialize_REST(){
|
void UDPRESTImplementation::initialize_REST(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
if (rest_hostname.empty()) {
|
if (rest_hostname.empty()) {
|
||||||
FILE_LOG(logDEBUG) << __AT__ <<"can't initialize with empty string or NULL for detectorHostname";
|
FILE_LOG(logDEBUG) << __AT__ <<"can't initialize with empty string or NULL for detectorHostname";
|
||||||
@@ -116,7 +119,6 @@ void UDPRESTImplementation::initialize_REST(){
|
|||||||
ss >> test;
|
ss >> test;
|
||||||
|
|
||||||
|
|
||||||
cout << "aaaa" <<filePath << endl;
|
|
||||||
test = "{\"path\":\"" + string( getFilePath() ) + "\"}";
|
test = "{\"path\":\"" + string( getFilePath() ) + "\"}";
|
||||||
code = rest->post_json("state/initialize", &answer, test);
|
code = rest->post_json("state/initialize", &answer, test);
|
||||||
FILE_LOG(logDEBUG) << __AT__ << "state/configure got " << code;
|
FILE_LOG(logDEBUG) << __AT__ << "state/configure got " << code;
|
||||||
@@ -147,17 +149,34 @@ int UDPRESTImplementation::setDetectorType(detectorType det){
|
|||||||
|
|
||||||
/*Frame indices and numbers caught*/
|
/*Frame indices and numbers caught*/
|
||||||
|
|
||||||
bool UDPRESTImplementation::getAcquistionStarted(){return acqStarted;};
|
bool UDPRESTImplementation::getAcquistionStarted(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
return acqStarted;
|
||||||
|
};
|
||||||
|
|
||||||
bool UDPRESTImplementation::getMeasurementStarted(){return measurementStarted;};
|
bool UDPRESTImplementation::getMeasurementStarted(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
return measurementStarted;
|
||||||
|
};
|
||||||
|
|
||||||
int UDPRESTImplementation::getFramesCaught(){return (packetsCaught/packetsPerFrame);}
|
int UDPRESTImplementation::getFramesCaught(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
return (packetsCaught/packetsPerFrame);
|
||||||
|
}
|
||||||
|
|
||||||
int UDPRESTImplementation::getTotalFramesCaught(){return (totalPacketsCaught/packetsPerFrame);}
|
int UDPRESTImplementation::getTotalFramesCaught(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
return (totalPacketsCaught/packetsPerFrame);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t UDPRESTImplementation::getStartFrameIndex(){return startFrameIndex;}
|
uint32_t UDPRESTImplementation::getStartFrameIndex(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
return startFrameIndex;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t UDPRESTImplementation::getFrameIndex(){
|
uint32_t UDPRESTImplementation::getFrameIndex(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
if(!packetsCaught)
|
if(!packetsCaught)
|
||||||
frameIndex=-1;
|
frameIndex=-1;
|
||||||
else
|
else
|
||||||
@@ -167,15 +186,22 @@ uint32_t UDPRESTImplementation::getFrameIndex(){
|
|||||||
|
|
||||||
|
|
||||||
uint32_t UDPRESTImplementation::getAcquisitionIndex(){
|
uint32_t UDPRESTImplementation::getAcquisitionIndex(){
|
||||||
|
//FILE_LOG(logDEBUG) << __AT__ << " called, idx: " << acquisitionIndex;
|
||||||
if(!totalPacketsCaught)
|
if(!totalPacketsCaught)
|
||||||
acquisitionIndex=-1;
|
acquisitionIndex = -1;
|
||||||
else
|
else
|
||||||
acquisitionIndex = currframenum - startAcquisitionIndex;
|
acquisitionIndex = currframenum - startAcquisitionIndex;
|
||||||
|
|
||||||
|
//FILE_LOG(logDEBUG) << __AT__ << " idx: " << acquisitionIndex
|
||||||
|
// << " currframenum: " << currframenum
|
||||||
|
// << " startAcqIdx: " << startAcquisitionIndex;
|
||||||
|
|
||||||
return acquisitionIndex;
|
return acquisitionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::resetTotalFramesCaught(){
|
void UDPRESTImplementation::resetTotalFramesCaught(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
acqStarted = false;
|
acqStarted = false;
|
||||||
startAcquisitionIndex = 0;
|
startAcquisitionIndex = 0;
|
||||||
totalPacketsCaught = 0;
|
totalPacketsCaught = 0;
|
||||||
@@ -184,21 +210,23 @@ void UDPRESTImplementation::resetTotalFramesCaught(){
|
|||||||
|
|
||||||
/*file parameters*/
|
/*file parameters*/
|
||||||
int UDPRESTImplementation::getFileIndex(){
|
int UDPRESTImplementation::getFileIndex(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
return fileIndex;
|
return fileIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UDPRESTImplementation::setFileIndex(int i){
|
int UDPRESTImplementation::setFileIndex(int i){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
||||||
/*
|
|
||||||
if(i>=0)
|
if(i>=0)
|
||||||
fileIndex = i;
|
fileIndex = i;
|
||||||
*/
|
|
||||||
return getFileIndex();
|
return getFileIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::setFrameIndexNeeded(int i){
|
int UDPRESTImplementation::setFrameIndexNeeded(int i){
|
||||||
cout << "[WARNING] This is a base implementation, " << __func__ << " could have no effects." << endl;
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
frameIndexNeeded = i;
|
frameIndexNeeded = i;
|
||||||
return frameIndexNeeded;
|
return frameIndexNeeded;
|
||||||
}
|
}
|
||||||
@@ -230,6 +258,7 @@ int UDPRESTImplementation::setEnableOverwrite(int i){
|
|||||||
/*other parameters*/
|
/*other parameters*/
|
||||||
|
|
||||||
slsReceiverDefs::runStatus UDPRESTImplementation::getStatus() const{
|
slsReceiverDefs::runStatus UDPRESTImplementation::getStatus() const{
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called, status: " << status;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,12 +272,15 @@ char *UDPRESTImplementation::getDetectorHostname() const{
|
|||||||
|
|
||||||
void UDPRESTImplementation::setEthernetInterface(char* c){
|
void UDPRESTImplementation::setEthernetInterface(char* c){
|
||||||
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
||||||
|
|
||||||
|
// TODO: this segfaults
|
||||||
//strcpy(eth,c);
|
//strcpy(eth,c);
|
||||||
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " done";
|
//FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " done";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::setUDPPortNo(int p){
|
void UDPRESTImplementation::setUDPPortNo(int p){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
server_port[i] = p+i;
|
server_port[i] = p+i;
|
||||||
}
|
}
|
||||||
@@ -299,6 +331,7 @@ int32_t UDPRESTImplementation::setDynamicRange(int32_t dr){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::setShortFrame(int i){
|
int UDPRESTImplementation::setShortFrame(int i){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
shortFrame=i;
|
shortFrame=i;
|
||||||
|
|
||||||
if(shortFrame!=-1){
|
if(shortFrame!=-1){
|
||||||
@@ -329,6 +362,7 @@ int UDPRESTImplementation::setShortFrame(int i){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::setNFrameToGui(int i){
|
int UDPRESTImplementation::setNFrameToGui(int i){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
if(i>=0){
|
if(i>=0){
|
||||||
nFrameToGui = i;
|
nFrameToGui = i;
|
||||||
setupFifoStructure();
|
setupFifoStructure();
|
||||||
@@ -339,7 +373,7 @@ int UDPRESTImplementation::setNFrameToGui(int i){
|
|||||||
|
|
||||||
|
|
||||||
int64_t UDPRESTImplementation::setAcquisitionPeriod(int64_t index){
|
int64_t UDPRESTImplementation::setAcquisitionPeriod(int64_t index){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
if(index >= 0){
|
if(index >= 0){
|
||||||
if(index != acquisitionPeriod){
|
if(index != acquisitionPeriod){
|
||||||
acquisitionPeriod = index;
|
acquisitionPeriod = index;
|
||||||
@@ -350,9 +384,13 @@ int64_t UDPRESTImplementation::setAcquisitionPeriod(int64_t index){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UDPRESTImplementation::getDataCompression(){return dataCompression;}
|
bool UDPRESTImplementation::getDataCompression(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
return dataCompression;
|
||||||
|
}
|
||||||
|
|
||||||
int UDPRESTImplementation::enableDataCompression(bool enable){
|
int UDPRESTImplementation::enableDataCompression(bool enable){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
cout << "Data compression ";
|
cout << "Data compression ";
|
||||||
if(enable)
|
if(enable)
|
||||||
cout << "enabled" << endl;
|
cout << "enabled" << endl;
|
||||||
@@ -406,6 +444,7 @@ int UDPRESTImplementation::enableDataCompression(bool enable){
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::deleteFilter(){
|
void UDPRESTImplementation::deleteFilter(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int i;
|
int i;
|
||||||
cmSub=NULL;
|
cmSub=NULL;
|
||||||
|
|
||||||
@@ -423,6 +462,7 @@ void UDPRESTImplementation::deleteFilter(){
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::setupFilter(){
|
void UDPRESTImplementation::setupFilter(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
double hc = 0;
|
double hc = 0;
|
||||||
double sigma = 5;
|
double sigma = 5;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
@@ -459,6 +499,11 @@ void UDPRESTImplementation::setupFilter(){
|
|||||||
|
|
||||||
//LEO: it is not clear to me..
|
//LEO: it is not clear to me..
|
||||||
void UDPRESTImplementation::setupFifoStructure(){
|
void UDPRESTImplementation::setupFifoStructure(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called, doing nothing";
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
void UDPRESTImplementation::setupFifoStructure(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
int64_t i;
|
int64_t i;
|
||||||
int oldn = numJobsPerThread;
|
int oldn = numJobsPerThread;
|
||||||
@@ -504,10 +549,6 @@ void UDPRESTImplementation::setupFifoStructure(){
|
|||||||
cout << "Number of Frames per buffer:" << numJobsPerThread << endl;
|
cout << "Number of Frames per buffer:" << numJobsPerThread << endl;
|
||||||
cout << "Fifo Size:" << fifosize << endl;
|
cout << "Fifo Size:" << fifosize << endl;
|
||||||
|
|
||||||
/*
|
|
||||||
//for testing
|
|
||||||
numJobsPerThread = 3; fifosize = 11;
|
|
||||||
*/
|
|
||||||
|
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
//deleting old structure and creating fifo structure
|
//deleting old structure and creating fifo structure
|
||||||
@@ -524,7 +565,7 @@ void UDPRESTImplementation::setupFifoStructure(){
|
|||||||
|
|
||||||
//allocate memory
|
//allocate memory
|
||||||
mem0[i]=(char*)malloc((bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*fifosize);
|
mem0[i]=(char*)malloc((bufferSize * numJobsPerThread + HEADER_SIZE_NUM_TOT_PACKETS)*fifosize);
|
||||||
/** shud let the client know about this */
|
// shud let the client know about this
|
||||||
if (mem0[i]==NULL){
|
if (mem0[i]==NULL){
|
||||||
cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY FOR LISTENING !!!!!!!+++++++++++++++++++++" << endl;
|
cout<<"++++++++++++++++++++++ COULD NOT ALLOCATE MEMORY FOR LISTENING !!!!!!!+++++++++++++++++++++" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
@@ -538,7 +579,7 @@ void UDPRESTImplementation::setupFifoStructure(){
|
|||||||
}
|
}
|
||||||
cout << "Fifo structure(s) reconstructed" << endl;
|
cout << "Fifo structure(s) reconstructed" << endl;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -548,6 +589,7 @@ void UDPRESTImplementation::setupFifoStructure(){
|
|||||||
/** acquisition functions */
|
/** acquisition functions */
|
||||||
|
|
||||||
void UDPRESTImplementation::readFrame(char* c,char** raw, uint32_t &fnum){
|
void UDPRESTImplementation::readFrame(char* c,char** raw, uint32_t &fnum){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
//point to gui data
|
//point to gui data
|
||||||
if (guiData == NULL)
|
if (guiData == NULL)
|
||||||
guiData = latestData;
|
guiData = latestData;
|
||||||
@@ -582,6 +624,7 @@ void UDPRESTImplementation::readFrame(char* c,char** raw, uint32_t &fnum){
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){
|
void UDPRESTImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char* buf){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
//random read when gui not ready
|
//random read when gui not ready
|
||||||
if((!nFrameToGui) && (!guiData)){
|
if((!nFrameToGui) && (!guiData)){
|
||||||
@@ -639,7 +682,6 @@ void UDPRESTImplementation::copyFrameToGui(char* startbuf[], uint32_t fnum, char
|
|||||||
int UDPRESTImplementation::createUDPSockets(){
|
int UDPRESTImplementation::createUDPSockets(){
|
||||||
|
|
||||||
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
FILE_LOG(logDEBUG) << __FILE__ << "::" << __func__ << " starting";
|
||||||
std::cout << "AAAAAAAAAAAa" << std::endl;
|
|
||||||
|
|
||||||
//if eth is mistaken with ip address
|
//if eth is mistaken with ip address
|
||||||
if (strchr(eth,'.')!=NULL)
|
if (strchr(eth,'.')!=NULL)
|
||||||
@@ -688,6 +730,21 @@ int UDPRESTImplementation::shutDownUDPSockets(){
|
|||||||
FILE_LOG(logDEBUG) << __AT__ << "called";
|
FILE_LOG(logDEBUG) << __AT__ << "called";
|
||||||
FILE_LOG(logDEBUG) << __AT__ << "doing nothing";
|
FILE_LOG(logDEBUG) << __AT__ << "doing nothing";
|
||||||
|
|
||||||
|
std::string answer;
|
||||||
|
int code = rest->get_json("state", &answer);
|
||||||
|
std::cout << answer << std::endl;
|
||||||
|
|
||||||
|
code = rest->post_json("state/close", &answer);
|
||||||
|
std::cout << answer << std::endl;
|
||||||
|
code = rest->post_json("state/reset", &answer);
|
||||||
|
std::cout << answer << std::endl;
|
||||||
|
|
||||||
|
code = rest->get_json("state", &answer);
|
||||||
|
std::cout << answer << std::endl;
|
||||||
|
|
||||||
|
status = slsReceiverDefs::IDLE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(int i=0;i<numListeningThreads;i++){
|
for(int i=0;i<numListeningThreads;i++){
|
||||||
@@ -710,6 +767,8 @@ int UDPRESTImplementation::shutDownUDPSockets(){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::createListeningThreads(bool destroy){
|
int UDPRESTImplementation::createListeningThreads(bool destroy){
|
||||||
|
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int i;
|
int i;
|
||||||
void* status;
|
void* status;
|
||||||
|
|
||||||
@@ -765,6 +824,7 @@ int UDPRESTImplementation::createListeningThreads(bool destroy){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::createWriterThreads(bool destroy){
|
int UDPRESTImplementation::createWriterThreads(bool destroy){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int i;
|
int i;
|
||||||
void* status;
|
void* status;
|
||||||
|
|
||||||
@@ -826,6 +886,7 @@ int UDPRESTImplementation::createWriterThreads(bool destroy){
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::setThreadPriorities(){
|
void UDPRESTImplementation::setThreadPriorities(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int i;
|
int i;
|
||||||
//assign priorities
|
//assign priorities
|
||||||
struct sched_param tcp_param, listen_param, write_param;
|
struct sched_param tcp_param, listen_param, write_param;
|
||||||
@@ -863,7 +924,7 @@ void UDPRESTImplementation::setThreadPriorities(){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::setupWriter(){
|
int UDPRESTImplementation::setupWriter(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
//reset writing thread variables
|
//reset writing thread variables
|
||||||
packetsInFile=0;
|
packetsInFile=0;
|
||||||
packetsCaught=0;
|
packetsCaught=0;
|
||||||
@@ -946,6 +1007,8 @@ int UDPRESTImplementation::setupWriter(){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::createCompressionFile(int ithr, int iframe){
|
int UDPRESTImplementation::createCompressionFile(int ithr, int iframe){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
#ifdef MYROOT1
|
#ifdef MYROOT1
|
||||||
char temp[MAX_STR_LENGTH];
|
char temp[MAX_STR_LENGTH];
|
||||||
//create file name for gui purposes, and set up acquistion parameters
|
//create file name for gui purposes, and set up acquistion parameters
|
||||||
@@ -974,8 +1037,9 @@ int UDPRESTImplementation::createCompressionFile(int ithr, int iframe){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::createNewFile(){
|
int UDPRESTImplementation::createNewFile(){
|
||||||
int gt = getFrameIndex();
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
if(gt==-1) gt=0;
|
int gt = getFrameIndex();
|
||||||
|
if(gt==-1) gt=0;
|
||||||
//create file name
|
//create file name
|
||||||
if(frameIndexNeeded==-1)
|
if(frameIndexNeeded==-1)
|
||||||
sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
sprintf(savefilename, "%s/%s_%d.raw", filePath,fileName,fileIndex);
|
||||||
@@ -1117,6 +1181,7 @@ int UDPRESTImplementation::startReceiver(char message[]){
|
|||||||
code = rest->get_json("state", &answer);
|
code = rest->get_json("state", &answer);
|
||||||
std::cout << answer << std::endl;
|
std::cout << answer << std::endl;
|
||||||
|
|
||||||
|
status = slsReceiverDefs::RUNNING;
|
||||||
|
|
||||||
//reset listening thread variables
|
//reset listening thread variables
|
||||||
/*
|
/*
|
||||||
@@ -1172,8 +1237,6 @@ int UDPRESTImplementation::startReceiver(char message[]){
|
|||||||
sem_post(&writersmp[i]);
|
sem_post(&writersmp[i]);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
cout << "Receiver Started.\nStatus:" << status << endl;
|
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1230,6 +1293,8 @@ void UDPRESTImplementation::startReadout(){
|
|||||||
|
|
||||||
|
|
||||||
void* UDPRESTImplementation::startListeningThread(void* this_pointer){
|
void* UDPRESTImplementation::startListeningThread(void* this_pointer){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
((UDPRESTImplementation*)this_pointer)->startListening();
|
((UDPRESTImplementation*)this_pointer)->startListening();
|
||||||
|
|
||||||
return this_pointer;
|
return this_pointer;
|
||||||
@@ -1238,6 +1303,7 @@ void* UDPRESTImplementation::startListeningThread(void* this_pointer){
|
|||||||
|
|
||||||
|
|
||||||
void* UDPRESTImplementation::startWritingThread(void* this_pointer){
|
void* UDPRESTImplementation::startWritingThread(void* this_pointer){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
((UDPRESTImplementation*)this_pointer)->startWriting();
|
((UDPRESTImplementation*)this_pointer)->startWriting();
|
||||||
return this_pointer;
|
return this_pointer;
|
||||||
}
|
}
|
||||||
@@ -1248,6 +1314,8 @@ void* UDPRESTImplementation::startWritingThread(void* this_pointer){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::startListening(){
|
int UDPRESTImplementation::startListening(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
int ithread = currentListeningThreadIndex;
|
int ithread = currentListeningThreadIndex;
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cout << "In startListening() " << endl;
|
cout << "In startListening() " << endl;
|
||||||
@@ -1449,6 +1517,7 @@ int UDPRESTImplementation::startListening(){
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::startWriting(){
|
int UDPRESTImplementation::startWriting(){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int ithread = currentWriterThreadIndex;
|
int ithread = currentWriterThreadIndex;
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
cout << ithread << "In startWriting()" <<endl;
|
cout << ithread << "In startWriting()" <<endl;
|
||||||
@@ -1642,6 +1711,7 @@ int loop;
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::startFrameIndices(int ithread){
|
void UDPRESTImplementation::startFrameIndices(int ithread){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
if (myDetectorType == EIGER)
|
if (myDetectorType == EIGER)
|
||||||
//add currframenum later in this method for scans
|
//add currframenum later in this method for scans
|
||||||
@@ -1676,6 +1746,8 @@ void UDPRESTImplementation::startFrameIndices(int ithread){
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::stopListening(int ithread, int rc, int &pc, int &t){
|
void UDPRESTImplementation::stopListening(int ithread, int rc, int &pc, int &t){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifdef VERYVERBOSE
|
#ifdef VERYVERBOSE
|
||||||
@@ -1754,6 +1826,7 @@ int i;
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::stopWriting(int ithread, char* wbuffer[]){
|
void UDPRESTImplementation::stopWriting(int ithread, char* wbuffer[]){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int i,j;
|
int i,j;
|
||||||
#ifdef VERYDEBUG
|
#ifdef VERYDEBUG
|
||||||
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuffer[wIndex] << endl;
|
cout << ithread << " **********************popped last dummy frame:" << (void*)wbuffer[wIndex] << endl;
|
||||||
@@ -1821,6 +1894,7 @@ void UDPRESTImplementation::stopWriting(int ithread, char* wbuffer[]){
|
|||||||
|
|
||||||
|
|
||||||
void UDPRESTImplementation::writeToFile_withoutCompression(char* buf,int numpackets, uint32_t framenum){
|
void UDPRESTImplementation::writeToFile_withoutCompression(char* buf,int numpackets, uint32_t framenum){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
int packetsToSave, offset,lastpacket;
|
int packetsToSave, offset,lastpacket;
|
||||||
uint32_t tempframenum = framenum;
|
uint32_t tempframenum = framenum;
|
||||||
|
|
||||||
@@ -1924,6 +1998,8 @@ void UDPRESTImplementation::writeToFile_withoutCompression(char* buf,int numpack
|
|||||||
|
|
||||||
void UDPRESTImplementation::handleDataCompression(int ithread, char* wbuffer[], int &npackets, char* data, int xmax, int ymax, int &nf){
|
void UDPRESTImplementation::handleDataCompression(int ithread, char* wbuffer[], int &npackets, char* data, int xmax, int ymax, int &nf){
|
||||||
|
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
#if defined(MYROOT1) && defined(ALLFILE_DEBUG)
|
#if defined(MYROOT1) && defined(ALLFILE_DEBUG)
|
||||||
writeToFile_withoutCompression(wbuf[0], numpackets,currframenum);
|
writeToFile_withoutCompression(wbuf[0], numpackets,currframenum);
|
||||||
#endif
|
#endif
|
||||||
@@ -2022,6 +2098,7 @@ void UDPRESTImplementation::handleDataCompression(int ithread, char* wbuffer[],
|
|||||||
|
|
||||||
|
|
||||||
int UDPRESTImplementation::enableTenGiga(int enable){
|
int UDPRESTImplementation::enableTenGiga(int enable){
|
||||||
|
FILE_LOG(logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
cout << "Enabling 10Gbe to" << enable << endl;
|
cout << "Enabling 10Gbe to" << enable << endl;
|
||||||
|
|
||||||
|
|||||||
@@ -29,25 +29,25 @@ slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
|||||||
|
|
||||||
|
|
||||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
||||||
myDetectorType(GOTTHARD),
|
myDetectorType(GOTTHARD),
|
||||||
receiverBase(rbase),
|
receiverBase(rbase),
|
||||||
ret(OK),
|
ret(OK),
|
||||||
lockStatus(0),
|
lockStatus(0),
|
||||||
shortFrame(-1),
|
shortFrame(-1),
|
||||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
||||||
dynamicrange(16),
|
dynamicrange(16),
|
||||||
socket(NULL),
|
socket(NULL),
|
||||||
killTCPServerThread(0),
|
killTCPServerThread(0),
|
||||||
tenGigaEnable(0), portNumber(DEFAULT_PORTNO+2){
|
tenGigaEnable(0), portNumber(DEFAULT_PORTNO+2){
|
||||||
|
|
||||||
int port_no=portNumber;
|
int port_no=portNumber;
|
||||||
|
|
||||||
|
|
||||||
if (pn>0)
|
if (pn>0)
|
||||||
port_no = pn;
|
port_no = pn;
|
||||||
|
|
||||||
success=OK;
|
success=OK;
|
||||||
|
|
||||||
//create socket
|
//create socket
|
||||||
if(success == OK){
|
if(success == OK){
|
||||||
socket = new MySocketTCP(port_no);
|
socket = new MySocketTCP(port_no);
|
||||||
@@ -56,24 +56,25 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
|
|||||||
delete socket;
|
delete socket;
|
||||||
socket=NULL;
|
socket=NULL;
|
||||||
} else {
|
} else {
|
||||||
portNumber=port_no;
|
portNumber=port_no;
|
||||||
//initialize variables
|
//initialize variables
|
||||||
strcpy(socket->lastClientIP,"none");
|
strcpy(socket->lastClientIP,"none");
|
||||||
strcpy(socket->thisClientIP,"none1");
|
strcpy(socket->thisClientIP,"none1");
|
||||||
strcpy(mess,"dummy message");
|
strcpy(mess,"dummy message");
|
||||||
|
|
||||||
function_table();
|
function_table();
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "Function table assigned." << endl;
|
cout << "Function table assigned." << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//Catch signal SIGINT to close files properly
|
//Catch signal SIGINT to close files properly
|
||||||
signal(SIGINT,staticCloseFile);
|
signal(SIGINT,staticCloseFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int slsReceiverTCPIPInterface::setPortNumber(int pn){
|
int slsReceiverTCPIPInterface::setPortNumber(int pn){
|
||||||
int p_number;
|
int p_number;
|
||||||
MySocketTCP *oldsocket=NULL;;
|
MySocketTCP *oldsocket=NULL;;
|
||||||
|
|||||||
Reference in New Issue
Block a user