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

@@ -14,7 +14,6 @@
#include <string>
#include <iomanip>
#include <string.h>
using namespace std;
#define MAX_MASTER_FILE_LENGTH 2000
@@ -44,10 +43,10 @@ class BinaryFileStatic {
static std::string CreateFileName(char* fpath, char* fnameprefix, uint64_t findex, bool frindexenable,
uint64_t fnum = 0, int dindex = -1, int numunits = 1, int unitindex = 0)
{
ostringstream osfn;
std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix;
if (dindex >= 0) osfn << "_d" << (dindex * numunits + unitindex);
if (frindexenable) osfn << "_f" << setfill('0') << setw(12) << fnum;
if (frindexenable) osfn << "_f" << std::setfill('0') << std::setw(12) << fnum;
osfn << "_" << findex;
osfn << ".raw";
return osfn.str();
@@ -60,9 +59,9 @@ class BinaryFileStatic {
* @param findex file index
* @returns master file name
*/
string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
std::string CreateMasterFileName(char* fpath, char* fnameprefix, uint64_t findex)
{
ostringstream osfn;
std::ostringstream osfn;
osfn << fpath << "/" << fnameprefix;
osfn << "_master";
osfn << "_" << findex;
@@ -115,7 +114,7 @@ class BinaryFileStatic {
* @param version version of software for binary writing
* @returns 0 for success and 1 for fail
*/
static int CreateMasterDataFile(FILE*& fd, string fname, bool owenable,
static int CreateMasterDataFile(FILE*& fd, std::string fname, bool owenable,
uint32_t dr, bool tenE, uint32_t size,
uint32_t nPixelsX, uint32_t nPixelsY, uint64_t nf,
uint32_t maxf,

View File

@@ -14,6 +14,8 @@ class Fifo;
class DataStreamer;
class ZmqSocket;
#include <vector>
class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
public:
@@ -23,13 +25,13 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
* @param ind self index
* @param f address of Fifo pointer
* @param dr pointer to dynamic range
* @param sEnable pointer to short frame enable
* @param r roi
* @param fi pointer to file index
* @param fd flipped data enable for x and y dimensions
* @param ajh additional json header
* @param sm pointer to silent mode
*/
DataStreamer(int ind, Fifo*& f, uint32_t* dr, int* sEnable,
DataStreamer(int ind, Fifo*& f, uint32_t* dr, std::vector<ROI*>* r,
uint64_t* fi, int* fd, char* ajh, bool* sm);
/**
@@ -172,8 +174,11 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
/** Pointer to dynamic range */
uint32_t* dynamicRange;
/** Pointer to short frame enable */
int* shortFrameEnable;
/** ROI */
std::vector<ROI*>* roi;
/** adc Configured */
int adcConfigured;
/** Pointer to file index */
uint64_t* fileIndex;

View File

@@ -11,6 +11,7 @@
#include "receiver_defs.h"
#include <math.h> //ceil
#include <vector>
class GeneralData {
@@ -155,6 +156,25 @@ public:
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
}
/**
* Set ROI
* @param i ROI
*/
virtual void SetROI(std::vector<slsReceiverDefs::ROI*> i) {
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
};
/**
* Get Adc configured
* @param index thread index for debugging purposes
* @param i ROI
* @returns adc configured
*/
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI*> i) const{
cprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
return 0;
};
/**
* Setting dynamic range changes member variables
* @param dr dynamic range
@@ -225,6 +245,10 @@ public:
class GotthardData : public GeneralData {
private:
const static int nChip = 10;
const static int nChan = 128;
const static int nChipsPerAdc = 2;
public:
/** Constructor */
@@ -244,32 +268,8 @@ class GotthardData : public GeneralData {
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 50000;
};
};
class ShortGotthardData : public GeneralData {
public:
/** Constructor */
ShortGotthardData(){
myDetectorType = slsReceiverDefs::GOTTHARD;
nPixelsX = 256;
nPixelsY = 1;
headerSizeinPacket = 4;
dataSize = 512;
packetSize = 518;
packetsPerFrame = 1;
imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFF;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 50000;
nPixelsXComplete = 1280;
nPixelsYComplete = 1;
imageSizeComplete = 1280 * 2;
};
/**
* Get Header Infomation (frame number, packet number)
* @param index thread index for debugging purposes
@@ -279,8 +279,15 @@ class ShortGotthardData : public GeneralData {
*/
virtual void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const
{
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
packetNumber = 0;
if (nPixelsX == 1280) {
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++;
packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
} else {
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
packetNumber = 0;
}
}
/**
@@ -296,11 +303,96 @@ class ShortGotthardData : public GeneralData {
virtual void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const
{
subFrameNumber = -1;
bunchId = -1;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
packetNumber = 0;
if (nPixelsX == 1280) {
subFrameNumber = -1;
bunchId = -1;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
frameNumber++;
packetNumber = frameNumber&packetIndexMask;
frameNumber = (frameNumber & frameIndexMask) >> frameIndexOffset;
} else {
subFrameNumber = -1;
bunchId = -1;
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
packetNumber = 0;
}
}
/**
* Set ROI
* @param i ROI
*/
virtual void SetROI(std::vector<slsReceiverDefs::ROI*> i) {
// all adcs
if(!i.size()) {
nPixelsX = 1280;
dataSize = 1280;
packetSize = GOTTHARD_PACKET_SIZE;
packetsPerFrame = 2;
imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFE;
frameIndexOffset = 1;
packetIndexMask = 1;
maxFramesPerFile = MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 50000;
nPixelsXComplete = 0;
nPixelsYComplete = 0;
imageSizeComplete = 0;
}
// single adc
else {
nPixelsX = 256;
dataSize = 512;
packetSize = 518;
packetsPerFrame = 1;
imageSize = dataSize*packetsPerFrame;
frameIndexMask = 0xFFFFFFFF;
frameIndexOffset = 0;
packetIndexMask = 0;
maxFramesPerFile = SHORT_MAX_FRAMES_PER_FILE;
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_receiver_header);
defaultFifoDepth = 25000;
nPixelsXComplete = 1280;
nPixelsYComplete = 1;
imageSizeComplete = 1280 * 2;
}
};
/**
* Get Adc configured
* @param index thread index for debugging purposes
* @param i ROI
* @returns adc configured
*/
virtual const int GetAdcConfigured(int index, std::vector<slsReceiverDefs::ROI*> i) const{
int adc = -1;
// single adc
if(i.size()) {
// gotthard can have only one adc per detector enabled (or all)
// so just looking at the first roi is enough (more not possible at the moment)
//if its for 1 adc or general
if ((i[0]->xmin == 0) && (i[0]->xmax == nChip * nChan))
adc = -1;
else {
//adc = mid value/numchans also for only 1 roi
adc = ((((i[0]->xmax) + (i[0]->xmin))/2)/
(nChan * nChipsPerAdc));
if((adc < 0) || (adc > 4)) {
FILE_LOG(logWARNING) << index << ": Deleting ROI. "
"Adc value should be between 0 and 4";
adc = -1;
}
}
}
return adc;
};
};

View File

@@ -23,7 +23,6 @@ using namespace H5;
#include <stdlib.h> //malloc
#include <sstream>
#include <cstring> //memset
using namespace std;
class HDF5FileStatic: public virtual slsReceiverDefs {

View File

@@ -182,10 +182,10 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
//***acquisition parameters***
/**
* Get Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
* Get ROI
* @return index of adc enabled, else -1 if all enabled
*/
int getShortFrameEnable() const;
std::vector<ROI*> getROI() const;
/**
* Get the Frequency of Frames Sent to GUI
@@ -332,7 +332,7 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
* Configure command line parameters
* @param config_map mapping of config parameters passed from command line arguments
*/
void configure(map<string, string> config_map);
void configure(std::map<std::string, std::string> config_map);
/*
* Set multi detector size
@@ -448,11 +448,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
//***acquisition parameters***
/**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
* @param i index of adc enabled, else -1 if all enabled
* Set ROI
* @param i ROI
* @return OK or FAIL
*/
int setShortFrameEnable(const int i);
int setROI(const std::vector<ROI*> i);
/**
* Set the Frequency of Frames Sent to GUI
@@ -785,8 +785,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
bool dataCompressionEnable;
//***acquisition parameters***
/* Short Frame Enable or index of adc enabled, else -1 if all enabled (gotthard specific) TODO: move to setROI */
int shortFrameEnable;
/* ROI */
std::vector<ROI*> roi;
/** Frequency of Frames sent to GUI */
uint32_t frameToGuiFrequency;
/** Timer of Frames sent to GUI when frequency is 0 */

View File

@@ -11,13 +11,13 @@
* @short Base class with all the functions for the UDP inteface of the receiver
*/
#include <exception>
#include "sls_receiver_defs.h"
#include "receiver_defs.h"
#include "utilities.h"
#include "logger.h"
#include <exception>
#include <vector>
class UDPInterface {
@@ -54,6 +54,8 @@ class UDPInterface {
* -setStreamingSourceIP
* -setAdditionalJsonHeader
* -setDataStreamEnable
* -setROI
*
*
*
* supported sequence of method-calls:
@@ -114,7 +116,7 @@ class UDPInterface {
* @param [in] receiver_type type can be standard or custom (must be derived from base class)
* @return a UDPInterface reference to object depending on receiver type
*/
static UDPInterface *create(string receiver_type = "standard");
static UDPInterface *create(std::string receiver_type = "standard");
/**
* Destructor
@@ -271,10 +273,10 @@ class UDPInterface {
//***acquisition parameters***
/**
* Get Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
* Get ROI
* @return index of adc enabled, else -1 if all enabled
*/
virtual int getShortFrameEnable() const = 0;
virtual std::vector<slsReceiverDefs::ROI*> getROI() const = 0;
/**
* Get the Frequency of Frames Sent to GUI
@@ -420,7 +422,7 @@ class UDPInterface {
* Configure command line parameters
* @param config_map mapping of config parameters passed from command line arguments
*/
virtual void configure(map<string, string> config_map) = 0;
virtual void configure(std::map<std::string, std::string> config_map) = 0;
/*
* Set multi detector size
@@ -535,11 +537,11 @@ class UDPInterface {
//***acquisition parameters***
/**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
* @param i index of adc enabled, else -1 if all enabled
* Set ROI
* @param i ROI
* @return OK or FAIL
*/
virtual int setShortFrameEnable(const int i) = 0;
virtual int setROI(const std::vector<slsReceiverDefs::ROI*> i) = 0;
/**
* Set the Frequency of Frames Sent to GUI

View File

@@ -14,7 +14,6 @@ class DataProcessor;
class DataStreamer;
class Fifo;
#include <vector>
class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBaseImplementation {
@@ -74,11 +73,11 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
void setFileWriteEnable(const bool b);
/**
* Set Short Frame Enabled, later will be moved to getROI (so far only for gotthard)
* @param i index of adc enabled, else -1 if all enabled
* Set ROI
* @param i ROI
* @return OK or FAIL
*/
int setShortFrameEnable(const int i);
int setROI(const std::vector<ROI*> i);
/**
* Set the Frequency of Frames Sent to GUI

View File

@@ -11,7 +11,6 @@
#include <semaphore.h>
#include <vector>
#include <iostream>
using namespace std;
typedef double double32_t;
typedef float float32_t;
@@ -46,7 +45,7 @@ public:
int getFreeValue() const;
private:
vector <Element*> array;
std::vector <Element*> array;
unsigned int tail; // input index
unsigned int head; // output index
unsigned int Capacity;

View File

@@ -43,7 +43,7 @@ class sockaddr_in;
#include <errno.h>
#include <stdio.h>
#include "logger.h"
using namespace std;
#define DEFAULT_PACKET_SIZE 1286
#define SOCKET_BUFFER_SIZE (100*1024*1024) //100 MB
@@ -142,8 +142,8 @@ public:
strcpy(ip,"0.0.0.0");
clientAddress_length=sizeof(clientAddress);
if (eth) {
strcpy(ip,nameToIp(string(eth)).c_str());
if (string(ip)==string("0.0.0.0"))
strcpy(ip,nameToIp(std::string(eth)).c_str());
if (std::string(ip)==std::string("0.0.0.0"))
strcpy(ip,eth);
}
@@ -161,7 +161,7 @@ public:
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
if (string(ip)!=string("0.0.0.0")) {
if (std::string(ip)!=std::string("0.0.0.0")) {
if (inet_pton(AF_INET, ip, &(serverAddress.sin_addr)));
else
serverAddress.sin_addr.s_addr = htonl(INADDR_ANY);
@@ -493,7 +493,7 @@ public:
* @param ip IP
* @returns hostname
*/
static string ipToName(string ip) {
static std::string ipToName(std::string ip) {
struct ifaddrs *addrs, *iap;
struct sockaddr_in *sa;
@@ -507,7 +507,7 @@ public:
if (iap->ifa_addr && (iap->ifa_flags & IFF_UP) && iap->ifa_addr->sa_family == AF_INET) {
sa = (struct sockaddr_in *)(iap->ifa_addr);
inet_ntop(iap->ifa_addr->sa_family, (void *)&(sa->sin_addr), buf, buf_len);
if (ip==string(buf)) {
if (ip==std::string(buf)) {
//printf("%s\n", iap->ifa_name);
strcpy(buf,iap->ifa_name);
break;
@@ -515,7 +515,7 @@ public:
}
}
freeifaddrs(addrs);
return string(buf);
return std::string(buf);
};
/**
@@ -523,7 +523,7 @@ public:
* @param inf interface
* @returns mac address
*/
static string nameToMac(string inf) {
static std::string nameToMac(std::string inf) {
struct ifreq ifr;
int sock, j, k;
char mac[32];
@@ -534,7 +534,7 @@ public:
if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) {
perror("ioctl(SIOCGIFHWADDR) ");
return string("00:00:00:00:00:00");
return std::string("00:00:00:00:00:00");
}
for (j=0, k=0; j<6; j++) {
k+=snprintf(mac+k, mac_len-k-1, j ? ":%02X" : "%02X",
@@ -545,7 +545,7 @@ public:
if(sock!=1){
close(sock);
}
return string(mac);
return std::string(mac);
};
@@ -554,7 +554,7 @@ public:
* @param inf hostname
* @returns IP
*/
static string nameToIp(string inf){
static std::string nameToIp(std::string inf){
struct ifreq ifr;
int sock;
char *p, addr[32];
@@ -565,7 +565,7 @@ public:
if (-1==ioctl(sock, SIOCGIFADDR, &ifr)) {
perror("ioctl(SIOCGIFADDR) ");
return string("0.0.0.0");
return std::string("0.0.0.0");
}
p=inet_ntoa(((struct sockaddr_in *)(&ifr.ifr_addr))->sin_addr);
strncpy(addr,p,addr_len-1);
@@ -574,7 +574,7 @@ public:
if(sock!=1){
close(sock);
}
return string(addr);
return std::string(addr);
};
@@ -584,7 +584,7 @@ public:
* @param ifr interface request structure
* @returns sock
*/
static int getSock(string inf, struct ifreq *ifr) {
static int getSock(std::string inf, struct ifreq *ifr) {
int sock;
sock=socket(PF_INET, SOCK_STREAM, 0);

View File

@@ -24,13 +24,13 @@
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define MYCONCAT(x,y)
#define __AT__ string(__FILE__) + string("::") + string(__func__) + string("(): ")
#define __AT__ std::string(__FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")
#define __SHORT_FORM_OF_FILE__ \
(strrchr(__FILE__,'/') \
? strrchr(__FILE__,'/')+1 \
: __FILE__ \
)
#define __SHORT_AT__ string(__SHORT_FORM_OF_FILE__) + string("::") + string(__func__) + string("(): ")
#define __SHORT_AT__ std::string(__SHORT_FORM_OF_FILE__) + std::string("::") + std::string(__func__) + std::string("(): ")

View File

@@ -163,8 +163,8 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
/** set detector hostname */
int set_detector_hostname();
/** set short frame */
int set_short_frame();
/** set roi */
int set_roi();
/** Set up UDP Details */
int setup_udp();

View File

@@ -205,6 +205,19 @@ public:
};
/**
@short structure for a region of interest
xmin,xmax,ymin,ymax define the limits of the region
*/
typedef struct {
int xmin; /**< is the roi xmin (in channel number) */
int xmax; /**< is the roi xmax (in channel number)*/
int ymin; /**< is the roi ymin (in channel number)*/
int ymax; /**< is the roi ymax (in channel number)*/
} ROI ;
#ifdef __cplusplus
/** returns string from enabled/disabled
\param b true or false

View File

@@ -22,7 +22,7 @@ enum recFuncs{
F_SEND_RECEIVER_DETHOSTNAME, /**< set detector hostname to receiver */
//network functions
F_RECEIVER_SHORT_FRAME, /**< Sets receiver to receive short frames */
F_RECEIVER_SET_ROI, /**< Sets receiver ROI */
F_SETUP_RECEIVER_UDP, /**< sets the receiver udp connection and returns receiver mac address */
//Acquisition setup functions

View File

@@ -5,12 +5,11 @@
#include <iostream>
#include <map>
using namespace std;
#include "sls_receiver_defs.h"
/* uncomment next line to enable debug output */
//#define EIGER_DEBUG
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);

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()){