mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 23:10:02 +02:00
moench receiver orders packets to frames
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@533 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
8c3e7f6160
commit
ded2a4de5c
@ -21,6 +21,11 @@
|
|||||||
#define GOTTHARD_SHORT_BUFFER_SIZE 518
|
#define GOTTHARD_SHORT_BUFFER_SIZE 518
|
||||||
#define GOTTHARD_SHORT_DATABYTES 512
|
#define GOTTHARD_SHORT_DATABYTES 512
|
||||||
|
|
||||||
|
#define GOTTHARD_FRAME_INDEX_MASK 0xFFFFFFFF
|
||||||
|
#define GOTTHARD_FRAME_INDEX_OFFSET 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MOENCH_ALIGNED_FRAME_SIZE 65536
|
#define MOENCH_ALIGNED_FRAME_SIZE 65536
|
||||||
@ -33,6 +38,11 @@
|
|||||||
#define MOENCH_BYTES_IN_ONE_DIMENSION (MOENCH_PIXELS_IN_ONE_DIMENSION*2)
|
#define MOENCH_BYTES_IN_ONE_DIMENSION (MOENCH_PIXELS_IN_ONE_DIMENSION*2)
|
||||||
|
|
||||||
|
|
||||||
|
#define MOENCH_FRAME_INDEX_MASK 0xFFFFFF00
|
||||||
|
#define MOENCH_FRAME_INDEX_OFFSET 8
|
||||||
|
#define MOENCH_PACKET_INDEX_MASK 0xFF
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,13 +66,20 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det,bool moenchwit
|
|||||||
pAcquisitionFinished(NULL),
|
pAcquisitionFinished(NULL),
|
||||||
rawDataReadyCallBack(NULL),
|
rawDataReadyCallBack(NULL),
|
||||||
pRawDataReady(NULL),
|
pRawDataReady(NULL),
|
||||||
withGotthard(moenchwithGotthardTest)
|
withGotthard(moenchwithGotthardTest),
|
||||||
|
frameIndexMask(GOTTHARD_FRAME_INDEX_MASK),
|
||||||
|
frameIndexOffset(GOTTHARD_FRAME_INDEX_OFFSET)
|
||||||
|
|
||||||
{
|
{
|
||||||
if(myDetectorType == MOENCH){
|
if(myDetectorType == MOENCH){
|
||||||
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
maxFramesPerFile = MOENCH_MAX_FRAMES_PER_FILE;
|
||||||
bufferSize = MOENCH_BUFFER_SIZE;
|
bufferSize = MOENCH_BUFFER_SIZE;
|
||||||
packetsPerFrame = MOENCH_PACKETS_PER_FRAME;
|
packetsPerFrame = MOENCH_PACKETS_PER_FRAME;
|
||||||
|
if(!withGotthard){
|
||||||
|
frameIndexMask = MOENCH_FRAME_INDEX_MASK;
|
||||||
|
frameIndexOffset = MOENCH_FRAME_INDEX_OFFSET;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(savefilename,"");
|
strcpy(savefilename,"");
|
||||||
@ -349,7 +356,12 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
|
|
||||||
//start for each scan
|
//start for each scan
|
||||||
if(startFrameIndex==-1){
|
if(startFrameIndex==-1){
|
||||||
startFrameIndex=(int)(*((int*)buffer))-packetsPerFrame;
|
if(!frameIndexOffset)
|
||||||
|
startFrameIndex = (int)(*((int*)buffer));
|
||||||
|
else
|
||||||
|
startFrameIndex = (((int)(*((int*)buffer))) & (frameIndexMask)) >> frameIndexOffset;
|
||||||
|
|
||||||
|
startFrameIndex -= packetsPerFrame;
|
||||||
//cout<<"startFrameIndex:"<<startFrameIndex<<endl;
|
//cout<<"startFrameIndex:"<<startFrameIndex<<endl;
|
||||||
prevframenum=startFrameIndex;
|
prevframenum=startFrameIndex;
|
||||||
}
|
}
|
||||||
@ -369,7 +381,7 @@ int slsReceiverFunctionList::startListening(){
|
|||||||
if(fifo->isFull())
|
if(fifo->isFull())
|
||||||
;//cout<<"**********************FIFO FULLLLLLLL************************"<<endl;
|
;//cout<<"**********************FIFO FULLLLLLLL************************"<<endl;
|
||||||
else{
|
else{
|
||||||
//cout<<"read index:"<<dec<<(int)(*(int*)buffer)<<endl;
|
//cout<<"read index:"<<dec<<(int)(*(int*)buffer)<<endl;& (frameIndexMask)) >> frameIndexOffset;
|
||||||
fifo->push(buffer);
|
fifo->push(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +506,12 @@ int slsReceiverFunctionList::startWriting(){
|
|||||||
if(fifo->pop(wbuf)){
|
if(fifo->pop(wbuf)){
|
||||||
framesCaught++;
|
framesCaught++;
|
||||||
totalFramesCaught++;
|
totalFramesCaught++;
|
||||||
currframenum = (int)(*((int*)wbuf));//cout<<"**************curreframenm:"<<currframenum<<endl;
|
if(!frameIndexOffset)
|
||||||
|
currframenum = (int)(*((int*)wbuf));
|
||||||
|
else
|
||||||
|
currframenum = (((int)(*((int*)wbuf))) & (frameIndexMask)) >> frameIndexOffset;
|
||||||
|
//currframenum = (int)(*((int*)wbuf));
|
||||||
|
//cout<<"**************curreframenm:"<<currframenum<<endl;
|
||||||
|
|
||||||
//write data
|
//write data
|
||||||
if(enableFileWrite){
|
if(enableFileWrite){
|
||||||
|
@ -198,6 +198,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
void registerWriteReceiverDataCallback(int( *userCallback)(char*, int, FILE*, void*), void *pArg) {writeReceiverData = userCallback; pwriteReceiverDataArg = pArg;};
|
void registerWriteReceiverDataCallback(int( *userCallback)(char*, int, FILE*, void*), void *pArg) {writeReceiverData = userCallback; pwriteReceiverDataArg = pArg;};
|
||||||
|
|
||||||
|
int getFrameIndex(int index){return index & MOENCH_FRAME_INDEX_MASK}
|
||||||
|
|
||||||
|
int get
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** detector type */
|
/** detector type */
|
||||||
@ -362,6 +366,13 @@ private:
|
|||||||
/**temporary variable to test moench with gotthard module*/
|
/**temporary variable to test moench with gotthard module*/
|
||||||
bool withGotthard;
|
bool withGotthard;
|
||||||
|
|
||||||
|
/** frame index mask */
|
||||||
|
int frameIndexMask;
|
||||||
|
|
||||||
|
/** frame index offset */
|
||||||
|
int frameIndexOffset;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,13 +34,14 @@ slsReceiverFuncs::slsReceiverFuncs(int argc, char *argv[], int &success):
|
|||||||
ret(OK),
|
ret(OK),
|
||||||
lockStatus(0),
|
lockStatus(0),
|
||||||
shortFrame(-1),
|
shortFrame(-1),
|
||||||
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME){
|
packetsPerFrame(GOTTHARD_PACKETS_PER_FRAME),
|
||||||
|
withGotthard(0){
|
||||||
|
|
||||||
int port_no = DEFAULT_PORTNO+2;
|
int port_no = DEFAULT_PORTNO+2;
|
||||||
ifstream infile;
|
ifstream infile;
|
||||||
string sLine,sargname;
|
string sLine,sargname;
|
||||||
int iline = 0;
|
int iline = 0;
|
||||||
int withGotthard = 0;
|
|
||||||
|
|
||||||
success=OK;
|
success=OK;
|
||||||
string fname = "";
|
string fname = "";
|
||||||
@ -930,8 +931,6 @@ int slsReceiverFuncs::moench_read_frame(){
|
|||||||
for(i=0;i<rnel;i++) retval[i]=0;
|
for(i=0;i<rnel;i++) retval[i]=0;
|
||||||
for(i=0;i<rnel;i++) origVal[i]=0;
|
for(i=0;i<rnel;i++) origVal[i]=0;
|
||||||
|
|
||||||
/*int onebuffersize = bufferSize/MOENCH_PACKETS_PER_FRAME;
|
|
||||||
int onedatasize = MOENCH_DATA_BYTES/MOENCH_PACKETS_PER_FRAME;*/
|
|
||||||
|
|
||||||
int index=-1;
|
int index=-1;
|
||||||
int startIndex=-1;
|
int startIndex=-1;
|
||||||
@ -971,9 +970,13 @@ int slsReceiverFuncs::moench_read_frame(){
|
|||||||
raw=NULL;
|
raw=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//************** default order*****************************
|
||||||
|
//filling up in y direction and then in x direcction
|
||||||
|
if(withGotthard){
|
||||||
|
count = 0;
|
||||||
offset = 4;
|
offset = 4;
|
||||||
j=0;
|
j=0;
|
||||||
//filling up in y direction and then in x direcction
|
|
||||||
for(x=0;x<(MOENCH_BYTES_IN_ONE_DIMENSION/MOENCH_BYTES_PER_ADC);x++){
|
for(x=0;x<(MOENCH_BYTES_IN_ONE_DIMENSION/MOENCH_BYTES_PER_ADC);x++){
|
||||||
for(y=0;y<MOENCH_PIXELS_IN_ONE_DIMENSION;y++){
|
for(y=0;y<MOENCH_PIXELS_IN_ONE_DIMENSION;y++){
|
||||||
|
|
||||||
@ -986,20 +989,76 @@ int slsReceiverFuncs::moench_read_frame(){
|
|||||||
MOENCH_BYTES_PER_ADC);
|
MOENCH_BYTES_PER_ADC);
|
||||||
j++;
|
j++;
|
||||||
count++;
|
count++;
|
||||||
if(count==15){
|
if(count==16){
|
||||||
count=0;
|
count=0;
|
||||||
offset+=6;
|
offset+=6;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
for(i=0;i<MOENCH_PACKETS_PER_FRAME;i=i+2){
|
|
||||||
memcpy((((char*)retval)+ onedatasize*i), (((char*) origVal)+4+ onebuffersize*i) , onedatasize);
|
|
||||||
memcpy((((char*)retval)+ onedatasize*(i+1)), (((char*) origVal)+10+onedatasize+ onebuffersize*i),onedatasize);
|
|
||||||
}
|
}
|
||||||
|
//********************************************************
|
||||||
|
|
||||||
|
|
||||||
|
//************** packet number order**********************
|
||||||
|
else{
|
||||||
|
int numPackets = MOENCH_PACKETS_PER_FRAME; //40
|
||||||
|
int onePacketSize = MOENCH_DATA_BYTES / MOENCH_PACKETS_PER_FRAME; //1280*40 / 40 = 1280
|
||||||
|
int partsPerFrame = onePacketSize / MOENCH_BYTES_PER_ADC; // 1280 / 80 = 16
|
||||||
|
int origvalHeader = origVal;
|
||||||
|
int thisFrameNumber = (index & (MOENCH_FRAME_INDEX_MASK)) >> MOENCH_FRAME_INDEX_OFFSET;
|
||||||
|
cout<<"this frame number:"<<thisFrameNumber<<endl;
|
||||||
|
int packetIndex,x,y;
|
||||||
|
int iPacket = 0;
|
||||||
|
offset = 4;
|
||||||
|
|
||||||
|
|
||||||
|
while (iPacket < numPackets){
|
||||||
|
//read packet index
|
||||||
|
packetIndex = (*origvalHeader) & MOENCH_PACKET_INDEX_MASK;cout<<"packet index:"<<packetIndex<<endl;
|
||||||
|
//if its valid
|
||||||
|
if ((packetIndex < 40) || (packetIndex >= 0)){
|
||||||
|
x = packetIndex / 10;
|
||||||
|
y = packetIndex % 10;cout<<"x:"<<x<<"\t y:"<<y<<endl;
|
||||||
|
//copy 16 times 80 bytes
|
||||||
|
for (i = 0; i < partsPerFrame; i++) {
|
||||||
|
memcpy((((char*)retval) +
|
||||||
|
y * MOENCH_BYTES_IN_ONE_DIMENSION +
|
||||||
|
x * MOENCH_BYTES_PER_ADC),
|
||||||
|
(((char*) origVal) +
|
||||||
|
offset +
|
||||||
|
iPacket * onePacketSize +
|
||||||
|
i * MOENCH_BYTES_PER_ADC) ,
|
||||||
|
MOENCH_BYTES_PER_ADC);
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
cout << "cannot decode packet index:" << packetIndex << endl;
|
||||||
|
|
||||||
|
//increment
|
||||||
|
offset+=6;
|
||||||
|
origvalHeader = origvalHeader + offset + onePacketSize;
|
||||||
|
iPacket++;
|
||||||
|
|
||||||
|
cout <<" checking next frame number:"<<(((*origvalHeader) & (MOENCH_FRAME_INDEX_MASK)) >> MOENCH_FRAME_INDEX_OFFSET)<<endl;
|
||||||
|
//check if same frame number
|
||||||
|
while ((((*origvalHeader) & (MOENCH_FRAME_INDEX_MASK)) >> MOENCH_FRAME_INDEX_OFFSET) != thisFrameNumber){cout<<"did not match"<<endl;
|
||||||
|
if(iPacket >= numPackets)
|
||||||
|
break;
|
||||||
|
//increment
|
||||||
|
offset+=6;
|
||||||
|
origvalHeader = origvalHeader + offset + onePacketSize;
|
||||||
|
iPacket++;
|
||||||
|
}
|
||||||
|
cout<<"found or exited"<<endl;
|
||||||
|
}
|
||||||
|
cout<<"exited loop"<<endl;
|
||||||
|
}
|
||||||
|
//********************************************************
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
arg=((index - startIndex)/MOENCH_PACKETS_PER_FRAME)-1;
|
arg=((index - startIndex)/MOENCH_PACKETS_PER_FRAME)-1;
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
cout << "\nstartIndex:" << startIndex << endl;
|
cout << "\nstartIndex:" << startIndex << endl;
|
||||||
|
@ -198,6 +198,9 @@ public:
|
|||||||
/** Packets per frame */
|
/** Packets per frame */
|
||||||
int packetsPerFrame;
|
int packetsPerFrame;
|
||||||
|
|
||||||
|
/** temporary variable to debug moench receiver with gotthard module */
|
||||||
|
int withGotthard;
|
||||||
|
|
||||||
static int file_des;
|
static int file_des;
|
||||||
static int socketDescriptor;
|
static int socketDescriptor;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user