mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-22 22:40:02 +02:00
32 bit image, and 32 bit mode frame number for eiger fixed, startframeindex included in readframe for all det in tcpip class
This commit is contained in:
parent
c2b885f230
commit
5cfe7b4338
@ -61,6 +61,8 @@ class sockaddr_in;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdlib.h> /******exit */
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -558,6 +560,16 @@ enum communicationProtocol{
|
|||||||
break;
|
break;
|
||||||
case UDP:
|
case UDP:
|
||||||
if (socketDescriptor<0) return -1;
|
if (socketDescriptor<0) return -1;
|
||||||
|
|
||||||
|
/*
|
||||||
|
cout <<"******listening inside genericsocket"<<endl;
|
||||||
|
for(int i=0;i<10000;i++){
|
||||||
|
nsent = recvfrom(socketDescriptor,(char*)buf+total_sent,5000, 0, (struct sockaddr *) &clientAddress, &clientAddress_length);
|
||||||
|
cout<<i<<":"<<nsent<<"\t\t";
|
||||||
|
}
|
||||||
|
exit(-1);
|
||||||
|
*/
|
||||||
|
|
||||||
//if length given, listens to length, else listens for packetsize till length is reached
|
//if length given, listens to length, else listens for packetsize till length is reached
|
||||||
if(length){
|
if(length){
|
||||||
while(length>0){
|
while(length>0){
|
||||||
|
@ -273,8 +273,9 @@ public:
|
|||||||
* @param c pointer to current file name
|
* @param c pointer to current file name
|
||||||
* @param raw address of pointer, pointing to current frame to send to gui
|
* @param raw address of pointer, pointing to current frame to send to gui
|
||||||
* @param fnum frame number for eiger as it is not in the packet
|
* @param fnum frame number for eiger as it is not in the packet
|
||||||
|
* @param fstartind is the start index of the acquisition
|
||||||
*/
|
*/
|
||||||
virtual void readFrame(char* c,char** raw, uint32_t &fnum) = 0;
|
virtual void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind ) = 0;
|
||||||
|
|
||||||
/** set status to transmitting and
|
/** set status to transmitting and
|
||||||
* when fifo is empty later, sets status to run_finished
|
* when fifo is empty later, sets status to run_finished
|
||||||
|
@ -1000,8 +1000,8 @@ int slsReceiverTCPIPInterface::moench_read_frame(){
|
|||||||
|
|
||||||
else{
|
else{
|
||||||
ret = OK;
|
ret = OK;
|
||||||
startIndex=receiverBase->getStartFrameIndex();
|
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||||
receiverBase->readFrame(fName,&raw,index);
|
receiverBase->readFrame(fName,&raw,index,startIndex);
|
||||||
|
|
||||||
/**send garbage with -1 index to try again*/
|
/**send garbage with -1 index to try again*/
|
||||||
if (raw == NULL){
|
if (raw == NULL){
|
||||||
@ -1170,8 +1170,8 @@ int slsReceiverTCPIPInterface::gotthard_read_frame(){
|
|||||||
cout<<"haven't caught any frame yet"<<endl;
|
cout<<"haven't caught any frame yet"<<endl;
|
||||||
}else{
|
}else{
|
||||||
ret = OK;
|
ret = OK;
|
||||||
startIndex=receiverBase->getStartFrameIndex();
|
/*startIndex=receiverBase->getStartFrameIndex();*/
|
||||||
receiverBase->readFrame(fName,&raw,index);
|
receiverBase->readFrame(fName,&raw,index,startIndex);
|
||||||
|
|
||||||
/**send garbage with -1 index to try again*/
|
/**send garbage with -1 index to try again*/
|
||||||
if (raw == NULL){
|
if (raw == NULL){
|
||||||
@ -1302,13 +1302,9 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
char* raw = new char[frameSize];
|
char* raw = new char[frameSize];
|
||||||
char* origVal = new char[frameSize];
|
char* origVal = new char[frameSize];
|
||||||
char* retval = new char[dataSize];
|
char* retval = new char[dataSize];
|
||||||
|
uint32_t startIndex=0;
|
||||||
strcpy(mess,"Could not read frame\n");
|
strcpy(mess,"Could not read frame\n");
|
||||||
|
|
||||||
/* typedef struct{
|
|
||||||
unsigned char num1[4];
|
|
||||||
unsigned char num2[4];
|
|
||||||
} eiger_packet_header;*/
|
|
||||||
|
|
||||||
// execute action if the arguments correctly arrived
|
// execute action if the arguments correctly arrived
|
||||||
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
|
||||||
@ -1326,7 +1322,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
else{
|
else{
|
||||||
ret = OK;
|
ret = OK;
|
||||||
/** read a frame */
|
/** read a frame */
|
||||||
receiverBase->readFrame(fName,&raw, index);
|
receiverBase->readFrame(fName,&raw,index,startIndex);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "index:" << dec << index << endl;
|
cout << "index:" << dec << index << endl;
|
||||||
#endif
|
#endif
|
||||||
@ -1373,17 +1369,22 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
memcpy(retval+retindex ,origVal+c1 ,numbytesperlineperport);
|
memcpy(retval+retindex ,origVal+c1 ,numbytesperlineperport);
|
||||||
retindex += numbytesperlineperport;
|
retindex += numbytesperlineperport;
|
||||||
c1 += numbytesperlineperport;
|
c1 += numbytesperlineperport;
|
||||||
|
if(repeat == 2) c1 += 16;
|
||||||
}
|
}
|
||||||
for(irepeat=0;irepeat<repeat;irepeat++){//only for 32 bit mode, take 2 packets from same port
|
for(irepeat=0;irepeat<repeat;irepeat++){//only for 32 bit mode, take 2 packets from same port
|
||||||
|
|
||||||
memcpy(retval+retindex ,origVal+c2 ,numbytesperlineperport);
|
memcpy(retval+retindex ,origVal+c2 ,numbytesperlineperport);
|
||||||
retindex += numbytesperlineperport;
|
retindex += numbytesperlineperport;
|
||||||
c2 += numbytesperlineperport;
|
c2 += numbytesperlineperport;
|
||||||
|
if(repeat == 2) c2 += 16;
|
||||||
}
|
}
|
||||||
ibytesperpacket += numbytesperlineperport;
|
ibytesperpacket += numbytesperlineperport;
|
||||||
}
|
}
|
||||||
|
if(repeat == 1) {
|
||||||
c1 += 16;
|
c1 += 16;
|
||||||
c2 += 16;
|
c2 += 16;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t temp;
|
int64_t temp;
|
||||||
@ -1404,7 +1405,7 @@ int slsReceiverTCPIPInterface::eiger_read_frame(){
|
|||||||
for(i=0;i<(1024*(16*dynamicrange)*2)/4;i++)
|
for(i=0;i<(1024*(16*dynamicrange)*2)/4;i++)
|
||||||
(*(((uint32_t*)retval)+i)) = htonl((uint32_t)(*(((uint32_t*)retval)+i)));
|
(*(((uint32_t*)retval)+i)) = htonl((uint32_t)(*(((uint32_t*)retval)+i)));
|
||||||
*/
|
*/
|
||||||
arg = index-1;
|
arg = index-startIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#define EIGER_32BIT_INITIAL_CONSTANT 0x17c
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -785,7 +787,7 @@ void slsReceiverUDPFunctions::setupFifoStructure(){
|
|||||||
|
|
||||||
/** acquisition functions */
|
/** acquisition functions */
|
||||||
|
|
||||||
void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum){
|
void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind){
|
||||||
//point to gui data
|
//point to gui data
|
||||||
if (guiData == NULL)
|
if (guiData == NULL)
|
||||||
guiData = latestData;
|
guiData = latestData;
|
||||||
@ -793,7 +795,7 @@ void slsReceiverUDPFunctions::readFrame(char* c,char** raw, uint32_t &fnum){
|
|||||||
//copy data and filename
|
//copy data and filename
|
||||||
strcpy(c,guiFileName);
|
strcpy(c,guiFileName);
|
||||||
fnum = guiFrameNumber;
|
fnum = guiFrameNumber;
|
||||||
|
fstartind = getStartFrameIndex();
|
||||||
|
|
||||||
//could not get gui data
|
//could not get gui data
|
||||||
if(!guiDataReady){
|
if(!guiDataReady){
|
||||||
@ -1506,9 +1508,13 @@ int slsReceiverUDPFunctions::startListening(){
|
|||||||
//normal listening
|
//normal listening
|
||||||
else if(!carryonBufferSize){
|
else if(!carryonBufferSize){
|
||||||
|
|
||||||
|
/* if(!ithread){*/
|
||||||
rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize);
|
rc = udpSocket[ithread]->ReceiveDataOnly(buffer[ithread] + HEADER_SIZE_NUM_TOT_PACKETS, maxBufferSize);
|
||||||
expected = maxBufferSize;
|
expected = maxBufferSize;
|
||||||
|
/*}else{
|
||||||
|
while(1) usleep(100000000);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
//the remaining packets from previous buffer
|
//the remaining packets from previous buffer
|
||||||
else{
|
else{
|
||||||
@ -1726,7 +1732,10 @@ int loop;
|
|||||||
//for progress
|
//for progress
|
||||||
if(myDetectorType == EIGER){
|
if(myDetectorType == EIGER){
|
||||||
tempframenum = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
tempframenum = htonl(*(unsigned int*)((eiger_image_header *)((char*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS)))->fnum);
|
||||||
|
if(dynamicRange != 32)
|
||||||
tempframenum += (startFrameIndex-1); //eiger frame numbers start at 1, so need to -1
|
tempframenum += (startFrameIndex-1); //eiger frame numbers start at 1, so need to -1
|
||||||
|
else
|
||||||
|
tempframenum = ((tempframenum / EIGER_32BIT_INITIAL_CONSTANT) + startFrameIndex)-1;//eiger 32 bit mode is a multiple of 17c. +startframeindex for scans
|
||||||
}else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
}else if ((myDetectorType == GOTTHARD) && (shortFrame == -1))
|
||||||
tempframenum = (((((uint32_t)(*((uint32_t*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset);
|
tempframenum = (((((uint32_t)(*((uint32_t*)(wbuf[ithread] + HEADER_SIZE_NUM_TOT_PACKETS))))+1)& (frameIndexMask)) >> frameIndexOffset);
|
||||||
else
|
else
|
||||||
@ -1751,6 +1760,7 @@ int loop;
|
|||||||
|
|
||||||
if (cbAction < DO_EVERYTHING){
|
if (cbAction < DO_EVERYTHING){
|
||||||
for(i=0;i<numListeningThreads;++i)
|
for(i=0;i<numListeningThreads;++i)
|
||||||
|
/* for eiger 32 bit mode, currframenum like gotthard, does not start from 0 or 1 */
|
||||||
rawDataReadyCallBack(currframenum, wbuf[i], numpackets * onePacketSize, sfilefd, guiData,pRawDataReady);
|
rawDataReadyCallBack(currframenum, wbuf[i], numpackets * onePacketSize, sfilefd, guiData,pRawDataReady);
|
||||||
}else if (numpackets > 0){
|
}else if (numpackets > 0){
|
||||||
for(i=0;i<numListeningThreads;++i)
|
for(i=0;i<numListeningThreads;++i)
|
||||||
@ -1871,9 +1881,14 @@ void slsReceiverUDPFunctions::startFrameIndices(int ithread){
|
|||||||
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
cout << "startAcquisitionIndex:" << startAcquisitionIndex<<endl;
|
||||||
}
|
}
|
||||||
//for scans, cuz currfraenum resets
|
//for scans, cuz currfraenum resets
|
||||||
else if (myDetectorType == EIGER)
|
else if (myDetectorType == EIGER){
|
||||||
|
if(dynamicRange == 32)
|
||||||
|
startFrameIndex = (currframenum + 1);// to be added later for scans
|
||||||
|
else
|
||||||
startFrameIndex += currframenum;
|
startFrameIndex += currframenum;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
cout << "startFrameIndex:" << startFrameIndex<<endl;
|
cout << "startFrameIndex:" << startFrameIndex<<endl;
|
||||||
prevframenum=startFrameIndex;
|
prevframenum=startFrameIndex;
|
||||||
|
@ -286,8 +286,9 @@ public:
|
|||||||
* @param c pointer to current file name
|
* @param c pointer to current file name
|
||||||
* @param raw address of pointer, pointing to current frame to send to gui
|
* @param raw address of pointer, pointing to current frame to send to gui
|
||||||
* @param fnum frame number for eiger as it is not in the packet
|
* @param fnum frame number for eiger as it is not in the packet
|
||||||
|
* @param fstartind is the start index of the acquisition
|
||||||
*/
|
*/
|
||||||
void readFrame(char* c,char** raw, uint32_t &fnum);
|
void readFrame(char* c,char** raw, uint32_t &fnum, uint32_t &fstartind);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes all files
|
* Closes all files
|
||||||
@ -468,7 +469,6 @@ private:
|
|||||||
unsigned char header_after[24];
|
unsigned char header_after[24];
|
||||||
} eiger_image_header;
|
} eiger_image_header;
|
||||||
|
|
||||||
|
|
||||||
/** structure of an eiger image header*/
|
/** structure of an eiger image header*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user