client: update roi on updatedetector, (ctb, moench)moved nchans and databyte calculated to updatenumberofchannels and called for any update in roi, readoutflag or #samples changed (get should not update). ctb,moench server: roi fixed, . gotthard server: bug fix waiting to finish, ad9252 spi call fix. receiver: updated for moench and 10g

This commit is contained in:
maliakal_d 2019-03-06 17:25:18 +01:00
parent 0765b330f1
commit ca817c6ae9
14 changed files with 193 additions and 100 deletions

View File

@ -554,7 +554,7 @@ void setupDetector() {
// clear roi // clear roi
{ {
int ret = OK, retvalsize = 0; int ret = OK, retvalsize = 0;
setROI(0, rois, &ret, &retvalsize); setROI(0, rois, &retvalsize, &ret);
} }
} }
@ -617,6 +617,7 @@ int getChannels() {
} }
if (digitalEnable) if (digitalEnable)
nchans += NCHAN_DIGITAL; nchans += NCHAN_DIGITAL;
FILE_LOG(logINFO, ("\tNumber of Channels calculated: %d\n", nchans))
return nchans; return nchans;
} }
@ -674,13 +675,13 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret) {
int iroi = 0; int iroi = 0;
// for every roi // for every roi
for (iroi = 0; iroi < n; ++iroi) { for (iroi = 0; iroi < n; ++iroi) {
FILE_LOG(logINFO, ("\t%d: (%d, %d)\n", arg[iroi].xmin, arg[iroi].xmax)); FILE_LOG(logINFO, ("\t%d: (%d, %d)\n", iroi, arg[iroi].xmin, arg[iroi].xmax));
// swap if xmin > xmax // swap if xmin > xmax
if (arg[iroi].xmin > arg[iroi].xmax) { if (arg[iroi].xmin > arg[iroi].xmax) {
int temp = arg[iroi].xmin; int temp = arg[iroi].xmin;
arg[iroi].xmin = arg[iroi].xmax; arg[iroi].xmin = arg[iroi].xmax;
arg[iroi].xmax = temp; arg[iroi].xmax = temp;
FILE_LOG(logINFORED, ("\tCorrected %d: (%d, %d)\n", arg[iroi].xmin, arg[iroi].xmax)); FILE_LOG(logINFORED, ("\tCorrected %d: (%d, %d)\n", iroi, arg[iroi].xmin, arg[iroi].xmax));
} }
int ich = 0; int ich = 0;
// for the roi specified // for the roi specified

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 9d9251293d1a0b5300b8d7191949cf01de1c7b81 Repsitory UUID: 0765b330f116fd47b84c065d89789f4996573f23
Revision: 21 Revision: 24
Branch: refactor Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4255 Last Changed Rev: 4381
Last Changed Date: 2019-01-15 10:22:16.000000002 +0100 ./.target-makefrag Last Changed Date: 2019-03-06 13:42:29.000000002 +0100 ./.target-makefrag

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "9d9251293d1a0b5300b8d7191949cf01de1c7b81" #define GITREPUUID "0765b330f116fd47b84c065d89789f4996573f23"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4255 #define GITREV 0x4381
#define GITDATE 0x20190115 #define GITDATE 0x20190306
#define GITBRANCH "refactor" #define GITBRANCH "refactor"

View File

@ -1522,7 +1522,10 @@ int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t
FILE_LOG(logINFO, ("\twaited %d loops to start\n", loop)); FILE_LOG(logINFO, ("\twaited %d loops to start\n", loop));
FILE_LOG(logINFO, ("\tWaiting for acquisition to end (frames left: %lld)\n", (long long int)getTimeLeft(FRAME_NUMBER))); FILE_LOG(logINFO, ("\tWaiting for acquisition to end (frames left: %lld)\n", (long long int)getTimeLeft(FRAME_NUMBER)));
waitForAcquisitionFinish(); // wait for status to be done
while(runBusy()){
usleep(500);
}
// set to previous parameters // set to previous parameters
FILE_LOG(logINFO, ("\tSetting previous parameters:\n" FILE_LOG(logINFO, ("\tSetting previous parameters:\n"

View File

@ -1,9 +1,9 @@
Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer Path: slsDetectorPackage/slsDetectorServers/moenchDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 08bd2378f4956ea9a0b75381872854b3b129288f Repsitory UUID: 0765b330f116fd47b84c065d89789f4996573f23
Revision: 9 Revision: 13
Branch: refactor Branch: refactor
Last Changed Author: Dhanya_Thattil Last Changed Author: Dhanya_Thattil
Last Changed Rev: 4372 Last Changed Rev: 4381
Last Changed Date: 2019-03-05 09:35:29.000000002 +0100 ./RegisterDefs.h Last Changed Date: 2019-03-06 13:42:29.000000002 +0100 ./RegisterDefs.h

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "08bd2378f4956ea9a0b75381872854b3b129288f" #define GITREPUUID "0765b330f116fd47b84c065d89789f4996573f23"
#define GITAUTH "Dhanya_Thattil" #define GITAUTH "Dhanya_Thattil"
#define GITREV 0x4372 #define GITREV 0x4381
#define GITDATE 0x20190305 #define GITDATE 0x20190306
#define GITBRANCH "refactor" #define GITBRANCH "refactor"

View File

@ -533,12 +533,12 @@ void setupDetector() {
setTiming(DEFAULT_TIMING_MODE); setTiming(DEFAULT_TIMING_MODE);
// ensuring normal readout (only option for moench) // ensuring normal readout (only option for moench)
bus_w(addr, bus_r(addr) & (~CONFIG_DSBL_ANLG_OTPT_MSK) & (~CONFIG_ENBLE_DGTL_OTPT_MSK)); bus_w(CONFIG_REG, bus_r(CONFIG_REG) & (~CONFIG_DSBL_ANLG_OTPT_MSK) & (~CONFIG_ENBLE_DGTL_OTPT_MSK));
// clear roi // clear roi
{ {
int ret = OK, retvalsize = 0; int ret = OK, retvalsize = 0;
setROI(0, rois, &ret, &retvalsize); setROI(0, rois, &retvalsize, &ret);
} }
} }
@ -600,6 +600,7 @@ int getChannels() {
} }
if (digitalEnable) if (digitalEnable)
nchans += NCHAN_DIGITAL; nchans += NCHAN_DIGITAL;
FILE_LOG(logINFO, ("\tNumber of Channels calculated: %d\n", nchans))
return nchans; return nchans;
} }
@ -657,13 +658,13 @@ ROI* setROI(int n, ROI arg[], int *retvalsize, int *ret) {
int iroi = 0; int iroi = 0;
// for every roi // for every roi
for (iroi = 0; iroi < n; ++iroi) { for (iroi = 0; iroi < n; ++iroi) {
FILE_LOG(logINFO, ("\t%d: (%d, %d)\n", arg[iroi].xmin, arg[iroi].xmax)); FILE_LOG(logINFO, ("\t%d: (%d, %d)\n", iroi, arg[iroi].xmin, arg[iroi].xmax));
// swap if xmin > xmax // swap if xmin > xmax
if (arg[iroi].xmin > arg[iroi].xmax) { if (arg[iroi].xmin > arg[iroi].xmax) {
int temp = arg[iroi].xmin; int temp = arg[iroi].xmin;
arg[iroi].xmin = arg[iroi].xmax; arg[iroi].xmin = arg[iroi].xmax;
arg[iroi].xmax = temp; arg[iroi].xmax = temp;
FILE_LOG(logINFORED, ("\tCorrected %d: (%d, %d)\n", arg[iroi].xmin, arg[iroi].xmax)); FILE_LOG(logINFORED, ("\tCorrected %d: (%d, %d)\n", iroi, arg[iroi].xmin, arg[iroi].xmax));
} }
int ich = 0; int ich = 0;
// for the roi specified // for the roi specified

View File

@ -142,7 +142,7 @@ void AD9252_Set(int addr, int val) {
codata = val + (addr << 8); codata = val + (addr << 8);
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr)); FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
serializeToSPI(AD9252_Reg, codata, AD9252_CsMask, AD9252_ADC_NUMBITS, serializeToSPI(AD9252_Reg, codata, AD9252_CsMask, AD9252_ADC_NUMBITS,
AD9252_ClkMask, AD9252_DigMask, AD9252_DigOffset); AD9252_ClkMask, AD9252_DigMask, AD9252_DigOffset, 0);
} }
/** /**

View File

@ -168,7 +168,6 @@ int mapCSP0(void) {
(long long unsigned int)CSP0BASE, (long long unsigned int)CSP0BASE,
(long long unsigned int)(CSP0BASE+MEM_SIZE))); (long long unsigned int)(CSP0BASE+MEM_SIZE)));
FILE_LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG))); FILE_LOG(logINFO, ("Status Register: %08x\n", bus_r(STATUS_REG)));
FILE_LOG(logINFO, ("looka t me Register: %08x\n", bus_r(LOOK_AT_ME_REG)));
}else }else
FILE_LOG(logINFO, ("Memory already mapped before\n")); FILE_LOG(logINFO, ("Memory already mapped before\n"));
return OK; return OK;

View File

@ -2193,11 +2193,29 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
#endif #endif
// #samples // #samples, roi
#if defined(CHIPTESTBOARDD) || defined(MOENCHD) #if defined(CHIPTESTBOARDD) || defined(MOENCHD) || defined(GOTTHARDD)
i64 = setTimer(SAMPLES,GET_FLAG); i64 = setTimer(SAMPLES,GET_FLAG);
n = sendData(file_des,&i64,sizeof(i64),INT64); n = sendData(file_des,&i64,sizeof(i64),INT64);
if (n < 0) return printSocketReadError(); if (n < 0) return printSocketReadError();
// roi
ROI* retval = NULL;
ROI arg[1];
int ret = OK, nretval = 0;
retval = setROI(-1, arg, &nretval, &ret);
//retvalsize could be swapped during sendData
int nretval1 = nretval;
sendData(file_des, &nretval1, sizeof(nretval1), INT32);
int iloop = 0;
for(iloop = 0; iloop < nretval; ++iloop) {
sendData(file_des, &retval[iloop].xmin, sizeof(int), INT32);
sendData(file_des, &retval[iloop].xmax, sizeof(int), INT32);
sendData(file_des, &retval[iloop].ymin, sizeof(int), INT32);
sendData(file_des, &retval[iloop].ymax, sizeof(int), INT32);
}
#endif #endif
if (lockStatus == 0) { if (lockStatus == 0) {

View File

@ -293,7 +293,6 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL
list.nGappixelsY = 0; list.nGappixelsY = 0;
break; break;
case CHIPTESTBOARD: case CHIPTESTBOARD:
case MOENCH:
list.nChanX = 36; list.nChanX = 36;
list.nChanY = 1; list.nChanY = 1;
list.nChipX = 1; list.nChipX = 1;
@ -302,6 +301,16 @@ void slsDetector::setDetectorSpecificParameters(detectorType type, detParameterL
list.dynamicRange = 16; list.dynamicRange = 16;
list.nGappixelsX = 0; list.nGappixelsX = 0;
list.nGappixelsY = 0; list.nGappixelsY = 0;
break;
case MOENCH:
list.nChanX = 32;
list.nChanY = 1;
list.nChipX = 1;
list.nChipY = 1;
list.nDacs = 8;
list.dynamicRange = 16;
list.nGappixelsX = 0;
list.nGappixelsY = 0;
break; break;
case EIGER: case EIGER:
list.nChanX = 256; list.nChanX = 256;
@ -461,9 +470,9 @@ void slsDetector::initializeDetectorStructure(detectorType type) {
thisDetector->gappixels * thisDetector->nGappixels[Y]) * thisDetector->gappixels * thisDetector->nGappixels[Y]) *
thisDetector->dynamicRange / 8; thisDetector->dynamicRange / 8;
// special for jctb // update #nchans and databytes, as it depends on #samples, roi, readoutflags (ctb only)
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) { if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
getTotalNumberOfChannels(); updateTotalNumberOfChannels();
} }
/** calculates the memory offsets for /** calculates the memory offsets for
@ -740,42 +749,44 @@ std::string slsDetector::getDetectorTypeAsString() {
} }
int slsDetector::getTotalNumberOfChannels() { int slsDetector::getTotalNumberOfChannels() {
FILE_LOG(logDEBUG1) << "Get total number of channels";
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
if (thisDetector->roFlags & DIGITAL_ONLY) {
thisDetector->nChan[X] = 4;
} else if (thisDetector->roFlags & ANALOG_AND_DIGITAL) {
thisDetector->nChan[X] = 36;
} else {
thisDetector->nChan[X] = 32;
}
if (thisDetector->nChan[X] >= 32) {
if (thisDetector->nROI > 0) {
thisDetector->nChan[X] -= 32;
for (int iroi = 0; iroi < thisDetector->nROI; ++iroi) {
thisDetector->nChan[X] +=
thisDetector->roiLimits[iroi].xmax -
thisDetector->roiLimits[iroi].xmin + 1;
}
}
}
thisDetector->nChans = thisDetector->nChan[X];
thisDetector->dataBytes = thisDetector->nChans * thisDetector->nChips * 2 * thisDetector->timerValue[SAMPLES];
}
FILE_LOG(logDEBUG1) << "Total number of channels: " << thisDetector->nChans * thisDetector->nChips << ". Data bytes: " << thisDetector->dataBytes;
return thisDetector->nChans * thisDetector->nChips; return thisDetector->nChans * thisDetector->nChips;
} }
void slsDetector::updateTotalNumberOfChannels() {
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
// default number of channels
thisDetector->nChan[X] = 32;
// if roi, recalculate #nchanX
if (thisDetector->nROI > 0) {
thisDetector->nChan[X] = 0;
for (int iroi = 0; iroi < thisDetector->nROI; ++iroi) {
thisDetector->nChan[X] +=
(thisDetector->roiLimits[iroi].xmax -
thisDetector->roiLimits[iroi].xmin + 1);
}
}
// add digital signals depending on readout flags
if (thisDetector->myDetectorType == CHIPTESTBOARD &&
(thisDetector->roFlags & DIGITAL_ONLY || thisDetector->roFlags & ANALOG_AND_DIGITAL)) {
thisDetector->nChan[X] += 4;
}
// recalculate derived parameters chans and databytes
thisDetector->nChans = thisDetector->nChan[X];
thisDetector->dataBytes = thisDetector->nChans * thisDetector->nChips *
(thisDetector->dynamicRange / 8) * thisDetector->timerValue[SAMPLES];
FILE_LOG(logDEBUG1) << "Number of Channels:" << thisDetector->nChans << " Databytes: " << thisDetector->dataBytes;
}
}
int slsDetector::getTotalNumberOfChannels(dimension d) { int slsDetector::getTotalNumberOfChannels(dimension d) {
getTotalNumberOfChannels();
return thisDetector->nChan[d] * thisDetector->nChip[d]; return thisDetector->nChan[d] * thisDetector->nChip[d];
} }
int slsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) { int slsDetector::getTotalNumberOfChannelsInclGapPixels(dimension d) {
getTotalNumberOfChannels();
return (thisDetector->nChan[d] * thisDetector->nChip[d] + thisDetector->gappixels * thisDetector->nGappixels[d]); return (thisDetector->nChan[d] * thisDetector->nChip[d] + thisDetector->gappixels * thisDetector->nGappixels[d]);
} }
@ -1111,7 +1122,31 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
if (i64 >= 0) { if (i64 >= 0) {
thisDetector->timerValue[SAMPLES] = i64; thisDetector->timerValue[SAMPLES] = i64;
} }
getTotalNumberOfChannels(); }
// roi
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH|| thisDetector->myDetectorType == GOTTHARD) {
n += client.receiveData(&i32, sizeof(i32));
thisDetector->nROI = i32;
for (int i = 0; i < thisDetector->nROI; ++i) {
n += client.receiveData(&i32, sizeof(i32));
thisDetector->roiLimits[i].xmin = i32;
n += client.receiveData(&i32, sizeof(i32));
thisDetector->roiLimits[i].xmax = i32;
n += client.receiveData(&i32, sizeof(i32));
thisDetector->roiLimits[i].ymin = i32;
n += client.receiveData(&i32, sizeof(i32));
thisDetector->roiLimits[i].xmax = i32;
}
// moench (send to processor)
if (thisDetector->myDetectorType == MOENCH) {
sendROIToProcessor();
}
}
// update #nchans and databytes, as it depends on #samples, roi, readoutflags (ctb only)
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
updateTotalNumberOfChannels();
} }
@ -1906,6 +1941,11 @@ int64_t slsDetector::setTimer(timerIndex index, int64_t t) {
} else { } else {
FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval; FILE_LOG(logDEBUG1) << getTimerType(index) << ": " << retval;
thisDetector->timerValue[index] = retval; thisDetector->timerValue[index] = retval;
// update #nchans and databytes, as it depends on #samples, roi, readoutflags (ctb only)
if (index == SAMPLES &&
(thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH)) {
updateTotalNumberOfChannels();
}
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {
client.close(); client.close();
ret = updateDetector(); ret = updateDetector();
@ -2084,6 +2124,7 @@ int slsDetector::setDynamicRange(int n) {
} }
} }
// only for eiger
// setting dr consequences on databytes shm // setting dr consequences on databytes shm
// (a get can also change timer value, hence check difference) // (a get can also change timer value, hence check difference)
if (olddr != thisDetector->dynamicRange) { if (olddr != thisDetector->dynamicRange) {
@ -2094,9 +2135,6 @@ int slsDetector::setDynamicRange(int n) {
(thisDetector->nChip[Y] * thisDetector->nChan[Y] + (thisDetector->nChip[Y] * thisDetector->nChan[Y] +
thisDetector->gappixels * thisDetector->nGappixels[Y]) * thisDetector->gappixels * thisDetector->nGappixels[Y]) *
retval / 8; retval / 8;
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
getTotalNumberOfChannels();
}
FILE_LOG(logDEBUG1) << "Data bytes " << thisDetector->dataBytes; FILE_LOG(logDEBUG1) << "Data bytes " << thisDetector->dataBytes;
FILE_LOG(logDEBUG1) << "Data bytes including gap pixels" << thisDetector->dataBytesInclGapPixels; FILE_LOG(logDEBUG1) << "Data bytes including gap pixels" << thisDetector->dataBytesInclGapPixels;
} }
@ -2248,6 +2286,10 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
} else { } else {
FILE_LOG(logDEBUG1) << "Readout flag: " << retval; FILE_LOG(logDEBUG1) << "Readout flag: " << retval;
thisDetector->roFlags = (readOutFlags)retval; thisDetector->roFlags = (readOutFlags)retval;
// update #nchans and databytes, as it depends on #samples, roi, readoutflags (ctb only)
if (thisDetector->myDetectorType == CHIPTESTBOARD) {
updateTotalNumberOfChannels();
}
} }
} }
if (ret == FORCE_UPDATE) { if (ret == FORCE_UPDATE) {
@ -3114,6 +3156,17 @@ int slsDetector::setCounterBit(int i) {
return retval; return retval;
} }
int slsDetector::sendROIToProcessor() {
std::ostringstream os;
os << "[" << thisDetector->roiLimits[0].xmin << ", " << thisDetector->roiLimits[0].xmax << ", " <<
thisDetector->roiLimits[0].ymin << ", " << thisDetector->roiLimits[0].ymax << "]";
std::string sroi = os.str();
std::string result = setAdditionalJsonParameter("roi", sroi);
if (result == sroi)
return OK;
return FAIL;
}
int slsDetector::setROI(int n, ROI roiLimits[]) { int slsDetector::setROI(int n, ROI roiLimits[]) {
// sort ascending order // sort ascending order
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
@ -3138,35 +3191,29 @@ int slsDetector::setROI(int n, ROI roiLimits[]) {
int ret = sendROI(n, roiLimits); int ret = sendROI(n, roiLimits);
if(ret==FAIL) if(ret==FAIL)
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI)); setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
// moench (send to processor)
if (thisDetector->myDetectorType == MOENCH) {
sendROIToProcessor();
}
// update #nchans and databytes, as it depends on #samples, roi, readoutflags (ctb only)
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) { if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
getTotalNumberOfChannels(); updateTotalNumberOfChannels();
// moench (send to processor)
if (thisDetector->myDetectorType == MOENCH) {
std::ostringstream os;
os << "[" << roiLimits[0].xmin << ", " << roiLimits[0].xmax << ", " <<
roiLimits[0].ymin << ", " << roiLimits[0].ymax << "]";
std::string sroi = os.str();
std::string result = setAdditionalJsonParameter("roi", sroi);
if (result == sroi)
return OK;
return FAIL;
}
} }
return ret; return ret;
} }
slsDetectorDefs::ROI *slsDetector::getROI(int &n) { slsDetectorDefs::ROI *slsDetector::getROI(int &n) {
sendROI(-1, nullptr); sendROI(-1, nullptr);
n = thisDetector->nROI; n = thisDetector->nROI;
// moench - get json header(due to different clients, diff shm) (get roi is from detector: updated anyway)
if (thisDetector->myDetectorType == MOENCH) {
getAdditionalJsonHeader();
}
// update #nchans and databytes, as it depends on #samples, roi, readoutflags (ctb only)
if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) { if (thisDetector->myDetectorType == CHIPTESTBOARD || thisDetector->myDetectorType == MOENCH) {
getTotalNumberOfChannels(); updateTotalNumberOfChannels();
// moench - get json header(due to different clients, diff shm) (get roi is from detector: updated anyway)
if (thisDetector->myDetectorType == MOENCH) {
getAdditionalJsonHeader();
}
} }
return thisDetector->roiLimits; return thisDetector->roiLimits;
} }
int slsDetector::getNRoi() { int slsDetector::getNRoi() {

View File

@ -377,13 +377,18 @@ public:
*/ */
int setDetectorType(detectorType type=GET_DETECTOR_TYPE); int setDetectorType(detectorType type=GET_DETECTOR_TYPE);
/** /**
* Returns the total number of channels from shared memory * Returns the total number of channels from shared memory
* @returns the total number of channels * @returns the total number of channels
*/ */
int getTotalNumberOfChannels(); int getTotalNumberOfChannels();
/**
* Update total number of channels (chiptestboard or moench)
* depending on the number of samples, roi, readout flags(ctb)
*/
void updateTotalNumberOfChannels();
/** /**
* Returns the total number of channels in dimension d from shared memory * Returns the total number of channels in dimension d from shared memory
* @param d dimension d * @param d dimension d
@ -1067,6 +1072,12 @@ public:
*/ */
int setCounterBit(int i = -1); int setCounterBit(int i = -1);
/**
* send ROI to processor (moench only)
* @returns OK or FAIL
*/
int sendROIToProcessor();
/** /**
* Set ROI (Gotthard) * Set ROI (Gotthard)
* At the moment only one set allowed * At the moment only one set allowed

View File

@ -213,7 +213,7 @@ public:
* @param s number of samples * @param s number of samples
* @param t tengiga enable * @param t tengiga enable
*/ */
virtual void setImageSize(std::vector<slsDetectorDefs::ROI> i, int s, bool t, slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) { virtual void setImageSize(std::vector<slsDetectorDefs::ROI> r, int s, bool t, slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) {
cprintf(RED,"setImageSize is a generic function that should be overloaded by a derived class\n"); cprintf(RED,"setImageSize is a generic function that should be overloaded by a derived class\n");
}; };
@ -555,15 +555,18 @@ public:
* @param s number of samples * @param s number of samples
* @param t tengiga enable * @param t tengiga enable
*/ */
void setImageSize(std::vector<slsDetectorDefs::ROI> i, int s, bool t, slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) { void setImageSize(std::vector<slsDetectorDefs::ROI> r, int s, bool t, slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) {
int nchans = 0; int nchans = 0;
if (f != slsDetectorDefs::GET_READOUT_FLAGS) { if (f != slsDetectorDefs::GET_READOUT_FLAGS) {
// analog channels // analog channels
if (f == slsDetectorDefs::NORMAL_READOUT || f & slsDetectorDefs::ANALOG_AND_DIGITAL) { if (f == slsDetectorDefs::NORMAL_READOUT || f & slsDetectorDefs::ANALOG_AND_DIGITAL) {
nchans += NCHAN_ANALOG; nchans += NCHAN_ANALOG;
// if roi // if roi
if (i.size()) { if (r.size()) {
nchans = abs(i[0].xmax - i[0].xmin); nchans = 0;
for (auto &roi : r) {
nchans += (roi.xmax - roi.xmin + 1);
}
} }
} }
// digital channels // digital channels
@ -575,18 +578,20 @@ public:
nPixelsY = s; nPixelsY = s;
// 10G // 10G
if (t) { if (t) {
// fixed values headerSizeinPacket = 22;
dataSize = 0; // FIXME: fix when firmware written dataSize = 8192;
packetSize = headerSizeinPacket + dataSize; packetSize = headerSizeinPacket + dataSize;
packetsPerFrame = 0; // FIXME: fix when firmware written imageSize = nPixelsX * nPixelsY * 2;
imageSize = dataSize*packetsPerFrame; // FIXME: OR fix when firmware written packetsPerFrame = ceil((double)imageSize / (double)packetSize);
} standardheader = false; }
// 1g udp (via fifo readout) // 1g udp (via fifo readout)
else { else {
dataSize = UDP_PACKET_DATA_BYTES; headerSizeinPacket = sizeof(slsDetectorDefs::sls_detector_header);
packetSize = headerSizeinPacket + dataSize; dataSize = UDP_PACKET_DATA_BYTES;
imageSize = nchans * NUM_BYTES_PER_PIXEL * s; packetSize = headerSizeinPacket + dataSize;
packetsPerFrame = ceil((double)imageSize / (double)UDP_PACKET_DATA_BYTES); imageSize = nPixelsX * nPixelsY * 2;
packetsPerFrame = ceil((double)imageSize / (double)UDP_PACKET_DATA_BYTES);
standardheader = true;
} }
} }
@ -658,12 +663,15 @@ private:
* @param s number of samples * @param s number of samples
* @param t tengiga enable * @param t tengiga enable
*/ */
void setImageSize(std::vector<slsDetectorDefs::ROI> i, int s, bool t, void setImageSize(std::vector<slsDetectorDefs::ROI> r, int s, bool t,
slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) { slsDetectorDefs::readOutFlags f = slsDetectorDefs::GET_READOUT_FLAGS) {
int nchans = NCHAN_ANALOG; int nchans = NCHAN_ANALOG;
// if roi // if roi
if (i.size()) { if (r.size()) {
nchans = abs(i[0].xmax - i[0].xmin); nchans = 0;
for (auto &roi : r) {
nchans += abs(roi.xmax - roi.xmin) + 1;
}
} }
nPixelsX = nchans; nPixelsX = nchans;

View File

@ -480,6 +480,9 @@ int slsReceiverImplementation::setReadOutFlags(const readOutFlags f) {
flag.append("nooverflow "); flag.append("nooverflow ");
FILE_LOG(logINFO) << "ReadoutFlags: " << flag; FILE_LOG(logINFO) << "ReadoutFlags: " << flag;
if (myDetectorType == CHIPTESTBOARD) {
FILE_LOG (logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
}
return OK; return OK;
} }
@ -672,6 +675,7 @@ int slsReceiverImplementation::setROI(const std::vector<slsDetectorDefs::ROI> i)
} }
std::string message = sstm.str(); std::string message = sstm.str();
FILE_LOG(logINFO) << message; FILE_LOG(logINFO) << message;
FILE_LOG (logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
return OK; return OK;
} }
@ -844,6 +848,7 @@ int slsReceiverImplementation::setTenGigaEnable(const bool b) {
return FAIL; return FAIL;
} }
FILE_LOG(logINFO) << "Ten Giga: " << stringEnable(tengigaEnable); FILE_LOG(logINFO) << "Ten Giga: " << stringEnable(tengigaEnable);
FILE_LOG (logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
return OK; return OK;
} }