mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
made default streamer to be the ip related to hostname, otherwise can be specified from the client, also made it compatible with chip test board detector now
This commit is contained in:
@ -100,9 +100,10 @@ class DataStreamer : private virtual slsReceiverDefs, public ThreadObject {
|
||||
* Creates Zmq Sockets
|
||||
* @param nunits pointer to number of theads/ units per detector
|
||||
* @param port streaming port start index
|
||||
* @param srcip streaming source ip
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int CreateZmqSockets(int* nunits, uint32_t port);
|
||||
int CreateZmqSockets(int* nunits, uint32_t port, const char* srcip);
|
||||
|
||||
/**
|
||||
* Shuts down and deletes Zmq Sockets
|
||||
|
@ -163,6 +163,14 @@ public:
|
||||
bprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* Setting packets per frame changes member variables
|
||||
* @param packets per frame
|
||||
*/
|
||||
virtual void SetPacketsPerFrame(uint32_t ppf) {
|
||||
bprintf(RED,"This is a generic function that should be overloaded by a derived class\n");
|
||||
};
|
||||
|
||||
/**
|
||||
* Print all variables
|
||||
*/
|
||||
@ -376,21 +384,35 @@ class Moench03Data : public GeneralData {
|
||||
|
||||
class JCTBData : public GeneralData {
|
||||
|
||||
|
||||
private:
|
||||
/** Structure of an jungfrau ctb packet header */
|
||||
typedef struct {
|
||||
unsigned char emptyHeader[6];
|
||||
unsigned char reserved[4];
|
||||
unsigned char packetNumber[1];
|
||||
unsigned char frameNumber[3];
|
||||
unsigned char bunchid[8];
|
||||
} jfrauctb_packet_header_t;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/** Bytes Per Adc */
|
||||
const static uint32_t bytesPerAdc = 2;
|
||||
|
||||
/** Constructor */
|
||||
JCTBData(){
|
||||
myDetectorType = slsReceiverDefs::JUNGFRAUCTB;
|
||||
nPixelsX = 32;
|
||||
nPixelsY = 128;
|
||||
nPixelsX = 32; //(256*4);
|
||||
nPixelsY = 128; //(256*2);
|
||||
headerSizeinPacket = 22;
|
||||
dataSize = 8192;
|
||||
packetSize = headerSizeinPacket + dataSize;
|
||||
packetsPerFrame = 1;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
frameIndexMask = 0xFFFFFF;
|
||||
maxFramesPerFile = JFCTB_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsReceiverDefs::sls_detector_header);
|
||||
defaultFifoDepth = 2500;
|
||||
@ -399,6 +421,46 @@ class JCTBData : public GeneralData {
|
||||
imageSize_Streamer = imageSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get Header Infomation (frame number, packet number)
|
||||
* @param index thread index for debugging purposes
|
||||
* @param packetData pointer to data
|
||||
* @param frameNumber frame number
|
||||
* @param packetNumber packet number
|
||||
*/
|
||||
virtual void GetHeaderInfo(int index, char* packetData, uint64_t& frameNumber, uint32_t& packetNumber) const {
|
||||
jfrauctb_packet_header_t* header = (jfrauctb_packet_header_t*)(packetData);
|
||||
frameNumber = (uint64_t)((*( (uint32_t*) header->frameNumber)) & frameIndexMask);
|
||||
packetNumber = (uint32_t)(*( (uint8_t*) header->packetNumber));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Header Infomation (frame number, packet number)
|
||||
* @param index thread index for debugging purposes
|
||||
* @param packetData pointer to data
|
||||
* @param dynamicRange dynamic range to assign subframenumber if 32 bit mode
|
||||
* @param frameNumber frame number * @param packetNumber packet number
|
||||
* @param subFrameNumber sub frame number if applicable
|
||||
* @param bunchId bunch id
|
||||
*/
|
||||
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
||||
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t& bunchId) const {
|
||||
subFrameNumber = -1;
|
||||
jfrauctb_packet_header_t* header = (jfrauctb_packet_header_t*)(packetData);
|
||||
frameNumber = (uint64_t)((*( (uint32_t*) header->frameNumber)) & frameIndexMask);
|
||||
packetNumber = (uint32_t)(*( (uint8_t*) header->packetNumber));
|
||||
bunchId = (*((uint64_t*) header->bunchid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting packets per frame changes member variables
|
||||
* @param packets per frame
|
||||
*/
|
||||
void SetPacketsPerFrame(uint32_t ppf) {
|
||||
packetsPerFrame = ppf;
|
||||
imageSize = dataSize*packetsPerFrame;
|
||||
};
|
||||
|
||||
/**
|
||||
* Print all variables
|
||||
*/
|
||||
|
@ -213,6 +213,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
uint64_t getNumberOfFrames() const;
|
||||
|
||||
/*
|
||||
* Get Number of Samples expected by receiver from detector (for chip test board only)
|
||||
* @return number of samples expected
|
||||
*/
|
||||
uint64_t getNumberofSamples() const;
|
||||
|
||||
/**
|
||||
* Get Dynamic Range or Number of Bits Per Pixel
|
||||
* @return dynamic range that is 4, 8, 16 or 32
|
||||
@ -253,6 +259,11 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
uint32_t getStreamingPort() const;
|
||||
|
||||
/**
|
||||
* Get streaming source ip
|
||||
* @return streaming source ip
|
||||
*/
|
||||
char *getStreamingSourceIP() const;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
@ -413,10 +424,16 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
* Set Number of Frames expected by receiver from detector
|
||||
* The data receiver status will change from running to idle when it gets this number of frames
|
||||
* @param i number of frames expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setNumberOfFrames(const uint64_t i);
|
||||
|
||||
/**
|
||||
* Set Number of Samples expected by receiver from detector
|
||||
* @param i number of Samples expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setNumberofSamples(const uint64_t i);
|
||||
|
||||
/**
|
||||
* Set Dynamic Range or Number of Bits Per Pixel
|
||||
* @param i dynamic range that is 4, 8, 16 or 32
|
||||
@ -529,6 +546,12 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
*/
|
||||
void setStreamingPort(const uint32_t i);
|
||||
|
||||
/**
|
||||
* Set streaming source ip
|
||||
* @param c streaming source ip
|
||||
*/
|
||||
void setStreamingSourceIP(const char* c);
|
||||
|
||||
//***callback functions***
|
||||
/**
|
||||
* Call back for start acquisition
|
||||
@ -598,6 +621,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
uint64_t subExpTime;
|
||||
/** Frame Number */
|
||||
uint64_t numberOfFrames;
|
||||
/** Samples Number */
|
||||
uint64_t numberOfSamples;
|
||||
/** Dynamic Range */
|
||||
uint32_t dynamicRange;
|
||||
/** Ten Giga Enable*/
|
||||
@ -652,7 +677,8 @@ class UDPBaseImplementation : protected virtual slsReceiverDefs, public UDPInter
|
||||
bool dataStreamEnable;
|
||||
/** streaming port */
|
||||
uint32_t streamingPort;
|
||||
|
||||
/** streaming port */
|
||||
char streamingSrcIP[MAX_STR_LENGTH];
|
||||
|
||||
//***callback parameters***
|
||||
/**
|
||||
|
@ -43,12 +43,14 @@ class UDPInterface {
|
||||
* -setAcquisitionPeriod
|
||||
* -setNumberOfFrames
|
||||
* -setAcquisitionTime
|
||||
* -setSubExpTime
|
||||
* -setSubExpTime (if eiger)
|
||||
* -setNumberofSamples (if chip test board)
|
||||
* -setDynamicRange
|
||||
* -setFlippedData
|
||||
* -setActivate
|
||||
* -setTenGigaEnable
|
||||
* -setFlippedData (if eiger)
|
||||
* -setActivate (if eiger)
|
||||
* -setTenGigaEnable (if eiger)
|
||||
* -setStreamingPort
|
||||
* -setStreamingSourceIP
|
||||
* -setDataStreamEnable
|
||||
*
|
||||
*
|
||||
@ -293,11 +295,17 @@ class UDPInterface {
|
||||
|
||||
/*
|
||||
* Get Number of Frames expected by receiver from detector
|
||||
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented)
|
||||
* @return number of frames expected
|
||||
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (for Leo? Not implemented)
|
||||
* @return number of samples expected
|
||||
*/
|
||||
virtual uint64_t getNumberOfFrames() const = 0;
|
||||
|
||||
/*
|
||||
* Get Number of Samples expected by receiver from detector (for chip test board only)
|
||||
* @return number of samples expected
|
||||
*/
|
||||
virtual uint64_t getNumberofSamples() const = 0;
|
||||
|
||||
/**
|
||||
* Get Dynamic Range or Number of Bits Per Pixel
|
||||
* @return dynamic range that is 4, 8, 16 or 32
|
||||
@ -337,6 +345,12 @@ class UDPInterface {
|
||||
*/
|
||||
virtual uint32_t getStreamingPort() const = 0;
|
||||
|
||||
/**
|
||||
* Get streaming source ip
|
||||
* @return streaming source ip
|
||||
*/
|
||||
virtual char *getStreamingSourceIP() const = 0;
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* Setters ***************************************************************
|
||||
@ -492,12 +506,19 @@ class UDPInterface {
|
||||
|
||||
/**
|
||||
* Set Number of Frames expected by receiver from detector
|
||||
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (Not implemented)
|
||||
* The data receiver status will change from running to idle when it gets this number of frames FIXME: (for Leo? Not implemented)
|
||||
* @param i number of frames expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setNumberOfFrames(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Number of Samples expected by receiver from detector
|
||||
* @param i number of Samples expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
virtual int setNumberofSamples(const uint64_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set Dynamic Range or Number of Bits Per Pixel
|
||||
* @param i dynamic range that is 4, 8, 16 or 32
|
||||
@ -610,6 +631,12 @@ class UDPInterface {
|
||||
*/
|
||||
virtual void setStreamingPort(const uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* Set streaming source ip
|
||||
* @param c streaming source ip
|
||||
*/
|
||||
virtual void setStreamingSourceIP(const char* c) = 0;
|
||||
|
||||
|
||||
//***callback functions***
|
||||
/**
|
||||
|
@ -80,6 +80,13 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
||||
*/
|
||||
int setDataStreamEnable(const bool enable);
|
||||
|
||||
/**
|
||||
* Set Number of Samples expected by receiver from detector
|
||||
* @param i number of Samples expected
|
||||
* @return OK or FAIL
|
||||
*/
|
||||
int setNumberofSamples(const uint64_t i);
|
||||
|
||||
/**
|
||||
* Set Dynamic Range or Number of Bits Per Pixel
|
||||
* @param i dynamic range that is 4, 8, 16 or 32
|
||||
@ -225,6 +232,9 @@ private:
|
||||
/** Number of Jobs */
|
||||
int numberofJobs;
|
||||
|
||||
/** Number of channels in roi for jungfrauctb */
|
||||
int nroichannels;
|
||||
|
||||
//** class objects ***
|
||||
/** General Data Properties */
|
||||
GeneralData* generalData;
|
||||
|
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "ansi.h"
|
||||
//#include "sls_receiver_defs.h"
|
||||
#include "sls_receiver_defs.h"
|
||||
|
||||
//#define ZMQ_DETAIL
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
#include <netdb.h> //gethostbyname()
|
||||
#include <arpa/inet.h> //inet_ntoa
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#include <string.h>
|
||||
#include <unistd.h> //usleep in some machines
|
||||
using namespace rapidjson;
|
||||
|
||||
#define DEFAULT_ZMQ_PORTNO 30001
|
||||
@ -56,6 +58,9 @@ public:
|
||||
|
||||
// construct address
|
||||
sprintf (serverAddress, "tcp://%s:%d", ip, portno);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE,"addres:%s\n",serverAddress);
|
||||
#endif
|
||||
|
||||
// create context
|
||||
contextDescriptor = zmq_ctx_new();
|
||||
@ -97,8 +102,10 @@ public:
|
||||
* Creates socket, context and connects to server
|
||||
* @param hostname hostname or ip of server
|
||||
* @param portnumber port number
|
||||
* @param ethip is the ip of the ethernet interface to stream zmq from.
|
||||
* If blank, it will get ip from "hostname -i", else stream to all interfaces
|
||||
*/
|
||||
ZmqSocket (const uint32_t portnumber):
|
||||
ZmqSocket (const uint32_t portnumber, const char *ethip=NULL):
|
||||
portno (portnumber),
|
||||
server (true),
|
||||
contextDescriptor (NULL),
|
||||
@ -113,16 +120,45 @@ public:
|
||||
if (socketDescriptor == NULL) {
|
||||
PrintError ();
|
||||
Close ();
|
||||
return;
|
||||
}
|
||||
|
||||
//Socket Options provided above
|
||||
|
||||
// construct address
|
||||
sprintf (serverAddress,"tcp://*:%d", portno);
|
||||
|
||||
// construct ip to stream from
|
||||
char ip[MAX_STR_LENGTH];
|
||||
memset(ip, 0, MAX_STR_LENGTH);
|
||||
|
||||
// if ethip pre-defined
|
||||
if (ethip != NULL)
|
||||
strcpy(ip,ethip);
|
||||
else {
|
||||
bool valid = false;
|
||||
FILE *sysFile = popen("hostname -i", "r");
|
||||
if (sysFile != NULL) {
|
||||
if (fgets(ip, MAX_STR_LENGTH, sysFile) != NULL) {
|
||||
sscanf(ip,"%s\n",ip);
|
||||
#ifdef VERBOSE
|
||||
cprintf(BLUE, "read ip:%s.\n",ip);
|
||||
#endif
|
||||
valid = true;
|
||||
pclose(sysFile);
|
||||
}
|
||||
}
|
||||
if(!valid)
|
||||
strcpy(ip,"*");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// construct addresss
|
||||
sprintf (serverAddress,"tcp://%s:%d", ip, portno);
|
||||
// bind address
|
||||
if (zmq_bind (socketDescriptor, serverAddress) < 0) {
|
||||
PrintError ();
|
||||
Close ();
|
||||
return;
|
||||
}
|
||||
|
||||
//sleep for a few milliseconds to allow a slow-joiner
|
||||
@ -313,7 +349,7 @@ public:
|
||||
* @returns 0 if error or end of acquisition, else 1
|
||||
*/
|
||||
int ReceiveHeader(const int index, uint64_t &acqIndex,
|
||||
uint64_t &frameIndex, uint32_t &subframeIndex, string &filename)
|
||||
uint64_t &frameIndex, uint32_t &subframeIndex, std::string &filename)
|
||||
{
|
||||
zmq_msg_t message;
|
||||
zmq_msg_init (&message);
|
||||
@ -389,7 +425,7 @@ public:
|
||||
* @returns true if successfull else false
|
||||
*/
|
||||
int ParseHeader(const int index, int length, zmq_msg_t& message, uint64_t &acqIndex,
|
||||
uint64_t &frameIndex, uint32_t &subframeIndex, string &filename, bool& dummy)
|
||||
uint64_t &frameIndex, uint32_t &subframeIndex, std::string &filename, bool& dummy)
|
||||
{
|
||||
|
||||
acqIndex = -1;
|
||||
@ -491,6 +527,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** Port Number */
|
||||
uint32_t portno;
|
||||
|
@ -45,3 +45,6 @@
|
||||
#define PROCESSOR_PRIORITY 70
|
||||
#define STREAMER_PRIORITY 10
|
||||
#define TCP_PRIORITY 10
|
||||
|
||||
//jctb
|
||||
#define DEFAULT_NROI_CHANNELS 32
|
||||
|
@ -264,6 +264,9 @@ class slsReceiverTCPIPInterface : private virtual slsReceiverDefs {
|
||||
/** set streaming port */
|
||||
int set_streaming_port();
|
||||
|
||||
/** set streaming source ip */
|
||||
int set_streaming_source_ip();
|
||||
|
||||
|
||||
|
||||
/** detector type */
|
||||
|
@ -61,6 +61,7 @@ enum recFuncs{
|
||||
F_SEND_RECEIVER_DETPOSID, /** < sets the detector position id in the reveiver */
|
||||
F_SEND_RECEIVER_MULTIDETSIZE, /** < sets the multi detector size to the receiver */
|
||||
F_SET_RECEIVER_STREAMING_PORT, /** < sets the receiver streaming port */
|
||||
F_RECEIVER_STREAMING_SRC_IP, /** < sets the receiver streaming source IP */
|
||||
/* Always append functions hereafter!!! */
|
||||
|
||||
|
||||
|
@ -154,10 +154,10 @@ int DataStreamer::SetThreadPriority(int priority) {
|
||||
}
|
||||
|
||||
|
||||
int DataStreamer::CreateZmqSockets(int* nunits, uint32_t port) {
|
||||
int DataStreamer::CreateZmqSockets(int* nunits, uint32_t port, const char* srcip) {
|
||||
uint32_t portnum = port + index;
|
||||
|
||||
zmqSocket = new ZmqSocket(portnum);
|
||||
zmqSocket = new ZmqSocket(portnum, (strlen(srcip)?srcip:NULL));
|
||||
if (zmqSocket->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket on port %d for Streamer %d\n", portnum, index);
|
||||
return FAIL;
|
||||
|
@ -47,6 +47,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
acquisitionTime = 0;
|
||||
subExpTime = 0;
|
||||
numberOfFrames = 0;
|
||||
numberOfSamples = 0;
|
||||
dynamicRange = 16;
|
||||
tengigaEnable = false;
|
||||
fifoDepth = 0;
|
||||
@ -80,6 +81,7 @@ void UDPBaseImplementation::initializeMembers(){
|
||||
frameToGuiTimerinMS = DEFAULT_STREAMING_TIMER_IN_MS;
|
||||
dataStreamEnable = false;
|
||||
streamingPort = 0;
|
||||
memset(streamingSrcIP, 0, sizeof(streamingSrcIP));
|
||||
}
|
||||
|
||||
UDPBaseImplementation::~UDPBaseImplementation(){}
|
||||
@ -197,6 +199,8 @@ uint64_t UDPBaseImplementation::getSubExpTime() const{ FILE_LOG(logDEBUG) << __A
|
||||
|
||||
uint64_t UDPBaseImplementation::getNumberOfFrames() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfFrames;}
|
||||
|
||||
uint64_t UDPBaseImplementation::getNumberofSamples() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return numberOfSamples;}
|
||||
|
||||
uint32_t UDPBaseImplementation::getDynamicRange() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return dynamicRange;}
|
||||
|
||||
bool UDPBaseImplementation::getTenGigaEnable() const{ FILE_LOG(logDEBUG) << __AT__ << " starting"; return tengigaEnable;}
|
||||
@ -210,6 +214,15 @@ int UDPBaseImplementation::getActivate() const{FILE_LOG(logDEBUG) << __AT__ << "
|
||||
|
||||
uint32_t UDPBaseImplementation::getStreamingPort() const{FILE_LOG(logDEBUG) << __AT__ << " starting"; return streamingPort;}
|
||||
|
||||
char *UDPBaseImplementation::getStreamingSourceIP() const{
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
char* output = new char[MAX_STR_LENGTH]();
|
||||
strcpy(output,streamingSrcIP);
|
||||
//freed by calling function
|
||||
return output;
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
* Setters ***************************************************************
|
||||
* They modify the local cache of configuration or detector parameters ***
|
||||
@ -435,6 +448,16 @@ int UDPBaseImplementation::setNumberOfFrames(const uint64_t i){
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setNumberofSamples(const uint64_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
numberOfSamples = i;
|
||||
FILE_LOG(logINFO) << "Number of Samples: " << numberOfSamples;
|
||||
|
||||
//overrridden child classes might return FAIL
|
||||
return OK;
|
||||
}
|
||||
|
||||
int UDPBaseImplementation::setDynamicRange(const uint32_t i){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
|
||||
@ -559,6 +582,12 @@ void UDPBaseImplementation::setStreamingPort(const uint32_t i) {
|
||||
FILE_LOG(logINFO) << "Streaming Port: " << streamingPort;
|
||||
}
|
||||
|
||||
void UDPBaseImplementation::setStreamingSourceIP(const char c[]){
|
||||
FILE_LOG(logDEBUG) << __AT__ << " starting";
|
||||
strcpy(streamingSrcIP, c);
|
||||
FILE_LOG(logINFO) << "Streaming Source IP: " << streamingSrcIP;
|
||||
}
|
||||
|
||||
|
||||
/***callback functions***/
|
||||
void UDPBaseImplementation::registerCallBackStartAcquisition(int (*func)(char*, char*, uint64_t, uint32_t, void*),void *arg){
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <cstdlib> //system
|
||||
#include <cstring> //strcpy
|
||||
#include <errno.h> //eperm
|
||||
#include <math.h> //ceil
|
||||
using namespace std;
|
||||
|
||||
|
||||
@ -54,6 +55,7 @@ void UDPStandardImplementation::InitializeMembers() {
|
||||
//*** receiver parameters ***
|
||||
numThreads = 1;
|
||||
numberofJobs = 1;
|
||||
nroichannels = 0;
|
||||
|
||||
//** class objects ***
|
||||
generalData = 0;
|
||||
@ -164,17 +166,6 @@ int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
||||
int UDPStandardImplementation::setFrameToGuiFrequency(const uint32_t freq) {
|
||||
if (frameToGuiFrequency != freq) {
|
||||
frameToGuiFrequency = freq;
|
||||
|
||||
/*//only the ones lisening to more than 1 frame at a time needs to change fifo structure
|
||||
switch (myDetectorType) {
|
||||
case GOTTHARD:
|
||||
case PROPIX:
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
FILE_LOG (logINFO) << "Frame to Gui Frequency: " << frameToGuiFrequency;
|
||||
return OK;
|
||||
@ -199,7 +190,7 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {\
|
||||
// check again
|
||||
if (streamingPort == 0)
|
||||
streamingPort = DEFAULT_ZMQ_PORTNO + (detID * ((myDetectorType == EIGER) ? 2 : 1) ); // multiplied by 2 as eiger has 2 ports
|
||||
if (dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort) == FAIL) {
|
||||
if (dataStreamer[i]->CreateZmqSockets(&numThreads, streamingPort, streamingSrcIP) == FAIL) {
|
||||
error = true;
|
||||
break;
|
||||
}
|
||||
@ -223,6 +214,25 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {\
|
||||
}
|
||||
|
||||
|
||||
|
||||
int UDPStandardImplementation::setNumberofSamples(const uint64_t i) {
|
||||
if (numberOfSamples != i) {
|
||||
numberOfSamples = i;
|
||||
|
||||
//side effects
|
||||
uint32_t ppf = ceil(double(2 * (nroichannels ? nroichannels : DEFAULT_NROI_CHANNELS) * numberOfSamples) / double(generalData->dataSize));
|
||||
generalData->SetPacketsPerFrame(ppf);
|
||||
|
||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||
if (SetupFifoStructure() == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
FILE_LOG (logINFO) << "Number of Samples: " << numberOfSamples;
|
||||
FILE_LOG (logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
int UDPStandardImplementation::setDynamicRange(const uint32_t i) {
|
||||
if (dynamicRange != i) {
|
||||
dynamicRange = i;
|
||||
|
@ -281,7 +281,8 @@ const char* slsReceiverTCPIPInterface::getFunctionName(enum recFuncs func) {
|
||||
case F_SET_RECEIVER_FILE_FORMAT: return "F_SET_RECEIVER_FILE_FORMAT";
|
||||
case F_SEND_RECEIVER_DETPOSID: return "F_SEND_RECEIVER_DETPOSID";
|
||||
case F_SEND_RECEIVER_MULTIDETSIZE: return "F_SEND_RECEIVER_MULTIDETSIZE";
|
||||
case F_SET_RECEIVER_STREAMING_PORT: return "F_SET_RECEIVER_STREAMING_PORT";
|
||||
case F_RECEIVER_STREAMING_SRC_IP: return "F_RECEIVER_STREAMING_SRC_IP";
|
||||
|
||||
default: return "Unknown Function";
|
||||
}
|
||||
}
|
||||
@ -328,6 +329,7 @@ int slsReceiverTCPIPInterface::function_table(){
|
||||
flist[F_SEND_RECEIVER_DETPOSID] = &slsReceiverTCPIPInterface::set_detector_posid;
|
||||
flist[F_SEND_RECEIVER_MULTIDETSIZE] = &slsReceiverTCPIPInterface::set_multi_detector_size;
|
||||
flist[F_SET_RECEIVER_STREAMING_PORT] = &slsReceiverTCPIPInterface::set_streaming_port;
|
||||
flist[F_RECEIVER_STREAMING_SRC_IP] = &slsReceiverTCPIPInterface::set_streaming_source_ip;
|
||||
#ifdef VERYVERBOSE
|
||||
for (int i = 0; i < NUM_REC_FUNCTIONS ; i++) {
|
||||
FILE_LOG(logINFO) << "function fnum: " << i << " (" << getFunctionName((enum recFuncs)i) << ") located at " << (unsigned int)flist[i];
|
||||
@ -681,6 +683,15 @@ int slsReceiverTCPIPInterface::send_update() {
|
||||
#endif
|
||||
mySock->SendDataOnly(&ind,sizeof(ind));
|
||||
|
||||
// streaming source ip
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
path = receiverBase->getStreamingSourceIP();
|
||||
#endif
|
||||
mySock->SendDataOnly(path,MAX_STR_LENGTH);
|
||||
if (path != NULL)
|
||||
delete[] path;
|
||||
|
||||
|
||||
if (!lockStatus)
|
||||
strcpy(mySock->lastClientIP,mySock->thisClientIP);
|
||||
|
||||
@ -997,6 +1008,15 @@ int slsReceiverTCPIPInterface::set_timer() {
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
receiverBase->setSubExpTime(index[1]);
|
||||
break;
|
||||
case SAMPLES_JCTB:
|
||||
if (myDetectorType != JUNGFRAUCTB) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]);
|
||||
FILE_LOG(logERROR) << "Warning: " << mess;
|
||||
break;
|
||||
}
|
||||
receiverBase->setNumberofSamples(index[1]);
|
||||
break;
|
||||
default:
|
||||
ret = FAIL;
|
||||
sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]);
|
||||
@ -1019,6 +1039,15 @@ int slsReceiverTCPIPInterface::set_timer() {
|
||||
case SUBFRAME_ACQUISITION_TIME:
|
||||
retval=receiverBase->getSubExpTime();
|
||||
break;
|
||||
case SAMPLES_JCTB:
|
||||
if (myDetectorType != JUNGFRAUCTB) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"This timer mode (%lld) does not exist for this receiver type\n", (long long int)index[0]);
|
||||
FILE_LOG(logERROR) << "Warning: " << mess;
|
||||
break;
|
||||
}
|
||||
retval=receiverBase->getNumberofSamples();
|
||||
break;
|
||||
default:
|
||||
ret = FAIL;
|
||||
sprintf(mess,"This timer mode (%lld) does not exist for receiver\n", (long long int)index[0]);
|
||||
@ -1404,7 +1433,8 @@ int slsReceiverTCPIPInterface::set_file_dir() {
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "file path:" << retval;
|
||||
if (retval != NULL)
|
||||
FILE_LOG(logDEBUG1) << "file path:" << retval;
|
||||
#endif
|
||||
|
||||
if (ret == OK && mySock->differentClients)
|
||||
@ -2366,3 +2396,54 @@ int slsReceiverTCPIPInterface::set_streaming_port() {
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int slsReceiverTCPIPInterface::set_streaming_source_ip() {
|
||||
ret = OK;
|
||||
memset(mess, 0, sizeof(mess));
|
||||
char arg[MAX_STR_LENGTH];
|
||||
memset(arg, 0, sizeof(arg));
|
||||
char* retval=NULL;
|
||||
|
||||
// receive arguments
|
||||
if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 )
|
||||
return printSocketReadError();
|
||||
|
||||
// execute action
|
||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||
if (receiverBase == NULL)
|
||||
invalidReceiverObject();
|
||||
else {
|
||||
// set
|
||||
if (mySock->differentClients && lockStatus)
|
||||
receiverlocked();
|
||||
else if (receiverBase->getStatus() != IDLE)
|
||||
receiverNotIdle();
|
||||
else {
|
||||
receiverBase->setStreamingSourceIP(arg);
|
||||
}
|
||||
|
||||
//get
|
||||
retval = receiverBase->getStreamingSourceIP();
|
||||
}
|
||||
#endif
|
||||
#ifdef VERYVERBOSE
|
||||
FILE_LOG(logDEBUG1) << "streaming source ip:" << retval;
|
||||
#endif
|
||||
|
||||
if (ret == OK && mySock->differentClients)
|
||||
ret = FORCE_UPDATE;
|
||||
|
||||
// send answer
|
||||
mySock->SendDataOnly(&ret,sizeof(ret));
|
||||
if (ret == FAIL)
|
||||
mySock->SendDataOnly(mess,sizeof(mess));
|
||||
mySock->SendDataOnly(retval,MAX_STR_LENGTH);
|
||||
delete[] retval;
|
||||
|
||||
|
||||
// return ok/fail
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user