Merge branch 'developer' into gui

This commit is contained in:
maliakal_d 2019-06-17 17:41:17 +02:00
commit b6bba0b7bc
15 changed files with 874 additions and 469 deletions

View File

@ -38,7 +38,7 @@
#include "Mythen3_01_jctbData.h"
#include "Mythen3_02_jctbData.h"
#include "adcSar2_jctbData.h"
#include "moench04CtbReceiverData.h"
#include "moench04CtbZmqData.h"
#include "deserializer.h"
#include "detectorData.h"
@ -299,7 +299,7 @@ hframe=new TGHorizontalFrame(this, 800,50);
TGNumberFormat::kNELLimitMinMax,0,16535);
hframe->AddFrame(eNumCount,new TGLayoutHints(kLHintsTop | kLHintsExpandX, 1, 1, 1, 1));
eNumCount->MapWindow();;
eNumCount->SetNumber(64*3);
eNumCount->SetNumber(128*3);
e= eNumCount->TGNumberEntry::GetNumberEntry();
eNumCount->Connect("ValueSet(Long_t)","ctbAcquisition",this,"ChangeNumberOfChannels(Long_t)");
e->Connect("ReturnPressed()","ctbAcquisition",this,"ChangeNumberOfChannels()");
@ -633,8 +633,8 @@ hframe=new TGHorizontalFrame(this, 800,50);
// mgAdcs=new TMultiGraph();
// bitStack=new THStack();
bitStack=adcStack;
bitStack=new THStack();
// bitStack=adcStack;
TH1F *hb;
for (int i=0; i<NSIGNALS; i++) {
sprintf(tit,"bit%d",i);
@ -670,7 +670,8 @@ hframe=new TGHorizontalFrame(this, 800,50);
dataStructure=NULL;
commonMode=NULL;
photonFinder=NULL;
h2DMap=NULL;
h2DMapAn=NULL;
h2DMapDig=NULL;
//h2Scan=NULL;
h1DMap=NULL;
@ -901,86 +902,46 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
uint16_t aval;
i=0;
for (ip=0; ip<nAnalogSamples; ip++) {
for (ii=0; ii<nadc; ii++) {
//for (ip=0; ip<adclist.size(); ip++) {
char *d_data= data->cvalues+2*nadc*nAnalogSamples;
char dval;
if (dataStructure) {
for (int x=0; x<nx; x++) {
for (int y=0; y<ny; y++) {
ped=0;
aval=dataStructure->getValue(data->cvalues,x,y);
if (adclist.empty())
ig=ii;
else
ig=adclist.at(ii);
aval=data->getChannel(i);//*((uint16_t*)(data->cvalues+i*2));//
// cout << "asample " << ip << " adc " << ig << " " << i << " " << aval << endl;
ped=0;
if (dataStructure) {
dataStructure->getPixel(i,x,y);
if (cbGetPedestal->IsOn()) {
if (photonFinder) {
photonFinder->addToPedestal(aval,x,y);
}
}
if (plotFlag[ig]) {
if (cbSubtractPedestal->IsOn()) {
if (photonFinder) {
ped=photonFinder->getPedestal(x,y,cmSub);
}
}
//normal filling except when deserializer
if (h2DMap)
h2DMap->SetBinContent(x+1,y+1,aval-ped);
if (h1DMap){
h1DMap->SetBinContent(x+1,aval-ped);
// cout << "plotting 1D " << endl;
}
// if (h2Scan) {
// //cout << "plotting Scan " << endl;
// h2Scan->SetBinContent((x+1)+y*nx,iScanStep+1,data->getChannel(i)-ped);
// } else
// cout << "No scan (analog)" << endl;
if (cbSubtractPedestal->IsOn()) {
if (photonFinder) {
ped=photonFinder->getPedestal(x,y,cmSub);
}
}
if (h2DMapAn)
h2DMapAn->SetBinContent(x+1,y+1,aval-ped);
if (h2DMapDig)
h2DMapDig->SetBinContent(x+1,y+1,dataStructure->getGain(data->cvalues,x,y));
}
//if (enableFlag[ig]) {
h=adcHisto[ig];
h1=countsHisto[ig];
//}
if (plotFlag[ig]) {
// cout << data->getChannel(i) << endl;
h->SetBinContent(ip+1,aval-ped);
h1->Fill(aval-ped);
}
i++;
}
}
char *d_data= data->cvalues+2*nadc*nAnalogSamples;
char dval;
/**** Digital Samples ****/
} else
if (deserializer) {
cout << "deserializer"<< endl;
if (dbitlist.empty())
val=deserializer::deserializeAll(d_data,plotlist,dr,nx,soff);//dataStructure->getData(d_data);
else
@ -988,168 +949,210 @@ sample1 (dbit0 + dbit1 +...)if (cmd == "rx_dbitlist") {
if (val) {
// if (h2DMap) {
// for (x=0; x<nx; x++) {
// for (y=0; y<ny; y++) {
// h2DMap->SetBinContent(x+1,y+1,val[y][x]);
// }
// }
// }
if (h1DMap){
for (x=0; x<nx; x++) {
h1DMap->SetBinContent(x+1,val[x]);
// cout << dec << x << " " << val[0][x] << endl;
}
}
// if (h2Scan) {
// for (x=0; x<nx; x++) {
// for (y=0; y<ny; y++) {
// //cout << "plotting Scan " << (x+1)+y*nx << " " << iScanStep+1 << " " << val[y][x] << endl;
// h2Scan->SetBinContent((x+1)+y*nx,iScanStep+1,val[y][x]);
// }
// }
// } else
// cout << "No scan (digital)" << endl;
delete [] val;
} else
cout << "get val did not succeed"<<endl;
}
} else {
cout << "analog histo " << endl;
for (ip=0; ip<nAnalogSamples; ip++) {
for (ii=0; ii<nadc; ii++) {
//for (ip=0; ip<adclist.size(); ip++) {
if (adclist.empty())
ig=ii;
else
ig=adclist.at(ii);
aval=data->getChannel(i);//*((uint16_t*)(data->cvalues+i*2));//
if (plotFlag[ig]) {
//if (enableFlag[ig]) {
h=adcHisto[ig];
h1=countsHisto[ig];
//}
// cout << data->getChannel(i) << endl;
h->SetBinContent(ip+1,aval);
h1->Fill(aval);
}
i++;
}
}
cout << "bit histo"<< endl;
if (dbitlist.empty()) {
for (ip=0; ip<nDigitalSamples; ip++) {
for (ig=0; ig<8; ig++) {
dval=*(d_data+ip*8+ig);
for (ib=(ig)*8; ib<(ig+1)*8; ib++) {
// cout << "dsample " << ip << " bit " << ib << endl;
// cout << "Bit number " << ib << endl;
if (bitPlotFlag[ib]) {
hb=bitHisto[ib];
// if (bitStack->GetHists()->Contains(hb)==0) cout << "ERROR!" << endl;
//#define ADCSAR2
// #ifdef ADCSAR2
// if (ib==0) vv1=dval;
// if (ib==16) vv2=dval;
// cout << ib << " " << hex << vv << dec << endl;
// #endif
if (dbitlist.empty()) {
for (ip=0; ip<nDigitalSamples; ip++) {
for (ig=0; ig<8; ig++) {
dval=*(d_data+ip*8+ig);
for (ib=(ig)*8; ib<(ig+1)*8; ib++) {
if (bitPlotFlag[ib]) {
hb=bitHisto[ib];
if (dval&(1<<(ib%8)))
hb->SetBinContent(ip+1,1+bitOffset[ib]);
else
hb->SetBinContent(ip+1,bitOffset[ib]);
}
}
}
// #ifdef ADCSAR2
// //this is a deserializer similar to MYTHEN!
// hb=bitHisto[0];
// int adcvalue=0;
// // int startbit= ig;
// for (int jj=0;jj<8;jj++){
// adcvalue=adcvalue+ (((vv1>>(jj*2)) & 0x1)<<(jj));
// }
// for (int jj=0;jj<4;jj++){
// adcvalue=adcvalue+ (((vv2>>(jj*2)) & 0x1)<<(jj+8));
// }
// hb->SetBinContent(ip+1, adcvalue);
// printf(" %d 0x%x 0x%x adc=%d \n", i, vv1, vv2, adcvalue);
// #endif
}
}
} else {
ii=0;
int iii=0;
int nb=dbitlist.size();
for (const auto &value : dbitlist) {
ib=value;
hb=bitHisto[ib];
cout << dec <<endl << "Bit " << ib << " " << (nDigitalSamples-dBitOffset)/8 << endl;
iii=0;
for (ip=0; ip<(nDigitalSamples-dBitOffset)/8; ip++) {
if (bitPlotFlag[ib]) {
dval=*(d_data+ii*nDigitalSamples/8+ip);
for (int jj=0; jj<8; jj++) {
if (dval&(1<<jj))
hb->SetBinContent(iii,1+bitOffset[ib]);
else
hb->SetBinContent(iii,bitOffset[ib]);
iii++;
}
}
}
ii++;
} else {
ii=0;
int iii=0;
int nb=dbitlist.size();
for (const auto &value : dbitlist) {
ib=value;
hb=bitHisto[ib];
// cout << dec <<endl << "Bit " << ib << " " << (nDigitalSamples-dBitOffset)/8 << endl;
iii=0;
for (ip=0; ip<(nDigitalSamples-dBitOffset)/8; ip++) {
if (bitPlotFlag[ib]) {
dval=*(d_data+ii*nDigitalSamples/8+ip);
for (int jj=0; jj<8; jj++) {
if (dval&(1<<jj))
hb->SetBinContent(iii,1+bitOffset[ib]);
else
hb->SetBinContent(iii,bitOffset[ib]);
iii++;
}
}
}
ii++;
}
}
}
Draw();
// iScanStep++;
if (photonFinder)
photonFinder->newFrame();
return i;
}
}
return 0;
}
void ctbAcquisition::Draw(){
if (globalPlot) {
// TThread::Lock();
cout << "Draw" << endl;
if (myCanvas && globalPlot!=0) {
myCanvas->cd();
myCanvas->Modified();
myCanvas->Update();
if (myCanvas) {
if (adcPlot && dbitPlot) {
myCanvas->cd(1);
// myCanvas->Modified();
// myCanvas->Update();
gPad->Modified();
gPad->Update();
myCanvas->cd(2);
// myCanvas->Modified();
// myCanvas->Update();
gPad->Modified();
gPad->Update();
} else {
myCanvas->cd();
myCanvas->Modified();
myCanvas->Update();
}
}
// TThread::UnLock();
}
}
//here!!
void ctbAcquisition::changePlot(){
if (rbPlotOff->IsOn()) {
globalPlot=0;
adcPlot=0;
dbitPlot=0;
} else {
globalPlot=0;
adcPlot=0;
dbitPlot=0;
for (int ii=0; ii<NADCS; ii++)
if (plotFlag[ii]==1) globalPlot=1;
if (plotFlag[ii]==1) adcPlot=1;
for (int ii=0; ii<NSIGNALS; ii++)
if (bitPlotFlag[ii]==1) globalPlot=1;
if (bitPlotFlag[ii]==1) dbitPlot=1;
}
globalPlot=adcPlot || dbitPlot;
if (globalPlot!=0 && myCanvas) {
if (rbWaveform->IsOn())
if (adcStack)
adcStack->Draw("NOSTACK");
if (adcPlot && dbitPlot) {
if (myCanvas->GetPad(1)==NULL || myCanvas->GetPad(2)==NULL) {
myCanvas->Clear();
myCanvas->Divide(1,2);
} else
cout << "Pad already there" << endl;
myCanvas->cd(1);
} else {
myCanvas->Clear();
// myCanvas->Divide(1,1);
myCanvas->cd();
}
if (adcPlot) {
if (rbWaveform->IsOn())
if (adcStack)
adcStack->Draw("NOSTACK");
else
cout << "adcStack is NULL" << endl;
else if (rbDistribution->IsOn())
if (countsStack)
countsStack->Draw("NOSTACK");
else
cout << "countsStack is NULL" << endl;
else if (rb2D->IsOn()) {
if (h2DMapAn)
h2DMapAn->Draw("colz");
else if (h1DMap)
h1DMap->Draw();
else
cout << "h2DMap and h1DMap are NULL" << endl;
}
}
if (dbitPlot) {
if (adcPlot)
myCanvas->cd(2);
if (rb2D->IsOn()) {
if (h2DMapDig)
h2DMapDig->Draw("colz");
} else if (bitStack)
bitStack->Draw("NOSTACK");
else
cout << "adcStack is NULL" << endl;
else if (rbDistribution->IsOn())
if (countsStack)
countsStack->Draw("NOSTACK");
else
cout << "countsStack is NULL" << endl;
else if (rb2D->IsOn()) {
if (h2DMap)
h2DMap->Draw("colz");
else if (h1DMap)
h1DMap->Draw();
else
cout << "h2DMap and h1DMap are NULL" << endl;
} // else if (rbScan->IsOn()) {
cout << "bitStack is NULL" << endl;
}
// else if (rbScan->IsOn()) {
// if (h2Scan)
// h2Scan->Draw("colz");
// else
// cout << "h2Scan is NULL" << endl;
// }
}
Draw();
Draw();
}
}
@ -1158,28 +1161,30 @@ void ctbAcquisition::changePlot(){
void ctbAcquisition::changeDetector(){
// cout << "change detector " << i << " old " << cbDetType->GetSelected() << endl;
if (dataStructure) delete dataStructure;
if (commonMode) delete commonMode;
if (photonFinder) delete photonFinder;
if (h2DMap) delete h2DMap;
if (dataStructure) delete dataStructure;
if (commonMode) delete commonMode;
if (photonFinder) delete photonFinder;
if (h2DMapAn) delete h2DMapAn;
if (h2DMapDig) delete h2DMapDig;
if (h1DMap) delete h1DMap;
// if (h2Scan) delete h2Scan;
h2DMap=NULL;
h2DMapAn=NULL;
h2DMapDig=NULL;
h1DMap=NULL;
// h2Scan=NULL;
photonFinder=NULL;
dataStructure=NULL;
commonMode=NULL;
TH2F *h2DMapOld=h2DMap;
TH2F *h2DMapOld=h2DMapAn;
// TH2F *h2ScanOld=h2Scan;
TH1F *h1DMapOld=h1DMap;
int dim=2;
int nx,ny;
int csize=3;
int nsigma=5;
commonModeSubtraction* cm=0;
eNumCount->SetState(kFALSE);
int nx,ny;
int csize=3;
int nsigma=5;
commonModeSubtraction* cm=0;
eNumCount->SetState(kFALSE);
eDynRange->SetState(kFALSE);
eSerOff->SetState(kFALSE);
deserializer=0;
@ -1187,12 +1192,12 @@ void ctbAcquisition::changeDetector(){
switch (cbDetType->GetSelected()) {
case DESERIALIZER:
deserializer=1;
// cout << "DESERIALIZER!" << endl;
cout << "DESERIALIZER!" << endl;
// dataStructure=new moench03T1CtbData();
// commonMode=new moench03CommonMode();
break;
case MOENCH04:
dataStructure=new moench04CtbReceiverData();
dataStructure=new moench04CtbZmqData(nAnalogSamples, nDigitalSamples);
cout << "MOENCH 0.4!" << endl;
commonMode=new moench03CommonMode();
break;
@ -1263,6 +1268,9 @@ void ctbAcquisition::changeDetector(){
if (deserializer) {
ny=1;
nx=eNumCount->GetIntNumber();
eNumCount->SetState(kTRUE);
eDynRange->SetState(kTRUE);
eSerOff->SetState(kTRUE);
}
// cout << "h size is " << nx << " " << ny << endl;
int ymax=ny, xmax=nx;
@ -1271,9 +1279,14 @@ void ctbAcquisition::changeDetector(){
cout << "*** " << nx << " " << ny << endl;
if (rb2D->IsOn()) {
if (ny>1) {
h2DMap=new TH2F("h2dmap","",nx,0,xmax,ny,0,ymax);
h2DMap->SetStats(kFALSE);
cout << "Created h2DMap"<< endl;
h2DMapAn=new TH2F("h2dmapAn","",nx,0,xmax,ny,0,ymax);
h2DMapAn->SetStats(kFALSE);
cout << "Created h2DMapAn"<< endl;
if (dbitPlot && adcPlot){
h2DMapDig=new TH2F("h2dmapDig","",nx,0,xmax,ny,0,ymax);
h2DMapDig->SetStats(kFALSE);
cout << "Created h2DMapDig"<< endl;
}
} else {
h1DMap=new TH1F("h1dmap","",nx,0,xmax);
h1DMap->SetStats(kFALSE);
@ -1598,8 +1611,10 @@ void ctbAcquisition::toggleAcquisition() {
for (int i=0; i<NSIGNALS; i++) {
bitHisto[i]->Reset();
}
cout << "reset 2d" << endl;;
if (h2DMap) h2DMap->Reset();
cout << "reset 2d an" << endl;;
if (h2DMapAn) h2DMapAn->Reset();
cout << "reset 2d dig" << endl;;
if (h2DMapDig) h2DMapDig->Reset();
cout << "reset 1d" << endl;;
if (h1DMap) h1DMap->Reset();
cout << "done" << endl;;
@ -1953,42 +1968,44 @@ void ctbAcquisition::ChangeNumberOfChannels(Long_t a){
void ctbAcquisition::ChangeSerialOffset(){
if (dataStructure) {
// if (dataStructure) {
cout << cbDetType->GetSelected()<< endl;
if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302 ){
cout << "settings offsets for MYTHEN" << endl;
mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
ms->setSerialOffset(eSerOff->GetIntNumber());
// // cout << cbDetType->GetSelected()<< endl;
// // if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302 ){
// // cout << "settings offsets for MYTHEN" << endl;
// // mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// // ms->setSerialOffset(eSerOff->GetIntNumber());
}
}
// // }
// }
};
void ctbAcquisition::ChangeDynamicRange(){
if (dataStructure) {
// if (dataStructure) {
cout << cbDetType->GetSelected()<< endl;
if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
cout << "settings dynamic range for MYTHEN" << endl;
mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
ms->setDynamicRange(eDynRange->GetIntNumber());
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
// cout << "settings dynamic range for MYTHEN" << endl;
// mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// ms->setDynamicRange(eDynRange->GetIntNumber());
}
}
// }
// }
};
void ctbAcquisition::ChangeNumberOfChannels(){
if (dataStructure) {
cout << cbDetType->GetSelected()<< endl;
if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
cout << "settings number of channels for MYTHEN" << endl;
mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
ms->setNumberOfCounters(eNumCount->GetIntNumber());
// if (dataStructure) {
// cout << cbDetType->GetSelected()<< endl;
// if (cbDetType->GetSelected()==MYTHEN301 || cbDetType->GetSelected()==MYTHEN302){
// cout << "settings number of channels for MYTHEN" << endl;
// mythen3_01_jctbData* ms=(mythen3_01_jctbData*)dataStructure;
// ms->setNumberOfCounters(eNumCount->GetIntNumber());
}
}
// }
// }
if (deserializer)
changePlot();
};
@ -2023,9 +2040,9 @@ void ctbAcquisition::ChangeHistoLimitsPedSub(){
if (cMinMaxPedSub->IsOn()) {
adcStack->SetMaximum( eMaxPedSub->GetNumber());
adcStack->SetMinimum( eMinPedSub->GetNumber());
if (h2DMap) {
h2DMap->SetMaximum( eMaxPedSub->GetNumber());
h2DMap->SetMinimum( eMinPedSub->GetNumber());
if (h2DMapAn) {
h2DMapAn->SetMaximum( eMaxPedSub->GetNumber());
h2DMapAn->SetMinimum( eMinPedSub->GetNumber());
}
if (h1DMap) {
h1DMap->SetMaximum( eMaxPedSub->GetNumber());
@ -2036,11 +2053,11 @@ void ctbAcquisition::ChangeHistoLimitsPedSub(){
} else {
if (adcStack->GetHistogram())
adcStack->GetHistogram()->GetYaxis()->UnZoom();
if (h2DMap) {
h2DMap->GetZaxis()->UnZoom();
if (h2DMapAn) {
h2DMapAn->GetZaxis()->UnZoom();
}
if (h1DMap) {
h1DMap->GetYaxis()->UnZoom();
h1DMap->GetYaxis()->UnZoom();
}
if (countsStack->GetHistogram())
countsStack->GetHistogram()->GetXaxis()->UnZoom();
@ -2061,9 +2078,9 @@ void ctbAcquisition::ChangeHistoLimitsRaw(){
if (cMinMaxRaw->IsOn()) {
adcStack->SetMaximum( eMaxRaw->GetNumber());
adcStack->SetMinimum( eMinRaw->GetNumber());
if (h2DMap) {
h2DMap->SetMaximum( eMaxRaw->GetNumber());
h2DMap->SetMinimum( eMinRaw->GetNumber());
if (h2DMapAn) {
h2DMapAn->SetMaximum( eMaxRaw->GetNumber());
h2DMapAn->SetMinimum( eMinRaw->GetNumber());
}
if (h1DMap) {
h1DMap->SetMaximum( eMaxRaw->GetNumber());
@ -2075,8 +2092,8 @@ void ctbAcquisition::ChangeHistoLimitsRaw(){
if (adcStack->GetHistogram())
adcStack->GetHistogram()->GetYaxis()->UnZoom();
if (h2DMap) {
h2DMap->GetZaxis()->UnZoom();
if (h2DMapAn) {
h2DMapAn->GetZaxis()->UnZoom();
}
if (h1DMap) {

View File

@ -20,8 +20,8 @@ class TTimer;
class TCanvas;
class TH2F;
class TH1F;
class TGLabel;
class TGTextButton;
class TGLabel;
class TGTextButton;
class multiSlsDetector;
class detectorData;
@ -103,7 +103,8 @@ class ctbAcquisition : public TGGroupFrame {
TH2F *h2DMap; // for 2D detectors
TH2F *h2DMapAn; // for 2D detectors
TH2F *h2DMapDig; // for 2D detectors
TH1F *h1DMap; //for 1D detectors
// TH2F *h2Scan; // for 2D detectors
@ -148,6 +149,8 @@ class ctbAcquisition : public TGGroupFrame {
char patternCompiler[10000];
int globalPlot;
int adcPlot;
int dbitPlot;
int nAnalogSamples, nDigitalSamples;
// int iScanStep;

View File

@ -126,7 +126,7 @@ void setwaittime(int iloop, uint64_t t) {
void pw(){
if (iaddr<MAXWORDS)
PAT[iaddr]= pat;
fprintf(fd,"patword %04x %016llx\n",iaddr, pat);
fprintf(fd,"patword 0x%04x 0x%016llx\n",iaddr, pat);
iaddr++;
if (iaddr>=MAXWORDS) printf("ERROR: too many word in the pattern (%d instead of %d)!",iaddr, MAXWORDS);
}
@ -154,18 +154,18 @@ main(void) {
fd=fopen(OUTFILE,"w");
#include INFILE
fprintf(fd,"patioctrl %016llx\n",iopat);
fprintf(fd,"patclkctrl %016llx\n",clkpat);
fprintf(fd,"patlimits %04x %04x\n",start, stop);
fprintf(fd,"patioctrl 0x%016llx\n",iopat);
fprintf(fd,"patclkctrl 0x%016llx\n",clkpat);
fprintf(fd,"patlimits 0x%04x 0x%04x\n",start, stop);
for (iloop=0; iloop<MAXLOOPS; iloop++) {
fprintf(fd,"patloop%d %04x %04x\n",iloop, startloopaddr[iloop], stoploopaddr[iloop]);
fprintf(fd,"patloop%d 0x%04x 0x%04x\n",iloop, startloopaddr[iloop], stoploopaddr[iloop]);
if ( startloopaddr[iloop]<0 || stoploopaddr[iloop]<= startloopaddr[iloop]) nloop[iloop]=0;
fprintf(fd,"patnloop%d %d\n",iloop, nloop[iloop]);
}
for (iloop=0; iloop<MAXTIMERS; iloop++) {
fprintf(fd,"patwait%d %04x\n",iloop, waitaddr[iloop]);
fprintf(fd,"patwait%d 0x%04x\n",iloop, waitaddr[iloop]);
if (waitaddr[iloop]<0) waittime[iloop]=0;
fprintf(fd,"patwaittime%d %lld\n",iloop, waittime[iloop]);
}

View File

@ -0,0 +1,276 @@
#ifndef MOENCH04ZMQDATA_H
#define MOENCH04ZMQDATA_H
#include "slsDetectorData.h"
class moench04CtbZmqData : public slsDetectorData<uint16_t> {
private:
int iframe;
int nadc;
int sc_width;
int sc_height;
const int aSamples;
const int dSamples;
public:
/**
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
(160x160 pixels, 40 packets 1286 large etc.)
\param c crosstalk parameter for the output buffer
*/
moench04CtbZmqData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
int row, col;
int isample;
int iadc;
int ix, iy;
int npackets=40;
int i;
int adc4(0);
for (int is=0; is<aSamples; is++) {
for (iadc=0; iadc<nadc; iadc++) {
i=is;
// adc4=(int)iadc/4;
if (i<sc_width*sc_height) {
// for (int i=0; i<sc_width*sc_height; i++) {
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
// if (adc4%2==0) {
if (iadc<16) {
row=199-i/sc_width;
} else {
row=200+i/sc_width;
}
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
}
}
}
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
/* xmap[ibyte]=-1; */
/* ymap[ibyte]=-1; */
/* } */
/* int off=sizeof(sls_detector_header)/2; */
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
/* i=ipacket*8208/2+ibyte; */
/* isample=ii/nadc; */
/* if (isample<nSamples) { */
/* iadc=ii%nadc; */
/* adc4 = (int)iadc/4; */
/* ix=isample%sc_width; */
/* iy=isample/sc_width; */
/* if (adc4%2==0) { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2-1-iy; */
/* } else { */
/* xmap[i+off]=adc_nr[iadc]+ix; */
/* ymap[i+off]=ny/2+iy; */
/* } */
/* } */
/* ii++; */
/* // } */
/* } */
/* } */
iframe=0;
// cout << "data struct created" << endl;
}
int getGain(char *data, int x, int y) {
int aoff=aSamples*2*32;
int irow;
int isc=x/sc_width;
int icol=x%sc_width;
if (y<200) irow=sc_height-1-y;
else {
irow=y-sc_height;
isc++;
}
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
int isample=irow*sc_width+icol;
uint64_t sample;
char *ptr;
if (isc<0 || isc>=32) return 0;
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
if (dSamples>isample) {
ptr=data+aoff+8*isample;
sample=*((uint64_t*)ptr);
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
if (sample & (1<<ibit[isc]))
return 1;
else
return 0;
} else
return 0;
}
/**
Returns the frame number for the given dataset. Purely virtual func.
\param buff pointer to the dataset
\returns frame number
*/
/* class jfrau_packet_header_t { */
/* public: */
/* unsigned char reserved[4]; */
/* unsigned char packetNumber[1]; */
/* unsigned char frameNumber[3]; */
/* unsigned char bunchid[8]; */
/* }; */
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
/**
Returns the packet number for the given dataset. purely virtual func
\param buff pointer to the dataset
\returns packet number number
*/
//int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
/* /\** */
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
/* \param data pointer to the memory to be analyzed */
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
/* \param dsize size of the memory slot to be analyzed */
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
/* *\/ */
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
/* /\** */
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
/* \param filebin input file stream (binary) */
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
/* *\/ */
/* virtual char *readNextFrame(ifstream &filebin){ */
/* // int afifo_length=0; */
/* uint16_t *afifo_cont; */
/* int ib=0; */
/* if (filebin.is_open()) { */
/* afifo_cont=new uint16_t[dataSize/2]; */
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
/* ib+=2; */
/* if (ib==dataSize) break; */
/* } */
/* if (ib>0) { */
/* iframe++; */
/* // cout << ib << "-" << endl; */
/* return (char*)afifo_cont; */
/* } else { */
/* delete [] afifo_cont; */
/* return NULL; */
/* } */
/* } */
/* return NULL; */
/* }; */
virtual char *readNextFrame(ifstream &filebin) {
int ff=-1, np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int &ff) {
int np=-1;
return readNextFrame(filebin, ff, np);
};
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
char *data=new char[dataSize];
char *d=readNextFrame(filebin, ff, np, data);
if (d==NULL) {delete [] data; data=NULL;}
return data;
}
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
char *retval=0;
int nd;
int fnum = -1;
np=0;
int pn;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){
ff=getFrameNumber(data);
// np=getPacketNumber(data);
return data;
}
}
return NULL;
};
/**
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
\param data pointer to the memory to be analyzed
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
\param dsize size of the memory slot to be analyzed
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
*/
virtual char *findNextFrame(char *data, int &ndata, int dsize){
if (dsize<dataSize) ndata=dsize;
else ndata=dataSize;
return data;
}
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
};
#endif

View File

@ -261,6 +261,8 @@ class slsDetectorData {
return d^m;
};
virtual int getGain(char *data, int ix, int iy=0){return 0;};
/**
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.

View File

@ -10,7 +10,8 @@ INSTMODE = 0777
SRC_CLNT = communication_funcs.c slsDetectorServer.c slsDetectorServer_funcs.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.c=.o)
all: clean versioning $(PROGS)
#all: clean versioning $(PROGS)
all: clean $(PROGS)
boot: $(OBJS)

View File

@ -1633,7 +1633,7 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
return;
}
FILE_LOG(logINFO, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
FILE_LOG(logDEBUG1, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
int valShift = val;
// convert to phase shift
if (degrees) {
@ -1649,6 +1649,7 @@ void configurePhase(enum CLKINDEX ind, int val, int degrees) {
FILE_LOG(logINFO, ("\tNothing to do in Phase Shift\n"));
return;
}
FILE_LOG(logINFOBLUE, ("\tConfiguring Phase of C%d(%s) to %d (degree mode: %d)\n", ind, clock_names[ind], val, degrees));
int phase = 0;
if (relativePhase > 0) {
@ -1723,15 +1724,32 @@ void configureFrequency(enum CLKINDEX ind, int val) {
return;
}
// reset phase
if (ind == ADC_CLK || ind == DBIT_CLK) {
FILE_LOG(logINFO, ("\tReseting phase of %s\n", clock_names[ind]));
configurePhase(ind, 0, 0);
}
// Remembering adcphase/ dbit phase
int adcPhase = getPhase(ADC_CLK, 0);
FILE_LOG(logDEBUG1, ("\tRemembering ADC phase: %d\n", adcPhase));
int dbitPhase = getPhase(DBIT_CLK, 0);
FILE_LOG(logDEBUG1, ("\tRemembering DBIT phase: %d\n", dbitPhase));
// Calculate and set output frequency
clkDivider[ind] = ALTERA_PLL_SetOuputFrequency (ind, PLL_VCO_FREQ_MHZ, val);
FILE_LOG(logINFO, ("\tC%d(%s): Frequency set to %d MHz\n", ind, clock_names[ind], clkDivider[ind]));
// adc and dbit phase is reset by pll (when setting output frequency)
clkPhase[ADC_CLK] = 0;
clkPhase[DBIT_CLK] = 0;
// set the phase if custom set
if (clkPhase[ADC_CLK] != adcPhase) {
FILE_LOG(logINFO, ("\tPhase reset by PLL\n\tCorrecting ADC phase to %d\n", adcPhase));
configurePhase(ADC_CLK, adcPhase, 0);
}
if (clkPhase[DBIT_CLK] != dbitPhase) {
FILE_LOG(logINFO, ("\tPhase reset by PLL\n\tCorrecting DBIT phase to %d\n", dbitPhase));
configurePhase(DBIT_CLK, dbitPhase, 0);
}
// required to reconfigure as adc clock is stopped temporarily when resetting pll (in changing output frequency)
AD9257_Configure();
}
int getFrequency(enum CLKINDEX ind) {

View File

@ -267,21 +267,13 @@ void AD9257_Configure(){
FILE_LOG(logINFO, ("\tPower mode chip run\n"));
AD9257_Set(AD9257_POWER_MODE_REG, AD9257_INT_CHIP_RUN_VAL);
// binary offset
FILE_LOG(logINFO, ("\tBinary offset\n"));
AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_BINARY_OFST_VAL);
// binary offset, lvds-iee reduced
FILE_LOG(logINFO, ("\tBinary offset, Lvds-ieee reduced\n"));
AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_BINARY_OFST_VAL | AD9257_OUT_LVDS_IEEE_VAL);
//output clock phase
#if defined(GOTTHARDD) || defined(JUNGFRAUD)
FILE_LOG(logINFO, ("\tOutput clock phase is at default: 180\n"));
#else
FILE_LOG(logINFO, ("\tOutput clock phase: 60\n"));
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_60_VAL);
#endif
// lvds-iee reduced , binary offset
FILE_LOG(logINFO, ("\tLvds-iee reduced, binary offset\n"));
AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_LVDS_IEEE_VAL);
FILE_LOG(logINFO, ("\tOutput clock phase: 180\n"));
AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_180_VAL);
// all devices on chip to receive next command
FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n"));
@ -298,9 +290,7 @@ void AD9257_Configure(){
AD9257_SetVrefVoltage(AD9257_VREF_DEFAULT_VAL, 0);
#else
FILE_LOG(logINFO, ("\tVref 1.33\n"));
//AD9257_Set(AD9257_VREF_REG, AD9257_VREF_1_33_VAL);
AD9257_SetVrefVoltage(AD9257_VREF_1_33_VAL, 0);
#endif
// no test mode

View File

@ -225,7 +225,7 @@ int ALTERA_PLL_SetOuputFrequency (int clkIndex, int pllVCOFreqMhz, int value) {
// write frequency (post-scale output counter C)
ALTERA_PLL_SetPllReconfigReg(ALTERA_PLL_C_COUNTER_REG, val);
// reset required to keep the phase
// reset required to keep the phase (must reconfigure adcs again after this as adc clock is stopped temporarily when resetting pll)
ALTERA_PLL_ResetPLL ();
/*double temp = ((double)pllVCOFreqMhz / (double)(low_count + high_count));

View File

@ -102,9 +102,9 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page test
- <b>exitreceiver</b> Shuts down all the receivers. Don't use it!!!!
- <b>rx_exit</b> Shuts down all the receivers. Don't use it!!!!
*/
descrToFuncMap[i].m_pFuncName = "exitreceiver";
descrToFuncMap[i].m_pFuncName = "rx_exit";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdExitServer;
++i;
@ -497,9 +497,9 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page config
- <b>checkrecversion</b> Checks the version compatibility with receiver server (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
- <b>rx_checkversion</b> Checks the version compatibility with receiver server (if rx_hostname is in shared memory). Only get! Only for Eiger, Jungfrau & Gotthard. \c Returns \c ("compatible", "incompatible")
*/
descrToFuncMap[i].m_pFuncName = "checkrecversion";
descrToFuncMap[i].m_pFuncName = "rx_checkversion";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSN;
++i;
@ -532,9 +532,9 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page config
- <b>receiverversion</b> Gets the software version of receiver. Only get! \c Returns \c (long int) in hexadecimal
- <b>rx_version</b> Gets the software version of receiver. Only get! \c Returns \c (long int) in hexadecimal
*/
descrToFuncMap[i].m_pFuncName = "receiverversion";
descrToFuncMap[i].m_pFuncName = "rx_version";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdSN;
++i;
@ -1522,9 +1522,9 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
*/
/*! \page output
- <b>outdir [dir]</b> Sets/gets the file output directory. \c Returns \c (string)
- <b>fpath [dir]</b> Sets/gets the file output directory. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "outdir";
descrToFuncMap[i].m_pFuncName = "fpath";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOutDir;
++i;
@ -1536,37 +1536,37 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page output
- <b>index [i]</b> Sets/gets the current file index. \c Returns \c (int)
- <b>findex [i]</b> Sets/gets the current file index. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "index";
descrToFuncMap[i].m_pFuncName = "findex";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFileIndex;
++i;
/*! \page output
- <b>enablefwrite [i]</b> Enables/disables file writing. 1 enables, 0 disables. \c Returns \c (int)
- <b>fwrite [i]</b> Enables/disables file writing. 1 enables, 0 disables. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "enablefwrite";
descrToFuncMap[i].m_pFuncName = "fwrite";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdEnablefwrite;
++i;
/*! \page output
- <b>overwrite [i]</b> enables(1) /disables(0) file overwriting. \c Returns \c (int)
- <b>foverwrite [i]</b> enables(1) /disables(0) file overwriting. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "overwrite";
descrToFuncMap[i].m_pFuncName = "foverwrite";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOverwrite;
++i;
/*! \page output
- <b>fileformat [i]</b> sets/gets the file format for data in receiver. Options: [binary, hdf5]. \c Returns \c (string)
- <b>fformat [i]</b> sets/gets the file format for data in receiver. Options: [binary, hdf5]. \c Returns \c (string)
*/
descrToFuncMap[i].m_pFuncName = "fileformat";
descrToFuncMap[i].m_pFuncName = "fformat";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdFileName;
++i;
/*! \page output
- <b>masterfile [i]</b> sets/gets the master file write enable in receiver. \c Returns \c (int)
- <b>fmaster [i]</b> sets/gets the master file write enable in receiver. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "masterfile";
descrToFuncMap[i].m_pFuncName = "fmaster";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdEnablefwrite;
++i;
@ -1790,23 +1790,23 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
*/
/*! \page receiver
- <b>receiver [s]</b> starts/stops the receiver to listen to detector packets. Options: [ \c start, \c stop]. \c Returns \c (string) status of receiver[ \c idle, \c running].
- <b>rx_status [s]</b> starts/stops the receiver to listen to detector packets. Options: [ \c start, \c stop]. \c Returns \c (string) status of receiver[ \c idle, \c running].
*/
descrToFuncMap[i].m_pFuncName = "receiver";
descrToFuncMap[i].m_pFuncName = "rx_status";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_online [i]</b> sets/gets the receiver in online/offline mode. 1 is online, 0 is offline. Get is from shared memory. \c Returns \c (int)
- <b>rx_online [i]</b> sets/gets the receiver in online/offline mode. 1 is online, 0 is offline. Get is from shared memory. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_online";
descrToFuncMap[i].m_pFuncName = "rx_online";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOnline;
++i;
/*! \page receiver
- <b>r_checkonline</b> Checks the receiver if it is online/offline mode. Only get! \c Returns (string) "All online" or "[list of offline hostnames] : Not online".
- <b>rx_checkonline</b> Checks the receiver if it is online/offline mode. Only get! \c Returns (string) "All online" or "[list of offline hostnames] : Not online".
*/
descrToFuncMap[i].m_pFuncName = "r_checkonline";
descrToFuncMap[i].m_pFuncName = "rx_checkonline";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdOnline;
++i;
@ -1832,23 +1832,23 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page receiver
- <b>r_lock [i]</b> locks/unlocks the receiver to communicate with only this client. 1 locks, 0 unlocks. \c Returns \c (int)
- <b>rx_lock [i]</b> locks/unlocks the receiver to communicate with only this client. 1 locks, 0 unlocks. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_lock";
descrToFuncMap[i].m_pFuncName = "rx_lock";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdLock;
++i;
/*! \page receiver
- <b>r_lastclient</b> gets the last client communicating with the receiver. Only get! \c Returns \c (int)
- <b>rx_lastclient</b> gets the last client communicating with the receiver. Only get! \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_lastclient";
descrToFuncMap[i].m_pFuncName = "rx_lastclient";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdLastClient;
++i;
/*! \page receiver
- <b>r_readfreq [i]</b> sets/gets the stream frequency of data from receiver to client. i > 0 is the nth frame being streamed. 0 sets frequency to a default timer (200ms). \c Returns \c (int)
- <b>rx_readfreq [i]</b> sets/gets the stream frequency of data from receiver to client. i > 0 is the nth frame being streamed. 0 sets frequency to a default timer (200ms). \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_readfreq";
descrToFuncMap[i].m_pFuncName = "rx_readfreq";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
@ -1860,30 +1860,30 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
++i;
/*! \page receiver
- <b>r_silent [i]</b> sets/gets receiver in silent mode, ie. it will not print anything during real time acquisition. 1 sets, 0 unsets. \c Returns \c (int)
- <b>rx_silent [i]</b> sets/gets receiver in silent mode, ie. it will not print anything during real time acquisition. 1 sets, 0 unsets. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_silent";
descrToFuncMap[i].m_pFuncName = "rx_silent";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_framesperfile [i]</b> sets/gets the frames per file in receiver to i. 0 means infinite or all frames in a single file. \c Returns \c (int)
- <b>rx_framesperfile [i]</b> sets/gets the frames per file in receiver to i. 0 means infinite or all frames in a single file. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_framesperfile";
descrToFuncMap[i].m_pFuncName = "rx_framesperfile";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_discardpolicy</b> sets/gets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames. \c Returns \c (int)
- <b>rx_discardpolicy</b> sets/gets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_discardpolicy";
descrToFuncMap[i].m_pFuncName = "rx_discardpolicy";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
/*! \page receiver
- <b>r_padding</b> sets/gets the frame padding in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames. \c Returns \c (int)
- <b>rx_padding</b> sets/gets the frame padding in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames. \c Returns \c (int)
*/
descrToFuncMap[i].m_pFuncName = "r_padding";
descrToFuncMap[i].m_pFuncName = "rx_padding";
descrToFuncMap[i].m_pFuncPtr = &slsDetectorCommand::cmdReceiver;
++i;
@ -2205,13 +2205,13 @@ std::string slsDetectorCommand::cmdAcquire(int narg, const char * const args[],
}
myDet->setOnline(ONLINE_FLAG, detPos);
int r_online = myDet->setReceiverOnline(ONLINE_FLAG, detPos);
int rx_online = myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (myDet->acquire() == FAIL)
return std::string("acquire failed");
if (r_online) {
if (rx_online) {
char answer[100];
sprintf(answer, "\nAcquired %d", myDet->getFramesCaughtByReceiver(detPos));
return std::string(answer);
@ -2487,7 +2487,7 @@ std::string slsDetectorCommand::cmdExitServer(int narg, const char * const args[
return std::string("Server shut down.");
else
return std::string("Error closing server\n");
} else if (cmd == "exitreceiver") {
} else if (cmd == "rx_exit") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (myDet->exitReceiver(detPos) == OK)
return std::string("Receiver shut down\n");
@ -2514,7 +2514,7 @@ std::string slsDetectorCommand::cmdExitServer(int narg, const char * const args[
std::string slsDetectorCommand::helpExitServer(int action) {
std::ostringstream os;
os << std::string("exitserver \t shuts down all the detector servers. Don't use it!!!!\n");
os << std::string("exitreceiver \t shuts down all the receiver servers.\n");
os << std::string("rx_exit \t shuts down all the receiver servers.\n");
os << std::string("execcommand \t executes command in detector server. Don't use it if you do not know what you are doing.\n");
os << std::string("rx_execcommand \t executes command in receiver server. Don't use it if you do not know what you are doing.\n");
return os.str();
@ -2593,9 +2593,9 @@ std::string slsDetectorCommand::cmdOutDir(int narg, const char * const args[], i
std::string slsDetectorCommand::helpOutDir(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION)
os << std::string("outdir \t gets the directory where the output files will be written\n");
os << std::string("fpath \t gets the directory where the output files will be written\n");
if (action == PUT_ACTION || action == HELP_ACTION)
os << std::string("outdir dir \t sets the directory where the output files will be written\n");
os << std::string("fpath dir \t sets the directory where the output files will be written\n");
return os.str();
}
@ -2608,7 +2608,7 @@ std::string slsDetectorCommand::cmdFileName(int narg, const char * const args[],
myDet->setFileName(std::string(args[1]), detPos);
return std::string(myDet->getFileName(detPos));
} else if (cmd == "fileformat") {
} else if (cmd == "fformat") {
if (action == PUT_ACTION) {
if (std::string(args[1]) == "binary")
myDet->setFileFormat(BINARY, detPos);
@ -2626,11 +2626,11 @@ std::string slsDetectorCommand::helpFileName(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION) {
os << std::string("fname \t gets the filename for the data without index and extension\n");
os << std::string("fileformat \t gets the file format for data\n");
os << std::string("fformat \t gets the file format for data\n");
}
if (action == PUT_ACTION || action == HELP_ACTION) {
os << std::string("fname s \t sets the filename for the data (index and extension will be automatically appended)\n");
os << std::string("fileformat s \t sets the file format for the data (binary, hdf5)\n");
os << std::string("fformat s \t sets the file format for the data (binary, hdf5)\n");
}
return os.str();
}
@ -2643,7 +2643,7 @@ std::string slsDetectorCommand::cmdEnablefwrite(int narg, const char * const arg
if (action == HELP_ACTION) {
return helpEnablefwrite(action);
}
if (cmd == "enablefwrite") {
if (cmd == "fwrite") {
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &i))
myDet->setFileWrite(i, detPos);
@ -2654,7 +2654,7 @@ std::string slsDetectorCommand::cmdEnablefwrite(int narg, const char * const arg
return std::string(ans);
}
else if (cmd == "masterfile") {
else if (cmd == "fmaster") {
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &i))
myDet->setMasterFileWrite(i, detPos);
@ -2671,12 +2671,12 @@ std::string slsDetectorCommand::cmdEnablefwrite(int narg, const char * const arg
std::string slsDetectorCommand::helpEnablefwrite(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION) {
os << std::string("enablefwrite \t When Enabled writes the data into the file\n");
os << std::string("masterfile \t When Enabled writes the master file\n");
os << std::string("fwrite \t When Enabled writes the data into the file\n");
os << std::string("fmaster \t When Enabled writes the master file\n");
}
if (action == PUT_ACTION || action == HELP_ACTION) {
os << std::string("enablefwrite i \t should be 1 or 0\n");
os << std::string("masterfile i \t sets the master file write enable. should be 1 or 0\n");
os << std::string("fwrite i \t should be 1 or 0\n");
os << std::string("fmaster i \t sets the master file write enable. should be 1 or 0\n");
}
return os.str();
}
@ -2692,7 +2692,7 @@ std::string slsDetectorCommand::cmdOverwrite(int narg, const char * const args[]
if (sscanf(args[1], "%d", &i))
myDet->setFileOverWrite(i, detPos);
else
return std::string("could not decode overwrite");
return std::string("could not decode foverwrite");
}
sprintf(ans, "%d", myDet->getFileOverWrite(detPos));
return std::string(ans);
@ -2701,9 +2701,9 @@ std::string slsDetectorCommand::cmdOverwrite(int narg, const char * const args[]
std::string slsDetectorCommand::helpOverwrite(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION)
os << std::string("overwrite \t When Enabled overwrites files\n");
os << std::string("foverwrite \t When Enabled overwrites files\n");
if (action == PUT_ACTION || action == HELP_ACTION)
os << std::string("overwrite i \t should be 1 or 0 or -1\n");
os << std::string("foverwrite i \t should be 1 or 0 or -1\n");
return os.str();
}
@ -2721,9 +2721,9 @@ std::string slsDetectorCommand::cmdFileIndex(int narg, const char * const args[]
std::string slsDetectorCommand::helpFileIndex(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION)
os << std::string("index \t gets the file index for the next the data file\n");
os << std::string("findex \t gets the file index for the next the data file\n");
if (action == PUT_ACTION || action == HELP_ACTION)
os << std::string("index i \t sets the fileindex for the next data file\n");
os << std::string("findex i \t sets the fileindex for the next data file\n");
return os.str();
}
@ -3195,7 +3195,7 @@ std::string slsDetectorCommand::cmdLock(int narg, const char * const args[], int
sprintf(ans, "%d", myDet->lockServer(-1, detPos));
}
else if (cmd == "r_lock") {
else if (cmd == "rx_lock") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &val))
@ -3217,11 +3217,11 @@ std::string slsDetectorCommand::helpLock(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "lock i \n locks (1) or unlocks (0) the detector to communicate to this client" << std::endl;
os << "r_lock i \n locks (1) or unlocks (0) the receiver to communicate to this client" << std::endl;
os << "rx_lock i \n locks (1) or unlocks (0) the receiver to communicate to this client" << std::endl;
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "lock \n returns the detector lock status" << std::endl;
os << "r_lock \n returns the receiver lock status" << std::endl;
os << "rx_lock \n returns the receiver lock status" << std::endl;
}
return os.str();
}
@ -3239,7 +3239,7 @@ std::string slsDetectorCommand::cmdLastClient(int narg, const char * const args[
return myDet->getLastClientIP(detPos);
}
else if (cmd == "r_lastclient") {
else if (cmd == "rx_lastclient") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
return myDet->getReceiverLastClientIP(detPos);
}
@ -3252,7 +3252,7 @@ std::string slsDetectorCommand::helpLastClient(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION) {
os << "lastclient \n returns the last client communicating with the detector" << std::endl;
os << "r_lastclient \n returns the last client communicating with the receiver" << std::endl;
os << "rx_lastclient \n returns the last client communicating with the receiver" << std::endl;
}
return os.str();
}
@ -3301,7 +3301,7 @@ std::string slsDetectorCommand::cmdOnline(int narg, const char * const args[], i
}
int ret = myDet->setDeactivatedRxrPaddingMode(-1, detPos);
sprintf(ans, "%d %s", myDet->activate(-1, detPos), ret == 1 ? "padding" : (ret == 0 ? "nopadding" : "unknown"));
} else if (cmd == "r_online") {
} else if (cmd == "rx_online") {
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &ival))
myDet->setReceiverOnline(ival, detPos);
@ -3328,14 +3328,14 @@ std::string slsDetectorCommand::helpOnline(int action) {
std::ostringstream os;
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "online i \n sets the detector in online (1) or offline (0) mode" << std::endl;
os << "r_online i \n sets the receiver in online (1) or offline (0) mode" << std::endl;
os << "rx_online i \n sets the receiver in online (1) or offline (0) mode" << std::endl;
os << "activate i [p]\n sets the detector in activated (1) or deactivated (0) mode (does not send data). p is optional and can be padding (default) or nonpadding for receivers for deactivated detectors. Only for Eiger." << std::endl;
}
if (action == GET_ACTION || action == HELP_ACTION) {
os << "online \n gets the detector online (1) or offline (0) mode" << std::endl;
os << "checkonline \n returns the hostnames of all detectors in offline mode" << std::endl;
os << "r_online \n gets the receiver online (1) or offline (0) mode" << std::endl;
os << "r_checkonline \n returns the hostnames of all receiver in offline mode" << std::endl;
os << "rx_online \n gets the receiver online (1) or offline (0) mode" << std::endl;
os << "rx_checkonline \n returns the hostnames of all receiver in offline mode" << std::endl;
os << "activate \n gets the detector activated (1) or deactivated (0) mode. And padding or nonpadding for the deactivated receiver. Only for Eiger." << std::endl;
}
return os.str();
@ -3655,7 +3655,7 @@ std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int a
return std::string(answer);
}
if (cmd == "receiverversion") {
if (cmd == "rx_version") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
int64_t retval = myDet->getReceiverSoftwareVersion(detPos);
if (retval < 0)
@ -3673,7 +3673,7 @@ std::string slsDetectorCommand::cmdSN(int narg, const char * const args[], int a
return std::string(answer);
}
if (cmd == "checkrecversion") {
if (cmd == "rx_checkversion") {
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
int retval = myDet->checkReceiverVersionCompatibility(detPos);
if (retval < 0)
@ -3690,12 +3690,12 @@ std::string slsDetectorCommand::helpSN(int action) {
std::ostringstream os;
if (action == GET_ACTION || action == HELP_ACTION) {
os << "checkdetversion \n gets the version compatibility with detector server (if hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl;
os << "checkrecversion \n gets the version compatibility with receiver server (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl;
os << "rx_checkversion \n gets the version compatibility with receiver server (if rx_hostname is in shared memory). Only for Eiger, Jungfrau & Gotthard. Prints compatible/ incompatible." << std::endl;
os << "detectornumber \n gets the serial number of the detector (MAC)" << std::endl;
os << "detectorversion \n gets the firmware version of the detector" << std::endl;
os << "softwareversion \n gets the software version of the detector" << std::endl;
os << "thisversion \n gets the version of this software" << std::endl;
os << "receiverversion \n gets the version of the receiver" << std::endl;
os << "rx_version \n gets the version of the receiver" << std::endl;
}
return os.str();
}
@ -5060,7 +5060,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
myDet->setOnline(ONLINE_FLAG, detPos);
myDet->setReceiverOnline(ONLINE_FLAG, detPos);
if (cmd == "receiver") {
if (cmd == "rx_status") {
if (action == PUT_ACTION) {
if (!strcasecmp(args[1], "start"))
myDet->startReceiver(detPos);
@ -5100,7 +5100,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
sprintf(answer, "%lu", myDet->getReceiverCurrentFrameIndex(detPos));
return std::string(answer);
}
} else if (cmd == "r_readfreq") {
} else if (cmd == "rx_readfreq") {
if (action == PUT_ACTION) {
if (!sscanf(args[1], "%d", &ival))
return std::string("Could not scan read frequency mode ") + std::string(args[1]);
@ -5136,10 +5136,10 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
}
else if (cmd == "r_silent") {
else if (cmd == "rx_silent") {
if (action == PUT_ACTION) {
if (!sscanf(args[1], "%d", &ival))
return std::string("Could not scan r_online input ") + std::string(args[1]);
return std::string("Could not scan rx_online input ") + std::string(args[1]);
if (ival >= 0)
sprintf(answer, "%d", myDet->setReceiverSilentMode(ival, detPos));
} else
@ -5148,7 +5148,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
}
else if (cmd == "r_framesperfile") {
else if (cmd == "rx_framesperfile") {
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &ival)) {
myDet->setFramesPerFile(ival, detPos);
@ -5160,7 +5160,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
return std::string(answer);
}
else if (cmd == "r_discardpolicy") {
else if (cmd == "rx_discardpolicy") {
if (action == PUT_ACTION) {
frameDiscardPolicy f = myDet->getReceiverFrameDiscardPolicy(std::string(args[1]));
if (f == GET_FRAME_DISCARD_POLICY)
@ -5170,7 +5170,7 @@ std::string slsDetectorCommand::cmdReceiver(int narg, const char * const args[],
return myDet->getReceiverFrameDiscardPolicy(myDet->setReceiverFramesDiscardPolicy(GET_FRAME_DISCARD_POLICY, detPos));
}
else if (cmd == "r_padding") {
else if (cmd == "rx_padding") {
if (action == PUT_ACTION) {
if (sscanf(args[1], "%d", &ival)) {
myDet->setPartialFramesPadding(ival, detPos);
@ -5205,13 +5205,13 @@ std::string slsDetectorCommand::helpReceiver(int action) {
if (action == PUT_ACTION || action == HELP_ACTION) {
os << "receiver [status] \t starts/stops the receiver to listen to detector packets. - can be start, stop." << std::endl;
os << "resetframescaught [any value] \t resets frames caught by receiver" << std::endl;
os << "r_readfreq \t sets the gui read frequency of the receiver, 0 if gui requests frame, >0 if receiver sends every nth frame to gui" << std::endl;
os << "rx_readfreq \t sets the gui read frequency of the receiver, 0 if gui requests frame, >0 if receiver sends every nth frame to gui" << std::endl;
os << "tengiga \t sets system to be configure for 10Gbe if set to 1, else 1Gbe if set to 0" << std::endl;
os << "rx_fifodepth [val]\t sets receiver fifo depth to val" << std::endl;
os << "r_silent [i]\t sets receiver in silent mode, ie. it will not print anything during real time acquisition. 1 sets, 0 unsets." << std::endl;
os << "r_framesperfile s\t sets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
os << "r_discardpolicy s\t sets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames." << std::endl;
os << "r_padding s\t enables/disables partial frames to be padded in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames." << std::endl;
os << "rx_silent [i]\t sets receiver in silent mode, ie. it will not print anything during real time acquisition. 1 sets, 0 unsets." << std::endl;
os << "rx_framesperfile s\t sets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
os << "rx_discardpolicy s\t sets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames." << std::endl;
os << "rx_padding s\t enables/disables partial frames to be padded in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames." << std::endl;
os << "rx_jsonaddheader [t]\n sets additional json header to be streamed "
"out with the zmq from receiver. Default is empty. t must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
"Use only if it needs to be processed by an intermediate process." << std::endl;
@ -5222,13 +5222,13 @@ std::string slsDetectorCommand::helpReceiver(int action) {
os << "receiver \t returns the status of receiver - can be running or idle" << std::endl;
os << "framescaught \t returns the number of frames caught by receiver(average for multi)" << std::endl;
os << "frameindex \t returns the current frame index of receiver(average for multi)" << std::endl;
os << "r_readfreq \t returns the gui read frequency of the receiver" << std::endl;
os << "rx_readfreq \t returns the gui read frequency of the receiver" << std::endl;
os << "tengiga \t returns 1 if the system is configured for 10Gbe else 0 for 1Gbe" << std::endl;
os << "rx_fifodepth \t returns receiver fifo depth" << std::endl;
os << "r_silent \t returns receiver silent mode enable. 1 is silent, 0 not silent." << std::endl;
os << "r_framesperfile \t gets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
os << "r_discardpolicy \t gets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames." << std::endl;
os << "r_padding \t gets partial frames padding enable in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames." << std::endl;
os << "rx_silent \t returns receiver silent mode enable. 1 is silent, 0 not silent." << std::endl;
os << "rx_framesperfile \t gets the number of frames per file in receiver. 0 means infinite or all frames in a single file." << std::endl;
os << "rx_discardpolicy \t gets the frame discard policy in the receiver. nodiscard (default) - discards nothing, discardempty - discard only empty frames, discardpartial(fastest) - discards all partial frames." << std::endl;
os << "rx_padding \t gets partial frames padding enable in the receiver. 0 does not pad partial frames(fastest), 1 (default) pads partial frames." << std::endl;
os << "rx_jsonaddheader \n gets additional json header to be streamed "
"out with the zmq from receiver." << std::endl;
os << "rx_jsonpara [k] \n gets value of additional json header parameter k to be streamed out with the zmq from receiver. If empty, then no parameter found." << std::endl;

View File

@ -3,6 +3,8 @@
#include "sls_detector_defs.h"
#include <sstream>
#include "tests/globals.h"
auto GET = slsDetectorDefs::GET_ACTION;
auto PUT = slsDetectorDefs::PUT_ACTION;
@ -47,119 +49,120 @@ TEST_CASE("frames", "[.cmd]") {
}
}
TEST_CASE("receiver", "[.cmd]") {
TEST_CASE("rx_status", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("receiver start", PUT, nullptr, oss);
REQUIRE(oss.str() == "receiver running\n");
multiSlsDetectorClient("rx_status start", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_status running\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("receiver", GET, nullptr, oss);
REQUIRE(oss.str() == "receiver running\n");
multiSlsDetectorClient("rx_status", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_status running\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("receiver stop", PUT, nullptr, oss);
REQUIRE(oss.str() == "receiver idle\n");
multiSlsDetectorClient("rx_status stop", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_status idle\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("receiver", GET, nullptr, oss);
REQUIRE(oss.str() == "receiver idle\n");
multiSlsDetectorClient("rx_status", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_status idle\n");
}
}
TEST_CASE("enablefwrite", "[.cmd]") {
TEST_CASE("fwrite", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("enablefwrite 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "enablefwrite 1\n");
multiSlsDetectorClient("fwrite 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "fwrite 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("enablefwrite", GET, nullptr, oss);
REQUIRE(oss.str() == "enablefwrite 1\n");
multiSlsDetectorClient("fwrite", GET, nullptr, oss);
REQUIRE(oss.str() == "fwrite 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("enablefwrite 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "enablefwrite 0\n");
multiSlsDetectorClient("fwrite 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "fwrite 0\n");
}
}
TEST_CASE("enableoverwrite", "[.cmd]") {
TEST_CASE("enablefoverwrite", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("overwrite 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "overwrite 1\n");
multiSlsDetectorClient("foverwrite 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "foverwrite 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("overwrite", GET, nullptr, oss);
REQUIRE(oss.str() == "overwrite 1\n");
multiSlsDetectorClient("foverwrite", GET, nullptr, oss);
REQUIRE(oss.str() == "foverwrite 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("overwrite 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "overwrite 0\n");
multiSlsDetectorClient("foverwrite 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "foverwrite 0\n");
}
}
TEST_CASE("activatecmd", "[.cmd]") {
//EIGER ONLY
// TEST_CASE("activatecmd", "[.cmd]") {
// {
// // TODO! read padding from somewhere
// std::ostringstream oss;
// multiSlsDetectorClient("activate 0", PUT, nullptr, oss);
// REQUIRE(oss.str() == "activate 0 padding\n");
// }
// {
// std::ostringstream oss;
// multiSlsDetectorClient("activate", GET, nullptr, oss);
// REQUIRE(oss.str() == "activate 0 padding\n");
// }
// {
// std::ostringstream oss;
// multiSlsDetectorClient("activate 1", PUT, nullptr, oss);
// REQUIRE(oss.str() == "activate 1 padding\n");
// }
// }
TEST_CASE("fmaster", "[.cmd]") {
{
// TODO! read padding from somewhere
std::ostringstream oss;
multiSlsDetectorClient("activate 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "activate 0 padding\n");
multiSlsDetectorClient("fmaster 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "fmaster 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("activate", GET, nullptr, oss);
REQUIRE(oss.str() == "activate 0 padding\n");
multiSlsDetectorClient("fmaster", GET, nullptr, oss);
REQUIRE(oss.str() == "fmaster 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("activate 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "activate 1 padding\n");
multiSlsDetectorClient("fmaster 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "fmaster 1\n");
}
}
TEST_CASE("masterfile", "[.cmd]") {
TEST_CASE("findex", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("masterfile 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "masterfile 0\n");
multiSlsDetectorClient("findex 57", PUT, nullptr, oss);
REQUIRE(oss.str() == "findex 57\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("masterfile", GET, nullptr, oss);
REQUIRE(oss.str() == "masterfile 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("masterfile 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "masterfile 1\n");
}
}
TEST_CASE("index", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("index 57", PUT, nullptr, oss);
REQUIRE(oss.str() == "index 57\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("index", GET, nullptr, oss);
REQUIRE(oss.str() == "index 57\n");
multiSlsDetectorClient("findex", GET, nullptr, oss);
REQUIRE(oss.str() == "findex 57\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("index 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "index 0\n");
multiSlsDetectorClient("findex 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "findex 0\n");
}
}
@ -229,21 +232,21 @@ TEST_CASE("resetframescaught get framescaught", "[.cmd]") {
}
}
TEST_CASE("r_silent", "[.cmd]") {
TEST_CASE("rx_silent", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("r_silent 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_silent 1\n");
multiSlsDetectorClient("rx_silent 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_silent 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_silent", GET, nullptr, oss);
REQUIRE(oss.str() == "r_silent 1\n");
multiSlsDetectorClient("rx_silent", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_silent 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_silent 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_silent 0\n");
multiSlsDetectorClient("rx_silent 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_silent 0\n");
}
}
@ -275,63 +278,138 @@ TEST_CASE("r_silent", "[.cmd]") {
// REQUIRE(oss.str() == "rx_udpsocksize 104857600\n");
// }
TEST_CASE("r_framesperfile", "[.cmd]") {
TEST_CASE("rx_framesperfile", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("r_framesperfile 50", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_framesperfile 50\n");
multiSlsDetectorClient("rx_framesperfile 50", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_framesperfile 50\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_framesperfile", GET, nullptr, oss);
REQUIRE(oss.str() == "r_framesperfile 50\n");
multiSlsDetectorClient("rx_framesperfile", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_framesperfile 50\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_framesperfile 10000", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_framesperfile 10000\n");
multiSlsDetectorClient("rx_framesperfile 10000", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_framesperfile 10000\n");
}
}
TEST_CASE("r_discardpolicy", "[.cmd]") {
TEST_CASE("rx_discardpolicy", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("r_discardpolicy discardempty", PUT, nullptr,
multiSlsDetectorClient("rx_discardpolicy discardempty", PUT, nullptr,
oss);
REQUIRE(oss.str() == "r_discardpolicy discardempty\n");
REQUIRE(oss.str() == "rx_discardpolicy discardempty\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_discardpolicy", GET, nullptr, oss);
REQUIRE(oss.str() == "r_discardpolicy discardempty\n");
multiSlsDetectorClient("rx_discardpolicy", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_discardpolicy discardempty\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_discardpolicy discardpartial", PUT, nullptr,
multiSlsDetectorClient("rx_discardpolicy discardpartial", PUT, nullptr,
oss);
REQUIRE(oss.str() == "r_discardpolicy discardpartial\n");
REQUIRE(oss.str() == "rx_discardpolicy discardpartial\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_discardpolicy nodiscard", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_discardpolicy nodiscard\n");
multiSlsDetectorClient("rx_discardpolicy nodiscard", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_discardpolicy nodiscard\n");
}
}
TEST_CASE("r_padding", "[.cmd]") {
TEST_CASE("rx_padding", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("r_padding 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_padding 0\n");
multiSlsDetectorClient("rx_padding 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_padding 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_padding", GET, nullptr, oss);
REQUIRE(oss.str() == "r_padding 0\n");
multiSlsDetectorClient("rx_padding", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_padding 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("r_padding 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "r_padding 1\n");
multiSlsDetectorClient("rx_padding 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_padding 1\n");
}
}
TEST_CASE("rx_readfreq", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("rx_readfreq 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_readfreq 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_readfreq", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_readfreq 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_readfreq 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_readfreq 0\n");
}
}
TEST_CASE("rx_lock", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("rx_lock 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_lock 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_lock", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_lock 1\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_lock 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_lock 0\n");
}
}
TEST_CASE("rx_lastclient", "[.cmd]") {
std::ostringstream oss;
multiSlsDetectorClient("rx_lastclient", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_lastclient " + test::my_ip + "\n");
}
TEST_CASE("rx_online", "[.cmd]") {
{
std::ostringstream oss;
multiSlsDetectorClient("rx_online 0", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_online 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_online", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_online 0\n");
}
{
std::ostringstream oss;
multiSlsDetectorClient("rx_online 1", PUT, nullptr, oss);
REQUIRE(oss.str() == "rx_online 1\n");
}
}
TEST_CASE("rx_checkonline", "[.cmd]") {
std::ostringstream oss;
multiSlsDetectorClient("rx_checkonline", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_checkonline All receiver online\n");
}
TEST_CASE("rx_checkversion", "[.cmd]") {
std::ostringstream oss;
multiSlsDetectorClient("rx_checkversion", GET, nullptr, oss);
REQUIRE(oss.str() == "rx_checkversion compatible\n");
}

View File

@ -37,7 +37,7 @@ template <typename T> class CmdProxy {
auto d_it = depreciated_functions.find(command);
if (d_it != depreciated_functions.end()) {
FILE_LOG(logWARNING)
<< "WARNING: " << command
<< command
<< " is depreciated and will be removed. Please migrate to: "
<< d_it->second;
command = d_it->second;
@ -60,11 +60,25 @@ template <typename T> class CmdProxy {
// Initialize maps for translating name and function
FunctionMap functions{{"newfunc", &CmdProxy::NewFunction}};
StringMap depreciated_functions{{"oldvrfcmd", "vrf"},
{"veryveryold", "vcp"},
{"anothercmd", "vrs"},
{"this_as_well", "enablefwrite"}};
StringMap depreciated_functions{{"r_readfreq", "rx_readfreq"},
{"r_padding", "rx_padding"},
{"r_silent", "rx_silent"},
{"r_lastclient", "rx_lastclient"},
{"r_lock", "rx_lock"},
{"r_online", "rx_online"},
{"r_checkonline", "rx_checkonline"},
{"r_framesperfile", "rx_framesperfile"},
{"r_discardpolicy", "rx_discardpolicy"},
{"receiverversion", "rx_version"},
{"receiver", "rx_status"},
{"index", "findex"},
{"exitreceiver", "rx_exit"},
{"enablefwrite", "fwrite"},
{"checkrecversion", "rx_checkversion"},
{"masterfile", "fmaster"},
{"outdir", "fpath"},
{"fileformat", "fformat"},
{"overwrite", "foverwrite"}};
template <typename U> std::string ResultToString(const U &ret) {
std::ostringstream os;
@ -76,21 +90,22 @@ template <typename T> class CmdProxy {
void WrongNumberOfParameters(size_t expected) {
throw RuntimeError("ERROR: Expected " + std::to_string(expected) +
" parameters but got " + std::to_string(args.size()) +
"\n");
" parameters but got " +
std::to_string(args.size()) + "\n");
}
// Mapped functions
//example
std::string NewFunction() {
if(args.size() == 0){
// example
std::string NewFunction() {
if (args.size() == 0) {
std::cout << "This is the new function function\n";
return ResultToString(det->setExposureTime(-1, true));
}else if(args.size() == 1){
} else if (args.size() == 1) {
std::cout << "Setting exposure time to " << args[0] << "s\n";
return ResultToString(det->setExposureTime(std::stod(args[0]), true, det_id));
}else{
return ResultToString(
det->setExposureTime(std::stod(args[0]), true, det_id));
} else {
WrongNumberOfParameters(1);
return {};
}

View File

@ -5,7 +5,10 @@ using ti = slsDetectorDefs::timerIndex;
using ro = slsDetectorDefs::readOutFlags;
using sv = slsDetectorDefs::speedVariable;
using defs = slsDetectorDefs;
namespace test {
extern std::string hostname;
extern std::string detector_type;
extern dt type;
extern std::string my_ip;
extern std::string my_ip;
} // namespace test

View File

@ -12,22 +12,24 @@
using Opt = Catch::clara::Opt;
using dt = slsDetectorDefs::detectorType;
namespace test {
std::string hostname;
std::string detector_type;
std::string my_ip;
dt type;
} // namespace test
int main(int argc, char *argv[]) {
my_ip = "undefined";
test::my_ip = "undefined";
Catch::Session session;
auto cli = session.cli() |
Opt(hostname, "hostname")["-hn"]["--hostname"](
"Detector hostname for integration tests") |
Opt(detector_type, "detector_type")["-dt"]["--detector_type"](
"Detector type for integration tests") |
Opt(my_ip, "my_ip")["-hip"]["--host_ip"](
"Host ip address");
auto cli =
session.cli() |
Opt(test::hostname, "hostname")["-hn"]["--hostname"](
"Detector hostname for integration tests") |
Opt(test::detector_type, "detector_type")["-dt"]["--detector_type"](
"Detector type for integration tests") |
Opt(test::my_ip, "my_ip")["-hip"]["--host_ip"]("Host ip address");
session.cli(cli);
@ -36,7 +38,7 @@ int main(int argc, char *argv[]) {
return ret;
}
type = slsDetectorDefs::detectorTypeToEnum(detector_type);
test::type = slsDetectorDefs::detectorTypeToEnum(test::detector_type);
return session.run();
}