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);