client: moved shortenable to roi in reciever, roi not yet written in master file

This commit is contained in:
2018-09-19 17:35:26 +02:00
parent 961489edb1
commit c784f0f539
38 changed files with 615 additions and 459 deletions

View File

@ -9,7 +9,6 @@
#include "Fifo.h"
#include <iostream>
using namespace std;
FILE* BinaryFile::masterfd = 0;

View File

@ -18,9 +18,8 @@
#include <iostream>
#include <errno.h>
#include <cstring>
using namespace std;
const string DataProcessor::TypeName = "DataProcessor";
const std::string DataProcessor::TypeName = "DataProcessor";
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo*& f,
@ -78,7 +77,7 @@ DataProcessor::~DataProcessor() {
}
/** getters */
string DataProcessor::GetType(){
std::string DataProcessor::GetType(){
return TypeName;
}
@ -478,7 +477,7 @@ void DataProcessor::PadMissingPackets(char* buf) {
if (!nmissing)
break;
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << endl;
FILE_LOG(logDEBUG) << "padding for " << index << " for pnum: " << pnum << std::endl;
// missing packet
switch(myDetectorType) {

View File

@ -11,12 +11,11 @@
#include <iostream>
#include <errno.h>
using namespace std;
const string DataStreamer::TypeName = "DataStreamer";
const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable,
DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI*>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm) :
ThreadObject(ind),
runningFlag(0),
@ -24,7 +23,8 @@ DataStreamer::DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable,
fifo(f),
zmqSocket(0),
dynamicRange(dr),
shortFrameEnable(sEnable),
roi(r),
adcConfigured(-1),
fileIndex(fi),
flippedData(fd),
additionJsonHeader(ajh),
@ -51,7 +51,7 @@ DataStreamer::~DataStreamer() {
}
/** getters */
string DataStreamer::GetType(){
std::string DataStreamer::GetType(){
return TypeName;
}
@ -88,7 +88,9 @@ void DataStreamer::ResetParametersforNewMeasurement(char* fname){
delete [] completeBuffer;
completeBuffer = 0;
}
if (*shortFrameEnable >= 0) {
if (roi->size()) {
if (generalData->myDetectorType == GOTTHARD)
adcConfigured = generalData->GetAdcConfigured(index, *roi);
completeBuffer = new char[generalData->imageSizeComplete];
memset(completeBuffer, 0, generalData->imageSizeComplete);
}
@ -216,7 +218,7 @@ void DataStreamer::ProcessAnImage(char* buf) {
cprintf(RED,"Error: Could not send zmq header for fnum %lld and streamer %d\n",
(long long int) fnum, index);
memcpy(completeBuffer + ((generalData->imageSize)**shortFrameEnable), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured), buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header), (uint32_t)(*((uint32_t*)buf)) ); // new size possibly from callback
if (!zmqSocket->SendData(completeBuffer, generalData->imageSizeComplete))
cprintf(RED,"Error: Could not send zmq data for fnum %lld and streamer %d\n",
(long long int) fnum, index);

View File

@ -10,7 +10,6 @@
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
Fifo::Fifo(int ind, uint32_t fifoItemSize, uint32_t depth):

View File

@ -7,7 +7,6 @@
#include "File.h"
#include <iostream>
using namespace std;
File::File(int ind, uint32_t* maxf,
@ -35,28 +34,28 @@ File::File(int ind, uint32_t* maxf,
File::~File() {}
string File::GetCurrentFileName() {
std::string File::GetCurrentFileName() {
return currentFileName;
}
void File::PrintMembers() {
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << endl
<< "Index: " << index << endl
<< "Max Frames Per File: " << *maxFramesPerFile << endl
<< "Number of Detectors in x dir: " << numDetX << endl
<< "Number of Detectors in y dir: " << numDetY << endl
<< "File Name Prefix: " << fileNamePrefix << endl
<< "File Path: " << filePath << endl
<< "File Index: " << *fileIndex << endl
<< "Over Write Enable: " << *overWriteEnable << endl
FILE_LOG(logINFO) << "\nGeneral Writer Variables:" << std::endl
<< "Index: " << index << std::endl
<< "Max Frames Per File: " << *maxFramesPerFile << std::endl
<< "Number of Detectors in x dir: " << numDetX << std::endl
<< "Number of Detectors in y dir: " << numDetY << std::endl
<< "File Name Prefix: " << fileNamePrefix << std::endl
<< "File Path: " << filePath << std::endl
<< "File Index: " << *fileIndex << std::endl
<< "Over Write Enable: " << *overWriteEnable << std::endl
<< "Detector Index: " << *detIndex << endl
<< "Number of Units Per Detector: " << *numUnitsPerDetector << endl
<< "Number of Images in Acquisition: " << *numImages << endl
<< "Dynamic Range: " << *dynamicRange << endl
<< "UDP Port number: " << *udpPortNumber << endl
<< "Master File Name: " << masterFileName << endl
<< "Current File Name: " << currentFileName << endl
<< "Detector Index: " << *detIndex << std::endl
<< "Number of Units Per Detector: " << *numUnitsPerDetector << std::endl
<< "Number of Images in Acquisition: " << *numImages << std::endl
<< "Dynamic Range: " << *dynamicRange << std::endl
<< "UDP Port number: " << *udpPortNumber << std::endl
<< "Master File Name: " << masterFileName << std::endl
<< "Current File Name: " << currentFileName << std::endl
<< "Silent Mode: " << *silentMode;
}

View File

@ -11,8 +11,6 @@
#include <iomanip>
#include <libgen.h> //basename
#include <string.h>
using namespace std;
pthread_mutex_t HDF5File::Mutex = PTHREAD_MUTEX_INITIALIZER;

View File

@ -14,9 +14,8 @@
#include <iostream>
#include <errno.h>
#include <cstring>
using namespace std;
const string Listener::TypeName = "Listener";
const std::string Listener::TypeName = "Listener";
Listener::Listener(int ind, detectorType dtype, Fifo*& f, runStatus* s,
@ -74,7 +73,7 @@ Listener::~Listener() {
}
/** getters */
string Listener::GetType(){
std::string Listener::GetType(){
return TypeName;
}

View File

@ -7,13 +7,6 @@
#include <iostream>
#include <cstdio>
using namespace std;

View File

@ -9,7 +9,6 @@
#include <iostream>
#include <syscall.h>
using namespace std;

View File

@ -9,7 +9,6 @@
#include <sys/stat.h> // stat
#include <iostream>
#include <string.h>
using namespace std;
@ -82,7 +81,9 @@ void UDPBaseImplementation::initializeMembers(){
dataCompressionEnable = false;
//***acquisition parameters***
shortFrameEnable = -1;
for (std::vector<slsReceiverDefs::ROI*>::const_iterator it = roi.begin(); it != roi.end(); ++it)
delete(*it);
roi.clear();
frameToGuiFrequency = 0;
frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS;
dataStreamEnable = false;
@ -250,9 +251,9 @@ char *UDPBaseImplementation::getEthernetInterface() const{
/***acquisition parameters***/
int UDPBaseImplementation::getShortFrameEnable() const{
std::vector<slsReceiverDefs::ROI*> UDPBaseImplementation::getROI() const{
FILE_LOG(logDEBUG) << __AT__ << " starting";
return shortFrameEnable;
return roi;
}
uint32_t UDPBaseImplementation::getFrameToGuiFrequency() const{
@ -373,7 +374,7 @@ uint32_t UDPBaseImplementation::getActualUDPSocketBufferSize() const {
*************************************************************************/
/**initial parameters***/
void UDPBaseImplementation::configure(map<string, string> config_map){
void UDPBaseImplementation::configure(std::map<std::string, std::string> config_map){
FILE_LOG(logERROR) << __AT__ << " doing nothing...";
FILE_LOG(logERROR) << __AT__ << " must be overridden by child classes";
}
@ -541,11 +542,27 @@ void UDPBaseImplementation::setEthernetInterface(const char* c){
/***acquisition parameters***/
int UDPBaseImplementation::setShortFrameEnable(const int i){
int UDPBaseImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i){
FILE_LOG(logDEBUG) << __AT__ << " starting";
shortFrameEnable = i;
FILE_LOG(logINFO) << "Short Frame Enable: " << stringEnable(shortFrameEnable);
roi = i;
std::stringstream sstm;
sstm << "ROI: ";
if (!roi.size())
sstm << "0";
else {
for (unsigned int i = 0; i < roi.size(); ++i) {
sstm << "( " <<
roi[i]->xmin << ", " <<
roi[i]->xmax << ", " <<
roi[i]->ymin << ", " <<
roi[i]->ymax << " )";
}
}
std::string message = sstm.str();
FILE_LOG(logINFO) << message;
//overrridden child classes might return FAIL
return OK;
}

View File

@ -7,16 +7,14 @@
#include <iostream>
#include <string.h>
using namespace std;
#include "UDPInterface.h"
#include "UDPBaseImplementation.h"
#include "UDPStandardImplementation.h"
using namespace std;
UDPInterface * UDPInterface::create(string receiver_type){
UDPInterface * UDPInterface::create(std::string receiver_type){
if (receiver_type == "standard"){
FILE_LOG(logINFO) << "Starting " << receiver_type;

View File

@ -16,7 +16,6 @@
#include <cstring> //strcpy
#include <errno.h> //eperm
#include <fstream>
using namespace std;
/** cosntructor & destructor */
@ -33,16 +32,16 @@ UDPStandardImplementation::~UDPStandardImplementation() {
void UDPStandardImplementation::DeleteMembers() {
if (generalData) { delete generalData; generalData=0;}
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
delete(*it);
listener.clear();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
delete(*it);
dataProcessor.clear();
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it);
dataStreamer.clear();
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it);
fifo.clear();
}
@ -69,8 +68,8 @@ uint64_t UDPStandardImplementation::getTotalFramesCaught() const {
uint64_t sum = 0;
uint32_t flagsum = 0;
vector<DataProcessor*>::const_iterator it;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
std::vector<DataProcessor*>::const_iterator it;
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
flagsum += ((*it)->GetMeasurementStartedFlag() ? 1 : 0);
sum += (*it)->GetNumTotalFramesCaught();
}
@ -85,7 +84,7 @@ uint64_t UDPStandardImplementation::getFramesCaught() const {
uint64_t sum = 0;
uint32_t flagsum = 0;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
sum += (*it)->GetNumFramesCaught();
}
@ -100,7 +99,7 @@ int64_t UDPStandardImplementation::getAcquisitionIndex() const {
uint64_t sum = 0;
uint32_t flagsum = 0;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
flagsum += ((*it)->GetAcquisitionStartedFlag() ? 1 : 0);
sum += (*it)->GetActualProcessedAcquisitionIndex();
}
@ -120,7 +119,7 @@ int UDPStandardImplementation::setGapPixelsEnable(const bool b) {
// side effects
generalData->SetGapPixelsEnable(b, dynamicRange);
// to update npixelsx, npixelsy in file writer
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetPixelDimension();
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
@ -144,7 +143,7 @@ void UDPStandardImplementation::setFileFormat(const fileFormat f){
break;
}
//destroy file writer, set file format and create file writer
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetFileFormat(f);
FILE_LOG(logINFO) << "File Format:" << getFileFormatType(fileFormatType);
@ -168,35 +167,64 @@ void UDPStandardImplementation::setFileWriteEnable(const bool b){
int UDPStandardImplementation::setShortFrameEnable(const int i) {
int UDPStandardImplementation::setROI(const std::vector<slsReceiverDefs::ROI*> i) {
if (myDetectorType != GOTTHARD) {
cprintf(RED, "Error: Can not set short frame for this detector\n");
cprintf(RED, "Error: Can not set ROI for this detector\n");
return FAIL;
}
if (shortFrameEnable != i) {
shortFrameEnable = i;
if (generalData)
delete generalData;
if (i != -1)
generalData = new ShortGotthardData();
else
generalData = new GotthardData();
bool change = false;
if (roi.size() != i.size())
change = true;
else {
for (unsigned int iloop = 0; iloop < i.size(); ++iloop) {
if (
(roi[iloop]->xmin != i[iloop]->xmin) ||
(roi[iloop]->xmax != i[iloop]->xmax) ||
(roi[iloop]->ymin != i[iloop]->ymin) ||
(roi[iloop]->xmax != i[iloop]->xmax)) {
change = true;
break;
}
}
}
if (change) {
roi = i;
generalData->SetROI(i);
framesPerFile = generalData->maxFramesPerFile;
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
if (SetupFifoStructure() == FAIL)
return FAIL;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->SetGeneralData(generalData);
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetGeneralData(generalData);
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
(*it)->SetGeneralData(generalData);
}
FILE_LOG(logINFO) << "Short Frame Enable: " << shortFrameEnable;
std::stringstream sstm;
sstm << "ROI: ";
if (!roi.size())
sstm << "0";
else {
for (unsigned int i = 0; i < roi.size(); ++i) {
sstm << "( " <<
roi[i]->xmin << ", " <<
roi[i]->xmax << ", " <<
roi[i]->ymin << ", " <<
roi[i]->ymax << " )";
}
}
std::string message = sstm.str();
FILE_LOG(logINFO) << message;
return OK;
}
@ -216,21 +244,22 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
dataStreamEnable = enable;
//data sockets have to be created again as the client ones are
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it);
dataStreamer.clear();
if (enable) {
for ( int i = 0; i < numThreads; ++i ) {
try {
DataStreamer* s = new DataStreamer(i, fifo[i], &dynamicRange,
&shortFrameEnable, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
&roi, &fileIndex, flippedData, additionalJsonHeader, &silentMode);
dataStreamer.push_back(s);
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP);
}
catch(...) {
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
delete(*it);
dataStreamer.clear();
dataStreamEnable = false;
@ -269,7 +298,7 @@ int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
generalData->SetDynamicRange(i,tengigaEnable);
generalData->SetGapPixelsEnable(gapPixelsEnable, dynamicRange);
// to update npixelsx, npixelsy in file writer
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetPixelDimension();
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
@ -374,10 +403,10 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
}
catch (...) {
FILE_LOG(logERROR) << "Could not create listener/dataprocessor threads (index:" << i << ")";
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
delete(*it);
listener.clear();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
delete(*it);
dataProcessor.clear();
return FAIL;
@ -385,9 +414,9 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
}
//set up writer and callbacks
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->SetGeneralData(generalData);
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->SetGeneralData(generalData);
SetThreadPriorities();
@ -427,13 +456,13 @@ void UDPStandardImplementation::setDetectorPositionId(const int i){
void UDPStandardImplementation::resetAcquisitionCount() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->ResetParametersforNewAcquisition();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->ResetParametersforNewAcquisition();
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
(*it)->ResetParametersforNewAcquisition();
FILE_LOG(logINFO) << "Acquisition Count has been reset";
@ -498,10 +527,10 @@ void UDPStandardImplementation::stopReceiver(){
bool running = true;
while(running) {
running = false;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
if ((*it)->IsRunning())
running = true;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
if ((*it)->IsRunning())
running = true;
usleep(5000);
@ -512,8 +541,8 @@ void UDPStandardImplementation::stopReceiver(){
if (fileWriteEnable && fileFormatType == HDF5) {
uint64_t maxIndexCaught = 0;
bool anycaught = false;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
if((*it)->GetMeasurementStartedFlag())
anycaught = true;
}
@ -525,7 +554,7 @@ void UDPStandardImplementation::stopReceiver(){
running = true;
while(running) {
running = false;
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
if ((*it)->IsRunning())
running = true;
usleep(5000);
@ -575,7 +604,7 @@ void UDPStandardImplementation::startReadout(){
// wait for incoming delayed packets
//current packets caught
volatile int totalP = 0,prev=-1;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
totalP += (*it)->GetPacketsCaught();
//wait for all packets
@ -594,7 +623,7 @@ void UDPStandardImplementation::startReadout(){
prev = totalP;
totalP = 0;
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
totalP += (*it)->GetPacketsCaught();
#ifdef VERY_VERBOSE
cprintf(MAGENTA,"\tupdated: totalP:%d\n",totalP);
@ -613,7 +642,7 @@ void UDPStandardImplementation::startReadout(){
void UDPStandardImplementation::shutDownUDPSockets() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->ShutDownUDPSocket();
}
@ -622,9 +651,9 @@ void UDPStandardImplementation::shutDownUDPSockets() {
void UDPStandardImplementation::closeFiles() {
uint64_t maxIndexCaught = 0;
bool anycaught = false;
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it) {
(*it)->CloseFiles();
maxIndexCaught = max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
maxIndexCaught = std::max(maxIndexCaught, (*it)->GetProcessedMeasurementIndex());
if((*it)->GetMeasurementStartedFlag())
anycaught = true;
}
@ -640,7 +669,7 @@ int UDPStandardImplementation::setUDPSocketBufferSize(const uint32_t s) {
int UDPStandardImplementation::restreamStop() {
bool ret = OK;
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it) {
if ((*it)->RestreamStop() == FAIL)
ret = FAIL;
}
@ -660,14 +689,14 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
int max_back_log;
const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog";
{
ifstream proc_file(proc_file_name);
std::ifstream proc_file(proc_file_name);
proc_file >> max_back_log;
}
if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) {
ofstream proc_file(proc_file_name);
std::ofstream proc_file(proc_file_name);
if (proc_file.good()) {
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << endl;
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << std::endl;
cprintf(GREEN, "Max length of input packet queue "
"[/proc/sys/net/core/netdev_max_backlog] modified to %d\n",
MAX_SOCKET_INPUT_PACKET_QUEUE);
@ -683,13 +712,13 @@ void UDPStandardImplementation::SetLocalNetworkParameters() {
void UDPStandardImplementation::SetThreadPriorities() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it){
if ((*it)->SetThreadPriority(LISTENER_PRIORITY) == FAIL) {
FILE_LOG(logWARNING) << "Could not prioritize listener threads. (No Root Privileges?)";
return;
}
}
ostringstream osfn;
std::ostringstream osfn;
osfn << "Priorities set - "
"Listener:" << LISTENER_PRIORITY;
@ -701,7 +730,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
numberofJobs = 1;
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it);
fifo.clear();
for ( int i = 0; i < numThreads; i++ ) {
@ -714,7 +743,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
fifo.push_back(f);
} catch (...) {
cprintf(RED,"Error: Could not allocate memory for fifo structure of index %d\n", i);
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
for (std::vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
delete(*it);
fifo.clear();
return FAIL;
@ -733,15 +762,15 @@ int UDPStandardImplementation::SetupFifoStructure() {
void UDPStandardImplementation::ResetParametersforNewMeasurement() {
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
(*it)->ResetParametersforNewMeasurement();
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
(*it)->ResetParametersforNewMeasurement();
if (dataStreamEnable) {
char fnametostream[MAX_STR_LENGTH];
snprintf(fnametostream, MAX_STR_LENGTH, "%s/%s", filePath, fileName);
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
(*it)->ResetParametersforNewMeasurement(fnametostream);
}
}
@ -785,15 +814,15 @@ int UDPStandardImplementation::SetupWriter() {
void UDPStandardImplementation::StartRunning() {
//set running mask and post semaphore to start the inner loop in execution thread
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
for (std::vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it) {
(*it)->StartRunning();
(*it)->Continue();
}
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
for (std::vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it){
(*it)->StartRunning();
(*it)->Continue();
}
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
for (std::vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it){
(*it)->StartRunning();
(*it)->Continue();
}

View File

@ -16,7 +16,6 @@
#include <sys/wait.h> //wait
#include <unistd.h> //usleep
#include <syscall.h>
using namespace std;
bool keeprunning;

View File

@ -14,7 +14,6 @@
#include "slsReceiver.h"
#include "gitInfoReceiver.h"
using namespace std;
@ -22,9 +21,9 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
tcpipInterface (0) {
// options
map<string, string> configuration_map;
std::map<std::string, std::string> configuration_map;
int tcpip_port_no = 1954;
string fname = "";
std::string fname = "";
int64_t tempval = 0;
//parse command line for config
@ -68,28 +67,28 @@ slsReceiver::slsReceiver(int argc, char *argv[]):
case 'v':
tempval = GITREV;
tempval = (tempval <<32) | GITDATE;
cout << "SLS Receiver " << GITBRANCH << " (0x" << hex << tempval << ")" << endl;
throw exception();
std::cout << "SLS Receiver " << GITBRANCH << " (0x" << std::hex << tempval << ")" << std::endl;
throw std::exception();
case 'h':
default:
string help_message = "\n"
+ string(argv[0]) + "\n"
+ "Usage: " + string(argv[0]) + " [arguments]\n"
std::string help_message = "\n"
+ std::string(argv[0]) + "\n"
+ "Usage: " + std::string(argv[0]) + " [arguments]\n"
+ "Possible arguments are:\n"
+ "\t-f, --config <fname> : Loads config from file\n"
+ "\t-t, --rx_tcpport <port> : TCP Communication Port with client. \n"
+ "\t Default: 1954. Required for multiple \n"
+ "\t receivers\n\n";
FILE_LOG(logINFO) << help_message << endl;
throw exception();
FILE_LOG(logINFO) << help_message << std::endl;
throw std::exception();
}
}
if( !fname.empty() && read_config_file(fname, &tcpip_port_no, &configuration_map) == FAIL) {
throw exception();
throw std::exception();
}
// might throw an exception

View File

@ -17,7 +17,7 @@
#include <fstream>
#include <stdlib.h>
#include <syscall.h>
using namespace std;
#include <vector>
@ -140,7 +140,7 @@ void* slsReceiverTCPIPInterface::startTCPServerThread(void *this_pointer){
void slsReceiverTCPIPInterface::startTCPServer(){
cprintf(BLUE,"Created [ TCP server Tid: %ld ]\n", (long)syscall(SYS_gettid));
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << endl;
FILE_LOG(logINFO) << "SLS Receiver starting TCP Server on port " << portNumber << std::endl;
#ifdef VERYVERBOSE
FILE_LOG(logDEBUG5) << "Starting Receiver TCP Server";
@ -206,7 +206,7 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
case F_GET_RECEIVER_ID: return "F_GET_RECEIVER_ID";
case F_GET_RECEIVER_TYPE: return "F_GET_RECEIVER_TYPE";
case F_SEND_RECEIVER_DETHOSTNAME: return "F_SEND_RECEIVER_DETHOSTNAME";
case F_RECEIVER_SHORT_FRAME: return "F_RECEIVER_SHORT_FRAME";
case F_RECEIVER_SET_ROI: return "F_RECEIVER_SET_ROI";
case F_SETUP_RECEIVER_UDP: return "F_SETUP_RECEIVER_UDP";
case F_SET_RECEIVER_TIMER: return "F_SET_RECEIVER_TIMER";
case F_SET_RECEIVER_DYNAMIC_RANGE: return "F_SET_RECEIVER_DYNAMIC_RANGE";
@ -263,7 +263,7 @@ int slsReceiverTCPIPInterface::function_table(){
flist[F_GET_RECEIVER_ID] = &slsReceiverTCPIPInterface::get_id;
flist[F_GET_RECEIVER_TYPE] = &slsReceiverTCPIPInterface::set_detector_type;
flist[F_SEND_RECEIVER_DETHOSTNAME] = &slsReceiverTCPIPInterface::set_detector_hostname;
flist[F_RECEIVER_SHORT_FRAME] = &slsReceiverTCPIPInterface::set_short_frame;
flist[F_RECEIVER_SET_ROI] = &slsReceiverTCPIPInterface::set_roi;
flist[F_SETUP_RECEIVER_UDP] = &slsReceiverTCPIPInterface::setup_udp;
flist[F_SET_RECEIVER_TIMER] = &slsReceiverTCPIPInterface::set_timer;
flist[F_SET_RECEIVER_DYNAMIC_RANGE] = &slsReceiverTCPIPInterface::set_dynamic_range;
@ -535,7 +535,7 @@ int slsReceiverTCPIPInterface::set_port() {
sprintf(mess,"Port Number (%d) too low\n", p_number);
FILE_LOG(logERROR) << mess;
} else {
FILE_LOG(logINFO) << "set port to " << p_number <<endl;
FILE_LOG(logINFO) << "set port to " << p_number <<std::endl;
strcpy(oldLastClientIP, mySock->lastClientIP);
try {
@ -879,16 +879,24 @@ int slsReceiverTCPIPInterface::set_detector_hostname() {
int slsReceiverTCPIPInterface::set_short_frame() {
int slsReceiverTCPIPInterface::set_roi() {
ret = OK;
memset(mess, 0, sizeof(mess));
int index = 0;
int retval = -100;
int nroi = 0;
// receive arguments
if (mySock->ReceiveDataOnly(&index,sizeof(index)) < 0 )
if (mySock->ReceiveDataOnly(&nroi,sizeof(nroi)) < 0 )
return printSocketReadError();
std::vector <ROI*> roiLimits;
int iloop = 0;
for (iloop = 0; iloop < nroi; iloop++) {
ROI temp;
if ( mySock->ReceiveDataOnly(&temp,sizeof(ROI)) < 0 )
return printSocketReadError();
roiLimits.push_back(&temp);
}
//does not exist
if (myDetectorType != GOTTHARD)
functionNotImplemented();
@ -904,8 +912,8 @@ int slsReceiverTCPIPInterface::set_short_frame() {
else if (receiverBase->getStatus() != IDLE)
receiverNotIdle();
else {
receiverBase->setShortFrameEnable(index);
retval = receiverBase->getShortFrameEnable();
ret = receiverBase->setROI(roiLimits);
//retval = receiverBase->getROI();
}
#endif
}
@ -916,7 +924,6 @@ int slsReceiverTCPIPInterface::set_short_frame() {
mySock->SendDataOnly(&ret,sizeof(ret));
if (ret == FAIL)
mySock->SendDataOnly(mess,sizeof(mess));
mySock->SendDataOnly(&retval,sizeof(retval));
// return ok/fail
return ret;
@ -957,7 +964,7 @@ int slsReceiverTCPIPInterface::setup_udp(){
//setup udpip
//get ethernet interface or IP to listen to
FILE_LOG(logINFO) << "Receiver UDP IP: " << args[0];
string temp = genericSocket::ipToName(args[0]);
std::string temp = genericSocket::ipToName(args[0]);
if (temp == "none"){
ret = FAIL;
strcpy(mess, "Failed to get ethernet interface or IP\n");

View File

@ -11,20 +11,19 @@
#include "logger.h"
using namespace std;
int read_config_file(string fname, int *tcpip_port_no, map<string, string> * configuration_map ){
int read_config_file(std::string fname, int *tcpip_port_no, std::map<std::string, std::string> * configuration_map ){
ifstream infile;
string sLine,sargname, sargvalue;
std::ifstream infile;
std::string sLine,sargname, sargvalue;
int iline = 0;
int success = slsReceiverDefs::OK;
FILE_LOG(logINFO) << "config file name " << fname;
try {
infile.open(fname.c_str(), ios_base::in);
infile.open(fname.c_str(), std::ios_base::in);
} catch(...) {
FILE_LOG(logERROR) << "Could not open configuration file " << fname ;
success = slsReceiverDefs::FAIL;
@ -37,14 +36,14 @@ int read_config_file(string fname, int *tcpip_port_no, map<string, string> * con
//VERBOSE_PRINT(sLine);
if(sLine.find('#') != string::npos)
if(sLine.find('#') != std::string::npos)
continue;
else if(sLine.length()<2)
continue;
else{
istringstream sstr(sLine);
std::istringstream sstr(sLine);
//parameter name
if(sstr.good()){