mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-20 00:37:12 +02:00
rxr done WIP
This commit is contained in:
@ -95,7 +95,7 @@ void ClientInterface::startTCPServer() {
|
||||
}
|
||||
|
||||
if (receiver) {
|
||||
receiver->shutDownUDPSockets();
|
||||
receiver->shutDownUDPSocket();
|
||||
}
|
||||
LOG(logINFOBLUE) << "Exiting [ TCP server Tid: " << syscall(SYS_gettid) << "]";
|
||||
}
|
||||
@ -186,10 +186,8 @@ int ClientInterface::functionTable(){
|
||||
flist[F_SET_RECEIVER_QUAD] = &ClientInterface::set_quad_type;
|
||||
flist[F_SET_RECEIVER_READ_N_LINES] = &ClientInterface::set_read_n_lines;
|
||||
flist[F_SET_RECEIVER_UDP_IP] = &ClientInterface::set_udp_ip;
|
||||
flist[F_SET_RECEIVER_UDP_IP2] = &ClientInterface::set_udp_ip2;
|
||||
flist[F_SET_RECEIVER_UDP_PORT] = &ClientInterface::set_udp_port;
|
||||
flist[F_SET_RECEIVER_UDP_PORT2] = &ClientInterface::set_udp_port2;
|
||||
flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces;
|
||||
flist[F_SET_RECEIVER_NUM_INTERFACES] = &ClientInterface::set_num_interfaces;
|
||||
flist[F_RECEIVER_SET_ADC_MASK_10G] = &ClientInterface::set_adc_mask_10g;
|
||||
flist[F_RECEIVER_SET_NUM_COUNTERS] = &ClientInterface::set_num_counters;
|
||||
flist[F_INCREMENT_FILE_INDEX] = &ClientInterface::increment_file_index;
|
||||
@ -392,22 +390,24 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
impl()->setDetectorHostname(arg.hostname);
|
||||
|
||||
// udp setup
|
||||
sls::MacAddr retvals[2]; // primary interface.. only udpip, else udpip2
|
||||
if (arg.udp_dstmac == 0 && arg.udp_dstip != 0) {
|
||||
retvals[0] = setUdpIp(sls::IpAddr(arg.udp_dstip));
|
||||
}
|
||||
if (arg.udp_dstmac2 == 0 && arg.udp_dstip2 != 0) {
|
||||
retvals[1] = setUdpIp2(sls::IpAddr(arg.udp_dstip2));
|
||||
}
|
||||
impl()->setUDPPortNumber(arg.udp_dstport);
|
||||
impl()->setUDPPortNumber2(arg.udp_dstport2);
|
||||
if (myDetectorType == JUNGFRAU) {
|
||||
try {
|
||||
impl()->setNumberofUDPInterfaces(arg.udpInterfaces);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Failed to set number of interfaces to " +
|
||||
std::to_string(arg.udpInterfaces));
|
||||
impl()->setInterfaceId(arg.interfaceId);
|
||||
sls::MacAddr retval;
|
||||
if (arg.interfaceId == 0) {
|
||||
if (arg.udp_dstmac == 0 && arg.udp_dstip != 0) {
|
||||
retval = setUdpIp(sls::IpAddr(arg.udp_dstip));
|
||||
}
|
||||
impl()->setUDPPortNumber(arg.udp_dstport);
|
||||
} else {
|
||||
if (arg.udp_dstmac2 == 0 && arg.udp_dstip2 != 0) {
|
||||
retval = setUdpIp(sls::IpAddr(arg.udp_dstip2));
|
||||
}
|
||||
impl()->setUDPPortNumber(arg.udp_dstport2);
|
||||
}
|
||||
try {
|
||||
impl()->setNumberofUDPInterfaces(arg.udpInterfaces);
|
||||
} catch(const RuntimeError &e) {
|
||||
throw RuntimeError("Failed to set number of interfaces to " +
|
||||
std::to_string(arg.udpInterfaces));
|
||||
}
|
||||
impl()->setUDPSocketBufferSize(0);
|
||||
|
||||
@ -509,7 +509,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
|
||||
}
|
||||
impl()->setStreamingSourceIP(ip);
|
||||
}
|
||||
return socket.sendResult(retvals);
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
void ClientInterface::setDetectorType(detectorType arg) {
|
||||
@ -532,6 +532,7 @@ void ClientInterface::setDetectorType(detectorType arg) {
|
||||
receiver = sls::make_unique<Implementation>(arg);
|
||||
myDetectorType = arg;
|
||||
} catch (...) {
|
||||
receiver.reset();
|
||||
throw RuntimeError("Could not set detector type");
|
||||
}
|
||||
|
||||
@ -904,15 +905,9 @@ int ClientInterface::get_frame_index(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::get_missing_packets(Interface &socket) {
|
||||
std::vector<uint64_t> m = impl()->getNumMissingPackets();
|
||||
LOG(logDEBUG1) << "missing packets:" << sls::ToString(m);
|
||||
int retvalsize = m.size();
|
||||
uint64_t retval[retvalsize];
|
||||
std::copy(std::begin(m), std::end(m), retval);
|
||||
socket.Send(OK);
|
||||
socket.Send(&retvalsize, sizeof(retvalsize));
|
||||
socket.Send(retval, sizeof(retval));
|
||||
return OK;
|
||||
uint64_t retval = impl()->getNumMissingPackets();
|
||||
LOG(logDEBUG1) << "missing packets:" << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::get_frames_caught(Interface &socket) {
|
||||
@ -1564,9 +1559,7 @@ sls::MacAddr ClientInterface::setUdpIp(sls::IpAddr arg) {
|
||||
LOG(logERROR) << "Failed to get udp ethernet interface from IP " << arg << ". Got " << eth;
|
||||
}
|
||||
impl()->setEthernetInterface(eth);
|
||||
if (myDetectorType == EIGER) {
|
||||
impl()->setEthernetInterface2(eth);
|
||||
}
|
||||
|
||||
// get mac address
|
||||
auto retval = sls::InterfaceNameToMac(eth);
|
||||
if (retval == 0) {
|
||||
@ -1584,38 +1577,6 @@ int ClientInterface::set_udp_ip(Interface &socket) {
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
sls::MacAddr ClientInterface::setUdpIp2(sls::IpAddr arg) {
|
||||
// getting eth
|
||||
std::string eth = sls::IpToInterfaceName(arg.str());
|
||||
if (eth == "none") {
|
||||
throw RuntimeError("Failed to get udp ethernet interface2 from IP " + arg.str());
|
||||
}
|
||||
if (eth.find('.') != std::string::npos) {
|
||||
eth = "";
|
||||
LOG(logERROR) << "Failed to get udp ethernet interface2 from IP " << arg << ". Got " << eth;
|
||||
}
|
||||
impl()->setEthernetInterface2(eth);
|
||||
|
||||
// get mac address
|
||||
auto retval = sls::InterfaceNameToMac(eth);
|
||||
if (retval == 0) {
|
||||
throw RuntimeError("Failed to get udp mac adddress2 to listen to (eth:" + eth + ", ip:" + arg.str() + ")\n");
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int ClientInterface::set_udp_ip2(Interface &socket) {
|
||||
auto arg = socket.Receive<sls::IpAddr>();
|
||||
verifyIdle(socket);
|
||||
if (myDetectorType != JUNGFRAU) {
|
||||
throw RuntimeError("UDP Destination IP2 not implemented for this detector");
|
||||
}
|
||||
LOG(logINFO) << "Received UDP IP2: " << arg;
|
||||
auto retval = setUdpIp2(arg);
|
||||
LOG(logINFO) << "Receiver MAC Address2: " << retval;
|
||||
return socket.sendResult(retval);
|
||||
}
|
||||
|
||||
int ClientInterface::set_udp_port(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
verifyIdle(socket);
|
||||
@ -1625,18 +1586,6 @@ int ClientInterface::set_udp_port(Interface &socket) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::set_udp_port2(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
verifyIdle(socket);
|
||||
if (myDetectorType != JUNGFRAU && myDetectorType != EIGER) {
|
||||
throw RuntimeError("UDP Destination Port2 not implemented for this detector");
|
||||
}
|
||||
LOG(logDEBUG1) << "Setting UDP Port:" << arg;
|
||||
impl()->setUDPPortNumber2(arg);
|
||||
socket.Send(OK);
|
||||
return OK;
|
||||
}
|
||||
|
||||
int ClientInterface::set_num_interfaces(Interface &socket) {
|
||||
auto arg = socket.Receive<int>();
|
||||
arg = (arg > 1 ? 2 : 1);
|
||||
|
@ -146,10 +146,7 @@ class ClientInterface : private virtual slsDetectorDefs {
|
||||
int set_read_n_lines(sls::ServerInterface &socket);
|
||||
sls::MacAddr setUdpIp(sls::IpAddr arg);
|
||||
int set_udp_ip(sls::ServerInterface &socket);
|
||||
sls::MacAddr setUdpIp2(sls::IpAddr arg);
|
||||
int set_udp_ip2(sls::ServerInterface &socket);
|
||||
int set_udp_port(sls::ServerInterface &socket);
|
||||
int set_udp_port2(sls::ServerInterface &socket);
|
||||
int set_num_interfaces(sls::ServerInterface &socket);
|
||||
int set_adc_mask_10g(sls::ServerInterface &socket);
|
||||
int set_num_counters(sls::ServerInterface &socket);
|
||||
|
@ -17,7 +17,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
|
||||
|
||||
|
||||
DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
uint64_t* fi, int fd, int* nd, bool* qe, uint64_t* tot) :
|
||||
uint64_t* fi, int fd, int* nr, bool* qe, uint64_t* tot) :
|
||||
ThreadObject(ind, TypeName),
|
||||
fifo(f),
|
||||
dynamicRange(dr),
|
||||
@ -27,8 +27,8 @@ DataStreamer::DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
quadEnable(qe),
|
||||
totalNumFrames(tot)
|
||||
{
|
||||
numDet[0] = nd[0];
|
||||
numDet[1] = nd[1];
|
||||
numRx[0] = nr[0];
|
||||
numRx[1] = nr[1];
|
||||
|
||||
LOG(logDEBUG) << "DataStreamer " << ind << " created";
|
||||
}
|
||||
@ -74,9 +74,9 @@ void DataStreamer::SetGeneralData(GeneralData* g) {
|
||||
generalData->Print();
|
||||
}
|
||||
|
||||
void DataStreamer::SetNumberofDetectors(int* nd) {
|
||||
numDet[0] = nd[0];
|
||||
numDet[1] = nd[1];
|
||||
void DataStreamer::SetReceiverShape(int* nr) {
|
||||
numRx[0] = nr[0];
|
||||
numRx[1] = nr[1];
|
||||
}
|
||||
|
||||
void DataStreamer::SetFlippedDataX(int fd) {
|
||||
@ -211,8 +211,8 @@ int DataStreamer::SendHeader(sls_receiver_header* rheader, uint32_t size, uint32
|
||||
|
||||
zHeader.dynamicRange = *dynamicRange;
|
||||
zHeader.fileIndex = *fileIndex;
|
||||
zHeader.ndetx = numDet[0];
|
||||
zHeader.ndety = numDet[1];
|
||||
zHeader.nSocketX = numRx[0];
|
||||
zHeader.nSocketY = numRx[1];
|
||||
zHeader.npixelsx = nx;
|
||||
zHeader.npixelsy = ny;
|
||||
zHeader.imageSize = size;
|
||||
|
@ -29,12 +29,12 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param r roi
|
||||
* @param fi pointer to file index
|
||||
* @param fd flipped data enable for x dimension
|
||||
* @param nd pointer to number of detectors in each dimension
|
||||
* @param nd pointer to number of receivers in each dimension
|
||||
* @param qe pointer to quad Enable
|
||||
* @param tot pointer to total number of frames
|
||||
*/
|
||||
DataStreamer(int ind, Fifo* f, uint32_t* dr, ROI* r,
|
||||
uint64_t* fi, int fd, int* nd, bool* qe, uint64_t* tot);
|
||||
uint64_t* fi, int fd, int* nr, bool* qe, uint64_t* tot);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -60,10 +60,10 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void SetGeneralData(GeneralData* g);
|
||||
|
||||
/**
|
||||
* Set number of detectors
|
||||
* @param number of detectors in both dimensions
|
||||
* Set receiver shape
|
||||
* @param number of receivers in both dimensions
|
||||
*/
|
||||
void SetNumberofDetectors(int* nd);
|
||||
void SetReceiverShape(int* nr);
|
||||
|
||||
/**
|
||||
* Set Flipped data enable across x dimension
|
||||
@ -178,8 +178,8 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
|
||||
/** Complete buffer used for roi, eg. shortGotthard */
|
||||
char* completeBuffer{nullptr};
|
||||
|
||||
/** Number of Detectors in X and Y dimension */
|
||||
int numDet[2];
|
||||
/** Number of Recievers in X and Y dimension */
|
||||
int numRx[2];
|
||||
|
||||
/** Quad Enable */
|
||||
bool* quadEnable;
|
||||
|
@ -64,9 +64,6 @@ public:
|
||||
/** Default Fifo depth */
|
||||
uint32_t defaultFifoDepth;
|
||||
|
||||
/** Threads per receiver */
|
||||
uint32_t threadsPerReceiver;
|
||||
|
||||
/** Size of a header packet */
|
||||
uint32_t headerPacketSize;
|
||||
|
||||
@ -105,7 +102,6 @@ public:
|
||||
maxFramesPerFile(0),
|
||||
fifoBufferHeaderSize(0),
|
||||
defaultFifoDepth(0),
|
||||
threadsPerReceiver(1),
|
||||
headerPacketSize(0),
|
||||
nPixelsXComplete(0),
|
||||
nPixelsYComplete(0),
|
||||
@ -233,7 +229,6 @@ public:
|
||||
LOG(level) << "Max Frames Per File: " << maxFramesPerFile;
|
||||
LOG(level) << "Fifo Buffer Header Size: " << fifoBufferHeaderSize;
|
||||
LOG(level) << "Default Fifo Depth: " << defaultFifoDepth;
|
||||
LOG(level) << "Threads Per Receiver: " << threadsPerReceiver;
|
||||
LOG(level) << "Header Packet Size: " << headerPacketSize;
|
||||
LOG(level) << "Complete Pixels X: " << nPixelsXComplete;
|
||||
LOG(level) << "Complete Pixels Y: " << nPixelsYComplete;
|
||||
@ -415,7 +410,6 @@ class EigerData : public GeneralData {
|
||||
maxFramesPerFile = EIGER_MAX_FRAMES_PER_FILE;
|
||||
fifoBufferHeaderSize= FIFO_HEADER_NUMBYTES + sizeof(slsDetectorDefs::sls_receiver_header);
|
||||
defaultFifoDepth = 1000;
|
||||
threadsPerReceiver = 2;
|
||||
headerPacketSize = 40;
|
||||
standardheader = true;
|
||||
};
|
||||
@ -479,7 +473,6 @@ class JungfrauData : public GeneralData {
|
||||
nPixelsY = 256;
|
||||
packetsPerFrame = 64;
|
||||
imageSize = dataSize * packetsPerFrame;
|
||||
threadsPerReceiver = 2;
|
||||
defaultUdpSocketBufferSize = (500 * 1024 * 1024);
|
||||
|
||||
}
|
||||
@ -488,7 +481,6 @@ class JungfrauData : public GeneralData {
|
||||
nPixelsY = 512;
|
||||
packetsPerFrame = 128;
|
||||
imageSize = dataSize * packetsPerFrame;
|
||||
threadsPerReceiver = 1;
|
||||
defaultUdpSocketBufferSize = (1000 * 1024 * 1024);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -76,12 +76,12 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
uint64_t getFramesCaught() const;
|
||||
uint64_t getAcquisitionIndex() const;
|
||||
int getProgress() const;
|
||||
std::vector<uint64_t> getNumMissingPackets() const;
|
||||
uint64_t getNumMissingPackets() const;
|
||||
void startReceiver();
|
||||
void setStoppedFlag(bool stopped);
|
||||
void stopReceiver();
|
||||
void startReadout();
|
||||
void shutDownUDPSockets();
|
||||
void shutDownUDPSocket();
|
||||
void closeFiles();
|
||||
void restreamStop();
|
||||
|
||||
@ -91,19 +91,15 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* Network Configuration (UDP) *
|
||||
* *
|
||||
* ************************************************/
|
||||
int getInterfaceId() const;
|
||||
void setInterfaceId(const int value);
|
||||
int getNumberofUDPInterfaces() const;
|
||||
/* [Jungfrau] */
|
||||
void setNumberofUDPInterfaces(const int n);
|
||||
std::string getEthernetInterface() const;
|
||||
void setEthernetInterface(const std::string &c);
|
||||
std::string getEthernetInterface2() const;
|
||||
/* [Jungfrau] */
|
||||
void setEthernetInterface2(const std::string &c);
|
||||
uint32_t getUDPPortNumber() const;
|
||||
void setUDPPortNumber(const uint32_t i);
|
||||
uint32_t getUDPPortNumber2() const;
|
||||
/* [Eiger][Jungfrau] */
|
||||
void setUDPPortNumber2(const uint32_t i);
|
||||
int64_t getUDPSocketBufferSize() const;
|
||||
void setUDPSocketBufferSize(const int64_t s);
|
||||
int64_t getActualUDPSocketBufferSize() const;
|
||||
@ -226,7 +222,7 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
void SetupFifoStructure();
|
||||
|
||||
void ResetParametersforNewAcquisition();
|
||||
void CreateUDPSockets();
|
||||
void CreateUDPSocket();
|
||||
void SetupWriter();
|
||||
void StartRunning();
|
||||
|
||||
@ -238,9 +234,9 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
* ************************************************/
|
||||
|
||||
// config parameters
|
||||
int numThreads;
|
||||
detectorType myDetectorType;
|
||||
int numDet[MAX_DIMENSIONS];
|
||||
int numRx[MAX_DIMENSIONS];
|
||||
int detID;
|
||||
std::string detHostname;
|
||||
bool silentMode;
|
||||
@ -263,9 +259,10 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
bool stoppedFlag;
|
||||
|
||||
// network configuration (UDP)
|
||||
int interfaceId;
|
||||
int numUDPInterfaces;
|
||||
std::vector <std::string> eth;
|
||||
std::vector <uint32_t> udpPortNum;
|
||||
std::string eth;
|
||||
uint32_t udpPortNum;
|
||||
int64_t udpSocketBufferSize;
|
||||
int64_t actualUDPSocketBufferSize;
|
||||
|
||||
@ -318,8 +315,8 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
|
||||
// class objects
|
||||
GeneralData *generalData;
|
||||
std::vector<std::unique_ptr<Listener>> listener;
|
||||
std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
|
||||
std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
|
||||
std::vector<std::unique_ptr<Fifo>> fifo;
|
||||
std::unique_ptr<Listener> listener;
|
||||
std::unique_ptr<DataProcessor> dataProcessor;
|
||||
std::unique_ptr<DataStreamer> dataStreamer;
|
||||
std::unique_ptr<Fifo> fifo;
|
||||
};
|
||||
|
@ -112,7 +112,7 @@ void Listener::SetGeneralData(GeneralData* g) {
|
||||
}
|
||||
|
||||
|
||||
void Listener::CreateUDPSockets() {
|
||||
void Listener::CreateUDPSocket() {
|
||||
if (!(*activated)) {
|
||||
return;
|
||||
}
|
||||
|
@ -83,9 +83,9 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
void SetGeneralData(GeneralData* g);
|
||||
|
||||
/**
|
||||
* Creates UDP Sockets
|
||||
* Creates UDP Socket
|
||||
*/
|
||||
void CreateUDPSockets();
|
||||
void CreateUDPSocket();
|
||||
|
||||
/**
|
||||
* Shuts down and deletes UDP Sockets
|
||||
|
Reference in New Issue
Block a user