mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 18:40:42 +02:00
fnum wrong, need to add file features
This commit is contained in:
parent
d95aaa2089
commit
c89f6e649c
@ -12,7 +12,11 @@
|
|||||||
|
|
||||||
#include "ThreadObject.h"
|
#include "ThreadObject.h"
|
||||||
|
|
||||||
|
class GeneralData;
|
||||||
class Fifo;
|
class Fifo;
|
||||||
|
class FileWriter;
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
||||||
|
|
||||||
@ -21,8 +25,10 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofDataProcessors
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
|
* @param s pointer to receiver status
|
||||||
|
* @param m pointer to mutex for status
|
||||||
*/
|
*/
|
||||||
DataProcessor(Fifo*& f);
|
DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -49,6 +55,12 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
static bool GetMeasurementStartedFlag();
|
static bool GetMeasurementStartedFlag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set GeneralData pointer to the one given
|
||||||
|
* @param g address of GeneralData (Detector Data) pointer
|
||||||
|
*/
|
||||||
|
static void SetGeneralData(GeneralData*& g);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Total Complete Frames Caught for an entire acquisition (including all scans)
|
* Get Total Complete Frames Caught for an entire acquisition (including all scans)
|
||||||
* @return total number of frames caught for entire acquisition
|
* @return total number of frames caught for entire acquisition
|
||||||
@ -124,6 +136,13 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
void ThreadExecution();
|
void ThreadExecution();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees dummy buffer,
|
||||||
|
* reset running mask by calling StopRunning()
|
||||||
|
* @param buf address of pointer
|
||||||
|
*/
|
||||||
|
void StopProcessing(char* buf);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** type of thread */
|
/** type of thread */
|
||||||
@ -141,6 +160,9 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** mutex to update static items among objects (threads)*/
|
/** mutex to update static items among objects (threads)*/
|
||||||
static pthread_mutex_t Mutex;
|
static pthread_mutex_t Mutex;
|
||||||
|
|
||||||
|
/** GeneralData (Detector Data) object */
|
||||||
|
static const GeneralData* generalData;
|
||||||
|
|
||||||
/** Fifo structure */
|
/** Fifo structure */
|
||||||
Fifo* fifo;
|
Fifo* fifo;
|
||||||
|
|
||||||
@ -152,6 +174,12 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Measurement Started flag */
|
/** Measurement Started flag */
|
||||||
static bool measurementStartedFlag;
|
static bool measurementStartedFlag;
|
||||||
|
|
||||||
|
/** Receiver Status */
|
||||||
|
runStatus* status;
|
||||||
|
|
||||||
|
/** Status mutex */
|
||||||
|
pthread_mutex_t* statusMutex;
|
||||||
|
|
||||||
/**Number of complete frames caught for an entire acquisition (including all scans) */
|
/**Number of complete frames caught for an entire acquisition (including all scans) */
|
||||||
uint64_t numTotalFramesCaught;
|
uint64_t numTotalFramesCaught;
|
||||||
|
|
||||||
@ -167,6 +195,8 @@ class DataProcessor : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Frame Number of latest processed frame number of an entire Acquisition (including all scans) */
|
/** Frame Number of latest processed frame number of an entire Acquisition (including all scans) */
|
||||||
uint64_t currentFrameIndex;
|
uint64_t currentFrameIndex;
|
||||||
|
|
||||||
|
/** File writer implemented as binary or hdf5 filewriter */
|
||||||
|
std::vector <FileWriter*> fileWriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,10 +8,7 @@
|
|||||||
*@short abstract for setting/getting properties of detector data
|
*@short abstract for setting/getting properties of detector data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "receiver_defs.h"
|
||||||
typedef double double32_t;
|
|
||||||
typedef float float32_t;
|
|
||||||
typedef int int32_t;
|
|
||||||
|
|
||||||
|
|
||||||
class GeneralData {
|
class GeneralData {
|
||||||
@ -87,7 +84,7 @@ public:
|
|||||||
* @param bunchId bunch id
|
* @param bunchId bunch id
|
||||||
*/
|
*/
|
||||||
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
||||||
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) {
|
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) const {
|
||||||
subFrameNumber = 0;
|
subFrameNumber = 0;
|
||||||
bunchId = 0;
|
bunchId = 0;
|
||||||
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
frameNumber = ((uint32_t)(*((uint32_t*)(packetData))));
|
||||||
@ -113,6 +110,45 @@ public:
|
|||||||
virtual void SetTenGigaEnable(bool tgEnable, int dr) {
|
virtual void SetTenGigaEnable(bool tgEnable, int dr) {
|
||||||
//This is a generic function that is overloaded by a dervied class
|
//This is a generic function that is overloaded by a dervied class
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print all variables
|
||||||
|
*/
|
||||||
|
void Print() const {
|
||||||
|
printf("\n\nDetector Data Variables:\n");
|
||||||
|
printf( "Pixels X: %d\n"
|
||||||
|
"Pixels Y: %d\n"
|
||||||
|
"Data Size: %d\n"
|
||||||
|
"Packet Size: %d\n"
|
||||||
|
"Packets per Frame: %d\n"
|
||||||
|
"Image Size: %d\n"
|
||||||
|
"Frame Index Mask: 0x%llx\n"
|
||||||
|
"Frame Index Offset: %d\n"
|
||||||
|
"Packet Index Mask: 0x%x\n"
|
||||||
|
"Packet Index Offset: %d\n"
|
||||||
|
"Max Frames Per File: %d\n"
|
||||||
|
"Fifo Buffer Size: %d\n"
|
||||||
|
"Fifo Buffer Header Size: %d\n"
|
||||||
|
"Default Fifo Depth: %d\n"
|
||||||
|
"Threads Per Receiver: %d\n"
|
||||||
|
"Header Packet Size: %d\n",
|
||||||
|
nPixelsX,
|
||||||
|
nPixelsY,
|
||||||
|
dataSize,
|
||||||
|
packetSize,
|
||||||
|
packetsPerFrame,
|
||||||
|
imageSize,
|
||||||
|
(long long int)frameIndexMask,
|
||||||
|
frameIndexOffset,
|
||||||
|
packetIndexMask,
|
||||||
|
packetIndexOffset,
|
||||||
|
maxFramesPerFile,
|
||||||
|
fifoBufferSize,
|
||||||
|
fifoBufferHeaderSize,
|
||||||
|
defaultFifoDepth,
|
||||||
|
threadsPerReceiver,
|
||||||
|
headerPacketSize);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -211,6 +247,14 @@ class Moench02Data : public GeneralData {
|
|||||||
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print all variables
|
||||||
|
*/
|
||||||
|
void Print() const {
|
||||||
|
GeneralData::Print();
|
||||||
|
printf("Bytes Per Adc: %d\n",bytesPerAdc);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -237,6 +281,14 @@ class Moench03Data : public GeneralData {
|
|||||||
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print all variables
|
||||||
|
*/
|
||||||
|
void Print() const {
|
||||||
|
GeneralData::Print();
|
||||||
|
printf("Packet Header Size: %d\n",packetHeaderSize);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -260,6 +312,14 @@ class JCTBData : public GeneralData {
|
|||||||
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
|
fifoBufferHeaderSize= FIFO_BUFFER_HEADER_SIZE + FILE_FRAME_HEADER_SIZE;
|
||||||
defaultFifoDepth = 2500;
|
defaultFifoDepth = 2500;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print all variables
|
||||||
|
*/
|
||||||
|
void Print() const {
|
||||||
|
GeneralData::Print();
|
||||||
|
printf("Bytes Per Adc: %d\n",bytesPerAdc);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -306,13 +366,21 @@ private:
|
|||||||
* @param bunchId bunch id
|
* @param bunchId bunch id
|
||||||
*/
|
*/
|
||||||
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
||||||
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) {
|
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) const {
|
||||||
subFrameNumber = 0;
|
subFrameNumber = 0;
|
||||||
jfrau_packet_header_t* header = (jfrau_packet_header_t*)(packetData);
|
jfrau_packet_header_t* header = (jfrau_packet_header_t*)(packetData);
|
||||||
frameNumber = (uint64_t)(*( (uint32_t*) header->frameNumber));
|
frameNumber = (uint64_t)(*( (uint32_t*) header->frameNumber));
|
||||||
packetNumber = (uint32_t)(*( (uint8_t*) header->packetNumber));
|
packetNumber = (uint32_t)(*( (uint8_t*) header->packetNumber));
|
||||||
bunchId = (*((uint64_t*) header->bunchid));
|
bunchId = (*((uint64_t*) header->bunchid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print all variables
|
||||||
|
*/
|
||||||
|
void Print() const {
|
||||||
|
GeneralData::Print();
|
||||||
|
printf("Packet Header Size: %d\n",packetHeaderSize);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -370,7 +438,7 @@ private:
|
|||||||
* @param bunchId bunch id
|
* @param bunchId bunch id
|
||||||
*/
|
*/
|
||||||
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
void GetHeaderInfo(int index, char* packetData, uint32_t dynamicRange,
|
||||||
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) {
|
uint64_t& frameNumber, uint32_t& packetNumber, uint32_t& subFrameNumber, uint64_t bunchId) const {
|
||||||
bunchId = 0;
|
bunchId = 0;
|
||||||
subFrameNumber = 0;
|
subFrameNumber = 0;
|
||||||
eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(packetData + footerOffset);
|
eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(packetData + footerOffset);
|
||||||
@ -406,6 +474,17 @@ private:
|
|||||||
fifoBufferSize = packetSize*packetsPerFrame;
|
fifoBufferSize = packetSize*packetsPerFrame;
|
||||||
footerOffset = packetHeaderSize+dataSize;
|
footerOffset = packetHeaderSize+dataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print all variables
|
||||||
|
*/
|
||||||
|
void Print() const {
|
||||||
|
GeneralData::Print();
|
||||||
|
printf( "Packet Header Size: %d"
|
||||||
|
"Footer Offset : %d\n",
|
||||||
|
packetHeaderSize,
|
||||||
|
footerOffset);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "ThreadObject.h"
|
#include "ThreadObject.h"
|
||||||
|
|
||||||
|
class GeneralData;
|
||||||
class Fifo;
|
class Fifo;
|
||||||
class genericSocket;
|
class genericSocket;
|
||||||
|
|
||||||
@ -22,8 +23,10 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
* Constructor
|
* Constructor
|
||||||
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
* Calls Base Class CreateThread(), sets ErrorMask if error and increments NumberofListerners
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
|
* @param s pointer to receiver status
|
||||||
|
* @param portno pointer to udp port number
|
||||||
*/
|
*/
|
||||||
Listener(Fifo*& f);
|
Listener(Fifo*& f, runStatus* s, uint32_t* portno);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructor
|
* Destructor
|
||||||
@ -50,6 +53,12 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
static bool GetMeasurementStartedFlag();
|
static bool GetMeasurementStartedFlag();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set GeneralData pointer to the one given
|
||||||
|
* @param g address of GeneralData (Detector Data) pointer
|
||||||
|
*/
|
||||||
|
static void SetGeneralData(GeneralData*& g);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Total Packets caught in an acquisition
|
* Get Total Packets caught in an acquisition
|
||||||
* @return Total Packets caught in an acquisition
|
* @return Total Packets caught in an acquisition
|
||||||
@ -71,6 +80,7 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
void StopRunning();
|
void StopRunning();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Fifo pointer to the one given
|
* Set Fifo pointer to the one given
|
||||||
* @param f address of Fifo pointer
|
* @param f address of Fifo pointer
|
||||||
@ -89,13 +99,10 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates UDP Sockets
|
* Creates UDP Sockets
|
||||||
* @param portnumber udp port number
|
|
||||||
* @param packetSize size of one packet
|
|
||||||
* @param eth ethernet interface or null
|
* @param eth ethernet interface or null
|
||||||
* @param headerPacketSize size of a header packet
|
|
||||||
* @return OK or FAIL
|
* @return OK or FAIL
|
||||||
*/
|
*/
|
||||||
int CreateUDPSockets(uint32_t portnumber, uint32_t packetSize, const char* eth, uint32_t headerPacketSize);
|
int CreateUDPSockets(const char* eth);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shuts down and deletes UDP Sockets
|
* Shuts down and deletes UDP Sockets
|
||||||
@ -126,6 +133,14 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
*/
|
*/
|
||||||
void ThreadExecution();
|
void ThreadExecution();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pushes non empty buffers into fifo/ frees empty buffer,
|
||||||
|
* pushes dummy buffer into fifo
|
||||||
|
* and reset running mask by calling StopRunning()
|
||||||
|
* @param buf address of buffer
|
||||||
|
*/
|
||||||
|
void StopListening(char* buf);
|
||||||
|
|
||||||
|
|
||||||
/** type of thread */
|
/** type of thread */
|
||||||
static const std::string TypeName;
|
static const std::string TypeName;
|
||||||
@ -142,6 +157,9 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Mutex to update static items among objects (threads)*/
|
/** Mutex to update static items among objects (threads)*/
|
||||||
static pthread_mutex_t Mutex;
|
static pthread_mutex_t Mutex;
|
||||||
|
|
||||||
|
/** GeneralData (Detector Data) object */
|
||||||
|
static const GeneralData* generalData;
|
||||||
|
|
||||||
/** Fifo structure */
|
/** Fifo structure */
|
||||||
Fifo* fifo;
|
Fifo* fifo;
|
||||||
|
|
||||||
@ -153,6 +171,15 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Measurement Started flag */
|
/** Measurement Started flag */
|
||||||
static bool measurementStartedFlag;
|
static bool measurementStartedFlag;
|
||||||
|
|
||||||
|
/** Receiver Status */
|
||||||
|
runStatus* status;
|
||||||
|
|
||||||
|
/** UDP Sockets - Detector to Receiver */
|
||||||
|
genericSocket* udpSocket;
|
||||||
|
|
||||||
|
/** UDP Port Number */
|
||||||
|
uint32_t* udpPortNumber;
|
||||||
|
|
||||||
/**Number of complete Packets caught for an entire acquisition (including all scans) */
|
/**Number of complete Packets caught for an entire acquisition (including all scans) */
|
||||||
uint64_t numTotalPacketsCaught;
|
uint64_t numTotalPacketsCaught;
|
||||||
|
|
||||||
@ -165,8 +192,6 @@ class Listener : private virtual slsReceiverDefs, public ThreadObject {
|
|||||||
/** Frame Number of First Frame for each real time acquisition (eg. for each scan) */
|
/** Frame Number of First Frame for each real time acquisition (eg. for each scan) */
|
||||||
uint64_t firstMeasurementIndex;
|
uint64_t firstMeasurementIndex;
|
||||||
|
|
||||||
/** UDP Sockets - Detector to Receiver */
|
|
||||||
genericSocket* udpSocket;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -15,7 +15,6 @@ class Listener;
|
|||||||
class DataProcessor;
|
class DataProcessor;
|
||||||
class DataStreamer;
|
class DataStreamer;
|
||||||
class Fifo;
|
class Fifo;
|
||||||
class FileWriter;
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -179,6 +178,7 @@ class UDPStandardImplementation: private virtual slsReceiverDefs, public UDPBase
|
|||||||
*/
|
*/
|
||||||
void closeFiles();
|
void closeFiles();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,6 +243,10 @@ private:
|
|||||||
/** Number of Jobs */
|
/** Number of Jobs */
|
||||||
int numberofJobs;
|
int numberofJobs;
|
||||||
|
|
||||||
|
//*** mutex ***
|
||||||
|
/** Status mutex */
|
||||||
|
pthread_mutex_t statusMutex;
|
||||||
|
|
||||||
|
|
||||||
//** class objects ***
|
//** class objects ***
|
||||||
/** General Data Properties */
|
/** General Data Properties */
|
||||||
@ -260,8 +264,6 @@ private:
|
|||||||
/** Fifo Structure to store addresses of memory writes */
|
/** Fifo Structure to store addresses of memory writes */
|
||||||
std::vector <Fifo*> fifo;
|
std::vector <Fifo*> fifo;
|
||||||
|
|
||||||
/** File writer implemented as binary or hdf5 filewriter */
|
|
||||||
std::vector <FileWriter*> fileWriter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,7 +83,11 @@ using namespace std;
|
|||||||
#define DEFAULT_GUI_PORTNO 65000
|
#define DEFAULT_GUI_PORTNO 65000
|
||||||
#define DEFAULT_ZMQ_PORTNO 70001
|
#define DEFAULT_ZMQ_PORTNO 70001
|
||||||
|
|
||||||
|
/** Structure of an eiger packet footer */
|
||||||
|
typedef struct {
|
||||||
|
unsigned char frameNumber[6];
|
||||||
|
unsigned char packetNumber[2];
|
||||||
|
} eiger_packet_footer_t;
|
||||||
|
|
||||||
class genericSocket{
|
class genericSocket{
|
||||||
|
|
||||||
@ -619,11 +623,19 @@ enum communicationProtocol{
|
|||||||
while(length>0){
|
while(length>0){
|
||||||
nsending = (length>packet_size) ? packet_size:length;
|
nsending = (length>packet_size) ? packet_size:length;
|
||||||
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
|
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,nsending, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
|
||||||
|
cprintf(CYAN,"nsent:%d\n",nsent);
|
||||||
|
|
||||||
|
if(nsent == header_packet_size)
|
||||||
|
continue;
|
||||||
if(nsent != nsending){ //if((nsent != nsending)){ && (nsent < packet_size)){
|
if(nsent != nsending){ //if((nsent != nsending)){ && (nsent < packet_size)){
|
||||||
if(nsent && (nsent != header_packet_size) && (nsent != -1))
|
if(nsent && (nsent != -1))
|
||||||
cprintf(RED,"Incomplete Packet size %d\n",nsent);
|
cprintf(RED,"Incomplete Packet size %d\n",nsent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
eiger_packet_footer_t* footer = (eiger_packet_footer_t*)(buf + 1024+8);
|
||||||
|
cprintf(MAGENTA,"generic fnum:%lld, pnum:%d \n",
|
||||||
|
(long long int)(uint64_t)((*( (uint64_t*) footer)) ),
|
||||||
|
(uint32_t)(*( (uint16_t*) footer->packetNumber)));
|
||||||
length-=nsent;
|
length-=nsent;
|
||||||
total_sent+=nsent;
|
total_sent+=nsent;
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
#define SAMPLE_TIME_IN_NS 100000000//100ms
|
#define SAMPLE_TIME_IN_NS 100000000//100ms
|
||||||
#define MAX_JOBS_PER_THREAD 1000
|
#define MAX_JOBS_PER_THREAD 1000
|
||||||
|
|
||||||
#define DUMMY_PACKET_VALUE 0xFFFFFFFF;
|
|
||||||
|
#define DUMMY_PACKET_VALUE 0xFFFFFFFF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,12 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "DataProcessor.h"
|
#include "DataProcessor.h"
|
||||||
|
#include "GeneralData.h"
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
|
#include "BinaryFileWriter.h"
|
||||||
|
#ifdef HDF5C
|
||||||
|
#include "HDF5FileWriter.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -23,14 +28,18 @@ uint64_t DataProcessor::RunningMask(0x0);
|
|||||||
|
|
||||||
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t DataProcessor::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
const GeneralData* DataProcessor::generalData(0);
|
||||||
|
|
||||||
bool DataProcessor::acquisitionStartedFlag(false);
|
bool DataProcessor::acquisitionStartedFlag(false);
|
||||||
|
|
||||||
bool DataProcessor::measurementStartedFlag(false);
|
bool DataProcessor::measurementStartedFlag(false);
|
||||||
|
|
||||||
|
|
||||||
DataProcessor::DataProcessor(Fifo*& f) :
|
DataProcessor::DataProcessor(Fifo*& f, runStatus* s, pthread_mutex_t* m) :
|
||||||
ThreadObject(NumberofDataProcessors),
|
ThreadObject(NumberofDataProcessors),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
|
status(s),
|
||||||
|
statusMutex(m),
|
||||||
numTotalFramesCaught(0),
|
numTotalFramesCaught(0),
|
||||||
numFramesCaught(0),
|
numFramesCaught(0),
|
||||||
firstAcquisitionIndex(0),
|
firstAcquisitionIndex(0),
|
||||||
@ -51,8 +60,14 @@ DataProcessor::DataProcessor(Fifo*& f) :
|
|||||||
|
|
||||||
DataProcessor::~DataProcessor() {
|
DataProcessor::~DataProcessor() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
for (vector<FileWriter*>::const_iterator it = fileWriter.begin(); it != fileWriter.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
|
fileWriter.clear();
|
||||||
|
|
||||||
ThreadObject::DestroyThread();
|
ThreadObject::DestroyThread();
|
||||||
NumberofDataProcessors--;
|
NumberofDataProcessors--;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** static functions */
|
/** static functions */
|
||||||
@ -76,6 +91,15 @@ bool DataProcessor::GetMeasurementStartedFlag(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DataProcessor::SetGeneralData(GeneralData*& g) {
|
||||||
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
generalData = g;
|
||||||
|
#ifdef VERY_VERBOSE
|
||||||
|
generalData->Print();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** non static functions */
|
/** non static functions */
|
||||||
|
|
||||||
string DataProcessor::GetType(){
|
string DataProcessor::GetType(){
|
||||||
@ -163,25 +187,42 @@ void DataProcessor::ThreadExecution() {
|
|||||||
char* buffer=0;
|
char* buffer=0;
|
||||||
fifo->PopAddress(buffer);
|
fifo->PopAddress(buffer);
|
||||||
#ifdef FIFODEBUG
|
#ifdef FIFODEBUG
|
||||||
cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
if (!index) cprintf(BLUE,"DataProcessor %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
||||||
#endif
|
#endif
|
||||||
uint32_t numPackets = (uint32_t)(*((uint32_t*)buffer));
|
uint32_t numPackets = (uint32_t)(*((uint32_t*)buffer));
|
||||||
|
if (numPackets == DUMMY_PACKET_VALUE) {
|
||||||
if(numPackets == DUMMY_PACKET_VALUE){
|
StopProcessing(buffer);
|
||||||
cprintf(GREEN,"DataProcessing %d: Got dummy value*****\n");
|
|
||||||
StopRunning();
|
|
||||||
fifo->FreeAddress(buffer);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t fnum; uint32_t pnum; uint32_t snum; uint64_t bcid;
|
uint64_t fnum; uint32_t pnum; uint32_t snum; uint64_t bcid;
|
||||||
GetHeaderInfo(index,buffer+generalData->fifoBufferHeaderSize,16,fnum,pnum,snum,bcid);
|
generalData->GetHeaderInfo(index,buffer+generalData->fifoBufferHeaderSize,16,fnum,pnum,snum,bcid);
|
||||||
cprintf(GREEN,"DataProcessing %d: fnum:%lld, pnum:%d\n",(long long int)fnum, pnum);
|
if (!index) cprintf(BLUE,"DataProcessing %d: fnum:%lld, pnum:%d\n", index, (long long int)fnum, pnum);
|
||||||
|
|
||||||
fifo->FreeAddress(buffer);
|
fifo->FreeAddress(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void DataProcessor::StopProcessing(char* buf) {
|
||||||
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
cprintf(BLUE,"%d: End of Processing\n", index);
|
||||||
|
|
||||||
|
fifo->FreeAddress(buf);
|
||||||
|
StopRunning();
|
||||||
|
|
||||||
|
if (!index) {
|
||||||
|
while (RunningMask)
|
||||||
|
usleep(5000);
|
||||||
|
pthread_mutex_lock(statusMutex);
|
||||||
|
*status = RUN_FINISHED;
|
||||||
|
pthread_mutex_unlock((statusMutex));
|
||||||
|
FILE_LOG(logINFO) << "Status: " << runStatusType(*status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int DataProcessor::CreateNewFile() {
|
int DataProcessor::CreateNewFile() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
//create file fileWriter.push_back(new BinaryFileWriter(fileName))
|
//create file fileWriter.push_back(new BinaryFileWriter(fileName))
|
||||||
|
@ -26,6 +26,7 @@ Fifo::Fifo(uint32_t fifoItemSize, uint32_t fifoDepth, bool &success):
|
|||||||
|
|
||||||
Fifo::~Fifo() {
|
Fifo::~Fifo() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
cprintf(RED,"destroying fifos\n");
|
||||||
DestroyFifos();
|
DestroyFifos();
|
||||||
NumberofFifoClassObjects--;
|
NumberofFifoClassObjects--;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Listener.h"
|
#include "Listener.h"
|
||||||
|
#include "GeneralData.h"
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "genericSocket.h"
|
#include "genericSocket.h"
|
||||||
|
|
||||||
@ -24,13 +25,18 @@ uint64_t Listener::RunningMask(0x0);
|
|||||||
|
|
||||||
pthread_mutex_t Listener::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t Listener::Mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
|
const GeneralData* Listener::generalData(0);
|
||||||
|
|
||||||
bool Listener::acquisitionStartedFlag(false);
|
bool Listener::acquisitionStartedFlag(false);
|
||||||
|
|
||||||
bool Listener::measurementStartedFlag(false);
|
bool Listener::measurementStartedFlag(false);
|
||||||
|
|
||||||
Listener::Listener(Fifo*& f) :
|
Listener::Listener(Fifo*& f, runStatus* s, uint32_t* portno) :
|
||||||
ThreadObject(NumberofListeners),
|
ThreadObject(NumberofListeners),
|
||||||
fifo(f),
|
fifo(f),
|
||||||
|
status(s),
|
||||||
|
udpSocket(0),
|
||||||
|
udpPortNumber(portno),
|
||||||
numTotalPacketsCaught(0),
|
numTotalPacketsCaught(0),
|
||||||
numPacketsCaught(0),
|
numPacketsCaught(0),
|
||||||
firstAcquisitionIndex(0),
|
firstAcquisitionIndex(0),
|
||||||
@ -74,6 +80,14 @@ bool Listener::GetMeasurementStartedFlag(){
|
|||||||
return measurementStartedFlag;
|
return measurementStartedFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Listener::SetGeneralData(GeneralData*& g) {
|
||||||
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
generalData = g;
|
||||||
|
//#ifdef VERY_VERBOSE
|
||||||
|
generalData->Print();
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** non static functions */
|
/** non static functions */
|
||||||
|
|
||||||
@ -157,45 +171,90 @@ void Listener::ThreadExecution() {
|
|||||||
char* buffer;
|
char* buffer;
|
||||||
fifo->GetNewAddress(buffer);
|
fifo->GetNewAddress(buffer);
|
||||||
#ifdef FIFODEBUG
|
#ifdef FIFODEBUG
|
||||||
cprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
if (!index) cprintf(GREEN,"Listener %d, pop 0x%p buffer:%s\n", index,(void*)(buffer),buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int rc;
|
int rc = 0;
|
||||||
|
|
||||||
while ((rc>0 && rc < generalData->packetSize)) {
|
//udpsocket doesnt exist
|
||||||
rc = udpSocket->ReceiveDataOnly(buffer + generalData->fifoBufferHeaderSize,fifoBufferSize);
|
if (!udpSocket) {
|
||||||
cprintf(BLUE,"Listening %d: rc: %d\n",index,rc);
|
FILE_LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not created or shut down earlier";
|
||||||
uint64_t fnum; uint32_t pnum; uint32_t snum; uint64_t bcid;
|
(*((uint32_t*)buffer)) = 0;
|
||||||
GetHeaderInfo(index,buffer,16,fnum,pnum,snum,bcid);
|
StopListening(buffer);
|
||||||
cprintf(BLUE,"Listening %d: fnum:%lld, pnum:%d\n",(long long int)fnum, pnum);
|
return;
|
||||||
*((uint32_t*)(buffer[ithread])) = (rc/generalData->packetSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rc <=0 ){
|
//get data
|
||||||
cprintf(BLUE,"Listening %d: Gonna send dummy value*****\n");
|
if (*status != TRANSMITTING) {
|
||||||
(*((uint32_t*)buffer)) = DUMMY_PACKET_VALUE;
|
rc = udpSocket->ReceiveDataOnly(buffer + generalData->fifoBufferHeaderSize,generalData->fifoBufferSize);
|
||||||
StopRunning();
|
if (!index) cprintf(GREEN,"Listening %d: rc: %d\n",index,rc);
|
||||||
|
(*((uint32_t*)buffer)) = ((rc <= 0) ? 0 : rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//done acquiring
|
||||||
|
if (*status == TRANSMITTING) {
|
||||||
|
StopListening(buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t fnum; uint32_t pnum; uint32_t snum; uint64_t bcid=0;
|
||||||
|
generalData->GetHeaderInfo(index,buffer + generalData->fifoBufferHeaderSize,16,fnum,pnum,snum,bcid);
|
||||||
|
if (!index) cprintf(GREEN,"Listening %d: fnum:%lld, pnum:%d\n", index, (long long int)fnum, pnum);
|
||||||
|
|
||||||
|
//push into fifo
|
||||||
fifo->PushAddress(buffer);
|
fifo->PushAddress(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Listener::CreateUDPSockets(uint32_t portnumber, uint32_t packetSize, const char* eth, uint32_t headerPacketSize) {
|
|
||||||
|
void Listener::StopListening(char* buf) {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
udpSocket = new genericSocket(portnumber, genericSocket::UDP, packetSize, eth, headerPacketSize);
|
cprintf(BLUE,"%d: End of Listening\n", index);
|
||||||
|
|
||||||
|
uint32_t numPackets = (uint32_t)(*((uint32_t*)buf));
|
||||||
|
|
||||||
|
//incomplete packets
|
||||||
|
if (numPackets > 0) {
|
||||||
|
fifo->PushAddress(buf);
|
||||||
|
fifo->GetNewAddress(buf);
|
||||||
|
#ifdef FIFODEBUG
|
||||||
|
if (!index) cprintf(GREEN,"Listener %d, Got incomplete, for dummy: pop 0x%p buffer:%s\n", index,(void*)(buf),buf);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
//dummy
|
||||||
|
(*((uint32_t*)buf)) = DUMMY_PACKET_VALUE;
|
||||||
|
fifo->PushAddress(buf);
|
||||||
|
|
||||||
|
StopRunning();
|
||||||
|
|
||||||
|
//#ifdef DEBUG4
|
||||||
|
if (!index) FILE_LOG(logINFO) << "Listening Thread (" << *udpPortNumber << ")"
|
||||||
|
" Packets caught: " << numPacketsCaught;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int Listener::CreateUDPSockets(const char* eth) {
|
||||||
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
udpSocket = new genericSocket(*udpPortNumber, genericSocket::UDP,
|
||||||
|
generalData->packetSize, eth, generalData->headerPacketSize);
|
||||||
int iret = udpSocket->getErrorStatus();
|
int iret = udpSocket->getErrorStatus();
|
||||||
if(!iret){
|
if(!iret){
|
||||||
cout << "UDP port opened at port " << portnumber << endl;
|
cout << "UDP port opened at port " << *udpPortNumber << endl;
|
||||||
}else{
|
}else{
|
||||||
FILE_LOG(logERROR) << "Could not create UDP socket on port " << portnumber << " error: " << iret;
|
FILE_LOG(logERROR) << "Could not create UDP socket on port " << *udpPortNumber << " error: " << iret;
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Listener::ShutDownUDPSocket() {
|
void Listener::ShutDownUDPSocket() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
#include "DataProcessor.h"
|
#include "DataProcessor.h"
|
||||||
#include "DataStreamer.h"
|
#include "DataStreamer.h"
|
||||||
#include "Fifo.h"
|
#include "Fifo.h"
|
||||||
#include "BinaryFileWriter.h"
|
|
||||||
#ifdef HDF5C
|
|
||||||
#include "HDF5FileWriter.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstdlib> //system
|
#include <cstdlib> //system
|
||||||
#include <cstring> //strcpy
|
#include <cstring> //strcpy
|
||||||
@ -39,11 +35,18 @@ void UDPStandardImplementation::DeleteMembers() {
|
|||||||
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
FILE_LOG (logDEBUG) << __AT__ << " starting";
|
||||||
|
|
||||||
if (generalData) { delete generalData; generalData=0;}
|
if (generalData) { delete generalData; generalData=0;}
|
||||||
|
for (vector<Listener*>::const_iterator it = listener.begin(); it != listener.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
listener.clear();
|
listener.clear();
|
||||||
|
for (vector<DataProcessor*>::const_iterator it = dataProcessor.begin(); it != dataProcessor.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
dataProcessor.clear();
|
dataProcessor.clear();
|
||||||
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
dataStreamer.clear();
|
dataStreamer.clear();
|
||||||
|
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
fileWriter.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,13 +63,11 @@ void UDPStandardImplementation::InitializeMembers() {
|
|||||||
numThreads = 1;
|
numThreads = 1;
|
||||||
numberofJobs = 1;
|
numberofJobs = 1;
|
||||||
|
|
||||||
|
//*** mutex ***
|
||||||
|
pthread_mutex_init(&statusMutex,NULL);
|
||||||
|
|
||||||
//** class objects ***
|
//** class objects ***
|
||||||
generalData = 0;
|
generalData = 0;
|
||||||
listener.clear();
|
|
||||||
dataProcessor.clear();
|
|
||||||
dataStreamer.clear();
|
|
||||||
fifo.clear();
|
|
||||||
fileWriter.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -142,6 +143,9 @@ int UDPStandardImplementation::setShortFrameEnable(const int i) {
|
|||||||
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
numberofJobs = -1; //changes to imagesize has to be noted to recreate fifo structure
|
||||||
if (SetupFifoStructure() == FAIL)
|
if (SetupFifoStructure() == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|
||||||
|
Listener::SetGeneralData(generalData);
|
||||||
|
DataProcessor::SetGeneralData(generalData);
|
||||||
}
|
}
|
||||||
FILE_LOG (logINFO) << "Short Frame Enable: " << shortFrameEnable;
|
FILE_LOG (logINFO) << "Short Frame Enable: " << shortFrameEnable;
|
||||||
return OK;
|
return OK;
|
||||||
@ -177,14 +181,18 @@ int UDPStandardImplementation::setDataStreamEnable(const bool enable) {
|
|||||||
dataStreamEnable = enable;
|
dataStreamEnable = enable;
|
||||||
|
|
||||||
//data sockets have to be created again as the client ones are
|
//data sockets have to be created again as the client ones are
|
||||||
if (dataStreamer.size())
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
dataStreamer.clear();
|
delete(*it);
|
||||||
|
dataStreamer.clear();
|
||||||
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
for ( int i=0; i < numThreads; ++i ) {
|
for ( int i=0; i < numThreads; ++i ) {
|
||||||
dataStreamer.push_back(new DataStreamer());
|
dataStreamer.push_back(new DataStreamer());
|
||||||
if (DataStreamer::GetErrorMask()) {
|
if (DataStreamer::GetErrorMask()) {
|
||||||
cprintf(BG_RED,"Error: Could not create data callback threads\n");
|
cprintf(BG_RED,"Error: Could not create data callback threads\n");
|
||||||
|
for (vector<DataStreamer*>::const_iterator it = dataStreamer.begin(); it != dataStreamer.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
|
dataStreamer.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -316,7 +324,7 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
|
|
||||||
FILE_LOG (logDEBUG) << "Setting receiver type";
|
FILE_LOG (logDEBUG) << "Setting receiver type";
|
||||||
|
|
||||||
DeleteMembers();
|
DeleteMembers();cout<<"size of fifo:"<<fifo.size()<<endl;
|
||||||
InitializeMembers();
|
InitializeMembers();
|
||||||
myDetectorType = d;
|
myDetectorType = d;
|
||||||
switch(myDetectorType) {
|
switch(myDetectorType) {
|
||||||
@ -344,23 +352,30 @@ int UDPStandardImplementation::setDetectorType(const detectorType d) {
|
|||||||
case JUNGFRAU: generalData = new JungfrauData(); break;
|
case JUNGFRAU: generalData = new JungfrauData(); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
Listener::SetGeneralData(generalData);
|
||||||
|
DataProcessor::SetGeneralData(generalData);
|
||||||
numThreads = generalData->threadsPerReceiver;
|
numThreads = generalData->threadsPerReceiver;
|
||||||
|
fifoDepth = generalData->defaultFifoDepth;
|
||||||
|
|
||||||
|
//create fifo structure
|
||||||
|
numberofJobs = -1;
|
||||||
|
if (SetupFifoStructure() == FAIL) {
|
||||||
|
FILE_LOG (logERROR) << "Error: Could not allocate memory for fifo structure";
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//create threads
|
||||||
for ( int i=0; i < numThreads; ++i ) {
|
for ( int i=0; i < numThreads; ++i ) {
|
||||||
|
listener.push_back(new Listener(fifo[i], &status, &udpPortNum[i]));
|
||||||
//create fifo structure
|
dataProcessor.push_back(new DataProcessor(fifo[i], &status, &statusMutex));
|
||||||
numberofJobs = -1;
|
|
||||||
if (SetupFifoStructure() == FAIL) {
|
|
||||||
FILE_LOG (logERROR) << "Error: Could not allocate memory for fifo (index:" << i << ")";
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//create threads
|
|
||||||
listener.push_back(new Listener(fifo[i]));
|
|
||||||
dataProcessor.push_back(new DataProcessor(fifo[i]));
|
|
||||||
if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) {
|
if (Listener::GetErrorMask() || DataProcessor::GetErrorMask()) {
|
||||||
FILE_LOG (logERROR) << "Error: Could not creates listener/dataprocessor threads (index:" << i << ")";
|
FILE_LOG (logERROR) << "Error: Could not creates listener/dataprocessor threads (index:" << i << ")";
|
||||||
|
for (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)
|
||||||
|
delete(*it);
|
||||||
|
dataProcessor.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -407,6 +422,11 @@ int UDPStandardImplementation::startReceiver(char *c) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//change status
|
||||||
|
pthread_mutex_lock(&statusMutex);
|
||||||
|
status = RUNNING;
|
||||||
|
pthread_mutex_unlock(&(statusMutex));
|
||||||
|
|
||||||
//Let Threads continue to be ready for acquisition
|
//Let Threads continue to be ready for acquisition
|
||||||
StartRunning();
|
StartRunning();
|
||||||
|
|
||||||
@ -428,11 +448,11 @@ void UDPStandardImplementation::stopReceiver(){
|
|||||||
usleep(5000);
|
usleep(5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* //change status
|
//change status
|
||||||
pthread_mutex_lock(&statusMutex);
|
pthread_mutex_lock(&statusMutex);
|
||||||
status = IDLE;
|
status = IDLE;
|
||||||
pthread_mutex_unlock(&(statusMutex));
|
pthread_mutex_unlock(&(statusMutex));
|
||||||
*/
|
|
||||||
FILE_LOG(logINFO) << "Receiver Stopped";
|
FILE_LOG(logINFO) << "Receiver Stopped";
|
||||||
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
FILE_LOG(logINFO) << "Status: " << runStatusType(status);
|
||||||
cout << endl << endl;
|
cout << endl << endl;
|
||||||
@ -489,10 +509,10 @@ void UDPStandardImplementation::startReadout(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*//set status
|
//set status
|
||||||
pthread_mutex_lock(&statusMutex);
|
pthread_mutex_lock(&statusMutex);
|
||||||
status = TRANSMITTING;
|
status = TRANSMITTING;
|
||||||
pthread_mutex_unlock(&statusMutex);*/
|
pthread_mutex_unlock(&statusMutex);
|
||||||
|
|
||||||
FILE_LOG(logINFO) << "Status: Transmitting";
|
FILE_LOG(logINFO) << "Status: Transmitting";
|
||||||
}
|
}
|
||||||
@ -518,7 +538,6 @@ void UDPStandardImplementation::closeFiles() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void UDPStandardImplementation::SetLocalNetworkParameters() {
|
void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||||
FILE_LOG (logDEBUG) << __AT__ << " called";
|
FILE_LOG (logDEBUG) << __AT__ << " called";
|
||||||
|
|
||||||
@ -553,7 +572,7 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
|
|
||||||
|
|
||||||
//recalculate number of jobs & fifodepth, return if no change
|
//recalculate number of jobs & fifodepth, return if no change
|
||||||
if ((myDetectorType == GOTTHARD) || (myDetectorType = PROPIX)) {
|
if ((myDetectorType == GOTTHARD) || (myDetectorType == PROPIX)) {
|
||||||
|
|
||||||
int oldnumberofjobs = numberofJobs;
|
int oldnumberofjobs = numberofJobs;
|
||||||
//listen to only n jobs at a time
|
//listen to only n jobs at a time
|
||||||
@ -585,24 +604,27 @@ int UDPStandardImplementation::SetupFifoStructure() {
|
|||||||
numberofJobs = 1;
|
numberofJobs = 1;
|
||||||
|
|
||||||
|
|
||||||
//create fifostructure
|
for (vector<Fifo*>::const_iterator it = fifo.begin(); it != fifo.end(); ++it)
|
||||||
|
delete(*it);
|
||||||
fifo.clear();
|
fifo.clear();
|
||||||
for ( int i=0; i < numThreads; i++ ) {
|
for ( int i = 0; i < numThreads; i++ ) {
|
||||||
|
|
||||||
//create fifo structure
|
//create fifo structure
|
||||||
bool success = true;
|
bool success = true;
|
||||||
fifo.push_back( new Fifo (
|
fifo.push_back( new Fifo (
|
||||||
(generalData->fifoBufferSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
(generalData->fifoBufferSize) * numberofJobs + (generalData->fifoBufferHeaderSize),
|
||||||
fifoDepth, success));
|
fifoDepth, success));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
cprintf(BG_RED,"Error: Could not allocate memory for listening \n");
|
cprintf(BG_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)
|
||||||
|
delete(*it);
|
||||||
|
fifo.clear();
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//set the listener & dataprocessor threads to point to the right fifo
|
//set the listener & dataprocessor threads to point to the right fifo
|
||||||
listener[i]->SetFifo(fifo[i]);
|
if(listener.size())listener[i]->SetFifo(fifo[i]);
|
||||||
dataProcessor[i]->SetFifo(fifo[i]);
|
if(dataProcessor.size())dataProcessor[i]->SetFifo(fifo[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_LOG (logINFO) << "Fifo structure(s) reconstructed";
|
FILE_LOG (logINFO) << "Fifo structure(s) reconstructed";
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -633,8 +655,7 @@ int UDPStandardImplementation::CreateUDPSockets() {
|
|||||||
}
|
}
|
||||||
bool error = false;
|
bool error = false;
|
||||||
for (unsigned int i = 0; i < listener.size(); ++i)
|
for (unsigned int i = 0; i < listener.size(); ++i)
|
||||||
if (listener[i]->CreateUDPSockets(udpPortNum[i], generalData->packetSize,
|
if (listener[i]->CreateUDPSockets((strlen(eth)?eth:NULL)) == FAIL) {
|
||||||
(strlen(eth)?eth:NULL), generalData->headerPacketSize) == FAIL) {
|
|
||||||
error = true;
|
error = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ int main(int argc, char *argv[]) {
|
|||||||
//receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL);
|
//receiver->registerCallBackRawDataReady(rawDataReadyCallBack,NULL);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
//start tcp server thread
|
//start tcp server thread
|
||||||
if(receiver->start() == slsReceiverDefs::OK){
|
if(receiver->start() == slsReceiverDefs::OK){
|
||||||
FILE_LOG(logDEBUG1) << "DONE!" << endl;
|
FILE_LOG(logDEBUG1) << "DONE!" << endl;
|
||||||
@ -113,7 +113,7 @@ int main(int argc, char *argv[]) {
|
|||||||
//stop tcp server thread, stop udp socket
|
//stop tcp server thread, stop udp socket
|
||||||
receiver->stop();
|
receiver->stop();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
deleteReceiver(receiver);
|
deleteReceiver(receiver);
|
||||||
cout << "Goodbye!" << endl;
|
cout << "Goodbye!" << endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -127,7 +127,6 @@ slsReceiver::slsReceiver(int argc, char *argv[], int &success){
|
|||||||
udp_interface = UDPInterface::create(udp_interface_type);
|
udp_interface = UDPInterface::create(udp_interface_type);
|
||||||
udp_interface->configure(configuration_map);
|
udp_interface->configure(configuration_map);
|
||||||
#endif
|
#endif
|
||||||
udp_interface = UDPInterface::create("standard");
|
|
||||||
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no);
|
tcpipInterface = new slsReceiverTCPIPInterface(success, udp_interface, tcpip_port_no);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ using namespace std;
|
|||||||
|
|
||||||
|
|
||||||
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
slsReceiverTCPIPInterface::~slsReceiverTCPIPInterface() {
|
||||||
/*stop();
|
stop();
|
||||||
if(mySock) {delete mySock; mySock=NULL;}*/
|
if(mySock) {delete mySock; mySock=NULL;}
|
||||||
}
|
}
|
||||||
|
|
||||||
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface* rbase, int pn):
|
||||||
@ -55,7 +55,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
|
|||||||
|
|
||||||
success=OK;
|
success=OK;
|
||||||
|
|
||||||
/*//create socket
|
//create socket
|
||||||
if(success == OK){
|
if(success == OK){
|
||||||
mySock = new MySocketTCP(port_no);
|
mySock = new MySocketTCP(port_no);
|
||||||
if (mySock->getErrorStatus()) {
|
if (mySock->getErrorStatus()) {
|
||||||
@ -73,7 +73,7 @@ slsReceiverTCPIPInterface::slsReceiverTCPIPInterface(int &success, UDPInterface*
|
|||||||
cout << "Function table assigned." << endl;
|
cout << "Function table assigned." << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user