diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp
index 98073816d..d142fb218 100644
--- a/slsDetectorSoftware/slsDetector/slsDetector.cpp
+++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp
@@ -1974,38 +1974,8 @@ int slsDetector::setThresholdEnergy(int e_eV, detectorSettings isettings, int tb
return thisDetector->currentThresholdEV;
}
- int fnum= F_SET_THRESHOLD_ENERGY;
- int retval;
- int ret=FAIL;
- char mess[MAX_STR_LENGTH]="";
-#ifdef VERBOSE
- std::cout<< "Setting threshold energy "<< std::endl;
-#endif
- if (thisDetector->onlineFlag==ONLINE_FLAG) {
- if (connectControl() == OK){
- controlSocket->SendDataOnly(&fnum,sizeof(fnum));
- controlSocket->SendDataOnly(&e_eV,sizeof(e_eV));
- controlSocket->SendDataOnly(&isettings,sizeof(isettings));
- controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
- if (ret==FAIL) {
- std::cout<< "Detector returned error: "<< std::endl;
- controlSocket->ReceiveDataOnly(mess,sizeof(mess));
- std::cout<< mess << std::endl;
- } else {
-#ifdef VERBOSE
- std::cout<< "Detector returned OK "<< std::endl;
-#endif
- controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
- thisDetector->currentThresholdEV=retval;
- }
- disconnectControl();
- if (ret==FORCE_UPDATE)
- updateDetector();
- }
- } else {
- thisDetector->currentThresholdEV=e_eV;
- }
- return thisDetector->currentThresholdEV;
+ return -1;
+
}
diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
index c23c417ca..57c357587 100644
--- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
+++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp
@@ -114,17 +114,18 @@ slsDetectorCommand::slsDetectorCommand(multiSlsDetector *det) {
/* digital test and debugging */
+
/*! \page test
- - digitest [i] will perform test which will plot the unique channel identifier, instead of data. Only get!
+ - digibittest:[i] performs digital test of the module i. Returns 0 if succeeded, otherwise error mask. Gotthard only. Only put!
*/
- descrToFuncMap[i].m_pFuncName="digitest"; // /* find command! */
+ descrToFuncMap[i].m_pFuncName="digibittest"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
++i;
/*! \page test
- - digibittest:[i] performs digital test of the module i. Returns 0 if succeeded, otherwise error mask. Only put!
+ - bustest performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Cannot set! Jungfrau only. Only get!
*/
- descrToFuncMap[i].m_pFuncName="digibittest"; //
+ descrToFuncMap[i].m_pFuncName="bustest"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdDigiTest;
++i;
@@ -3671,14 +3672,14 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int d
myDet->setOnline(ONLINE_FLAG, detPos);
- if (cmd=="digitest") {
+ if (cmd=="bustest"){
if (action==PUT_ACTION)
return string("cannot set ")+cmd;
- sprintf(answer,"0x%x",myDet->digitalTest(CHIP_TEST, -1, detPos));
+ sprintf(answer,"0x%x",myDet->digitalTest(DETECTOR_BUS_TEST));
return string(answer);
}
- if (cmd=="digibittest") {
+ else if (cmd=="digibittest") {
if (action==GET_ACTION)
return string("cannot get ")+cmd;
int ival=-1;
@@ -3694,7 +3695,7 @@ string slsDetectorCommand::cmdDigiTest(int narg, char *args[], int action, int d
}
- return string("unknown digital test mode ")+cmd;
+ return string("unknown test mode ")+cmd;
}
@@ -3703,10 +3704,8 @@ string slsDetectorCommand::helpDigiTest(int action) {
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION) {
- os << "digitaltest:i \t performs digital test of the module i. Returns 0 if succeeded, otherwise error mask."<< std::endl;
- }
- if (action==PUT_ACTION || action==HELP_ACTION) {
- os << "digibittest i\t will perform test which will plot the unique channel identifier, instead of data."<< std::endl;
+ os << "digibittest:i \t performs digital test of the module i. Returns 0 if succeeded, otherwise error mask.Gotthard only."<< std::endl;
+ os << "bustest \t performs test of the bus interface between FPGA and embedded Linux system. Can last up to a few minutes. Jungfrau only."<< std::endl;
}
return os.str();
}
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile
index 9942dd3ef..b4117a9cf 100755
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile
@@ -1,6 +1,6 @@
CC = powerpc-4xx-softfloat-gcc
BLACKFIN_CC = bfin-uclinux-gcc
-CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE #-DVIRTUAL -DPCCOMPILE -DMARTIN
+CFLAGS += -Wall -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE -DPCCOMPILE -DMARTIN
LDLIBS += -lm -lstdc++
PROGS = eigerDetectorServer
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile.virtual
index 1f4c400e5..ad079030a 100644
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile.virtual
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/Makefile.virtual
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS += -Wall -DDACS_INT -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DPCCOMPILE -DSTOP_SERVER #-DVERBOSE
+CFLAGS += -Wall -DEIGERD -DSLS_DETECTOR_FUNCTION_LIST -DPCCOMPILE -DSTOP_SERVER #-DVERBOSE
CFLAGS += -DVIRTUAL -DVIRTUAL_9M
MASTERFLAG += -DVIRTUAL_MASTER
LDLIBS += -lm -lstdc++ -pthread
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/ansi.h
index a122db0ad..1f2dbc999 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/ansi.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/ansi.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/ansi.h
\ No newline at end of file
+../../../slsSupportLib/include/ansi.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer
deleted file mode 100755
index dc163ece6..000000000
Binary files a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_developer and /dev/null differ
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_refactor b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_refactor
new file mode 100755
index 000000000..2daff2e25
Binary files /dev/null and b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/bin/eigerDetectorServer_refactor differ
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.c
index 87a4f95d1..19b563862 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.c
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.c
@@ -1 +1 @@
-../commonFiles/communication_funcs.c
\ No newline at end of file
+../../../slsSupportLib/include/communication_funcs.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.h
index f220903b2..7f8c3d192 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/communication_funcs.h
@@ -1 +1 @@
-../commonFiles/communication_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/communication_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfo.txt
index e00fa9aca..7426425d3 100644
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
-Path: slsDetectorsPackage/slsDetectorSoftware/eigerDetectorServer
+Path: slsDetectorPackage/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
-Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
-Revision: 350
-Branch: developer
-Last Changed Author: Gemma_Tinti
-Last Changed Rev: 3999
-Last Changed Date: 2018-09-28 14:11:53.000000002 +0200 ./Makefile.virtual
+Repsitory UUID: b9f97f42a6a369dfb5c484bffeaa7a417e9cbca1
+Revision: 1
+Branch: refactor
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 4067
+Last Changed Date: 2018-10-08 11:18:41.000000002 +0200 ./Makefile
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h
index 42a1e0ca6..3a8464eae 100644
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/gitInfoEiger.h
@@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
-#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
-#define GITAUTH "Gemma_Tinti"
-#define GITREV 0x3999
-#define GITDATE 0x20180928
-#define GITBRANCH "developer"
+#define GITREPUUID "b9f97f42a6a369dfb5c484bffeaa7a417e9cbca1"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x4067
+#define GITDATE 0x20181008
+#define GITBRANCH "refactor"
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c
index ddfd53164..e6bd4e6db 100644
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorFunctionList.c
@@ -29,8 +29,8 @@ enum{E_PARALLEL, E_NON_PARALLEL, E_SAFE};
sls_detector_module *detectorModules=NULL;
int *detectorChips=NULL;
int *detectorChans=NULL;
-dacs_t *detectorDacs=NULL;
-dacs_t *detectorAdcs=NULL;
+int *detectorDacs=NULL;
+int *detectorAdcs=NULL;
int eiger_highvoltage = 0;
int eiger_theo_highvoltage = 0;
@@ -406,8 +406,8 @@ void allocateDetectorStructureMemory(){
detectorModules=malloc(sizeof(sls_detector_module));
detectorChips=malloc(NCHIP*sizeof(int));
detectorChans=malloc(NCHIP*NCHAN*sizeof(int));
- detectorDacs=malloc(NDAC*sizeof(dacs_t));
- detectorAdcs=malloc(NADC*sizeof(dacs_t));
+ detectorDacs=malloc(NDAC*sizeof(int));
+ detectorAdcs=malloc(NADC*sizeof(int));
#ifdef VERBOSE
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
printf("chips from 0x%x to 0x%x\n",detectorChips, detectorChips+n*NCHIP);
@@ -423,7 +423,6 @@ void allocateDetectorStructureMemory(){
(detectorModules)->nadc=NADC;
(detectorModules)->nchip=NCHIP;
(detectorModules)->nchan=NCHIP*NCHAN;
- (detectorModules)->module=0;
(detectorModules)->gain=0;
(detectorModules)->offset=0;
(detectorModules)->reg=0;
@@ -448,7 +447,7 @@ void setupDetector() {
int retval[2]={-1,-1};
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
for(i = 0; i < NDAC; ++i) {
- setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval);
+ setDAC((enum DACINDEX)i,defaultvals[i],0,retval);
if (retval[0] != defaultvals[i])
cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
}
@@ -467,7 +466,7 @@ void setupDetector() {
setReadOutFlags(DEFAULT_READOUT_STOREINRAM_MODE);
setReadOutFlags(DEFAULT_READOUT_OVERFLOW32_MODE);
setSpeed(CLOCK_DIVIDER, DEFAULT_CLK_SPEED);//clk_devider,half speed
- setIODelay(DEFAULT_IO_DELAY, DEFAULT_MOD_INDEX);
+ setIODelay(DEFAULT_IO_DELAY);
setTiming(DEFAULT_TIMING_MODE);
//SetPhotonEnergyCalibrationParameters(-5.8381e-5,1.838515,5.09948e-7,-4.32390e-11,1.32527e-15);
setRateCorrection(DEFAULT_RATE_CORRECTION);
@@ -503,16 +502,8 @@ uint32_t readRegister(uint32_t offset) {
}
-/* set parameters - nmod, dr, roi */
+/* set parameters - dr, roi */
-int setNMod(int nm, enum dimension dim){
- return NMOD;
-}
-
-
-int getNModBoard(enum dimension arg){
- return NMAXMOD;
-}
int setDynamicRange(int dr){
#ifdef VIRTUAL
@@ -824,17 +815,17 @@ int setModule(sls_detector_module myMod, int delay){
return FAIL;
// settings
- setSettings( (enum detectorSettings)myMod.reg,-1);
+ setSettings( (enum detectorSettings)myMod.reg);
// iodelay
- if(setIODelay(delay, -1)!= delay){
+ if(setIODelay(delay)!= delay){
cprintf(RED,"could not set iodelay %d\n",delay);
return FAIL;
}
// dacs
for(i=0;idacs)+i));
}
@@ -911,7 +902,7 @@ int getModule(sls_detector_module *myMod){
-enum detectorSettings setSettings(enum detectorSettings sett, int imod){
+enum detectorSettings setSettings(enum detectorSettings sett){
if(sett == UNINITIALIZED){
return thisSettings;
}if(sett != GET_SETTINGS)
@@ -931,17 +922,17 @@ enum detectorSettings getSettings(){
/* parameters - threshold */
-int getThresholdEnergy(int imod){
+int getThresholdEnergy(){
printf(" Getting Threshold energy\n");
return eiger_photonenergy;
}
-int setThresholdEnergy(int ev, int imod){
+int setThresholdEnergy(int ev){
printf(" Setting threshold energy:%d\n",ev);
if(ev >= 0)
eiger_photonenergy = ev;
- return getThresholdEnergy(imod);
+ return getThresholdEnergy();
}
@@ -950,19 +941,19 @@ int setThresholdEnergy(int ev, int imod){
/* parameters - dac, adc, hv */
-void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
- printf("Going to set dac %d to %d of imod %d with mv mode %d \n", (int)ind, val, imod, mV);
+void setDAC(enum DACINDEX ind, int val, int mV, int retval[]){
+ printf("Going to set dac %d to %d with mv mode %d \n", (int)ind, val, mV);
if(ind == VTHRESHOLD){
int ret[5];
- setDAC(VCMP_LL,val,imod,mV,retval);
+ setDAC(VCMP_LL,val,mV,retval);
ret[0] = retval[mV];
- setDAC(VCMP_LR,val,imod,mV,retval);
+ setDAC(VCMP_LR,val,mV,retval);
ret[1] = retval[mV];
- setDAC(VCMP_RL,val,imod,mV,retval);
+ setDAC(VCMP_RL,val,mV,retval);
ret[2] = retval[mV];
- setDAC(VCMP_RR,val,imod,mV,retval);
+ setDAC(VCMP_RR,val,mV,retval);
ret[3] = retval[mV];
- setDAC(VCP,val,imod,mV,retval);
+ setDAC(VCP,val,mV,retval);
ret[4] = retval[mV];
@@ -1018,7 +1009,7 @@ void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]){
-int getADC(enum ADCINDEX ind, int imod){
+int getADC(enum ADCINDEX ind){
#ifdef VIRTUAL
return 0;
#else
@@ -1224,7 +1215,7 @@ int setDetectorPosition(int pos[]) {
/* eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter */
-int setIODelay(int val, int imod){
+int setIODelay(int val){
if(val!=-1){
printf(" Setting IO Delay: %d\n",val);
#ifndef VIRTUAL
@@ -1745,12 +1736,6 @@ int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod){
printf("Copying module %x to module %x\n",srcMod,destMod);
#endif
- if (srcMod->module>=0) {
-#ifdef VERBOSE
- printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module);
-#endif
- destMod->module=srcMod->module;
- }
if (srcMod->serialnumber>=0){
destMod->serialnumber=srcMod->serialnumber;
@@ -1829,37 +1814,21 @@ int calculateDataBytes(){
}
-int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerModule() * (int)getTotalNumberOfModules());}
-int getTotalNumberOfChips(){return ((int)getNumberOfChipsPerModule() * (int)getTotalNumberOfModules());}
-int getTotalNumberOfModules(){return NMOD;}
-int getNumberOfChannelsPerModule(){return ((int)getNumberOfChannelsPerChip() * (int)getTotalNumberOfChips());}
-int getNumberOfChipsPerModule(){return NCHIP;}
-int getNumberOfDACsPerModule(){return NDAC;}
-int getNumberOfADCsPerModule(){return NADC;}
+
+
+int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());}
+int getNumberOfChips(){return NCHIP;}
+int getNumberOfDACs(){return NDAC;}
+int getNumberOfADCs(){return NADC;}
int getNumberOfChannelsPerChip(){return NCHAN;}
-int getNumberOfGainsPerModule(){return NGAIN;}
-int getNumberOfOffsetsPerModule(){return NOFFSET;}
+int getNumberOfGains(){return NGAIN;}
+int getNumberOfOffsets(){return NOFFSET;}
-/* sync */
-
-enum masterFlags setMaster(enum masterFlags arg){
- return NO_MASTER;
-}
-
-
-
-enum synchronizationMode setSynchronization(enum synchronizationMode arg){
- return NO_SYNCHRONIZATION;
-}
-
-
-
-
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h
index 5eae871d9..fec509799 100644
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/slsDetectorServer_defs.h
@@ -45,8 +45,6 @@ enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
/* Hardware Definitions */
-#define NMAXMOD (1)
-#define NMOD (1)
#define NCHAN (256 * 256)
#define NCHIP (4)
#define NADC (0)
@@ -65,7 +63,6 @@ enum NETWORKINDEX {TXN_LEFT, TXN_RIGHT, TXN_FRAME,FLOWCTRL_10G};
#define SPECIAL9M_HIGHVOLTAGE_BUFFERSIZE (16)
/** Default Parameters */
-#define DEFAULT_MOD_INDEX (0)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_EXPTIME (1E9) //ns
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_defs.h
index c5062e03f..108fdd66a 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_defs.h
@@ -1 +1 @@
-../commonFiles/sls_detector_defs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_detector_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_funcs.h
index 844b67129..a21957495 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_detector_funcs.h
@@ -1 +1 @@
-../commonFiles/sls_detector_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_detector_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_defs.h
index 1de31caf5..fbea73b31 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_defs.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/sls_receiver_defs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_receiver_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_funcs.h
index c2ea4ded9..8f221c967 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/sls_receiver_funcs.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/sls_receiver_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_receiver_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh
index 509bffaf4..52fcd1d16 100755
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/updateGitVersion.sh
@@ -1,11 +1,11 @@
SERVER=eigerDetectorServer
-MAINDIR=slsDetectorsPackage
-SPECDIR=slsDetectorSoftware/$SERVER
+MAINDIR=slsDetectorPackage
+SPECDIR=slsDetectorSoftware/slsDetectorServers/$SERVER
TMPFILE=gitInfoEigerTmp.h
INCLFILE=gitInfoEiger.h
#evaluate the variables
-EVALFILE=../../evalVersionVariables.sh
+EVALFILE=../../../evalVersionVariables.sh
source $EVALFILE
@@ -24,7 +24,7 @@ OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}')
#update INCLFILE if changes
if [ "$OLDDATE" != "$NEWDATE" ]; then
echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt
- cd ../../
+ cd ../../../
./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
cd $WD
fi
diff --git a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/versionAPI.h b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/versionAPI.h
index d3bf8d6cf..5336e713b 120000
--- a/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/versionAPI.h
+++ b/slsDetectorSoftware/slsDetectorServers/eigerDetectorServer/versionAPI.h
@@ -1 +1 @@
-../commonFiles/versionAPI.h
\ No newline at end of file
+../../../slsSupportLib/include/versionAPI.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile
index f6eacbd00..fc5720dfd 100755
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile
@@ -6,7 +6,7 @@
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
-CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDACS_INT -DDEBUG # -DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
+CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDEBUG # -DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
PROGS= gotthardDetectorServer
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.propix b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.propix
deleted file mode 100755
index 7f40e78a3..000000000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.propix
+++ /dev/null
@@ -1,49 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $
-# first compile
-# make cris-axis-linux-gnu
-
-
-CROSS = bfin-uclinux-
-CC = $(CROSS)gcc
-
-CFLAGS += -Wall -DGOTTHARDD -DPROPIXD -DMCB_FUNCS -DDACS_INT -DDEBUG # -DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
-
-
-PROGS= propixDetectorServer
-INSTDIR= /tftpboot
-INSTMODE= 0777
-
-
-
-BINS = testlib_sharedlibc
-SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c
-OBJS = $(SRCS:%.c=%.o)
-
-
-
-all: clean $(PROGS)
-
-boot: $(OBJS)
-
-$(PROGS): $(OBJS)
- echo $(OBJS)
- @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
- $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
-
-
-install: $(PROGS)
- $(INSTALL) -d $(INSTDIR)
- $(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
-
-
-romfs:
- $(ROMFSINST) /bin/$(PROGS)
-
-clean:
- rm -rf $(PROGS) *.o *.gdb
-
-
-
-
-
-
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.virtual
index ca9bff23c..0a26d5378 100755
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.virtual
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/Makefile.virtual
@@ -2,7 +2,7 @@
DESTDIR ?= ./
CC = gcc
-CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
+CFLAGS += -Wall -DGOTTHARDD -DMCB_FUNCS -DDEBUG -DVIRTUAL
PROGS= $(DESTDIR)/gotthardDetectorServer_virtual
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/ansi.h
index a122db0ad..1f2dbc999 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/ansi.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/ansi.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/ansi.h
\ No newline at end of file
+../../../slsSupportLib/include/ansi.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.c
index 87a4f95d1..19b563862 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.c
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.c
@@ -1 +1 @@
-../commonFiles/communication_funcs.c
\ No newline at end of file
+../../../slsSupportLib/include/communication_funcs.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.h
index f220903b2..7f8c3d192 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/communication_funcs.h
@@ -1 +1 @@
-../commonFiles/communication_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/communication_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_developer
deleted file mode 100755
index 940e9e73a..000000000
Binary files a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServer_developer and /dev/null differ
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3 b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3
deleted file mode 100755
index 7d609b90d..000000000
Binary files a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/gotthardDetectorServerv4.0.0.3 and /dev/null differ
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_defs.h
index c5062e03f..108fdd66a 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_defs.h
@@ -1 +1 @@
-../commonFiles/sls_detector_defs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_detector_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_funcs.h
index 844b67129..a21957495 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_detector_funcs.h
@@ -1 +1 @@
-../commonFiles/sls_detector_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_detector_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_defs.h
index 1de31caf5..fbea73b31 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_defs.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/sls_receiver_defs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_receiver_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_funcs.h
index c2ea4ded9..8f221c967 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/sls_receiver_funcs.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/sls_receiver_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_receiver_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh
index 19d9acbcb..933604ab8 100755
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/updateGitVersion.sh
@@ -1,11 +1,11 @@
SERVER=gotthardDetectorServer
-MAINDIR=slsDetectorsPackage
-SPECDIR=slsDetectorSoftware/$SERVER
+MAINDIR=slsDetectorPackage
+SPECDIR=slsDetectorSoftware/slsDetectorServers/$SERVER
TMPFILE=gitInfoGotthardTmp.h
INCLFILE=gitInfoGotthard.h
#evaluate the variables
-EVALFILE=../../evalVersionVariables.sh
+EVALFILE=../../../evalVersionVariables.sh
source $EVALFILE
@@ -24,7 +24,7 @@ OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}')
#update INCLFILE if changes
if [ "$OLDDATE" != "$NEWDATE" ]; then
echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt
- cd ../../
+ cd ../../../
./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
cd $WD
-fi
\ No newline at end of file
+fi
diff --git a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/versionAPI.h b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/versionAPI.h
index d3bf8d6cf..5336e713b 120000
--- a/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/versionAPI.h
+++ b/slsDetectorSoftware/slsDetectorServers/gotthardDetectorServer/versionAPI.h
@@ -1 +1 @@
-../commonFiles/versionAPI.h
\ No newline at end of file
+../../../slsSupportLib/include/versionAPI.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile
index a1c89973e..85dd50095 100755
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile
@@ -1,6 +1,6 @@
CROSS = bfin-uclinux-
CC = $(CROSS)gcc
-CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
+CFLAGS += -Wall -DJUNGFRAUD -DSLS_DETECTOR_FUNCTION_LIST -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lstdc++
PROGS = jungfrauDetectorServer
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual
index 97b4812d6..3b7f1973b 100644
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/Makefile.virtual
@@ -1,5 +1,5 @@
CC = gcc
-CFLAGS += -Wall -DJUNGFRAUD -DVIRTUAL -DSLS_DETECTOR_FUNCTION_LIST -DDACS_INT -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
+CFLAGS += -Wall -DJUNGFRAUD -DVIRTUAL -DSLS_DETECTOR_FUNCTION_LIST -DSTOP_SERVER #-DVERBOSEI #-DVERBOSE
LDLIBS += -lm -lstdc++ -pthread
PROGS = jungfrauDetectorServer_virtual
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/ansi.h
index a122db0ad..1f2dbc999 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/ansi.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/ansi.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/ansi.h
\ No newline at end of file
+../../../slsSupportLib/include/ansi.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer
deleted file mode 100755
index d8de0a65d..000000000
Binary files a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_developer and /dev/null differ
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_refactor b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_refactor
new file mode 100755
index 000000000..206613888
Binary files /dev/null and b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/bin/jungfrauDetectorServer_refactor differ
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.c
index 87a4f95d1..19b563862 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.c
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.c
@@ -1 +1 @@
-../commonFiles/communication_funcs.c
\ No newline at end of file
+../../../slsSupportLib/include/communication_funcs.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.h
index f220903b2..7f8c3d192 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/communication_funcs.h
@@ -1 +1 @@
-../commonFiles/communication_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/communication_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt
index 5fdddd6d8..e9a0c5f70 100644
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfo.txt
@@ -1,9 +1,9 @@
-Path: slsDetectorsPackage/slsDetectorSoftware/jungfrauDetectorServer
+Path: slsDetectorPackage/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
-Repsitory UUID: c52025dd7c4b44b93e64353a22997d971996ab18
-Revision: 163
-Branch: developer
-Last Changed Author: Gemma_Tinti
-Last Changed Rev: 3999
-Last Changed Date: 2018-09-28 14:11:53.000000002 +0200 ./RegisterDefs.h
+Repsitory UUID: b9f97f42a6a369dfb5c484bffeaa7a417e9cbca1
+Revision: 1
+Branch: refactor
+Last Changed Author: Dhanya_Thattil
+Last Changed Rev: 4067
+Last Changed Date: 2018-10-08 13:53:39.000000002 +0200 ./Makefile.virtual
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h
index 42a1e0ca6..3a8464eae 100644
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/gitInfoJungfrau.h
@@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
-#define GITREPUUID "c52025dd7c4b44b93e64353a22997d971996ab18"
-#define GITAUTH "Gemma_Tinti"
-#define GITREV 0x3999
-#define GITDATE 0x20180928
-#define GITBRANCH "developer"
+#define GITREPUUID "b9f97f42a6a369dfb5c484bffeaa7a417e9cbca1"
+#define GITAUTH "Dhanya_Thattil"
+#define GITREV 0x4067
+#define GITDATE 0x20181008
+#define GITBRANCH "refactor"
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
index f39c44890..c922d0ddc 100644
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorFunctionList.c
@@ -14,8 +14,8 @@
/* global variables */
//jungfrau doesnt require chips and chans (save memory)
sls_detector_module *detectorModules=NULL;
-dacs_t *detectorDacs=NULL;
-dacs_t *detectorAdcs=NULL;
+int *detectorDacs=NULL;
+int *detectorAdcs=NULL;
enum detectorSettings thisSettings;
enum masterFlags masterMode = NO_MASTER;
@@ -234,9 +234,6 @@ int testBus() {
}
-int moduleTest( enum digitalTestMode arg, int imod){
- return OK;
-}
int detectorTest( enum digitalTestMode arg){
#ifdef VIRTUAL
@@ -402,8 +399,8 @@ void allocateDetectorStructureMemory(){
if (detectorDacs!=NULL) free(detectorDacs);
if (detectorAdcs!=NULL) free(detectorAdcs);
detectorModules=malloc(sizeof(sls_detector_module));
- detectorDacs=malloc(NDAC*sizeof(dacs_t));
- detectorAdcs=malloc(NADC*sizeof(dacs_t));
+ detectorDacs=malloc(NDAC*sizeof(int));
+ detectorAdcs=malloc(NADC*sizeof(int));
#ifdef VERBOSE
printf("modules from 0x%x to 0x%x\n",detectorModules, detectorModules+n);
printf("dacs from 0x%x to 0x%x\n",detectorDacs, detectorDacs+n*NDAC);
@@ -415,7 +412,6 @@ void allocateDetectorStructureMemory(){
(detectorModules)->nadc=NADC;
(detectorModules)->nchip=NCHIP;
(detectorModules)->nchan=NCHIP*NCHAN;
- (detectorModules)->module=0;
(detectorModules)->gain=0;
(detectorModules)->offset=0;
(detectorModules)->reg=0;
@@ -460,7 +456,7 @@ void setupDetector() {
bus_w(ADC_PORT_INVERT_REG, ADC_PORT_INVERT_VAL);
//Initialization of acquistion parameters
- setSettings(DEFAULT_SETTINGS,-1);
+ setSettings(DEFAULT_SETTINGS);
setTimer(FRAME_NUMBER, DEFAULT_NUM_FRAMES);
setTimer(CYCLES_NUMBER, DEFAULT_NUM_CYCLES);
@@ -493,7 +489,7 @@ int setDefaultDacs() {
for(i = 0; i < NDAC; ++i) {
// if not already default, set it to default
if (dacValues[i] != defaultvals[i]) {
- setDAC((enum DACINDEX)i,defaultvals[i],0,0,retval);
+ setDAC((enum DACINDEX)i,defaultvals[i],0,retval);
if (retval[0] != defaultvals[i]) {
cprintf(RED, "Warning: Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]);
ret = FAIL;
@@ -602,16 +598,8 @@ void configureASICTimer() {
-/* set parameters - nmod, dr, roi */
+/* set parameters - dr, roi */
-int setNMod(int nm, enum dimension dim){
- return NMOD;
-}
-
-
-int getNModBoard(enum dimension arg){
- return NMAXMOD;
-}
int setDynamicRange(int dr){
@@ -861,7 +849,7 @@ int setModule(sls_detector_module myMod){
printf("Setting module with settings %d\n",myMod.reg);
//#endif
- setSettings( (enum detectorSettings)myMod.reg,-1);
+ setSettings( (enum detectorSettings)myMod.reg);
//copy module locally
if (detectorModules)
@@ -869,7 +857,7 @@ int setModule(sls_detector_module myMod){
//set dac values
for(i=0;imodule>=0) {
-#ifdef VERBOSE
- printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module);
-#endif
- destMod->module=srcMod->module;
- }
if (srcMod->serialnumber>=0){
destMod->serialnumber=srcMod->serialnumber;
@@ -1732,28 +1714,14 @@ int calculateDataBytes(){
return DATA_BYTES;
}
-int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerModule() * (int)getTotalNumberOfModules());}
-int getTotalNumberOfChips(){return ((int)getNumberOfChipsPerModule() * (int)getTotalNumberOfModules());}
-int getTotalNumberOfModules(){return NMOD;}
-int getNumberOfChannelsPerModule(){return ((int)getNumberOfChannelsPerChip() * (int)getTotalNumberOfChips());}
-int getNumberOfChipsPerModule(){return NCHIP;}
-int getNumberOfDACsPerModule(){return NDAC;}
-int getNumberOfADCsPerModule(){return NADC;}
+int getTotalNumberOfChannels(){return ((int)getNumberOfChannelsPerChip() * (int)getNumberOfChips());}
+int getNumberOfChips(){return NCHIP;}
+int getNumberOfDACs(){return NDAC;}
+int getNumberOfADCs(){return NADC;}
int getNumberOfChannelsPerChip(){return NCHAN;}
-/* sync */
-
-enum masterFlags setMaster(enum masterFlags arg){
- return NO_MASTER;
-}
-
-enum synchronizationMode setSynchronization(enum synchronizationMode arg){
- return NO_SYNCHRONIZATION;
-}
-
-
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h
index f4e89e760..36260b519 100644
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/slsDetectorServer_defs.h
@@ -46,8 +46,6 @@ enum NETWORKINDEX { TXN_FRAME };
/* Hardware Definitions */
-#define NMAXMOD (1)
-#define NMOD (1)
#define NCHAN (256 * 256)
#define NCHIP (8)
#define NADC (0)
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_defs.h
index c5062e03f..108fdd66a 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_defs.h
@@ -1 +1 @@
-../commonFiles/sls_detector_defs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_detector_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_funcs.h
index 844b67129..a21957495 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_detector_funcs.h
@@ -1 +1 @@
-../commonFiles/sls_detector_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_detector_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_defs.h
index 1de31caf5..fbea73b31 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_defs.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_defs.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/sls_receiver_defs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_receiver_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_funcs.h
index c2ea4ded9..8f221c967 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/sls_receiver_funcs.h
@@ -1 +1 @@
-../../slsReceiverSoftware/include/sls_receiver_funcs.h
\ No newline at end of file
+../../../slsSupportLib/include/sls_receiver_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh
index 0c25e7f1e..917de1fcf 100755
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/updateGitVersion.sh
@@ -1,12 +1,12 @@
SERVER=jungfrauDetectorServer
-MAINDIR=slsDetectorsPackage
-SPECDIR=slsDetectorSoftware/$SERVER
+MAINDIR=slsDetectorPackage
+SPECDIR=slsDetectorSoftware/slsDetectorServers/$SERVER
TMPFILE=gitInfoJungfrauTmp.h
INCLFILE=gitInfoJungfrau.h
#evaluate the variables
-EVALFILE=../../evalVersionVariables.sh
+EVALFILE=../../../evalVersionVariables.sh
source $EVALFILE
@@ -25,7 +25,7 @@ OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}')
#update INCLFILE if changes
if [ "$OLDDATE" != "$NEWDATE" ]; then
echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt
- cd ../../
+ cd ../../../
./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
cd $WD
fi
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/versionAPI.h b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/versionAPI.h
index d3bf8d6cf..5336e713b 120000
--- a/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/versionAPI.h
+++ b/slsDetectorSoftware/slsDetectorServers/jungfrauDetectorServer/versionAPI.h
@@ -1 +1 @@
-../commonFiles/versionAPI.h
\ No newline at end of file
+../../../slsSupportLib/include/versionAPI.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/.target-makefrag b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/.target-makefrag
deleted file mode 100755
index ce093ecac..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/.target-makefrag
+++ /dev/null
@@ -1 +0,0 @@
-AXIS_BUILDTYPE ?= cris-axis-linux-gnu
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile
deleted file mode 100755
index 490d4761b..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-# $Id: Makefile,v 1.1.1.1 2006/02/04 03:35:01 freza Exp $
-# first compile
-# make cris-axis-linux-gnu
-
-
-CROSS = bfin-uclinux-
-CC = $(CROSS)gcc
-
-CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
-
-
-PROGS= moenchDetectorServer
-INSTDIR= /tftpboot
-INSTMODE= 0777
-
-
-
-BINS = testlib_sharedlibc
-SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
-OBJS = $(SRCS:%.c=%.o)
-
-
-
-all: clean versioning $(PROGS)
-
-boot: $(OBJS)
-
-versioning:
- @echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
-
-$(PROGS): $(OBJS)
- echo $(OBJS)
- $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
-
-
-install: $(PROGS)
- $(INSTALL) -d $(INSTDIR)
- $(INSTALL) -m $(INSTMODE) $(PROGS) $(INSTDIR)
-
-
-romfs:
- $(ROMFSINST) /bin/$(PROGS)
-
-clean:
- rm -rf $(PROGS) *.o *.gdb
-
-
-
-
-
-
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile.virtual b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile.virtual
deleted file mode 100755
index 38dd2537c..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/Makefile.virtual
+++ /dev/null
@@ -1,30 +0,0 @@
-
-DESTDIR ?= ./
-
-CC = gcc
-CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DVIRTUAL
-
-
-PROGS= $(DESTDIR)/moenchVirtualServer
-
-
-SRCS = server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
-OBJS = $(SRCS:%.c=%.o)
-
-moenchVirtualServer = $(PROGS)
-
-all: clean $(PROGS)
-
-
-$(PROGS): $(OBJS)
- $(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
-
-
-clean:
- rm -rf $(PROGS) *.o *.gdb
-
-
-
-
-
-
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/ansi.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/ansi.h
deleted file mode 120000
index a122db0ad..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/ansi.h
+++ /dev/null
@@ -1 +0,0 @@
-../../slsReceiverSoftware/include/ansi.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.c
deleted file mode 120000
index 87a4f95d1..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.c
+++ /dev/null
@@ -1 +0,0 @@
-../commonFiles/communication_funcs.c
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.h
deleted file mode 120000
index f220903b2..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/communication_funcs.h
+++ /dev/null
@@ -1 +0,0 @@
-../commonFiles/communication_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.c
deleted file mode 100755
index 25b6e7598..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.c
+++ /dev/null
@@ -1,2613 +0,0 @@
-
-#include "server_defs.h"
-#include "firmware_funcs.h"
-#include "mcb_funcs.h"
-#include "registers_m.h"
-
-#ifdef SHAREDMEMORY
-#include "sharedmemory.h"
-#endif
-
-#include
-#include
-#include
-
-#include
-
-//for memory mapping
-u_int64_t CSP0BASE;
-
-FILE *debugfp, *datafp;
-
-int fr;
-int wait_time;
-int *fifocntrl;
-
-//int *statusreg; commented out by dhanya
-const int nModY=1;
-int nModBoard;
-int nModX=NMAXMOD;
-int dynamicRange=16;//32;
-int dataBytes=NMAXMOD*NCHIP*NCHAN*2;
-int storeInRAM=0;
-int ROI_flag=0;
-int adcConfigured=-1;
-u_int32_t *ram_values=NULL;
-volatile char *now_ptr=NULL;
-volatile u_int16_t *values;
-int ram_size=0;
-
-int64_t totalTime=1;
-u_int32_t progressMask=0;
-
-int phase_shift=0;//DEFAULT_PHASE_SHIFT;
-int ipPacketSize=DEFAULT_IP_PACKETSIZE;
-int udpPacketSize=DEFAULT_UDP_PACKETSIZE;
-
-
-int ififostart, ififostop, ififostep, ififo;
-
-int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION, timingMode=AUTO_TIMING;
-
-enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
-
-
-#ifdef MCB_FUNCS
-extern const int nChans;
-extern const int nChips;
-//extern const int nDacs;
-//extern const int nAdcs;
-#endif
-#ifndef MCB_FUNCS
-
-const int nChans=NCHAN;
-const int nChips=NCHIP;
-const int nDacs=NDAC;
-const int nAdcs=NADC;
-#endif
-
-
-
-
-/**
- ENEt conf structs
-*/
-typedef struct mac_header_struct{
- u_int8_t mac_dest_mac2;
- u_int8_t mac_dest_mac1;
- u_int8_t mac_dummy1;
- u_int8_t mac_dummy2;
- u_int8_t mac_dest_mac6;
- u_int8_t mac_dest_mac5;
- u_int8_t mac_dest_mac4;
- u_int8_t mac_dest_mac3;
- u_int8_t mac_src_mac4;
- u_int8_t mac_src_mac3;
- u_int8_t mac_src_mac2;
- u_int8_t mac_src_mac1;
- u_int16_t mac_ether_type;
- u_int8_t mac_src_mac6;
- u_int8_t mac_src_mac5;
-} mac_header;
-
-typedef struct ip_header_struct {
- u_int16_t ip_len;
- u_int8_t ip_tos;
- u_int8_t ip_ihl:4 ,ip_ver:4;
- u_int16_t ip_offset:13,ip_flag:3;
- u_int16_t ip_ident;
- u_int16_t ip_chksum;
- u_int8_t ip_protocol;
- u_int8_t ip_ttl;
- u_int32_t ip_sourceip;
- u_int32_t ip_destip;
-} ip_header;
-
-typedef struct udp_header_struct{
- u_int16_t udp_destport;
- u_int16_t udp_srcport;
- u_int16_t udp_chksum;
- u_int16_t udp_len;
-} udp_header;
-
-typedef struct mac_conf_struct{
- mac_header mac;
- ip_header ip;
- udp_header udp;
- u_int32_t npack;
- u_int32_t lpack;
- u_int32_t npad;
- u_int32_t cdone;
-} mac_conf;
-
-typedef struct tse_conf_struct{
- u_int32_t rev; //0x0
- u_int32_t scratch;
- u_int32_t command_config;
- u_int32_t mac_0; //0x3
- u_int32_t mac_1;
- u_int32_t frm_length;
- u_int32_t pause_quant;
- u_int32_t rx_section_empty; //0x7
- u_int32_t rx_section_full;
- u_int32_t tx_section_empty;
- u_int32_t tx_section_full;
- u_int32_t rx_almost_empty; //0xB
- u_int32_t rx_almost_full;
- u_int32_t tx_almost_empty;
- u_int32_t tx_almost_full;
- u_int32_t mdio_addr0; //0xF
- u_int32_t mdio_addr1;
-}tse_conf;
-
-
-
-int mapCSP0(void) {
- printf("Mapping memory\n");
-#ifndef VIRTUAL
- int fd;
- fd = open("/dev/mem", O_RDWR | O_SYNC, 0);
- if (fd == -1) {
- printf("\nCan't find /dev/mem!\n");
- return FAIL;
- }
- printf("/dev/mem opened\n");
-
- CSP0BASE = (u_int32_t)mmap(0, MEM_SIZE, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fd, CSP0);
- if (CSP0BASE == (u_int32_t)MAP_FAILED) {
- printf("\nCan't map memmory area!!\n");
- return FAIL;
- }
- printf("CSP0 mapped\n");
-
-#endif
-#ifdef VIRTUAL
- CSP0BASE = malloc(MEM_SIZE);
- printf("memory allocated\n");
-#endif
-#ifdef SHAREDMEMORY
- if ( (res=inism(SMSV))<0) {
- printf("error attaching shared memory! %i",res);
- return FAIL;
- }
-#endif
- printf("CSPObase is 0x%x \n",CSP0BASE);
- printf("CSPOBASE=from %08x to %x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
-
- u_int32_t address;
- address = FIFO_DATA_REG_OFF;
- values=(u_int16_t*)(CSP0BASE+address*2);
- printf("statusreg=%08x\n",bus_r(STATUS_REG));
- printf("\n\n");
- return OK;
-}
-
-u_int16_t bus_r16(u_int32_t offset){
- volatile u_int16_t *ptr1;
- ptr1=(u_int16_t*)(CSP0BASE+offset*2);
- return *ptr1;
-}
-
-u_int16_t bus_w16(u_int32_t offset, u_int16_t data) {
- volatile u_int16_t *ptr1;
- ptr1=(u_int16_t*)(CSP0BASE+offset*2);
- *ptr1=data;
- return OK;
-}
-
-/** ramType is DARK_IMAGE_REG or GAIN_IMAGE_REG */
-u_int16_t ram_w16(u_int32_t ramType, int adc, int adcCh, int Ch, u_int16_t data) {
- unsigned int adr = (ramType | adc << 8 | adcCh << 5 | Ch );
- // printf("Writing to addr:%x\n",adr);
- return bus_w16(adr,data);
-}
-
-/** ramType is DARK_IMAGE_REG or GAIN_IMAGE_REG */
-u_int16_t ram_r16(u_int32_t ramType, int adc, int adcCh, int Ch){
- unsigned int adr = (ramType | adc << 8 | adcCh << 5 | Ch );
- // printf("Reading from addr:%x\n",adr);
- return bus_r16(adr);
-}
-
-u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
- volatile u_int32_t *ptr1;
-
- ptr1=(u_int32_t*)(CSP0BASE+offset*2);
- *ptr1=data;
-
- return OK;
-}
-
-
-u_int32_t bus_r(u_int32_t offset) {
- volatile u_int32_t *ptr1;
-
- ptr1=(u_int32_t*)(CSP0BASE+offset*2);
- return *ptr1;
-}
-
-
-int setPhaseShiftOnce(){
- u_int32_t addr, reg;
- int i;
- addr=MULTI_PURPOSE_REG;
- reg=bus_r(addr);
-#ifdef VERBOSE
- printf("Multipurpose reg:%x\n",reg);
-#endif
-
- //Checking if it is power on(negative number)
- // if(((reg&0xFFFF0000)>>16)>0){
- //bus_w(addr,0x0); //clear the reg
-
- if(reg==0){
- printf("\nImplementing phase shift of %d\n",phase_shift);
- for (i=1;i0) {
- bus_w(PLL_CNTRL_REG, 1);//reset PLL
- bus_w(PLL_CNTRL_REG, 0);
- phase_shift=0;
- for (i=0;i1) nc=d;// nc=161/d;
- else return -1;
-
- if (nc>255)
- return -1;
-
- int addr, addr1, addr0;
- u_int32_t pat,pat1,pat0;
-
- addr= PLL_PARAM_REG;
- addr0= PLL_PARAM_OUT_REG;
- addr1=PLL_CNTRL_REG;
- pat1=0x10;
-
-
- //write high count c0
-/* pat=(1<<12)|(7<<9)|nc; */
-/* bus_w(addr, pat); */
-/* bus_w(addr1, pat1); */
-/* bus_w(addr1, 0); */
-/* usleep (1000); */
-/* pat=bus_r(addr0); */
-/* bus_w(addr1, 0x4); */
-/* bus_w(addr1, 0); */
-/* pat=bus_r(addr0); */
-/* printf("M nominal count read %x (%d)\n",pat,(pat&0x1ff)); */
-
-
-
- //write low count c0
- pat=(nc-1)|(4<<12)|(1<<9);
- bus_w(addr, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- pat0=bus_r(PLL_PARAM_OUT_REG);
- usleep (1000);
- printf("C0 low count status %x\n",pat0);
-
- //write high count c0
- pat=(nc)|(4<<12)|(0<<9);
- bus_w(addr, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- pat0=bus_r(PLL_PARAM_OUT_REG);
- printf("C0 high count status %x\n",pat0);
- usleep (1000);
-
- //write low count c1
- pat=(nc-1)|(5<<12)|(1<<9);
- bus_w(addr, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- pat0=bus_r(PLL_PARAM_OUT_REG);
- printf("C1 high count status %x\n",pat0);
- usleep (1000);
-
- //write high count c1
- pat=(nc)|(5<<12)|(0<<9);
- bus_w(addr, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- pat0=bus_r(PLL_PARAM_OUT_REG);
- printf("C1 low count status %x\n",pat0);
- usleep (1000);
-
- //reconfigure pll
- pat1=0x8;
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- pat0=bus_r(PLL_PARAM_OUT_REG);
- printf("configure status %d\n",pat0);
- sleep (1);
- printf("finish status %x\n",pat0);
-
-
- bus_w(PLL_CNTRL_REG, 1); //reset PLL
- bus_w(PLL_CNTRL_REG, 0);
-
- return 0;
-}
-
-u_int32_t getClockDivider() {
- int addr, addr1, addr0;
- u_int32_t pat,pat1;
-
- addr0= PLL_PARAM_REG;
- addr= PLL_PARAM_OUT_REG;
- addr1=PLL_CNTRL_REG;
- pat1=0x4;
-
-
- //write low count c0
- pat=(4<<12)|(1<<9);
- bus_w(addr0, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- usleep (1000);
- pat=bus_r(addr);
- printf("C0 low count read %x (%d)\n",pat,(pat&0xff));
-
- //write high count c0
- pat=(4<<12)|(0<<9);
- bus_w(addr0, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- usleep (1000);
- pat=bus_r(addr);
- printf("C0 high count read %x (%d)\n",pat,(pat&0xff));
-
-
- //write low count c1
- pat=(5<<12)|(1<<9);
- bus_w(addr0, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- usleep (1000);
- pat=bus_r(addr);
- printf("C1 low count read %x (%d)\n",pat,(pat&0xff));
-
- //write high count c1
- pat=(5<<12)|(0<<9);
- bus_w(addr0, pat);
- bus_w(addr1, pat1);
- bus_w(addr1, 0);
- usleep (1000);
- pat=bus_r(addr);
- printf("C1 high count read %x (%d)\n",pat,(pat&0xff));
-
-
- return (pat&0xff);
-
-/* //write low count c0 */
-/* pat=(0<<12)|(7<<9); */
-/* bus_w(addr0, pat); */
-/* bus_w(addr1, pat1); */
-/* bus_w(addr1, 0); */
-/* usleep (1000); */
-/* pat=bus_r(addr); */
-/* printf("N nominal count read %x (%d)\n",pat,pat&0x1ff); */
-
-/* //write high count c0 */
-/* pat=(1<<12)|(7<<9); */
-/* bus_w(addr0, pat); */
-/* bus_w(addr1, pat1); */
-/* bus_w(addr1, 0); */
-/* usleep (1000); */
-/* pat=bus_r(addr); */
-/* printf("M nominal count read %x (%d)\n",pat,(pat&0x1ff)); */
-
-
-
-/* if ((pat&0x1ff)!=0) */
-/* return 161/(pat&0x1ff); */
-/* else */
-/* return -1; */
-}
-
-u_int32_t setSetLength(int d) {
- return 0;
-}
-
-u_int32_t getSetLength() {
- return 0;
-}
-
-u_int32_t setOversampling(int d) {
-
- if (d>=0 && d<=255)
- bus_w(OVERSAMPLING_REG, d);
-
- return bus_r(OVERSAMPLING_REG);
-}
-
-
-u_int32_t setWaitStates(int d1) {
- return 0;
-}
-
-u_int32_t getWaitStates() {
- return 0;
-}
-
-
-u_int32_t setTotClockDivider(int d) {
- return 0;
-}
-
-u_int32_t getTotClockDivider() {
- return 0;
-}
-
-
-u_int32_t setTotDutyCycle(int d) {
- return 0;
-}
-
-u_int32_t getTotDutyCycle() {
- return 0;
-}
-
-
-u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
-
- //int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING};
- // int off=d*SIGNAL_OFFSET;
-
- u_int32_t c;
- c=bus_r(EXT_SIGNAL_REG);
-
- if (d>=0 && d<4) {
- signals[d]=mode;
-#ifdef VERBOSE
- printf("settings signal variable number %d to value %04x\n", d, signals[d]);
-#endif
-
- // if output signal, set it!
-
- switch (mode) {
- case GATE_IN_ACTIVE_HIGH:
- case GATE_IN_ACTIVE_LOW:
- if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)
- setFPGASignal(d,mode);
- else
- setFPGASignal(d,SIGNAL_OFF);
- break;
- case TRIGGER_IN_RISING_EDGE:
- case TRIGGER_IN_FALLING_EDGE:
- if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER)
- setFPGASignal(d,mode);
- else
- setFPGASignal(d,SIGNAL_OFF);
- break;
- case RO_TRIGGER_IN_RISING_EDGE:
- case RO_TRIGGER_IN_FALLING_EDGE:
- if (timingMode==TRIGGER_READOUT)
- setFPGASignal(d,mode);
- else
- setFPGASignal(d,SIGNAL_OFF);
- break;
- case MASTER_SLAVE_SYNCHRONIZATION:
- setSynchronization(syncMode);
- break;
- default:
- setFPGASignal(d,mode);
- break;
- }
-
- setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
- }
-
-
-// if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0)
-// bus_w(EXT_SIGNAL_REG,((modes[mode])<=0) {
-#ifdef VERBOSE
- printf("writing signal register number %d mode %04x\n",d, modes[mode]);
-#endif
- bus_w(EXT_SIGNAL_REG,((modes[mode])<>off);
-
- if (mode=0 && d<4) {
-#ifdef VERBOSE
- printf("gettings signal variable number %d value %04x\n", d, signals[d]);
-#endif
- return signals[d];
- } else
- return -1;
-
-
-}
-
-
-int getFPGASignal(int d) {
-
- int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE};
-
- int off=d*SIGNAL_OFFSET;
- int mode=((bus_r(EXT_SIGNAL_REG)&(SIGNAL_MASK<>off);
-
- if (mode<=RO_TRIGGER_OUT_FALLING_EDGE) {
- if (modes[mode]!=SIGNAL_OFF && signals[d]!=MASTER_SLAVE_SYNCHRONIZATION)
- signals[d]=modes[mode];
-#ifdef VERYVERBOSE
- printf("gettings signal register number %d value %04x\n", d, modes[mode]);
-#endif
- return modes[mode];
- } else
- return -1;
-
-}
-
-
-
-
-
-/*
-enum externalCommunicationMode{
- GET_EXTERNAL_COMMUNICATION_MODE,
- AUTO,
- TRIGGER_EXPOSURE_SERIES,
- TRIGGER_EXPOSURE_BURST,
- TRIGGER_READOUT,
- TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE,
- GATE_FIX_NUMBER,
- GATE_FIX_DURATION,
- GATE_WITH_START_TRIGGER,
- GATE_COINCIDENCE_WITH_INTERNAL_ENABLE
-};
-*/
-
-
-int setTiming(int ti) {
-
-
- int ret=GET_EXTERNAL_COMMUNICATION_MODE;
-
- int g=-1, t=-1, rot=-1;
-
- int i;
-
- switch (ti) {
- case AUTO_TIMING:
- timingMode=ti;
- // disable all gates/triggers in except if used for master/slave synchronization
- for (i=0; i<4; i++) {
- if (getFPGASignal(i)>0 && getFPGASignal(i)=0 && t>=0 && rot<0) {
- ret=GATE_WITH_START_TRIGGER;
- } else if (g<0 && t>=0 && rot<0) {
- ret=TRIGGER_EXPOSURE;
- } else if (g>=0 && t<0 && rot<0) {
- ret=GATE_FIX_NUMBER;
- } else if (g<0 && t<0 && rot>0) {
- ret=TRIGGER_READOUT;
- } else if (g<0 && t<0 && rot<0) {
- ret=AUTO_TIMING;
- }
-
- // timingMode=ret;
-
- return ret;
-
-}
-
-
-
-int setConfigurationRegister(int d) {
-#ifdef VERBOSE
- printf("Setting configuration register to %x",d);
-#endif
- if (d>=0) {
- bus_w(CONFIG_REG,d);
- }
-#ifdef VERBOSE
- printf("configuration register is %x", bus_r(CONFIG_REG));
-#endif
- return bus_r(CONFIG_REG);
-}
-
-int setToT(int d) {
- //int ret=0;
- int reg;
-#ifdef VERBOSE
- printf("Setting ToT to %d\n",d);
-#endif
- reg=bus_r(CONFIG_REG);
-#ifdef VERBOSE
- printf("Before: ToT is %x\n", reg);
-#endif
- if (d>0) {
- bus_w(CONFIG_REG,reg|TOT_ENABLE_BIT);
- } else if (d==0) {
- bus_w(CONFIG_REG,reg&(~TOT_ENABLE_BIT));
- }
- reg=bus_r(CONFIG_REG);
-#ifdef VERBOSE
- printf("ToT is %x\n", reg);
-#endif
- if (reg&TOT_ENABLE_BIT)
- return 1;
- else
- return 0;
-}
-
-int setContinousReadOut(int d) {
- //int ret=0;
- int reg;
-#ifdef VERBOSE
- printf("Setting Continous readout to %d\n",d);
-#endif
- reg=bus_r(CONFIG_REG);
-#ifdef VERBOSE
- printf("Before: Continous readout is %x\n", reg);
-#endif
- if (d>0) {
- bus_w(CONFIG_REG,reg|CONT_RO_ENABLE_BIT);
- } else if (d==0) {
- bus_w(CONFIG_REG,reg&(~CONT_RO_ENABLE_BIT));
- }
- reg=bus_r(CONFIG_REG);
-#ifdef VERBOSE
- printf("Continous readout is %x\n", reg);
-#endif
- if (reg&CONT_RO_ENABLE_BIT)
- return 1;
- else
- return 0;
-}
-
-
-int startReceiver(int start) {
- u_int32_t addr=CONFIG_REG;
-#ifdef VERBOSE
- if(start)
- printf("Setting up detector to send to Receiver\n");
- else
- printf("Setting up detector to send to CPU\n");
-#endif
- int reg=bus_r(addr);
- //for start recever, write 0 and for stop, write 1
- if (!start)
- bus_w(CONFIG_REG,reg|CPU_OR_RECEIVER_BIT);
- else
- bus_w(CONFIG_REG,reg&(~CPU_OR_RECEIVER_BIT));
-
- reg=bus_r(addr);
-//#ifdef VERBOSE
- printf("Config Reg %x\n", reg);
-//#endif
- int d =reg&CPU_OR_RECEIVER_BIT;
- if(d!=0) d=1;
- if(d!=start)
- return OK;
- else
- return FAIL;
-}
-
-
-u_int64_t getDetectorNumber() {
- char output[255],mac[255]="";
- u_int64_t res=0;
- FILE* sysFile = popen("ifconfig eth0 | grep HWaddr | cut -d \" \" -f 11", "r");
- fgets(output, sizeof(output), sysFile);
- pclose(sysFile);
- //getting rid of ":"
- char * pch;
- pch = strtok (output,":");
- while (pch != NULL){
- strcat(mac,pch);
- pch = strtok (NULL, ":");
- }
- sscanf(mac,"%llx",&res);
- return res;
-}
-
-u_int32_t getFirmwareVersion() {
- return bus_r(FPGA_VERSION_REG);
-}
-
-u_int32_t getFirmwareSVNVersion(){
- return bus_r(FPGA_SVN_REG);
-}
-
-
-// for fpga test
-u_int32_t testFpga(void) {
- printf("Testing FPGA:\n");
- volatile u_int32_t val,addr,val2;
- int result=OK,i;
- //fixed pattern
- val=bus_r(FIX_PATT_REG);
- if (val==FIXED_PATT_VAL) {
- printf("fixed pattern ok!! %08x\n",val);
- } else {
- printf("fixed pattern wrong!! %08x\n",val);
- result=FAIL;
- }
-
- //dummy register
- addr = DUMMY_REG;
- for(i=0;i<1000000;i++)
- {
- val=0x5A5A5A5A-i;
- bus_w(addr, val);
- val=bus_r(addr);
- if (val!=0x5A5A5A5A-i) {
- printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of %x \n",i,val,0x5A5A5A5A-i);
- result=FAIL;
- }
- val=(i+(i<<10)+(i<<20));
- bus_w(addr, val);
- val2=bus_r(addr);
- if (val2!=val) {
- printf("ATTEMPT:%d:\tFPGA dummy register wrong!! read %x instead of %x.\n",i,val2,val);
- result=FAIL;
- }
- val=0x0F0F0F0F;
- bus_w(addr, val);
- val=bus_r(addr);
- if (val!=0x0F0F0F0F) {
- printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of 0x0F0F0F0F \n",i,val);
- result=FAIL;
- }
- val=0xF0F0F0F0;
- bus_w(addr, val);
- val=bus_r(addr);
- if (val!=0xF0F0F0F0) {
- printf("ATTEMPT:%d:\tFPGA dummy register wrong!! %x instead of 0xF0F0F0F0 \n\n",i,val);
- result=FAIL;
- }
- }
- if(result==OK)
- {
- printf("----------------------------------------------------------------------------------------------");
- printf("\nATTEMPT 1000000: FPGA DUMMY REGISTER OK!!!\n");
- printf("----------------------------------------------------------------------------------------------");
- }
- printf("\n");
- return result;
-}
-
-
-// for fpga test
-u_int32_t testRAM(void) {
- int result=OK;
- int i=0;
- allocateRAM();
- // while(i<100000) {
- memcpy(ram_values, values, dataBytes);
- printf ("Testing RAM:\t%d: copied fifo %x to memory %x size %d\n",i++, (unsigned int)(values), (unsigned int)(ram_values), dataBytes);
- // }
- return result;
-}
-
-int getNModBoard() {
- return nModX;
-}
-
-int setNMod(int n) {
- return nModX;
-}
-
-
-// fifo test
-int testFifos(void) {
- printf("Fifo test not implemented!\n");
- bus_w16(CONTROL_REG, START_FIFOTEST_BIT);
- bus_w16(CONTROL_REG, 0x0);
- return OK;
-}
-
-
-
-// program dacq settings
-
-int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
- int64_t v64;
- u_int32_t vLSB,vMSB;
- if (value!=-1) {
- vLSB=value&(0xffffffff);
- bus_w(aLSB,vLSB);
- v64=value>> 32;
- vMSB=v64&(0xffffffff);
- bus_w(aMSB,vMSB);
- }
- return get64BitReg(aLSB, aMSB);
-
-}
-
-int64_t get64BitReg(int aLSB, int aMSB){
- int64_t v64;
- u_int32_t vLSB,vMSB;
- vLSB=bus_r(aLSB);
- vMSB=bus_r(aMSB);
- v64=vMSB;
- v64=(v64<<32) | vLSB;
-
- printf("reg64(%x,%x) %x %x %llx\n", aLSB, aMSB, vLSB, vMSB, v64);
-
- return v64;
-}
-
-int64_t setFrames(int64_t value){
- return set64BitReg(value, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
-}
-
-int64_t getFrames(){
- printf("gf");
- return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
-}
-
-int64_t setExposureTime(int64_t value){
- /* time is in ns */
- if (value!=-1)
- value*=(1E-9*CLK_FREQ);
- return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t getExposureTime(){
- return get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t setGates(int64_t value){
- return set64BitReg(value, SET_GATES_LSB_REG, SET_GATES_MSB_REG);
-}
-
-int64_t getGates(){
- return get64BitReg(GET_GATES_LSB_REG, GET_GATES_MSB_REG);
-}
-
-int64_t setPeriod(int64_t value){
- /* time is in ns */
- if (value!=-1) {
- value*=(1E-9*CLK_FREQ);
- }
-
-
-
- return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t getPeriod(){
- return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t setDelay(int64_t value){
- /* time is in ns */
- if (value!=-1) {
- value*=(1E-9*CLK_FREQ);
- }
- return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t getDelay(){
- return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t setTrains(int64_t value){
- return set64BitReg(value, SET_TRAINS_LSB_REG, SET_TRAINS_MSB_REG);
-}
-
-int64_t getTrains(){
- return get64BitReg(GET_TRAINS_LSB_REG, GET_TRAINS_MSB_REG);
-}
-
-
-int64_t setProbes(int64_t value){
- return 0;
-}
-
-
-int64_t setProgress() {
-
- //????? eventually call after setting the registers
-
-return 0;
-
-}
-
-
-int64_t getProgress() {
-
-
- //should be done in firmware!!!!
-
- return 0;
-
-}
-
-int64_t getActualTime(){
- return get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG)/(1E-9*CLK_FREQ);
-}
-
-int64_t getMeasurementTime(){
- int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG);
- int64_t mask=0x8000000000000000;
- if (v & mask ) {
-#ifdef VERBOSE
- printf("no measurement time left\n");
-#endif
- return -1E+9;
- } else
- return v/(1E-9*CLK_FREQ);
-}
-
-
-
-
-int loadImage(int index, short int ImageVals[]){
- u_int32_t address;
- switch (index) {
- case DARK_IMAGE :
- address = DARK_IMAGE_REG;
- break;
- case GAIN_IMAGE :
- address = GAIN_IMAGE_REG;
- break;
- }
- volatile u_int16_t *ptr;
- ptr=(u_int16_t*)(CSP0BASE+address*2);
-#ifdef VERBOSE
- int i;
- for(i=0;i<6;i++)
- printf("%d:%d\t",i,ImageVals[i]);
-#endif
- memcpy(ptr,ImageVals ,dataBytes);
-#ifdef VERBOSE
- printf("\nLoaded x%08x address with image of index %d\n",(unsigned int)(ptr),index);
-#endif
- return OK;
-}
-
-
-
-int64_t getProbes(){
- return 0;
-}
-
-
-int setDACRegister(int idac, int val, int imod) {
- u_int32_t addr, reg, mask;
- int off;
-#ifdef VERBOSE
- if(val==-1)
- printf("Getting dac register%d module %d\n",idac,imod);
- else
- printf("Setting dac register %d module %d to %d\n",idac,imod,val);
-#endif
-
- switch(idac){
- case 0:
- case 1:
- case 2:
- addr=MOD_DACS1_REG;
- break;
- case 3:
- case 4:
- case 5:
- addr=MOD_DACS2_REG;
- break;
- case 6:
- case 7:
- addr=MOD_DACS3_REG;
- break;
- default:
- printf("weird idac value %d\n",idac);
- return -1;
- break;
- }
- //saving only the msb
- val=val>>2;
-
- off=(idac%3)*10;
- mask=~((0x3ff)<=0 && val>off)&0x3ff;
- //since we saved only the msb
- val=val<<2;
-
- //val=(bus_r(addr)>>off)&0x3ff;
-
-
-#ifdef VERBOSE
- printf("Dac %d module %d register is %d\n\n",idac,imod,val);
-#endif
- return val;
-}
-
-
-int getTemperature(int tempSensor, int imod){
- int val;
- imod=0;//ignoring more than 1 mod for now
- int i,j,repeats=6;
- u_int32_t tempVal=0;
-#ifdef VERBOSE
- char cTempSensor[2][100]={"ADCs/ASICs","VRs/FPGAs"};
- printf("Getting Temperature of module:%d for the %s for tempsensor:%d\n",imod,cTempSensor[tempSensor],tempSensor);
-#endif
- bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby
- bus_w(TEMP_IN_REG,((T1_CLK_BIT)&~(T1_CS_BIT))|(T2_CLK_BIT));//high clk low cs
-
- for(i=0;i<20;i++) {
- //repeats is number of register writes for delay
- for(j=0;j>1);//fpga
- }
- }
-
- bus_w(TEMP_IN_REG,(T1_CLK_BIT)|(T1_CS_BIT)|(T2_CLK_BIT)|(T2_CS_BIT));//standby
- val=((int)tempVal)/4.0;
-
-#ifdef VERBOSE
- printf("Temperature of module:%d for the %s is %.2fC\n",imod,cTempSensor[tempSensor],val);
-#endif
- return val;
-}
-
-
-
-int initHighVoltage(int val, int imod){
-#ifdef VERBOSE
- printf("Setting/Getting High Voltage of module:%d with val:%d\n",imod,val);
-#endif
- volatile u_int32_t addr=HV_REG;
- int writeVal,writeVal2;
- switch(val){
- case -1: break;
- case 0: writeVal=0x0; writeVal2=0x0; break;
- case 90: writeVal=0x0; writeVal2=0x1; break;
- case 110:writeVal=0x2; writeVal2=0x3; break;
- case 120:writeVal=0x4; writeVal2=0x5; break;
- case 150:writeVal=0x6; writeVal2=0x7; break;
- case 180:writeVal=0x8; writeVal2=0x9; break;
- case 200:writeVal=0xA; writeVal2=0xB; break;
- default :printf("Invalid voltage\n");return -2;break;
- }
- //to set value
- if(val!=-1){
- //set value to converted value
- bus_w(addr,writeVal);
- bus_w(addr,writeVal2);
-#ifdef VERBOSE
- printf("Value sent is %d and then %d\n",writeVal,writeVal2);
-#endif
- }
- //read value and return the converted value
- val=bus_r(addr);
-#ifdef VERBOSE
- printf("Value read from reg is %d\n",val);
-#endif
- switch(val){
- case 0x0:val=0;break;
- case 0x1:val=90;break;
- case 0x3:val=110;break;
- case 0x5:val=120;break;
- case 0x7:val=150;break;
- case 0x9:val=180;break;
- case 0xB:val=200;break;
- default:printf("Weird value read:%d\n",val);return -3;break;
- }
-#ifdef VERBOSE
- printf("High voltage of module:%d is %d\n",imod,val);
-#endif
- return val;
-}
-
-
-
-int initConfGain(int isettings,int val,int imod){
- int retval;
- u_int32_t addr=GAIN_REG;
-
- if(val!=-1){
-#ifdef VERBOSE
- printf("Setting Gain of module:%d with val:%d\n",imod,val);
-#endif
- bus_w(addr,((val<>SETTINGS_OFFSET);
-#ifdef VERBOSE
- printf("Settings read from reg is %d\n",retval);
-#endif
- if((isettings!=-1)&&(retval!=isettings)){
- printf("\n\nSettings r\n\n");
- return -1;
- }
-
- return retval;
-}
-
-
-
-int setADC(int adc){
- int reg,nchips,mask,nchans;
-
- if(adc==-1) ROI_flag=0;
- else ROI_flag=1;
-
- setDAQRegister();//token timing
- cleanFifo();//adc sync
-
-/* if(adc==-1){*/
- //set packet size
- ipPacketSize= DEFAULT_IP_PACKETSIZE;
- udpPacketSize=DEFAULT_UDP_PACKETSIZE;
- //set channel mask
- nchips = NCHIP;
- nchans = NCHANS;
- mask = ACTIVE_ADC_MASK;
- /*
- //with moench module 1 adc -- NOT IMPLEMENTED
- else{
- ipPacketSize= ADC1_IP_PACKETSIZE;
- udpPacketSize=ADC1_UDP_PACKETSIZE;
- //set channel mask
- nchips = NCHIPS_PER_ADC;
- nchans = GOTTHARDNCHAN;
- mask = 1<mac.mac_dest_mac1 =((macad>>(8*5))&0xFF);// 0x00; //pc7060
- mac_conf_regs->mac.mac_dest_mac2 =((macad>>(8*4))&0xFF);// 0x19; //pc7060
- mac_conf_regs->mac.mac_dest_mac3 =((macad>>(8*3))&0xFF);// 0x99; //pc7060
- mac_conf_regs->mac.mac_dest_mac4 =((macad>>(8*2))&0xFF);// 0x24; //pc7060
- mac_conf_regs->mac.mac_dest_mac5 =((macad>>(8*1))&0xFF);// 0xEB; //pc7060
- mac_conf_regs->mac.mac_dest_mac6 =((macad>>(8*0))&0xFF);// 0xEE; //pc7060
-
- /*
- mac_conf_regs->mac.mac_src_mac1 = 0x00;
- mac_conf_regs->mac.mac_src_mac2 = 0xAA;
- mac_conf_regs->mac.mac_src_mac3 = 0xBB;
- mac_conf_regs->mac.mac_src_mac4 = 0xCC;
- mac_conf_regs->mac.mac_src_mac5 = 0xDD;
- mac_conf_regs->mac.mac_src_mac6 = 0xEE;
- */
- mac_conf_regs->mac.mac_src_mac1 =((detectormacad>>(8*5))&0xFF);
- mac_conf_regs->mac.mac_src_mac2 =((detectormacad>>(8*4))&0xFF);
- mac_conf_regs->mac.mac_src_mac3 =((detectormacad>>(8*3))&0xFF);
- mac_conf_regs->mac.mac_src_mac4 =((detectormacad>>(8*2))&0xFF);
- mac_conf_regs->mac.mac_src_mac5 =((detectormacad>>(8*1))&0xFF);
- mac_conf_regs->mac.mac_src_mac6 =((detectormacad>>(8*0))&0xFF);
- mac_conf_regs->mac.mac_ether_type = 0x0800; //ipv4
-
-
-
- mac_conf_regs->ip.ip_ver = 0x4;
- mac_conf_regs->ip.ip_ihl = 0x5;
- mac_conf_regs->ip.ip_tos = 0x0;
- mac_conf_regs->ip.ip_len = ipPacketSize;//0x0522; // was 0x0526;
- mac_conf_regs->ip.ip_ident = 0x0000;
- mac_conf_regs->ip.ip_flag = 0x2;
- mac_conf_regs->ip.ip_offset = 0x00;
- mac_conf_regs->ip.ip_ttl = 0x70;
- mac_conf_regs->ip.ip_protocol = 0x11;
- mac_conf_regs->ip.ip_chksum = 0x0000 ; //6E42 now is automatically computed
- mac_conf_regs->ip.ip_sourceip = detipad; //0x8181CA2E;129.129.202.46
- mac_conf_regs->ip.ip_destip = ipad; //CA57
-
- //#ifdef VERBOSE
- printf("mac_dest:%llx %x:%x:%x:%x:%x:%x\n",
- macad,
- mac_conf_regs->mac.mac_dest_mac1,
- mac_conf_regs->mac.mac_dest_mac2,
- mac_conf_regs->mac.mac_dest_mac3,
- mac_conf_regs->mac.mac_dest_mac4,
- mac_conf_regs->mac.mac_dest_mac5,
- mac_conf_regs->mac.mac_dest_mac6);
- printf("mac_src:%llx %x:%x:%x:%x:%x:%x\n",
- detectormacad,
- mac_conf_regs->mac.mac_src_mac1,
- mac_conf_regs->mac.mac_src_mac2,
- mac_conf_regs->mac.mac_src_mac3,
- mac_conf_regs->mac.mac_src_mac4,
- mac_conf_regs->mac.mac_src_mac5,
- mac_conf_regs->mac.mac_src_mac6);
- printf("ip_ttl:%x\n",mac_conf_regs->ip.ip_ttl);
- printf("det_ip: %x %x\n",detipad, mac_conf_regs->ip.ip_sourceip);
- printf("dest_ip: %x %x\n",ipad, mac_conf_regs->ip.ip_destip);
-
- //#endif
-
- //checksum
- count=sizeof(mac_conf_regs->ip);
- addr=&(mac_conf_regs->ip);
- while( count > 1 ) {
- sum += *addr++;
- count -= 2;
- }
- if( count > 0 ) sum += *addr; // Add left-over byte, if any
- while (sum>>16) sum = (sum & 0xffff) + (sum >> 16);// Fold 32-bit sum to 16 bits
- checksum = (~sum)&0xffff;
- mac_conf_regs->ip.ip_chksum = checksum;
- //#ifdef VERBOSE
- printf("IP header checksum is 0x%x s\n",(unsigned int)(checksum));
- //#endif
-
- mac_conf_regs->udp.udp_srcport = 0xE185;
- mac_conf_regs->udp.udp_destport = udpport;//0xC351;
- mac_conf_regs->udp.udp_len = udpPacketSize;//0x050E; //was 0x0512;
- mac_conf_regs->udp.udp_chksum = 0x0000;
-
-#ifdef VERBOSE
- printf("Configuring TSE\n");
-#endif
- tse_conf_regs->rev = 0xA00;
- tse_conf_regs->scratch = 0xCCCCCCCC;
- tse_conf_regs->command_config = 0xB;
- tse_conf_regs->mac_0 = 0x17231C00;
- tse_conf_regs->mac_1 = 0xCB4A;
- tse_conf_regs->frm_length = 0x5DC; //max frame length (1500 bytes) (was 0x41C)
- tse_conf_regs->pause_quant = 0x0;
- tse_conf_regs->rx_section_empty = 0x7F0;
- tse_conf_regs->rx_section_full = 0x10;
- tse_conf_regs->tx_section_empty = 0x3F8; //was 0x7F0;
- tse_conf_regs->tx_section_full = 0x16;
- tse_conf_regs->rx_almost_empty = 0x8;
- tse_conf_regs->rx_almost_full = 0x8;
- tse_conf_regs->tx_almost_empty = 0x8;
- tse_conf_regs->tx_almost_full = 0x3;
- tse_conf_regs->mdio_addr0 = 0x12;
- tse_conf_regs->mdio_addr1 = 0x0;
-
- mac_conf_regs->cdone = 0xFFFFFFFF;
-
-
- if(ival)
- bus_w(addrr,(INT_RSTN_BIT|ENET_RESETN_BIT|WRITE_BACK_BIT|DIGITAL_TEST_BIT)); //0x2840,write shadow regs..
- else
- bus_w(addrr,(INT_RSTN_BIT|ENET_RESETN_BIT|WRITE_BACK_BIT)); //0x2840,write shadow regs..
-
- val=bus_r(addrr);
-#ifdef VERBOSE
- printf("Value read from Multi-purpose Reg:%x\n",val);
-#endif
- // if(val!=0x2840) return -1;
-
- usleep(100000);
-
- if(ival)
- bus_w(addrr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT|DIGITAL_TEST_BIT)); //0x2820,write shadow regs..
- else
- bus_w(addrr,(INT_RSTN_BIT|ENET_RESETN_BIT|SW1_BIT)); //0x2820,write shadow regs..
-
- val=bus_r(addrr);
-#ifdef VERBOSE
- printf("Value read from Multi-purpose Reg:%x\n",val);
-#endif
- // if(val!=0x2820) return -1;
-
-
-
-
- return adcConfigured;
-}
-
-
-int getAdcConfigured(){
- return adcConfigured;
-}
-
-u_int32_t runBusy(void) {
- u_int32_t s = bus_r(STATUS_REG) & 1;
-#ifdef VERBOSE
- printf("status %04x\n",s);
-#endif
- return s;
-}
-
-u_int32_t dataPresent(void) {
- return bus_r(LOOK_AT_ME_REG);
-}
-
-u_int32_t runState(void) {
- int s=bus_r(STATUS_REG);
-#ifdef SHAREDMEMORY
- if (s&RUN_BUSY_BIT)
- write_status_sm("Running");
- else
- write_status_sm("Stopped");
-#endif
-#ifdef VERBOSE
- printf("status %04x\n",s);
-#endif
-
-/* if (s==0x62001)
- exit(-1);*/
- return s;
-}
-
-
-// State Machine
-
-int startStateMachine(){
-int i;
-//#ifdef VERBOSE
- printf("*******Starting State Machine*******\n");
-//#endif
- cleanFifo();
- // fifoReset();
- now_ptr=(char*)ram_values;
-#ifdef SHAREDMEMORY
- write_stop_sm(0);
- write_status_sm("Started");
-#endif
-
-
- for(i=0;i<100;i++){
- //start state machine
- bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
- bus_w16(CONTROL_REG, 0x0);
- //verify
- if(bus_r(STATUS_REG) & RUN_BUSY_BIT)
- break;
- else
- usleep(5000);
- }
- if(i!=0)
- printf("tried to start state machine %d times\n",i);
- if(i==100){
- printf("\n***********COULD NOT START STATE MACHINE***************\n");
- return FAIL;
- }
-
- printf("statusreg=%08x\n",bus_r(STATUS_REG));
- return OK;
-}
-
-
-
-
-int stopStateMachine(){
- int i;
-//#ifdef VERBOSE
- printf("*******Stopping State Machine*******\n");
-//#endif
-#ifdef SHAREDMEMORY
- write_stop_sm(1);
- write_status_sm("Stopped");
-#endif
- for(i=0;i<100;i++){
- //stop state machine
- bus_w16(CONTROL_REG, STOP_ACQ_BIT);
- bus_w16(CONTROL_REG, 0x0);
- usleep(5000);
- //verify
- if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT))
- break;
- }
- if(i!=0)
- printf("tried to stop state machine %d times\n",i);
- if(i==100){
- printf("\n***********COULD NOT STOP STATE MACHINE***************\n");
- return FAIL;
- }
-
-/*
- usleep(5000);
- // if (!runBusy())
- if(!(bus_r(STATUS_REG)&RUNMACHINE_BUSY_BIT))
- return OK;
- else
- return FAIL;
- */
- printf("statusreg=%08x\n",bus_r(STATUS_REG));
- return OK;
-}
-
-
-int startReadOut(){
- u_int32_t status;
-#ifdef VERBOSE
- printf("Starting State Machine Readout\n");
-#endif
- status=bus_r(STATUS_REG)&RUN_BUSY_BIT;
-#ifdef DEBUG
- printf("State machine status is %08x\n",bus_r(STATUS_REG));
-#endif
- bus_w16(CONTROL_REG, START_ACQ_BIT |START_READOUT_BIT); // start readout
- bus_w16(CONTROL_REG, 0x0);
- return OK;
-}
-
-
-// fifo routines
-
-u_int32_t fifoReset(void) {
- return -1;
-}
-
-
-u_int32_t setNBits(u_int32_t n) {
- return -1;
-}
-
-u_int32_t getNBits(){
- return -1;
-}
-
-
-u_int32_t fifoReadCounter(int fifonum){
- return -1;
-}
-
-u_int32_t fifoReadStatus()
-{
- // reads from the global status register
-
- return bus_r(STATUS_REG)&(SOME_FIFO_FULL_BIT | ALL_FIFO_EMPTY_BIT);
-}
-
-u_int32_t fifo_full(void)
-{
- // checks fifo empty flag returns 1 if fifo is empty
- // otherwise 0
- return bus_r(STATUS_REG)&SOME_FIFO_FULL_BIT;
-}
-
-
-u_int32_t* fifo_read_event()
-{
-
- int i=0;
-
-#ifdef VIRTUAL
- return NULL;
-#endif
-
-#ifdef VERBOSE
- printf("before looping\n");
-#endif
- volatile u_int32_t t = bus_r(LOOK_AT_ME_REG);
-
-#ifdef VERBOSE
- printf("lookatmereg=x%x\n",t);
-#endif
-/*
- while ((t&0x1)==0)
- {
- t = bus_r(LOOK_AT_ME_REG);
- if (!runBusy()){
- return NULL;
- }
- }
-*/
-
- while((t&0x1)==0) {
-#ifdef VERYVERBOSE
- printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
-#endif
-#ifdef VERYVERBOSE
- printf("look at me reg:%08x\n",bus_r(LOOK_AT_ME_REG));
-#endif
- if (runBusy()==0) {
- t = bus_r(LOOK_AT_ME_REG);
-#ifdef VERYVERBOSE
- printf("status should be idle!..look at me reg:%08x\n",bus_r(LOOK_AT_ME_REG));
-#endif
- if ((t&0x1)==0) {
-#ifdef VERBOSE
- printf("no frame found - exiting\n");
- printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
-#endif
-#ifdef VERYVERBOSE
- printf("returning null\n");
-#endif
- printf("lookatmereg=x%x\n",t);
- return NULL;
- } else {
-#ifdef VERBOSE
- printf("no frame found %x status %x\n", bus_r(LOOK_AT_ME_REG),runState());
-#endif
- break;
- }
- }
- t = bus_r(LOOK_AT_ME_REG);
-#ifdef VERYVERBOSE
- printf("before starting while loop again: look at me reg:%08x\n\n",bus_r(LOOK_AT_ME_REG));
-#endif
- if (i%1000==0)
- printf("%08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
- i++;
- }
-#ifdef VERYVERBOSE
- printf(" out of while loop!\n");
-#endif
-#ifdef VERYVERBOSE
- printf("before readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
-#endif
-
- dma_memcpy(now_ptr,values ,dataBytes);
-
-
-#ifdef VERYVERBOSE
- int a;
- for (a=0;a<8; a=a+2)
- printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
- for (a=2554;a<2560; a=a+2)
- printf("\n%d %d: x%04x x%04x ",a+1,a,*(now_ptr+a+1),*(now_ptr+a) );
- printf("********\n");
- //memcpy(now_ptr, values, dataBytes);
-#endif
-#ifdef VERYVERBOSE
- printf("Copying to ptr %08x %d\n",(unsigned int)(now_ptr), dataBytes);
- printf("after readout %08x %08x\n", runState(), bus_r(LOOK_AT_ME_REG));
-#endif
-
- if (storeInRAM>0) {
- now_ptr+=dataBytes;
- }
- printf("lookatmereg=x%x\n",t);
- return ram_values;
-}
-
-
-
-u_int32_t* decode_data(int *datain)
-{
- u_int32_t *dataout;
- // const char one=1;
- const int bytesize=8;
- char *ptr=(char*)datain;
- //int nbits=dynamicRange;
- int ipos=0, ichan=0;;
- //int nch, boff=0;
- int ibyte;//, ibit;
- char iptr;
-
-#ifdef VERBOSE
- printf("Decoding data for DR %d\n",dynamicRange);
-#endif
- dataout=malloc(nChans*nChips*nModX*4);
- ichan=0;
- switch (dynamicRange) {
- case 1:
- for (ibyte=0; ibyte>(ipos))&0x1;
- ichan++;
- }
- }
- break;
- case 4:
- for (ibyte=0; ibyte>(ipos*4))&0xf;
- ichan++;
- }
- }
- break;
- case 8:
- for (ichan=0; ichan0)
- storeInRAM=1;
- else
- storeInRAM=0;
- return allocateRAM();
-}
-
-
-int allocateRAM() {
- size_t size;
- u_int32_t nt, nf;
- nt=setTrains(-1);
- nf=setFrames(-1);
- if (nt==0) nt=1;
- if (nf==0) nf=1;
- // ret=clearRAM();
- if (storeInRAM) {
- size=dataBytes*nf*nt;
- if (size>(23-i))&0x1)<> 8);
- // printf("%i: %i %i\n",a, frame[a],v);
- avg[a] += ((double)frame[a])/(double)frames;
- //if(frame[a] == 8191)
- // printf("ch %i: %u\n",a,frame[a]);
- }
- // printf("********\n");
- numberFrames++;
- }
-
- //no more data or no data
- else {
- if(getFrames()>-2) {
- dataret=FAIL;
- printf("no data and run stopped: %d frames left\n",(int)(getFrames()+2));
-
- } else {
- dataret=FINISHED;
- printf("acquisition successfully finished\n");
-
- }
- printf("dataret %d\n",dataret);
- }
- }
-
-
-
- double nf = (double)numberFrames;
- for(i =0; i < 1280; i++){
- adc = i / 256;
- adcCh = (i - adc * 256) / 32;
- Ch = i - adc * 256 - adcCh * 32;
- adc--;
- double v2 = avg[i];
- avg[i] = avg[i]/ ((double)numberFrames/(double)frames);
- unsigned short v = (unsigned short)avg[i];
- printf("setting avg for channel %i(%i,%i,%i): %i (double= %f (%f))\t", i,adc,adcCh,Ch, v,avg[i],v2);
- v=i*100;
- ram_w16(DARK_IMAGE_REG,adc,adcCh,Ch,v-4096);
- if(ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch) != v-4096){
- printf("value is wrong (%i,%i,%i): %i \n",adc,adcCh,Ch, ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch));
- }
- }
-
- /*for(adc = 1; adc < 5; adc++){
- for(adcCh = 0; adcCh < 8; adcCh++){
- for(Ch=0 ; Ch < 32; Ch++){
- int channel = (adc+1) * 32 * 8 + adcCh * 32 + Ch;
- double v2 = avg[channel];
- avg[channel] = avg[channel]/ ((double)numberFrames/(double)frames);
- unsigned short v = (unsigned short)avg[channel];
- printf("setting avg for channel %i: %i (double= %f (%f))\t", channel, v,avg[channel],v2);
- ram_w16(DARK_IMAGE_REG,adc,adcCh,Ch,v-4096);
- if(ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch) != v-4096){
- printf("value is wrong (%i,%i,%i): %i \n",adc,adcCh,Ch, ram_r16(DARK_IMAGE_REG,adc,adcCh,Ch));
- }
- }
- }
- }*/
-
-
-
- printf("frames: %i\n",numberFrames);
- printf("corrected avg by: %f\n",(double)numberFrames/(double)frames);
-
- printf("restoring previous condition\n");
- setFrames(framesBefore);
- setPeriod(periodBefore);
-
- printf("---------------------------\n");
- return 0;
-}
-
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.h
deleted file mode 100755
index 48918e428..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/firmware_funcs.h
+++ /dev/null
@@ -1,179 +0,0 @@
-#ifndef FIRMWARE_FUNCS_H
-#define FIRMWARE_FUNCS_H
-
-
-#include "sls_detector_defs.h"
-
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-//#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-int mapCSP0(void);
-
-u_int16_t bus_r16(u_int32_t offset);
-u_int16_t bus_w16(u_int32_t offset, u_int16_t data);//aldos function
-u_int32_t bus_w(u_int32_t offset, u_int32_t data);
-u_int32_t bus_r(u_int32_t offset);
-
-int setPhaseShiftOnce();
-int phaseStep(int st);
-int cleanFifo();
-int setDAQRegister();
-
-u_int32_t putout(char *s, int modnum);
-u_int32_t readin(int modnum);
-u_int32_t setClockDivider(int d);
-u_int32_t getClockDivider();
-u_int32_t setSetLength(int d);
-u_int32_t getSetLength();
-u_int32_t setWaitStates(int d);
-u_int32_t getWaitStates();
-u_int32_t setTotClockDivider(int d);
-u_int32_t getTotClockDivider();
-u_int32_t setTotDutyCycle(int d);
-u_int32_t getTotDutyCycle();
-u_int32_t setOversampling(int d);
-
-u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
-int getExtSignal(int d);
-
-u_int32_t setFPGASignal(int d, enum externalSignalFlag mode);
-int getFPGASignal(int d);
-
-int setTiming(int t);
-
-
-int setConfigurationRegister(int d);
-int setToT(int d);
-int setContinousReadOut(int d);
-int startReceiver(int d);
-
-int setDACRegister(int idac, int val, int imod);
-
-int getTemperature(int tempSensor,int imod);
-int initHighVoltage(int val,int imod);
-int initConfGain(int isettings,int val,int imod);
-
-int setADC(int adc);
-int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int ival, int udpport);
-int getAdcConfigured();
-
-
-u_int64_t getDetectorNumber();
-u_int32_t getFirmwareVersion();
-int testFifos(void);
-u_int32_t testFpga(void);
-u_int32_t testRAM(void);
-int testBus(void);
-int setDigitalTestBit(int ival);
-
-int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
-int64_t get64BitReg(int aLSB, int aMSB);
-
-int64_t setFrames(int64_t value);
-int64_t getFrames();
-
-int64_t setExposureTime(int64_t value);
-int64_t getExposureTime();
-
-int64_t setGates(int64_t value);
-int64_t getGates();
-
-int64_t setDelay(int64_t value);
-int64_t getDelay();
-
-int64_t setPeriod(int64_t value);
-int64_t getPeriod();
-
-int64_t setTrains(int64_t value);
-int64_t getTrains();
-
-int64_t setProbes(int64_t value);
-int64_t getProbes();
-
-int64_t getProgress();
-int64_t setProgress();
-
-int64_t getActualTime();
-int64_t getMeasurementTime();
-
-
-u_int32_t runBusy(void);
-u_int32_t runState(void);
-u_int32_t dataPresent(void);
-
-
-int startStateMachine();
-int stopStateMachine();
-int startReadOut();
-u_int32_t fifoReset(void);
-u_int32_t fifoReadCounter(int fifonum);
-u_int32_t fifoReadStatus();
-
-
-u_int32_t fifo_full(void);
-
-
-
-u_int32_t* fifo_read_event();
-u_int32_t* decode_data(int* datain);
-//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
-int setDynamicRange(int dr);
-int getDynamicRange();
-int getNModBoard();
-int setNMod(int n);
-int setStoreInRAM(int b);
-int allocateRAM();
-int clearRAM();
-
-
-int setMaster(int f);
-int setSynchronization(int s);
-
-int loadImage(int index, short int ImageVals[]);
-int readCounterBlock(int startACQ, short int CounterVals[]);
-int resetCounterBlock(int startACQ);
-
-int calibratePedestal(int frames);
-
-
-
-/*
-
-u_int32_t setNBits(u_int32_t);
-u_int32_t getNBits();
-*/
-
-/*
-//move to mcb_funcs?
-
-int readOutChan(int *val);
-u_int32_t getModuleNumber(int modnum);
-int testShiftIn(int imod);
-int testShiftOut(int imod);
-int testShiftStSel(int imod);
-int testDataInOut(int num, int imod);
-int testExtPulse(int imod);
-int testExtPulseMux(int imod, int ow);
-int testDataInOutMux(int imod, int ow, int num);
-int testOutMux(int imod);
-int testFpgaMux(int imod);
-int calibration_sensor(int num, int *values, int *dacs) ;
-int calibration_chip(int num, int *values, int *dacs);
-*/
-
-
-#endif
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfo.txt b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfo.txt
deleted file mode 100644
index 4ff46c75b..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfo.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-Path: slsDetectorsPackage/slsDetectorSoftware/moenchDetectorServer
-URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
-Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
-Repsitory UUID: e6bd874a88493557fc5127d4a1686832299aaf06
-Revision: 85
-Branch: 3.0.1
-Last Changed Author: Dhanya_Thattil
-Last Changed Rev: 3346
-Last Changed Date: 2018-02-07 09:14:36.000000002 +0100 ./server_funcs.c
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h
deleted file mode 100644
index 96f110d39..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoench.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
-#define GITREPUUID "e6bd874a88493557fc5127d4a1686832299aaf06"
-#define GITAUTH "Dhanya_Thattil"
-#define GITREV 0x3346
-#define GITDATE 0x20180207
-#define GITBRANCH "3.0.1"
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h
deleted file mode 100644
index dfd9bb246..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/gitInfoMoenchTmp.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#define GITURL ""
-#define GITREPUUID ""
-#define GITAUTH ""
-#define GITREV ""
-#define GITDATE ""
-#define GITBRANCH ""
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.c
deleted file mode 100755
index 1db487a31..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/mcb_funcs.c
+++ /dev/null
@@ -1,2528 +0,0 @@
-#ifdef MCB_FUNCS
-
-#include
-#include
-#include
-#include
-#include
-#include "registers_m.h"
-
-#ifndef PICASSOD
-#include "server_defs.h"
-#else
-#include "picasso_defs.h"
-#endif
-#include "firmware_funcs.h"
-#include "mcb_funcs.h"
-
-
-/* global variables */
-#undef DEBUG
-#undef DEBUGOUT
-
-extern int nModX;
-//extern int dataBytes;
-extern int dynamicRange;
-const int nChans=NCHAN;
-const int nChips=NCHIP;
-const int nDacs=NDAC;
-const int nAdcs=NADC;
-enum detectorSettings thisSettings;
-
-int sChan, sChip, sMod, sDac, sAdc;
-const int allSelected=-2;
-const int noneSelected=-1;
-
-
-sls_detector_module *detectorModules=NULL;
-int *detectorChips=NULL;
-int *detectorChans=NULL;
-int *detectorDacs=NULL;
-int *detectorAdcs=NULL;
-//int numberOfProbes;
-
-ROI rois[MAX_ROIS];
-int nROI=0;
-
-
-int initDetector() {
-
- int imod;
- // sls_detector_module *myModule;
- int n=getNModBoard();
- nModX=n;
-
-#ifdef VERBOSE
- printf("Board is for %d modules\n",n);
-#endif
- detectorModules=malloc(n*sizeof(sls_detector_module));
- detectorChips=malloc(n*NCHIP*sizeof(int));
- detectorChans=malloc(n*NCHIP*NCHAN*sizeof(int));
- detectorDacs=malloc(n*NDAC*sizeof(int));
- detectorAdcs=malloc(n*NADC*sizeof(int));
-#ifdef VERBOSE
- printf("modules from 0x%x to 0x%x\n",(unsigned int)(detectorModules), (unsigned int)(detectorModules+n));
- printf("chips from 0x%x to 0x%x\n",(unsigned int)(detectorChips), (unsigned int)(detectorChips+n*NCHIP));
- printf("chans from 0x%x to 0x%x\n",(unsigned int)(detectorChans), (unsigned int)(detectorChans+n*NCHIP*NCHAN));
- printf("dacs from 0x%x to 0x%x\n",(unsigned int)(detectorDacs), (unsigned int)(detectorDacs+n*NDAC));
- printf("adcs from 0x%x to 0x%x\n",(unsigned int)(detectorAdcs), (unsigned int)(detectorAdcs+n*NADC));
-#endif
- for (imod=0; imoddacs=detectorDacs+imod*NDAC;
- (detectorModules+imod)->adcs=detectorAdcs+imod*NADC;
- (detectorModules+imod)->chipregs=detectorChips+imod*NCHIP;
- (detectorModules+imod)->chanregs=detectorChans+imod*NCHIP*NCHAN;
- (detectorModules+imod)->ndac=NDAC;
- (detectorModules+imod)->nadc=NADC;
- (detectorModules+imod)->nchip=NCHIP;
- (detectorModules+imod)->nchan=NCHIP*NCHAN;
- (detectorModules+imod)->module=imod;
- (detectorModules+imod)->gain=0;
- (detectorModules+imod)->offset=0;
- (detectorModules+imod)->reg=0;
- /* initialize registers, dacs, retrieve sn, adc values etc */
- }
- thisSettings=UNINITIALIZED;
- sChan=noneSelected;
- sChip=noneSelected;
- sMod=noneSelected;
- sDac=noneSelected;
- sAdc=noneSelected;
-
- /*
- setCSregister(ALLMOD); //commented out by dhanya
- setSSregister(ALLMOD);
- counterClear(ALLMOD);
- clearSSregister(ALLMOD);
- putout("0000000000000000",ALLMOD);
- */
-
- /* initialize dynamic range etc. */
- /* dynamicRange=getDynamicRange(); //always 16 not required commented out
- nModX=setNMod(-1);*/
-
- //dataBytes=nModX*NCHIP*NCHAN*4;
- // dynamicRange=32;
- // initChip(0, 0,ALLMOD);
- //nModX=n;
- //
- allocateRAM();
-
-
- return OK;
-}
-
-
-
-
-int copyChannel(sls_detector_channel *destChan, sls_detector_channel *srcChan) {
- destChan->chan=srcChan->chan;
- destChan->chip=srcChan->chip;
- destChan->module=srcChan->module;
- destChan->reg=srcChan->reg;
- return OK;
-}
-
-
-int copyChip(sls_detector_chip *destChip, sls_detector_chip *srcChip) {
-
- int ichan;
- int ret=OK;
- if ((srcChip->nchan)>(destChip->nchan)) {
- printf("Number of channels of source is larger than number of channels of destination\n");
- return FAIL;
- }
-
- destChip->nchan=srcChip->nchan;
- destChip->reg=srcChip->reg;
- destChip->chip=srcChip->chip;
- destChip->module=srcChip->module;
- for (ichan=0; ichan<(srcChip->nchan); ichan++) {
- *((destChip->chanregs)+ichan)=*((srcChip->chanregs)+ichan);
- }
- return ret;
-}
-
-
-int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod) {
-
- int ichip, idac, ichan, iadc;
-
- int ret=OK;
-
-#ifdef VERBOSE
- printf("Copying module %x to module %x\n",(unsigned int)(srcMod),(unsigned int)(destMod));
-#endif
-
- if (srcMod->module>=0) {
-#ifdef VERBOSE
- printf("Copying module number %d to module number %d\n",srcMod->module,destMod->module);
-#endif
- destMod->module=srcMod->module;
- }
- if (srcMod->serialnumber>=0){
-/* #ifdef VERBOSE */
-/* printf("Copying module serial number %x to module serial number %x\n",srcMod->serialnumber,destMod->serialnumber); */
-/* #endif */
- destMod->serialnumber=srcMod->serialnumber;
- }
- if ((srcMod->nchip)>(destMod->nchip)) {
- printf("Number of chip of source is larger than number of chips of destination\n");
- return FAIL;
- }
- if ((srcMod->nchan)>(destMod->nchan)) {
- printf("Number of channels of source is larger than number of channels of destination\n");
- return FAIL;
- }
- if ((srcMod->ndac)>(destMod->ndac)) {
- printf("Number of dacs of source is larger than number of dacs of destination\n");
- return FAIL;
- }
- if ((srcMod->nadc)>(destMod->nadc)) {
- printf("Number of dacs of source is larger than number of dacs of destination\n");
- return FAIL;
- }
-
-#ifdef VERBOSE
- printf("DACs: src %d, dest %d\n",srcMod->ndac,destMod->ndac);
- printf("ADCs: src %d, dest %d\n",srcMod->nadc,destMod->nadc);
- printf("Chips: src %d, dest %d\n",srcMod->nchip,destMod->nchip);
- printf("Chans: src %d, dest %d\n",srcMod->nchan,destMod->nchan);
-
-#endif
-
-
-
- destMod->ndac=srcMod->ndac;
- destMod->nadc=srcMod->nadc;
- destMod->nchip=srcMod->nchip;
- destMod->nchan=srcMod->nchan;
- if (srcMod->reg>=0)
- destMod->reg=srcMod->reg;
-#ifdef VERBOSE
- printf("Copying register %x (%x)\n",destMod->reg,srcMod->reg );
-#endif
- if (srcMod->gain>=0)
- destMod->gain=srcMod->gain;
- if (srcMod->offset>=0)
- destMod->offset=srcMod->offset;
-
- // printf("copying gain and offset %f %f to %f %f\n",srcMod->gain,srcMod->offset,destMod->gain,destMod->offset);
-
- for (ichip=0; ichip<(srcMod->nchip); ichip++) {
- if (*((srcMod->chipregs)+ichip)>=0)
- *((destMod->chipregs)+ichip)=*((srcMod->chipregs)+ichip);
- }
- for (ichan=0; ichan<(srcMod->nchan); ichan++) {
- if (*((srcMod->chanregs)+ichan)>=0)
- *((destMod->chanregs)+ichan)=*((srcMod->chanregs)+ichan);
- }
- for (idac=0; idac<(srcMod->ndac); idac++) {
- if (*((srcMod->dacs)+idac)>=0)
- *((destMod->dacs)+idac)=*((srcMod->dacs)+idac);
- }
- for (iadc=0; iadc<(srcMod->nadc); iadc++) {
- if (*((srcMod->adcs)+iadc)>=0)
- *((destMod->adcs)+iadc)=*((srcMod->adcs)+iadc);
- }
- return ret;
-}
-
-
-
-/* Register commands */
-
-
-int clearDACSregister(int imod) {
-
- putout("1111111111111111",imod);//reset
- putout("1111111111111110",imod);//cs down
-
- /* commented out by dhanya
- putout("0000000001000000",imod);
- putout("0000000101000000",imod);
- putout("0000000101000000",imod);
- putout("0000000001000000",imod);
- */
-#ifdef DEBUG
- fprintf(stdout, "Clearing DAC shiftregister\n");
-#endif
- // sDac=0;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return OK;
-}
-
-int nextDAC(int imod) {
-
- putout("1111111111111011",imod);//cs up
- putout("1111111111111001",imod);//clk down
- putout("1111111111111111",imod);//reset
-
- /*commented out by dhanya
- putout("0000000001000000",imod);
- putout("0000000001001000",imod);
- putout("0000000001000000",imod);
- */
-#ifdef DEBUG
- fprintf(stdout, "Next DAC\n");
-#endif
- // sDac++;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return OK;
-}
-
-
-int clearCSregister(int imod) {
-
- putout("0000000001000000",imod);
- putout("0000100001000000",imod);
- putout("0000100001000000",imod);
- putout("0000000001000000",imod);
-#ifdef DEBUG
- fprintf(stdout, "Clearing CS shiftregister\n");
-#endif
- /*
- sChan=noneSelected;
- sMod=noneSelected;
- sDac=noneSelected;
- sAdc=noneSelected;
- */
- sChip=noneSelected;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- //putout("0000000000000000",imod);
- return 0;
-}
-
-int setCSregister(int imod){
-
- putout("0000000001000000",imod);
- putout("0001000001000000",imod);
- putout("0001000001000000",imod);
- putout("0000000001000000",imod);
-#ifdef DEBUG
- fprintf(stdout, "Setting CS shiftregister\n");
-#endif
- putout("0000000000000000",imod);
- sChip=allSelected;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return 0;
-}
-
-int nextChip(int imod){
-
- putout("0000000001000000",imod);
- putout("0010000001000000",imod);
- putout("0000000001000000",imod);
-#ifdef DEBUG
- fprintf(stdout, "Next Chip\n");
-#endif
- sChip++;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return 0;
-}
-
-int firstChip(int imod){
-
- putout("0100000001000000",imod);
- putout("0110000001000000",imod);
- putout("0100000001000000",imod);
-#ifdef DEBUG
- fprintf(stdout, "First Chip\n");
-#endif
- sChip=0;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return 0;
-}
-
-int clearSSregister(int imod){
- int i;
- putout("0000011000000000",imod);
- for (i=0; i<10; i++)
- putout("0000111000000000",imod);
- putout("0000011000000000",imod);
-#ifdef DEBUG
- fprintf(stdout,"Clearing SS shiftregister\n");
-#endif
- putout("0000000000000000",imod);
- sChan=noneSelected;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return 0;
-}
-
-int setSSregister(int imod){
- int i;
- putout("0000011000000000",imod);
- for (i=0; i<10; i++)
- putout("0001011000000000",imod);
- putout("0000011000000000",imod);
-#ifdef DEBUG
- fprintf(stdout,"Setting SS shiftregister\n");
-#endif
- putout("0000000000000000",imod);
- sChan=allSelected;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return 0;
-}
-
-int nextStrip(int imod){
- putout("0000011000000000",imod);
- putout("0010011000000000",imod);
- putout("0000011000000000",imod);
-#ifdef DEBUG
- fprintf(stdout,"|-");
-#endif
- sChan++;
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
- return 0;
-}
-
-int selChannel(const int strip,int imod) {
- int istrip;
- clearSSregister(imod);
- nextStrip(imod);
- for (istrip=0; istrip=0 && imod=0)
- initDAC(ind,val, imod);
-
- if (imod>=0 && imodndac)
- return (detectorDacs[ind+imod*NDAC]);
- }
- return FAIL;
- */
- return setDACRegister(ind, -1, imod);
-}
-
-
-int initDAC(int dac_addr, int value, int imod) {
-// int i;
-#ifdef VERBOSE
- printf("Programming dac %d with value %d\n", dac_addr, value);
-#endif
- clearDACSregister(imod);
- program_one_dac(dac_addr,value,imod);
- nextDAC(imod);
- clearDACSregister(imod);
-
- return 0;
-}
-
-int getTemperatureByModule(int tempSensor, int imod)
-{
- int im;
- //for the particular module
- if (imod>=0 && imod=0 && imod=0 && imod=0) {
-#ifdef VERBOSE
- fprintf(stdout, "voltage %d\n", *(v+iaddr));
-#endif
- program_one_dac(iaddr, *(v+iaddr),imod);
- }
- nextDAC(imod);
- }
-
-
- clearDACSregister(imod);
-
- return 0;
-
-}
-
-
-
-
-int setSettings(int i, int imod) {
-#ifdef VERBOSE
- if(i==-1)
- printf("\nReading settings of detector...\n");
- else
- printf("\ninside set settings wit settings=%d...\n",i);
-#endif
- int confgain[] = CONF_GAIN;
- int isett=-2,retval;
-
- //reading settings
- if(i==GET_SETTINGS){
- retval=initConfGainByModule(i,i,imod);
- if(retval==i)
- isett=UNDEFINED;
- }
- //writing settings
- else{
- retval=initConfGainByModule(i,confgain[i],imod);
- if(retval!=i)
- isett=UNDEFINED;
- }
- //if error while read/writing
- if(isett==UNDEFINED)
- printf("Error:Weird Value read back from the Gain/Settings Reg\n");
- else{
- //validating the settings read back
- if((retval>=HIGHGAIN)&&(retval<=VERYHIGHGAIN))
- isett=retval;
- else{
- isett=UNDEFINED;
- printf("Error:Wrong Settings Read out:%d\n",retval);
- }
- }
- thisSettings=isett;
-#ifdef VERBOSE
- printf("detector settings are %d\n",thisSettings);
-#endif
- return thisSettings;
-}
-
-
-
-
-/* Initialization*/
-
-int initChannelbyNumber(sls_detector_channel myChan) {
- int reg=myChan.reg;
- int ft=reg & TRIM_DR;
- int cae=(reg>>(NTRIMBITS))&1;
- int ae=(reg>>(NTRIMBITS+1))&1;
- int coe=(reg>>(NTRIMBITS+2))&1;
- int ocoe=(reg>>(NTRIMBITS+3))&1;
- int counts=(reg>>(NTRIMBITS+4));
-#ifdef VERBOSE
- printf("Initializing channel %d chip %d module %d reg %x\n",myChan.chan,myChan.chip,myChan.module, reg);
- printf("trim %d, cae %d, ae %d, coe %d, ocoe %d, counts %d\n",ft, cae, ae, coe, ocoe, counts);
-#endif
-
- if (myChan.chip<0)
- setCSregister(myChan.module);
- else
- selChip(myChan.chip,myChan.module);
-
- if (myChan.chan<0)
- setSSregister(myChan.module);
- else
- selChannel(myChan.chan,myChan.module);
-
- initChannel(ft,cae,ae, coe, ocoe, counts,myChan.module);
-
- setDynamicRange(dynamicRange);
-
- setCSregister(ALLMOD);
- clearSSregister(ALLMOD);
- putout("0000000000000000",ALLMOD);
-
- return myChan.reg;
-
-}
-
-int getChannelbyNumber(sls_detector_channel* myChan) {
- int imod, ichip, ichan;
- imod=myChan->module;
- ichip=myChan->chip;
- ichan=myChan->chan;
-
- if (detectorChans) {
- if (imod=0) {
- if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
- myChan->reg=detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan];
- return OK;
- }
- }
- return FAIL;
-
-}
-
-int getTrimbit(int imod, int ichip, int ichan) {
- if (detectorChans) {
- if (imod=0)
- if (ichip<(detectorModules+imod)->nchip && ichan<(detectorModules+imod)->nchan/(detectorModules+imod)->nchip)
- return (detectorChans[imod*NCHAN*NCHIP+ichip*NCHAN+ichan] & TRIM_DR);
- }
-
- return -1;
-}
-
-int initChannel(int ft,int cae, int ae, int coe, int ocoe, int counts, int imod){
-
- int ibit, bit, i, im, ichip, ichan;
- int chanmi, chanma, chipmi, chipma, modmi, modma;
-
-
-
- sMod=imod;
- // printf("initializing module %d\n",sMod);
- if (imod==ALLMOD) {
- sMod=allSelected;
-
- // printf("initializing all modules\n");
- }
-
- if (sChan==allSelected) {
- // printf("initializing all channels ft=%d coe=%d\n",ft,coe);
- chanmi=0;
- chanma=NCHAN;
- } else if (sChan==noneSelected || sChan>NCHAN || sChan<0) {
- // printf("initializing no channels ft=%d coe=%d\n",ft,coe);
- chanmi=0;
- chanma=-1;
- } else {
- // printf("initializing channel %d ft=%d coe=%d\n",sChan, ft,coe);
- chanmi=sChan;
- chanma=sChan+1;
- }
-
- if (sChip==allSelected) {
- // printf("initializing all chips\n");
- chipmi=0;
- chipma=NCHIP;
- } else if (sChip==noneSelected || sChip>NCHIP || sChip<0) {
- // printf("initializing no chips\n");
- chipmi=0;
- chipma=-1;
- } else {
- // printf("initializing chip %d\n",sChip);
- chipmi=sChip;
- chipma=sChip+1;
- }
-
-
- if (sMod==allSelected) {
- modmi=0;
- modma=nModX;//getNModBoard();
- } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
- modmi=0;
- modma=-1;
- return 1;
- } else {
- modmi=sMod;
- modma=sMod+1;
- }
-
- if (detectorChans) {
- for (im=modmi; im63 || ft<0) {
- fprintf(stdout,"Fine Threshold is %d while should be between 0 and 63!",ft);
- return 1;
- }
- /*cal_enable*/
- if (cae) {
- putout("0100000000000000",imod);
- putout("0110000000000000",imod);
- } else {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- }
- /*n_an_enable*/
- if (ae) {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- } else {
- putout("0100000000000000",imod);
- putout("0110000000000000",imod);
- putout("0100000000000000",imod);
- }
- /*trb5*/
- ibit=5;
- bit=ft & (1<>1;
- int nchan, ichan;
- int ft, cae, ae, coe, ocoe, counts, chanreg;
-
-
-
- nchan=myChip.nchan;
- if (ichip<0)
- setCSregister(imod);
- else
- selChip(ichip,imod);
-
- clearSSregister(imod);
- for (ichan=0; ichan>(NTRIMBITS+1))&1;
- ae=(chanreg>>(NTRIMBITS+2))&1;
- coe=((chanreg)>>(NTRIMBITS+3))&1;
- ocoe=((chanreg)>>(NTRIMBITS+4))&1;
- counts=((chanreg)>>(NTRIMBITS+5));
- nextStrip(imod);
- initChannel(ft,cae,ae, coe, ocoe, counts,imod);
- }
- initChip(obe,ow,imod);
- return myChip.reg;
-
-}
-
-int getChipbyNumber(sls_detector_chip* myChip){
- int imod, ichip;
- imod=myChip->module;
- ichip=myChip->chip;
-
- if (detectorChips) {
- if (imodnchip) {
- myChip->reg=detectorChips[ichip+imod*NCHIP];
- myChip->nchan=NCHAN;
- myChip->chanregs=detectorChans+imod*NCHAN*NCHIP+ichip*NCHIP;
- return OK;
- }
- }
- return FAIL;
-
-}
-
-
-
-int initChip(int obe, int ow,int imod){
- int i;
- int im, ichip;
- int chipmi, chipma, modmi, modma;
- /* switch (ow) {
- case 0:;
- case 1:
- setDynamicRange(32);
- break;
- case 2:
- setDynamicRange(16);
- break;
- case 3:
- setDynamicRange(8);
- break;
- case 4:
- setDynamicRange(4);
- break;
- case 5:
- setDynamicRange(1);
- break;
- default:
- setDynamicRange(32);
- break;
- }
- */
-
-#ifdef DEBUGOUT
- printf("Initializing chip\n");
-#endif
- putout("0000000000000000",imod);
-#ifdef DEBUGOUT
- printf("Output mode= %d\n", ow);
-#endif
-
- /* clearing shift in register */
- for (i=0; i<10; i++)
- putout("0000100000000000",imod);
- putout("0000000000000000",imod);
-
- if (ow>0) {
- putout("0100000000000000",imod);
- putout("0110000000000000",imod);
- putout("0100000000000000",imod);
- for (i=0; i<(OUTMUX_OFFSET-1); i++) {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- }
- if (ow>1) {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- }
- if (ow>2) {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- }
- if (ow>3) {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- }
- if (ow>4) {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- }
- }
-#ifdef DEBUGOUT
- printf("Output buffer enable= %d\n", obe);
-#endif
- if (obe) {
- putout("0100000000000000",imod);
- putout("0110000000000000",imod);
- putout("0100000000000000",imod);
- } else {
- putout("0000000000000000",imod);
- putout("0010000000000000",imod);
- putout("0000000000000000",imod);
- }
- /*}*/
- putout("0000000000000000",imod);
-
-
-
-
-
- sMod=imod;
- if (imod==ALLMOD)
- sMod=allSelected;
-
-
- if (sChip==allSelected) {
- chipmi=0;
- chipma=NCHIP;
- } else if (sChip==noneSelected || sChip>NCHIP || sChip<0) {
- chipmi=0;
- chipma=-1;
- } else {
- chipmi=sChip;
- chipma=sChip+1;
- }
-
-
- if (sMod==allSelected) {
- modmi=0;
- modma=nModX;//getNModBoard();
- } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
- modmi=0;
- modma=-1;
- } else {
- modmi=sMod;
- modma=sMod+1;
- }
-
- if (detectorChips) {
- for (im=modmi; imNCHIP || sChip<0) {
- chipmi=0;
- chipma=-1;
- } else {
- chipmi=sChip;
- chipma=sChip+1;
- }
-
-
- if (sMod==allSelected) {
- modmi=0;
- modma=nModX;//getNModBoard();
- } else if (sMod==noneSelected || sMod>nModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
- modmi=0;
- modma=-1;
- } else {
- modmi=sMod;
- modma=sMod+1;
- }
-
- if (detectorChips) {
- for (im=modmi; imnModX || sMod<0) {//(sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
- modmi=0;
- modma=-1;
- } else {
- modmi=sMod;
- modma=sMod+1;
- }
-
- if (detectorModules) {
- for (im=modmi; imreg)=cm;
-#ifdef VERBOSE
- printf("imod=%d reg=%d (%x)\n",im,(detectorModules+im)->reg,(unsigned int)((detectorModules+im)));
-#endif
- }
- }
- return 0;
-}
-
-int initModulebyNumber(sls_detector_module myMod) {
-
- printf("\ninside initmoduleynumber..\n");
-
- int nchip,nchan;//int ichip, nchip, ichan, nchan;
- int im, modmi,modma;
- // int ft, cae, ae, coe, ocoe, counts, chanreg;
- int imod;
- // int obe;
- // int ow;
- int v[NDAC];
-
-
- nchip=myMod.nchip;
- nchan=(myMod.nchan)/nchip;
-
- imod=myMod.module;
- sMod=imod;
-
- if (sMod==ALLMOD)
- sMod=allSelected;
-
- if (sMod==allSelected) {
- modmi=0;
- modma=nModX;//getNModBoard();
- } else if (sMod==noneSelected || sMod>nModX || sMod<0) {// (sMod==noneSelected || sMod>getNModBoard() || sMod<0) {
- modmi=0;
- modma=-1;
- } else {
- modmi=sMod;
- modma=sMod+1;
- }
-
-
- /*
- for (idac=0; idacmodule;
-#ifdef VERBOSE
- printf("Getting module %d\n",imod);
-#endif
- if (detectorModules) {
- copyModule(myMod,detectorModules+imod);
- ;
- } else
- return FAIL;
-
- return OK;
-}
-
-/* To chips */
-int clearCounter(int imod){
- int i;
-#ifdef DEBUG
- printf("Clearing counter with contclear\n");
-#endif
- putout("0000000000000000",imod);
- for (i=0; i<10; i++)
- putout("0000000000010000",imod);
- putout("0000000000000000",imod);
-
- return 0;
-}
-
-int clearOutReg(int imod){
- int i;
-#ifdef DEBUG
- printf("Clearing output register\n");
-#endif
- putout("0000010000000000",imod);
- for (i=0; i<10; i++)
- putout("0000110000000000",imod);
- putout("0000010000000000",imod);
- return 0;
-}
-int setOutReg(int imod){
- int i;
-#ifdef DEBUG
- printf("Setting output register\n");
-#endif
- putout("0000010000000000",imod);
- for (i=0; i<10; i++)
- putout("0001010000000000",imod);
- putout("0000010000000000",imod);
- return 0;
-}
-
-
-int extPulse(int ncal, int imod) {
- int ical;
-#ifdef DEBUG
- printf("Giving a clock pulse to the counter\n");
-#endif
- for (ical=0; ical0 && i%2==0) {
- printf("Shift in: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2);
- result++;
- }
- if (i%2>0 && (val & 1<0 && (dum & (1<0) {
- printf("Shift out: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, (dum &1<0 && i%2==0) {
- printf("Shift stsel: module %d chip %i bit %d read %d instead of %d \n",k,j,i,val & 1<< j, i%2);
- result++;
- }
- if (i%2>0 && (val & 1<> 1;
-
-
- putout("0000000000000000",ALLMOD);
- putout("0010000000000000",ALLMOD); //change mux setting
- putout("0000000000000000",ALLMOD);
- }
-
- printf("Test FpgaMux module %d : %d errors\n", imod,result);
- if (result)
- return 1;
- else
- return 0;
-}
-
-
-
-
-
-
-
-
-
-int calibration_sensor(int num, int *v, int *dacs) {
- int ich, ichip, imod;
- int val[10];
-
-
- printf("calibrating sensor...");
- for (imod=0; imod=0){
-
- if(n==0)
- adc=-1;
- else{
- //if its for 1 adc or general
- if ((arg[0].xmin==0) && (arg[0].xmax==GOTTHARDNCHIP*GOTTHARDNCHAN))
- adc=-1;
- else{
- //adc = mid value/numchans also for only 1 roi
- adc = ((((arg[0].xmax)+(arg[0].xmin))/2)/(GOTTHARDNCHAN*NCHIPS_PER_ADC));
- if((adc>=0) && (adc<=4));
- else {
- printf("warning:adc value greater than 5. deleting roi\n");
- adc=-1;
- }
- }
- }
-
-
- //set rois for just 1 adc - take only 1st roi
- if(adc!=-1){
- rois[0].xmin=adc*(GOTTHARDNCHAN*NCHIPS_PER_ADC);
- rois[0].xmax=(adc+1)*(GOTTHARDNCHAN*NCHIPS_PER_ADC)-1;
- rois[0].ymin=-1;
- rois[0].ymax=-1;
- nROI = 1;
- }else
- nROI = 0;
-
- if((arg[0].xmin!=rois[0].xmin)||(arg[0].xmax!=rois[0].xmax)||(arg[0].ymin!=rois[0].ymin)||(arg[0].ymax!=rois[0].ymax))
- *ret=FAIL;
- if(n!=nROI)
- *ret=FAIL;
-
- //set adc of interest
- setADC(adc);
- }*/
-
-//#ifdef VERBOSE
- printf("Rois:\n");
- for( i=0;i
-
-
-extern int sockfd;
-extern int phase_shift;
-
-
-
-void error(char *msg)
-{
- perror(msg);
-}
-
-int main(int argc, char *argv[])
-{
- int portno, b;
- char cmd[500];
- int retval=OK;
- int sd, fd;
- int iarg;
-
-
- for(iarg=1; iarg 2) && (!strcasecmp(argv[2],"stopserver"))){
- portno = DEFAULT_PORTNO+1;
- if ( sscanf(argv[1],"%d",&portno) ==0) {
- printf("could not open stop server: unknown port\n");
- return 1;
- }
- b=0;
- printf("\n\nStop Server\nOpening stop server on port %d\n",portno);
- }
-
- //control server
- else {
- portno = DEFAULT_PORTNO;
- sprintf(cmd,"%s %d stopserver &",argv[0],DEFAULT_PORTNO+1);
- printf("\n\nControl Server\nOpening control server on port %d\n",portno );
-
- //printf("\n\ncmd:%s\n",cmd);
- system(cmd);
- b=1;
- }
-
-
- init_detector(b);
-
-
- sd=bindSocket(portno);
- sockfd=sd;
- if (getServerError(sd)) {
- printf("server error!\n");
- return -1;
- }
-
- /* assign function table */
- function_table();
-#ifdef VERBOSE
- printf("function table assigned \n");
-#endif
-
-
- /* waits for connection */
- while(retval!=GOODBYE) {
-#ifdef VERBOSE
- printf("\n");
-#endif
-#ifdef VERY_VERBOSE
- printf("Waiting for client call\n");
-#endif
- fd=acceptConnection(sockfd);
-#ifdef VERY_VERBOSE
- printf("Conenction accepted\n");
-#endif
- retval=decode_function(fd);
-#ifdef VERY_VERBOSE
- printf("function executed\n");
-#endif
- closeConnection(fd);
-#ifdef VERY_VERBOSE
- printf("connection closed\n");
-#endif
- }
-
- exitServer(sockfd);
- printf("Goodbye!\n");
-
- return 0;
-}
-
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_defs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_defs.h
deleted file mode 100755
index e86b3107f..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_defs.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef SERVER_DEFS_H
-#define SERVER_DEFS_H
-
-#include "sls_detector_defs.h"
-
-#include
-
-
-// Hardware definitions
-
-#define NCHAN (160*160)
-#define NCHIP 1
-#define NMAXMODX 1
-#define NMAXMODY 1
-#define NMAXMOD (NMAXMODX*NMAXMODY)
-#define NDAC 8
-#define NADC 1
-
-
-
-
-
-
-#define NCHANS (NCHAN*NCHIP*NMAXMOD)
-#define NDACS (NDAC*NMAXMOD)
-
-#define NTRIMBITS 6
-#define NCOUNTBITS 24
-
-#define NCHIPS_PER_ADC 2
-
-//#define TRIM_DR ((2**NTRIMBITS)-1)
-//#define COUNT_DR ((2**NCOUNTBITS)-1)
-#define TRIM_DR (((int)pow(2,NTRIMBITS))-1)
-#define COUNT_DR (((int)pow(2,NCOUNTBITS))-1)
-
-
-#define ALLMOD 0xffff
-#define ALLFIFO 0xffff
-
-#define GOTTHARD_ADCSYNC_VAL 0x32214
-#define ADCSYNC_VAL 0x02111
-#define TOKEN_RESTART_DELAY 0x88000000
-#define TOKEN_RESTART_DELAY_ROI 0x1b000000
-#define TOKEN_TIMING_REV1 0x1f16
-#define TOKEN_TIMING_REV2 0x1f0f
-
-#define DEFAULT_PHASE_SHIFT 0 // 120
-#define DEFAULT_IP_PACKETSIZE 0x0522
-#define DEFAULT_UDP_PACKETSIZE 0x050E
-#define ADC1_IP_PACKETSIZE 256*2+14+20
-#define ADC1_UDP_PACKETSIZE 256*2+4+8+2
-
-#ifdef VIRTUAL
-#define DEBUGOUT
-#endif
-
-#define CLK_FREQ 65.6E+6
-
-
-#endif
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.c
deleted file mode 100755
index 33f776c33..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.c
+++ /dev/null
@@ -1,3083 +0,0 @@
-#include "sls_detector_defs.h"
-#include "server_funcs.h"
-#ifndef PICASSOD
-#include "server_defs.h"
-#else
-#include "picasso_defs.h"
-#endif
-#include "firmware_funcs.h"
-#include "mcb_funcs.h"
-#include "trimming_funcs.h"
-#include "registers_m.h"
-#include "gitInfoMoench.h"
-
-#define FIFO_DATA_REG_OFF 0x50<<11
-#define CONTROL_REG 0x24<<11
-// Global variables
-
-
-int (*flist[256])(int);
-
-
-//defined in the detector specific file
-#ifdef MYTHEND
-const enum detectorType myDetectorType=MYTHEN;
-#elif GOTTHARDD
-const enum detectorType myDetectorType=GOTTHARD;
-#elif EIGERD
-const enum detectorType myDetectorType=EIGER;
-#elif PICASSOD
-const enum detectorType myDetectorType=PICASSO;
-#elif MOENCHD
-const enum detectorType myDetectorType=MOENCH;
-#else
-const enum detectorType myDetectorType=GENERIC;
-#endif
-
-
-extern int nModX;
-extern int nModY;
-extern int dataBytes;
-extern int dynamicRange;
-extern int storeInRAM;
-
-extern int lockStatus;
-extern char lastClientIP[INET_ADDRSTRLEN];
-extern char thisClientIP[INET_ADDRSTRLEN];
-extern int differentClients;
-
-/* global variables for optimized readout */
-extern unsigned int *ram_values;
-char *dataretval=NULL;
-int nframes, iframes, dataret;
-char mess[MAX_STR_LENGTH];
-
-int digitalTestBit = 0;
-
-
-int init_detector(int b) {
- if (mapCSP0()==FAIL) { printf("Could not map memory\n");
- exit(1);
- }
-
- //
-
- bus_w16(CONTROL_REG, SYNC_RESET);
- bus_w16(CONTROL_REG, 0x0);
-
- //confirm if it is really moench
- if(((bus_r(PCB_REV_REG) & DETECTOR_TYPE_MASK)>>DETECTOR_TYPE_OFFSET) != MOENCH_MODULE ){
- printf("This is a Gotthard detector. Exiting Moench Server.\n\n");
- exit(-1);
- }
-
- if (b) {
- printf("***This is a MOENCH detector with %d chips per module***\n",NCHIP);
-
-#ifdef MCB_FUNCS
- printf("\nBoard Revision:0x%x\n",(bus_r(PCB_REV_REG)&BOARD_REVISION_MASK));
- initDetector();
- printf("Initializing Detector\n");
- bus_w16(CONTROL_REG, SYNC_RESET); // reset registers
-#endif
-
-
- testFpga();
- testRAM();
- printf("ADC_SYNC_REG:%x\n",bus_r(ADC_SYNC_REG));
- //moench specific
-
- // setPhaseShiftOnce(); //firmware.h
-
-
- prepareADC(); // server_funcs
- setADC(-1); //already does setdaqreg and clean fifo
- setSettings(GET_SETTINGS,-1);
-
- //Initialization
- setFrames(1);
- setTrains(1);
- setExposureTime(1e3);
- setPeriod(1E6);
- setDelay(0);
- setGates(0);
-
- setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
- setMaster(GET_MASTER);
- setSynchronization(GET_SYNCHRONIZATION_MODE);
- startReceiver(0); //firmware
- }
- strcpy(mess,"dummy message");
- strcpy(lastClientIP,"none");
- strcpy(thisClientIP,"none1");
- lockStatus=0;
- return OK;
-}
-
-
-int decode_function(int file_des) {
- int fnum,n;
- int retval=FAIL;
-#ifdef VERBOSE
- printf( "receive data\n");
-#endif
- n = receiveDataOnly(file_des,&fnum,sizeof(fnum));
- if (n <= 0) {
-#ifdef VERBOSE
- printf("ERROR reading from socket %d, %d %d\n", n, fnum, file_des);
-#endif
- return FAIL;
- }
-#ifdef VERBOSE
- else
- printf("size of data received %d\n",n);
-#endif
-
-#ifdef VERBOSE
- printf( "calling function fnum = %d %x\n",fnum,(unsigned int)(flist[fnum]));
-#endif
- if (fnum<0 || fnum>255)
- fnum=255;
- retval=(*flist[fnum])(file_des);
- if (retval==FAIL)
- printf( "Error executing the function = %d \n",fnum);
- return retval;
-}
-
-
-int function_table() {
- int i;
- for (i=0;i<256;i++){
- flist[i]=&M_nofunc;
- }
- flist[F_EXIT_SERVER]=&exit_server;
- flist[F_EXEC_COMMAND]=&exec_command;
- flist[F_GET_DETECTOR_TYPE]=&get_detector_type;
- flist[F_SET_NUMBER_OF_MODULES]=&set_number_of_modules;
- flist[F_GET_MAX_NUMBER_OF_MODULES]=&get_max_number_of_modules;
- flist[F_SET_EXTERNAL_SIGNAL_FLAG]=&set_external_signal_flag;
- flist[F_SET_EXTERNAL_COMMUNICATION_MODE]=&set_external_communication_mode;
- flist[F_GET_ID]=&get_id;
- flist[F_DIGITAL_TEST]=&digital_test;
- flist[F_WRITE_REGISTER]=&write_register;
- flist[F_READ_REGISTER]=&read_register;
- flist[F_SET_DAC]=&set_dac;
- flist[F_GET_ADC]=&get_adc;
- flist[F_SET_CHANNEL]=&set_channel;
- flist[F_SET_CHIP]=&set_chip;
- flist[F_SET_MODULE]=&set_module;
- flist[F_GET_CHANNEL]=&get_channel;
- flist[F_GET_CHIP]=&get_chip;
- flist[F_GET_MODULE]=&get_module;
- flist[F_GET_THRESHOLD_ENERGY]=&get_threshold_energy;
- flist[F_SET_THRESHOLD_ENERGY]=&set_threshold_energy;
- flist[F_SET_SETTINGS]=&set_settings;
- flist[F_START_ACQUISITION]=&start_acquisition;
- flist[F_STOP_ACQUISITION]=&stop_acquisition;
- flist[F_START_READOUT]=&start_readout;
- flist[F_GET_RUN_STATUS]=&get_run_status;
- flist[F_READ_FRAME]=&read_frame;
- flist[F_READ_ALL]=&read_all;
- flist[F_START_AND_READ_ALL]=&start_and_read_all;
- flist[F_SET_TIMER]=&set_timer;
- flist[F_GET_TIME_LEFT]=&get_time_left;
- flist[F_SET_DYNAMIC_RANGE]=&set_dynamic_range;
- flist[F_SET_ROI]=&set_roi;
- flist[F_SET_SPEED]=&set_speed;
- flist[F_SET_READOUT_FLAGS]=&set_readout_flags;
- flist[F_EXECUTE_TRIMMING]=&execute_trimming;
- flist[F_LOCK_SERVER]=&lock_server;
- flist[F_SET_PORT]=&set_port;
- flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip;
- flist[F_UPDATE_CLIENT]=&update_client;
- flist[F_CONFIGURE_MAC]=&configure_mac;
- flist[F_LOAD_IMAGE]=&load_image;
- flist[F_SET_MASTER]=&set_master;
- flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
- flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
- flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
- flist[F_START_RECEIVER]=&start_receiver;
- flist[F_STOP_RECEIVER]=&stop_receiver;
- flist[F_CALIBRATE_PEDESTAL]=&calibrate_pedestal;
- return OK;
-}
-
-
-int M_nofunc(int file_des){
-
- int ret=FAIL;
- sprintf(mess,"Unrecognized Function\n");
- printf(mess);
-
- sendDataOnly(file_des,&ret,sizeof(ret));
- sendDataOnly(file_des,mess,sizeof(mess));
- return GOODBYE;
-}
-
-
-int exit_server(int file_des) {
- int retval=FAIL;
- sendDataOnly(file_des,&retval,sizeof(retval));
- printf("closing server.");
- sprintf(mess,"closing server");
- sendDataOnly(file_des,mess,sizeof(mess));
- return GOODBYE;
-}
-
-int exec_command(int file_des) {
- char cmd[MAX_STR_LENGTH];
- char answer[MAX_STR_LENGTH];
- int retval=OK;
- int sysret=0;
- int n=0;
-
- /* receive arguments */
- n = receiveDataOnly(file_des,cmd,MAX_STR_LENGTH);
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- retval=FAIL;
- }
-
- /* execute action if the arguments correctly arrived*/
- if (retval==OK) {
-#ifdef VERBOSE
- printf("executing command %s\n", cmd);
-#endif
- if (lockStatus==0 || differentClients==0)
- sysret=system(cmd);
-
- //should be replaced by popen
- if (sysret==0) {
- sprintf(answer,"Succeeded\n");
- if (lockStatus==1 && differentClients==1)
- sprintf(answer,"Detector locked by %s\n", lastClientIP);
- } else {
- sprintf(answer,"Failed\n");
- retval=FAIL;
- }
- } else {
- sprintf(answer,"Could not receive the command\n");
- }
-
- /* send answer */
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- n = sendDataOnly(file_des,answer,MAX_STR_LENGTH);
- if (n < 0) {
- sprintf(mess,"Error writing to socket");
- retval=FAIL;
- }
-
-
- /*return ok/fail*/
- return retval;
-
-}
-
-
-
-int get_detector_type(int file_des) {
- int n=0;
- enum detectorType ret;
- int retval=OK;
-
- sprintf(mess,"Can't return detector type\n");
-
-
- /* receive arguments */
- /* execute action */
- ret=myDetectorType;
-
-#ifdef VERBOSE
- printf("Returning detector type %d\n",ret);
-#endif
-
- /* send answer */
- /* send OK/failed */
- if (differentClients==1)
- retval=FORCE_UPDATE;
-
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- if (retval!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&ret,sizeof(ret));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
- /*return ok/fail*/
- return retval;
-
-
-}
-
-
-int set_number_of_modules(int file_des) {
- int n;
- int arg[2], ret=0;
- int retval=OK;
- int dim, nm;
-
- sprintf(mess,"Can't set number of modules\n");
-
- /* receive arguments */
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket %d", n);
- retval=GOODBYE;
- }
- if (retval==OK) {
- dim=arg[0];
- nm=arg[1];
-
- /* execute action */
-#ifdef VERBOSE
- printf("Setting the number of modules in dimension %d to %d\n",dim,nm );
-#endif
-
- //if (nm!=GET_FLAG) {
- if (dim!=X && nm!=GET_FLAG) {
- retval=FAIL;
- sprintf(mess,"Can't change module number in dimension %d\n",dim);
- } else {
- if (lockStatus==1 && differentClients==1 && nm!=GET_FLAG) {
- sprintf(mess,"Detector locked by %s\n", lastClientIP);
- retval=FAIL;
- } else {
- ret=setNMod(nm);
- if (nModX==nm || nm==GET_FLAG) {
- retval=OK;
- if (differentClients==1)
- retval=FORCE_UPDATE;
- } else
- retval=FAIL;
- }
- }
- }
- /*} else {
- if (dim==Y) {
- ret=nModY;
- } else if (dim==X) {
- ret=setNMod(-1);
- }
- }
- */
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- if (retval!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&ret,sizeof(ret));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
- /*return ok/fail*/
- return retval;
-
-}
-
-
-int get_max_number_of_modules(int file_des) {
- int n;
- int ret;
- int retval=OK;
- enum dimension arg;
-
- sprintf(mess,"Can't get max number of modules\n");
- /* receive arguments */
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- retval=FAIL;
- }
- /* execute action */
-#ifdef VERBOSE
- printf("Getting the max number of modules in dimension %d \n",arg);
-#endif
-
-
- switch (arg) {
- case X:
- ret=getNModBoard();
- break;
- case Y:
- ret=NMAXMODY;
- break;
- default:
- ret=FAIL;
- retval=FAIL;
- break;
- }
-#ifdef VERBOSE
- printf("Max number of module in dimension %d is %d\n",arg,ret );
-#endif
-
-
-
- if (differentClients==1 && retval==OK) {
- retval=FORCE_UPDATE;
- }
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- if (retval!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&ret,sizeof(ret));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
-
-
- /*return ok/fail*/
- return retval;
-}
-
-
-//index 0 is in gate
-//index 1 is in trigger
-//index 2 is out gate
-//index 3 is out trigger
-
-int set_external_signal_flag(int file_des) {
- int n;
- int arg[2];
- int ret=OK;
- int signalindex;
- enum externalSignalFlag flag, retval;
-
- sprintf(mess,"Can't set external signal flag\n");
-
- /* receive arguments */
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
- retval=SIGNAL_OFF;
- if (ret==OK) {
- signalindex=arg[0];
- flag=arg[1];
- /* execute action */
- switch (flag) {
- case GET_EXTERNAL_SIGNAL_FLAG:
- retval=getExtSignal(signalindex);
- break;
-
- default:
- if (differentClients==0 || lockStatus==0) {
- retval=setExtSignal(signalindex,flag);
- } else {
- if (lockStatus!=0) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n", lastClientIP);
- }
- }
-
- }
-
-#ifdef VERBOSE
- printf("Setting external signal %d to flag %d\n",signalindex,flag );
- printf("Set to flag %d\n",retval);
-#endif
-
- } else {
- ret=FAIL;
- }
-
- if (ret==OK && differentClients!=0)
- ret=FORCE_UPDATE;
-
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
-
- /*return ok/fail*/
- return ret;
-
-}
-
-
-int set_external_communication_mode(int file_des) {
- int n;
- enum externalCommunicationMode arg, ret=GET_EXTERNAL_COMMUNICATION_MODE;
- int retval=OK;
-
- sprintf(mess,"Can't set external communication mode\n");
-
-
- /* receive arguments */
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- retval=FAIL;
- }
- /*
- enum externalCommunicationMode{
- GET_EXTERNAL_COMMUNICATION_MODE,
- AUTO,
- TRIGGER_EXPOSURE_SERIES,
- TRIGGER_EXPOSURE_BURST,
- TRIGGER_READOUT,
- TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE,
- GATE_FIX_NUMBER,
- GATE_FIX_DURATION,
- GATE_WITH_START_TRIGGER,
- GATE_COINCIDENCE_WITH_INTERNAL_ENABLE
- };
- */
- if (retval==OK) {
- /* execute action */
-
- ret=setTiming(arg);
-
- /* switch(arg) { */
- /* default: */
- /* sprintf(mess,"The meaning of single signals should be set\n"); */
- /* retval=FAIL; */
- /* } */
-
-
-#ifdef VERBOSE
- printf("Setting external communication mode to %d\n", arg);
-#endif
- } else
- ret=FAIL;
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- if (retval!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&ret,sizeof(ret));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
- /*return ok/fail*/
- return retval;
-}
-
-
-
-int get_id(int file_des) {
- // sends back 64 bits!
- int64_t retval=-1;
- int ret=OK;
- int n=0;
- enum idMode arg;
-
- sprintf(mess,"Can't return id\n");
-
- /* receive arguments */
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
-#ifdef VERBOSE
- printf("Getting id %d\n", arg);
-#endif
-
- switch (arg) {
- case DETECTOR_SERIAL_NUMBER:
- retval=getDetectorNumber();
- break;
- case DETECTOR_FIRMWARE_VERSION:
- retval = (getFirmwareVersion() & 0xFFFFFF);
- break;
- case DETECTOR_SOFTWARE_VERSION:
- retval = (GITDATE & 0xFFFFFF);
- break;
- default:
- printf("Required unknown id %d \n", arg);
- ret=FAIL;
- retval=FAIL;
- break;
- }
-
-#ifdef VERBOSE
- printf("Id is %llx\n", retval);
-#endif
-
- if (differentClients==1)
- ret=FORCE_UPDATE;
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
- /*return ok/fail*/
- return ret;
-
-}
-
-int digital_test(int file_des) {
-
- int retval;
- int ret=OK;
- int imod=-1;
- int n=0;
- int ibit=0;
- int ow;
- int ival;
- enum digitalTestMode arg;
-
- sprintf(mess,"Can't send digital test\n");
-
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
-#ifdef VERBOSE
- printf("Digital test mode %d\n",arg );
-#endif
-
- switch (arg) {
- case CHIP_TEST:
- n = receiveDataOnly(file_des,&imod,sizeof(imod));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- retval=FAIL;
- }
-#ifdef VERBOSE
- printf("of module %d\n", imod);
-#endif
- retval=0;
-#ifdef MCB_FUNCS
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- break;
- }
- if (imod >= nModX) {
- ret=FAIL;
- sprintf(mess,"Module %d disabled\n",imod);
- break;
- }
- if (testShiftIn(imod)) retval|=(1<<(ibit));
- ibit++;
- if (testShiftOut(imod)) retval|=(1<<(ibit));
- ibit++;
- if (testShiftStSel(imod)) retval|=(1<<(ibit));
- ibit++;
- //if ( testDataInOut(0x123456, imod)) retval|=(1<<(ibit++));
- //if ( testExtPulse(imod)) retval|=(1<<(ibit++));
- // for (ow=0; ow<6; ow++)
- // ow=1;
- //#ifndef PICASSOD
- for (ow=0; ow<5; ow++) {
- //#endif
- if (testDataInOutMux(imod, ow, 0x789abc)) retval|=(1<=getNModBoard())
- ret=FAIL;
- if (imod<0)
- imod=ALLMOD;
-
-#ifdef MCB_FUNCS
- switch (ind) {
- case V_DAC0 :
- idac=VDAC0;
- break;
- case V_DAC1:
- idac=VDAC1;
- break;
- case V_DAC2:
- idac=VDAC2;
- break;
- case V_DAC3:
- idac=VDAC3;
- break;
- case V_DAC4:
- idac=VDAC4;
- break;
- case V_DAC5:
- idac=VDAC5;
- break;
- case V_DAC6:
- idac=VDAC6;
- break;
- case V_DAC7:
- idac=VDAC7;
- break;
- case HV_POT:
- idac=HIGH_VOLTAGE;
- break;
-
- default:
- printf("Unknown DAC index %d for Moench\n",ind);
- sprintf(mess,"Unknown DAC index %d for Moench\n",ind);
- ret=FAIL;
- break;
- }
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else{
- if(idac==HIGH_VOLTAGE){
- retval[0]=initHighVoltageByModule(val,imod);
- ret=FAIL;
- if(retval[0]==-2)
- strcpy(mess,"Invalid Voltage.Valid values are 0,90,110,120,150,180,200");
- else if(retval[0]==-3)
- strcpy(mess,"Weird value read back or it has not been set yet\n");
- else
- ret=OK;
- }else{
- initDACbyIndexDACU(idac,val,imod,mV,retval);
- ret=FAIL;
- if(mV)
- temp = retval[1];
- else
- temp = retval[0];
- if ((abs(temp-val)<=3) || val==-1) {
- ret=OK;
-#ifdef VERBOSE
- printf("DAC set to %d in dac units and %d mV\n", retval[0],retval[1]);
-#endif
- }
- }
- }
- }
-
-#endif
-
-
- if(ret==FAIL)
- printf("Setting dac %d of module %d: wrote %d but read %d\n", ind, imod, val, temp);
- else{
- if (differentClients)
- ret=FORCE_UPDATE;
- }
-
-
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
-
- /*return ok/fail*/
- return ret;
-
-}
-
-
-
-int get_adc(int file_des) {
- //default: mod 0
- int retval;
- int ret=OK;
- int arg[2];
- enum dacIndex ind;
- int imod;
- int n;
- int idac=0;
-
- sprintf(mess,"Can't read ADC\n");
-
-
- n = receiveDataOnly(file_des,arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
- ind=arg[0];
- imod=arg[1];
-
-#ifdef VERBOSE
- printf("Getting ADC %d of module %d\n", ind, imod);
-#endif
-
- if (imod>=getNModBoard() || imod<0)
- ret=FAIL;
-
-#ifdef MCB_FUNCS
- switch (ind) {
- case TEMPERATURE_FPGA:
- idac=TEMP_FPGA;
- break;
- case TEMPERATURE_ADC:
- idac=TEMP_ADC;
- break;
- default:
- printf("Unknown DAC index %d\n",ind);
- sprintf(mess,"Unknown DAC index %d\n",ind);
- ret=FAIL;
- break;
- }
-
- if (ret==OK)
- retval=getTemperatureByModule(idac,imod);
-#endif
-
-#ifdef VERBOSE
- printf("ADC is %d V\n", retval);
-#endif
- if (ret==FAIL) {
- printf("Getting adc %d of module %d failed\n", ind, imod);
- }
-
- if (differentClients)
- ret=FORCE_UPDATE;
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
- /*return ok/fail*/
- return ret;
-
-}
-
-int set_channel(int file_des) {
- int ret=OK;
- sls_detector_channel myChan;
- int retval;
- int n;
-
-
- sprintf(mess,"Can't set channel\n");
-
-#ifdef VERBOSE
- printf("Setting channel\n");
-#endif
- ret=receiveChannel(file_des, &myChan);
- if (ret>=0)
- ret=OK;
- else
- ret=FAIL;
-#ifdef VERBOSE
- printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg);
-#endif
-
- if (ret==OK) {
- if (myChan.module>=getNModBoard())
- ret=FAIL;
- if (myChan.chip>=NCHIP)
- ret=FAIL;
- if (myChan.chan>=NCHAN)
- ret=FAIL;
- if (myChan.module<0)
- myChan.module=ALLMOD;
- }
-
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
-#ifdef MCB_FUNCS
- retval=initChannelbyNumber(myChan);
-#endif
- }
- }
- /* Maybe this is done inside the initialization funcs */
- //copyChannel(detectorChans[myChan.module][myChan.chip]+(myChan.chan), &myChan);
-
-
-
- if (differentClients==1 && ret==OK)
- ret=FORCE_UPDATE;
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
-
- /*return ok/fail*/
- return ret;
-
-}
-
-
-
-
-int get_channel(int file_des) {
-
- int ret=OK;
- sls_detector_channel retval;
-
- int arg[3];
- int ichan, ichip, imod;
- int n;
-
- sprintf(mess,"Can't get channel\n");
-
-
-
- n = receiveDataOnly(file_des,arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
- ichan=arg[0];
- ichip=arg[1];
- imod=arg[2];
-
- if (ret==OK) {
- ret=FAIL;
- if (imod>=0 && imod=0 && ichip=0 && ichan=0)
- ret=OK;
- else
- ret=FAIL;
-#ifdef VERBOSE
- printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan);
-#endif
-
- if (ret==OK) {
- if (myChip.module>=getNModBoard())
- ret=FAIL;
- if (myChip.module<0)
- myChip.module=ALLMOD;
- if (myChip.chip>=NCHIP)
- ret=FAIL;
- }
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
-#ifdef MCB_FUNCS
- retval=initChipbyNumber(myChip);
-#endif
- }
- /* Maybe this is done inside the initialization funcs */
- //copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip);
-
- if (differentClients && ret==OK)
- ret=FORCE_UPDATE;
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
-
- return ret;
-}
-
-int get_chip(int file_des) {
-
-
- int ret=OK;
- sls_detector_chip retval;
- int arg[2];
- int ichip, imod;
- int n;
-
-
-
- n = receiveDataOnly(file_des,arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
- ichip=arg[0];
- imod=arg[1];
- if (ret==OK) {
- ret=FAIL;
- if (imod>=0 && imod=0 && ichip=0)
- ret=OK;
- else
- ret=FAIL;
-
-
-#ifdef VERBOSE
- printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset);
-#endif
-
- if (ret==OK) {
- if (myModule.module>=getNModBoard()) {
- ret=FAIL;
- printf("Module number is too large %d\n",myModule.module);
- }
- if (myModule.module<0)
- myModule.module=ALLMOD;
- }
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
-#ifdef MCB_FUNCS
- retval=initModulebyNumber(myModule);
-#endif
- }
- }
-
- if (differentClients==1 && ret==OK)
- ret=FORCE_UPDATE;
-
- /* Maybe this is done inside the initialization funcs */
- //copyChip(detectorChips[myChip.module]+(myChip.chip), &myChip);
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
- free(myChip);
- free(myChan);
- free(myDac);
- free(myAdc);
-
- // setDynamicRange(dr); always 16 commented out
-
-
- return ret;
-}
-
-
-
-
-int get_module(int file_des) {
-
-
- int ret=OK;
-
-
- int arg;
- int imod;
- int n;
-
-
-
- sls_detector_module myModule;
- int *myChip=malloc(NCHIP*sizeof(int));
- int *myChan=malloc(NCHIP*NCHAN*sizeof(int));
- int *myDac=malloc(NDAC*sizeof(int));/**dhanya*/
- int *myAdc=malloc(NADC*sizeof(int));/**dhanya*/
-
-
- if (myDac)
- myModule.dacs=myDac;
- else {
- sprintf(mess,"could not allocate dacs\n");
- ret=FAIL;
- }
- if (myAdc)
- myModule.adcs=myAdc;
- else {
- sprintf(mess,"could not allocate adcs\n");
- ret=FAIL;
- }
- if (myChip)
- myModule.chipregs=myChip;
- else {
- sprintf(mess,"could not allocate chips\n");
- ret=FAIL;
- }
- if (myChan)
- myModule.chanregs=myChan;
- else {
- sprintf(mess,"could not allocate chans\n");
- ret=FAIL;
- }
-
- myModule.ndac=NDAC;
- myModule.nchip=NCHIP;
- myModule.nchan=NCHAN*NCHIP;
- myModule.nadc=NADC;
-
-
-
-
-
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
- imod=arg;
-
- if (ret==OK) {
- ret=FAIL;
- if (imod>=0 && imod-2) {
- dataret=FAIL;
- sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
- printf("%s\n",mess);
- } else {
- dataret=FINISHED;
- sprintf(mess,"acquisition successfully finished\n");
- printf("%s\n",mess);
- }
-#ifdef VERYVERBOSE
- printf("%d %d %x %s\n",(int)(sizeof(mess)),(int)(strlen(mess)),(unsigned int)( mess),mess);
-#endif
- sendDataOnly(file_des,&dataret,sizeof(dataret));
- sendDataOnly(file_des,mess,sizeof(mess));
-#ifdef VERYVERBOSE
- printf("message sent %s\n",mess);
-#endif
- printf("dataret %d\n",dataret);
- return dataret;
- }
- } else {
- nframes=0;
- while(fifo_read_event()) {
- nframes++;
- }
- dataretval=(char*)ram_values;
- dataret=OK;
-#ifdef VERBOSE
- printf("sending data of %d frames\n",nframes);
-#endif
- for (iframes=0; iframes-2) {
- dataret=FAIL;
- sprintf(mess,"no data and run stopped: %d frames left\n",(int)(getFrames()+2));
- printf("%s\n",mess);
- } else {
- dataret=FINISHED;
- sprintf(mess,"acquisition successfully finished\n");
- printf("%s\n",mess);
- if (differentClients)
- dataret=FORCE_UPDATE;
- }
-#ifdef VERBOSE
- printf("Frames left %d\n",(int)(getFrames()));
-#endif
- sendDataOnly(file_des,&dataret,sizeof(dataret));
- sendDataOnly(file_des,mess,sizeof(mess));
- printf("dataret %d\n",dataret);
- return dataret;
- }
- printf("dataret %d\n",dataret);
- return dataret;
-}
-
-
-
-
-
-
-
-
-int read_all(int file_des) {
-
-while(read_frame(file_des)==OK) {
-
-#ifdef VERBOSE
- printf("frame read\n");
-#endif
- ;
- }
-#ifdef VERBOSE
- printf("Frames finished\n");
-#endif
- return OK;
-
-
-}
-
-int start_and_read_all(int file_des) {
- //int dataret=OK;
-#ifdef VERBOSE
- printf("Starting and reading all frames\n");
-#endif
-
- if (differentClients==1 && lockStatus==1) {
- dataret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- sendDataOnly(file_des,&dataret,sizeof(dataret));
- sendDataOnly(file_des,mess,sizeof(mess));
- return dataret;
-
- }
-
- startStateMachine();
-
- /* ret=startStateMachine();
- if (ret!=OK) {
- sprintf(mess,"could not start state machine\n");
- sendDataOnly(file_des,&ret,sizeof(ret));
- sendDataOnly(file_des,mess,sizeof(mess));
-
- #ifdef VERBOSE
- printf("could not start state machine\n");
-#endif
-} else {*/
- read_all(file_des);
-#ifdef VERBOSE
- printf("Frames finished\n");
-#endif
- //}
-
-
- return OK;
-
-
-}
-
-int set_timer(int file_des) {
- enum timerIndex ind;
- int64_t tns;
- int n;
- int64_t retval;
- int ret=OK;
-
-
- sprintf(mess,"can't set timer\n");
-
- n = receiveDataOnly(file_des,&ind,sizeof(ind));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- n = receiveDataOnly(file_des,&tns,sizeof(tns));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- if (ret!=OK) {
- printf(mess);
- }
-
-#ifdef VERBOSE
- printf("setting timer %d to %lld ns\n",ind,tns);
-#endif
- if (ret==OK) {
-
- if (differentClients==1 && lockStatus==1 && tns!=-1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
- switch(ind) {
- case FRAME_NUMBER:
- retval=setFrames(tns);
- break;
- case ACQUISITION_TIME:
- retval=setExposureTime(tns);
- break;
- case FRAME_PERIOD:
- retval=setPeriod(tns);
- break;
- case DELAY_AFTER_TRIGGER:
- retval=setDelay(tns);
- break;
- case GATES_NUMBER:
- retval=setGates(tns);
- break;
- case PROBES_NUMBER:
- sprintf(mess,"can't set timer for moench\n");
- ret=FAIL;
- break;
- case CYCLES_NUMBER:
- retval=setTrains(tns);
- break;
- default:
- ret=FAIL;
- sprintf(mess,"timer index unknown %d\n",ind);
- break;
- }
- }
- }
- if (ret!=OK) {
- printf(mess);
- if (differentClients)
- ret=FORCE_UPDATE;
- }
-
- if (ret!=OK) {
- printf(mess);
- printf("set timer failed\n");
- } else if (ind==FRAME_NUMBER) {
- ret=allocateRAM();
- if (ret!=OK)
- sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
- }
-
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else {
-#ifdef VERBOSE
- printf("returning ok %d\n",(int)(sizeof(retval)));
-#endif
-
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- }
-
- return ret;
-
-}
-
-
-
-
-
-
-
-
-int get_time_left(int file_des) {
-
- enum timerIndex ind;
- int n;
- int64_t retval;
- int ret=OK;
-
- sprintf(mess,"can't get timer\n");
- n = receiveDataOnly(file_des,&ind,sizeof(ind));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
-
- //#ifdef VERBOSE
-
- printf("getting time left on timer %d \n",ind);
- //#endif
-
- if (ret==OK) {
- switch(ind) {
- case FRAME_NUMBER:
- printf("getting frames \n");
- retval=getFrames();
- break;
- case ACQUISITION_TIME:
- retval=getExposureTime();
- break;
- case FRAME_PERIOD:
- retval=getPeriod();
- break;
- case DELAY_AFTER_TRIGGER:
- retval=getDelay();
- break;
- case GATES_NUMBER:
- retval=getGates();
- break;
- case PROBES_NUMBER:
- retval=getProbes();
- break;
- case CYCLES_NUMBER:
- retval=getTrains();
- break;
- case PROGRESS:
- retval=getProgress();
- break;
- case ACTUAL_TIME:
- retval=getActualTime();
- break;
- case MEASUREMENT_TIME:
- retval=getMeasurementTime();
- break;
- default:
- ret=FAIL;
- sprintf(mess,"timer index unknown %d\n",ind);
- break;
- }
- }
-
-
- if (ret!=OK) {
- printf("get time left failed\n");
- } else if (differentClients)
- ret=FORCE_UPDATE;
-
- //#ifdef VERBOSE
-
- printf("time left on timer %d is %lld\n",ind, retval);
- //#endif
-
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=OK) {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- } else {
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- }
-#ifdef VERBOSE
-
- printf("data sent\n");
-#endif
-
- return ret;
-
-
-}
-
-int set_dynamic_range(int file_des) {
-
-
-
- int dr;
- int n;
- int retval;
- int ret=OK;
-
-
- sprintf(mess,"can't set dynamic range\n");
-
-
- n = receiveDataOnly(file_des,&dr,sizeof(dr));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
-
- if (differentClients==1 && lockStatus==1 && dr>=0) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
- retval=setDynamicRange(dr);
- }
-
- //if (dr>=0 && retval!=dr) ret=FAIL;
- if (ret!=OK) {
- sprintf(mess,"set dynamic range failed\n");
- } else {
- ret=allocateRAM();
- if (ret!=OK)
- sprintf(mess,"Could not allocate RAM for the dynamic range selected\n");
- else if (differentClients)
- ret=FORCE_UPDATE;
- }
-
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else {
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- }
- return ret;
-}
-
-int set_roi(int file_des) {
-
- int i;
- int ret=OK;
- int nroi=-1;
- int n=0;
- int retvalsize=0;
- ROI arg[MAX_ROIS];
- ROI* retval=0;
-
- strcpy(mess,"Could not set/get roi\n");
-
-
- n = receiveDataOnly(file_des,&nroi,sizeof(nroi));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- if(nroi!=-1){
- n = receiveDataOnly(file_des,arg,nroi*sizeof(ROI));
- if (n != (nroi*sizeof(ROI))) {
- sprintf(mess,"Received wrong number of bytes for ROI\n");
- ret=FAIL;
- }
-//#ifdef VERBOSE
- /*
- printf("Setting ROI to:");
- for( i=0;i=0) {
- if (differentClients==1 && lockStatus==1 && val>=0) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
- switch (arg) {
- case CLOCK_DIVIDER:
- retval=setClockDivider(val);
- break;
-
- case PHASE_SHIFT:
- retval=phaseStep(val);
- break;
-
- case OVERSAMPLING:
- retval=setOversampling(val);
- break;
-
- default:
- ret=FAIL;
- sprintf(mess,"Unknown speed parameter %d",arg);
- }
- }
- }
-
-
- switch (arg) {
- case CLOCK_DIVIDER:
- retval=getClockDivider();
- break;
-
- case PHASE_SHIFT:
- retval=phaseStep(-1);
- break;
-
- case OVERSAMPLING:
- retval=setOversampling(-1);
- break;
-
- default:
- ret=FAIL;
- sprintf(mess,"Unknown speed parameter %d",arg);
- }
- }
-
-
-
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else {
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- }
- return ret;
-}
-
-
-
-int set_readout_flags(int file_des) {
-
- enum readOutFlags arg;
- int n;
- int ret=FAIL;
-
-
- receiveDataOnly(file_des,&arg,sizeof(arg));
-
- sprintf(mess,"can't set readout flags for moench\n");
-
- sendDataOnly(file_des,&ret,sizeof(ret));
- sendDataOnly(file_des,mess,sizeof(mess));
-
- return ret;
-}
-
-
-
-
-
-int execute_trimming(int file_des) {
-
- int arg[3];
- int ret=FAIL;
- enum trimMode mode;
-
- sprintf(mess,"can't set execute trimming for moench\n");
-
- receiveDataOnly(file_des,&mode,sizeof(mode));
- receiveDataOnly(file_des,arg,sizeof(arg));
-
-
- sendDataOnly(file_des,&ret,sizeof(ret));
- sendDataOnly(file_des,mess,sizeof(mess));
-
- return ret;
-}
-
-
-int lock_server(int file_des) {
-
-
- int n;
- int ret=OK;
-
- int lock;
- n = receiveDataOnly(file_des,&lock,sizeof(lock));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- printf("Error reading from socket (lock)\n");
- ret=FAIL;
- }
- if (lock>=0) {
- if (lockStatus==0 || strcmp(lastClientIP,thisClientIP)==0 || strcmp(lastClientIP,"none")==0)
- lockStatus=lock;
- else {
- ret=FAIL;
- sprintf(mess,"Server already locked by %s\n", lastClientIP);
- }
- }
- if (differentClients && ret==OK)
- ret=FORCE_UPDATE;
-
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else
- n = sendDataOnly(file_des,&lockStatus,sizeof(lockStatus));
-
- return ret;
-
-}
-
-int set_port(int file_des) {
- int n;
- int ret=OK;
- int sd=-1;
-
- enum portType p_type; /** data? control? stop? Unused! */
- int p_number; /** new port number */
-
- n = receiveDataOnly(file_des,&p_type,sizeof(p_type));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- printf("Error reading from socket (ptype)\n");
- ret=FAIL;
- }
-
- n = receiveDataOnly(file_des,&p_number,sizeof(p_number));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- printf("Error reading from socket (pnum)\n");
- ret=FAIL;
- }
- if (differentClients==1 && lockStatus==1 ) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
- if (p_number<1024) {
- sprintf(mess,"Too low port number %d\n", p_number);
- printf("\n");
- ret=FAIL;
- }
-
- printf("set port %d to %d\n",p_type, p_number);
-
- sd=bindSocket(p_number);
- }
- if (sd>=0) {
- ret=OK;
- if (differentClients )
- ret=FORCE_UPDATE;
- } else {
- ret=FAIL;
- sprintf(mess,"Could not bind port %d\n", p_number);
- printf("Could not bind port %d\n", p_number);
- if (sd==-10) {
- sprintf(mess,"Port %d already set\n", p_number);
- printf("Port %d already set\n", p_number);
-
- }
- }
-
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else {
- n = sendDataOnly(file_des,&p_number,sizeof(p_number));
- closeConnection(file_des);
- exitServer(sockfd);
- sockfd=sd;
-
- }
-
- return ret;
-
-}
-
-int get_last_client_ip(int file_des) {
- int ret=OK;
- int n;
- if (differentClients )
- ret=FORCE_UPDATE;
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP));
-
- return ret;
-
-}
-
-
-int send_update(int file_des) {
-
- int ret=OK;
- enum detectorSettings t;
- int n;//int thr, n;
- //int it;
- int64_t retval, tns=-1;
- n = sendDataOnly(file_des,lastClientIP,sizeof(lastClientIP));
- n = sendDataOnly(file_des,&nModX,sizeof(nModX));
- n = sendDataOnly(file_des,&nModY,sizeof(nModY));
- n = sendDataOnly(file_des,&dynamicRange,sizeof(dynamicRange));
- n = sendDataOnly(file_des,&dataBytes,sizeof(dataBytes));
- t=setSettings(GET_SETTINGS,-1);
- n = sendDataOnly(file_des,&t,sizeof(t));
-/* thr=getThresholdEnergy();
- n = sendDataOnly(file_des,&thr,sizeof(thr));*/
- retval=setFrames(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));
- retval=setExposureTime(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));
- retval=setPeriod(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));
- retval=setDelay(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));
- retval=setGates(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));
-/* retval=setProbes(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));*/
- retval=setTrains(tns);
- n = sendDataOnly(file_des,&retval,sizeof(int64_t));
-
- if (lockStatus==0) {
- strcpy(lastClientIP,thisClientIP);
- }
-
- return ret;
-
-
-}
-int update_client(int file_des) {
-
- int ret=OK;
-
- sendDataOnly(file_des,&ret,sizeof(ret));
- return send_update(file_des);
-
-
-
-}
-
-
-int configure_mac(int file_des) {
-
- int ret=OK;
- char arg[6][50];
- int n;
-
- int imod=0;//should be in future sent from client as -1, arg[2]
- int ipad;
- long long int imacadd;
- long long int idetectormacadd;
- int udpport;
- int detipad;
- int retval=-100;
-
- sprintf(mess,"Can't configure MAC\n");
-
-
- n = receiveDataOnly(file_des,arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- sscanf(arg[0], "%x", &ipad);
- sscanf(arg[1], "%llx", &imacadd);
- sscanf(arg[2], "%x", &udpport);
- sscanf(arg[3], "%llx", &idetectormacadd);
- sscanf(arg[4], "%x", &detipad);
-//arg[5] is for eiger
-#ifdef VERBOSE
- int i;
- printf("\ndigital_test_bit in server %d\t",digitalTestBit);
- printf("\nipadd %x\t",ipad);
- printf("destination ip is %d.%d.%d.%d = 0x%x \n",(ipad>>24)&0xff,(ipad>>16)&0xff,(ipad>>8)&0xff,(ipad)&0xff,ipad);
- printf("macad:%llx\n",imacadd);
- for (i=0;i<6;i++)
- printf("mac adress %d is 0x%x \n",6-i,(unsigned int)(((imacadd>>(8*i))&0xFF)));
- printf("udp port:0x%x\n",udpport);
- printf("detector macad:%llx\n",idetectormacadd);
- for (i=0;i<6;i++)
- printf("detector mac adress %d is 0x%x \n",6-i,(unsigned int)(((idetectormacadd>>(8*i))&0xFF)));
- printf("detipad %x\n",detipad);
- printf("\n");
-#endif
-
-
-
- if (imod>=getNModBoard())
- ret=FAIL;
- if (imod<0)
- imod=ALLMOD;
-
- //#ifdef VERBOSE
- printf("Configuring MAC of module %d at port %x\n", imod, udpport);
- //#endif
-#ifdef MCB_FUNCS
- if (ret==OK){
- if(runBusy()){
- ret=stopStateMachine();
- if(ret==FAIL)
- strcpy(mess,"could not stop detector acquisition to configure mac");
- }
-
- if(ret==OK)
- configureMAC(ipad,imacadd,idetectormacadd,detipad,digitalTestBit,udpport);
- retval=getAdcConfigured();
- }
-#endif
- if (ret==FAIL)
- printf("configuring MAC of mod %d failed\n", imod);
- else
- printf("Configuremac successful of mod %d and adc %d\n",imod,retval);
-
- if (differentClients)
- ret=FORCE_UPDATE;
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL)
- n += sendDataOnly(file_des,mess,sizeof(mess));
- else
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- /*return ok/fail*/
- return ret;
-
-}
-
-
-
-int load_image(int file_des) {
- int retval;
- int ret=OK;
- int n;
- enum imageType index;
- short int ImageVals[NCHAN*NCHIP];
-
- sprintf(mess,"Loading image failed\n");
-
- n = receiveDataOnly(file_des,&index,sizeof(index));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- n = receiveDataOnly(file_des,ImageVals,dataBytes);
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- switch (index) {
- case DARK_IMAGE :
-#ifdef VERBOSE
- printf("Loading Dark image\n");
-#endif
- break;
- case GAIN_IMAGE :
-#ifdef VERBOSE
- printf("Loading Gain image\n");
-#endif
- break;
- default:
- printf("Unknown index %d\n",index);
- sprintf(mess,"Unknown index %d\n",index);
- ret=FAIL;
- break;
- }
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else{
- retval=loadImage(index,ImageVals);
- if (retval==-1)
- ret = FAIL;
- }
- }
-
- if(ret==OK){
- if (differentClients)
- ret=FORCE_UPDATE;
- }
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,&retval,sizeof(retval));
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
- /*return ok/fail*/
- return ret;
-}
-
-
-
-int set_master(int file_des) {
-
- enum masterFlags retval=GET_MASTER;
- enum masterFlags arg;
- int n;
- int ret=OK;
- // int regret=OK;
-
-
- sprintf(mess,"can't set master flags\n");
-
-
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
-
-#ifdef VERBOSE
- printf("setting master flags to %d\n",arg);
-#endif
-
- if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
- retval=setMaster(arg);
-
- }
- if (retval==GET_MASTER) {
- ret=FAIL;
- }
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else {
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- }
- return ret;
-}
-
-
-
-
-
-
-int set_synchronization(int file_des) {
-
- enum synchronizationMode retval=GET_MASTER;
- enum synchronizationMode arg;
- int n;
- int ret=OK;
- //int regret=OK;
-
-
- sprintf(mess,"can't set synchronization mode\n");
-
-
- n = receiveDataOnly(file_des,&arg,sizeof(arg));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-#ifdef VERBOSE
- printf("setting master flags to %d\n",arg);
-#endif
-
- if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else {
- //ret=setStoreInRAM(0);
- // initChipWithProbes(0,0,0, ALLMOD);
- retval=setSynchronization(arg);
- }
- if (retval==GET_SYNCHRONIZATION_MODE) {
- ret=FAIL;
- }
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL) {
- n = sendDataOnly(file_des,mess,sizeof(mess));
- } else {
- n = sendDataOnly(file_des,&retval,sizeof(retval));
- }
- return ret;
-}
-
-
-
-
-
-
-int read_counter_block(int file_des) {
-
- int ret=OK;
- int n;
- int startACQ;
- //char *retval=NULL;
- short int CounterVals[NCHAN*NCHIP];
-
- sprintf(mess,"Read counter block failed\n");
-
- n = receiveDataOnly(file_des,&startACQ,sizeof(startACQ));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else{
- ret=readCounterBlock(startACQ,CounterVals);
-#ifdef VERBOSE
- int i;
- for(i=0;i<6;i++)
- printf("%d:%d\t",i,CounterVals[i]);
-#endif
- }
- }
-
- if(ret!=FAIL){
- if (differentClients)
- ret=FORCE_UPDATE;
- }
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret!=FAIL) {
- /* send return argument */
- n += sendDataOnly(file_des,CounterVals,dataBytes);//1280*2
- } else {
- n += sendDataOnly(file_des,mess,sizeof(mess));
- }
-
- /*return ok/fail*/
- return ret;
-}
-
-
-
-
-
-int reset_counter_block(int file_des) {
-
- int ret=OK;
- int n;
- int startACQ;
-
- sprintf(mess,"Reset counter block failed\n");
-
- n = receiveDataOnly(file_des,&startACQ,sizeof(startACQ));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else
- ret=resetCounterBlock(startACQ);
- }
-
- if(ret==OK){
- if (differentClients)
- ret=FORCE_UPDATE;
- }
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL)
- n += sendDataOnly(file_des,mess,sizeof(mess));
-
- /*return ok/fail*/
- return ret;
-}
-
-
-
-
-
-
-int start_receiver(int file_des) {
- int ret=OK;
- int n=0;
- strcpy(mess,"Could not start receiver\n");
-
- /* execute action if the arguments correctly arrived*/
-#ifdef MCB_FUNCS
- if (lockStatus==1 && differentClients==1){//necessary???
- sprintf(mess,"Detector locked by %s\n", lastClientIP);
- ret=FAIL;
- }
- else
- ret = startReceiver(1);
-
-#endif
-
-
- if(ret==OK && differentClients){
- printf("Force update\n");
- ret=FORCE_UPDATE;
- }
-
- /* send answer */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if(ret==FAIL)
- n = sendDataOnly(file_des,mess,sizeof(mess));
- /*return ok/fail*/
- return ret;
-}
-
-
-
-
-
-
-int stop_receiver(int file_des) {
- int ret=OK;
- int n=0;
-
- strcpy(mess,"Could not stop receiver\n");
-
- /* execute action if the arguments correctly arrived*/
-#ifdef MCB_FUNCS
- if (lockStatus==1 && differentClients==1){//necessary???
- sprintf(mess,"Detector locked by %s\n", lastClientIP);
- ret=FAIL;
- }
- else
- ret=startReceiver(0);
-
-#endif
-
-
- if(ret==OK && differentClients){
- printf("Force update\n");
- ret=FORCE_UPDATE;
- }
-
- /* send answer */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if(ret==FAIL)
- n = sendDataOnly(file_des,mess,sizeof(mess));
- /*return ok/fail*/
- return ret;
-}
-
-
-
-
-
-int calibrate_pedestal(int file_des){
-
- int ret=OK;
- int retval=-1;
- int n;
- int frames;
-
- sprintf(mess,"Could not calibrate pedestal\n");
-
- n = receiveDataOnly(file_des,&frames,sizeof(frames));
- if (n < 0) {
- sprintf(mess,"Error reading from socket\n");
- ret=FAIL;
- }
-
- if (ret==OK) {
- if (differentClients==1 && lockStatus==1) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- } else
- ret=calibratePedestal(frames);
- }
-
- if(ret==OK){
- if (differentClients)
- ret=FORCE_UPDATE;
- }
-
- /* send answer */
- /* send OK/failed */
- n = sendDataOnly(file_des,&ret,sizeof(ret));
- if (ret==FAIL)
- n += sendDataOnly(file_des,mess,sizeof(mess));
- else
- n += sendDataOnly(file_des,&retval,sizeof(retval));
-
- /*return ok/fail*/
- return ret;
-}
-
-
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.h
deleted file mode 100755
index 890c7452d..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/server_funcs.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef SERVER_FUNCS_H
-#define SERVER_FUNCS_H
-
-
-#include "sls_detector_defs.h"
-
-
-#include
-/*
-#include
-#include
-#include
-*/
-#include "communication_funcs.h"
-
-
-
-
-#define GOODBYE -200
-
-int sockfd;
-
-int function_table();
-
-int decode_function(int);
-int init_detector(int);
-
-int M_nofunc(int);
-int exit_server(int);
-
-
-
-
-// General purpose functions
-int get_detector_type(int);
-int set_number_of_modules(int);
-int get_max_number_of_modules(int);
-
-
-int exec_command(int);
-int set_external_signal_flag(int);
-int set_external_communication_mode(int);
-int get_id(int);
-int digital_test(int);
-int write_register(int);
-int read_register(int);
-int set_dac(int);
-int get_adc(int);
-int set_channel(int);
-int set_chip(int);
-int set_module(int);
-int get_channel(int);
-int get_chip(int);
-int get_module(int);
-
-int get_threshold_energy(int);
-int set_threshold_energy(int);
-int set_settings(int);
-int start_acquisition(int);
-int stop_acquisition(int);
-int start_readout(int);
-int get_run_status(int);
-int read_frame(int);
-int read_all(int);
-int start_and_read_all(int);
-int set_timer(int);
-int get_time_left(int);
-int set_dynamic_range(int);
-int set_roi(int);
-int get_roi(int);
-int set_speed(int);
-void prepareADC(void);
-int set_readout_flags(int);
-int execute_trimming(int);
-int lock_server(int);
-int set_port(int);
-int get_last_client_ip(int);
-int set_master(int);
-int set_synchronization(int);
-
-int update_client(int);
-int send_update(int);
-int configure_mac(int);
-
-int load_image(int);
-int read_counter_block(int);
-int reset_counter_block(int);
-
-int start_receiver(int);
-int stop_receiver(int);
-
-
-int calibrate_pedestal(int);
-
-int set_roi(int);
-
-#endif
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.c
deleted file mode 100755
index 4504cfe05..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "sharedmemory.h"
-
-struct statusdata *stdata;
-
-int inism(int clsv) {
-
-static int scansmid;
-
- if (clsv==SMSV) {
- if ( (scansmid=shmget(SMKEY,1024,IPC_CREAT | 0666 ))==-1 ) {
- return -1;
- }
- if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
- return -2;
- }
- }
-
- if (clsv==SMCL) {
- if ( (scansmid=shmget(SMKEY,0,0) )==-1 ) {
- return -3;
- }
- if ( (stdata=shmat(scansmid,NULL,0))==(void*)-1) {
- return -4;
- }
- }
- return 1;
-}
-
-void write_status_sm(char *status) {
- strcpy(stdata->status,status);
-}
-
-void write_stop_sm(int v) {
- stdata->stop=v;
-}
-
-void write_runnumber_sm(int v) {
- stdata->runnumber=v;
-}
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.h
deleted file mode 100755
index bdbddf719..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sharedmemory.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef SM
-#define SM
-
-#include "sls_detector_defs.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-//#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-
-#include
-
-#include
-#include
-
-/* key for shared memory */
-#define SMKEY 10001
-
-#define SMSV 1
-#define SMCL 2
-
-
-struct statusdata {
- int runnumber;
- int stop;
- char status[20];
-} ;
-
-
-/* for shared memory */
-
-int inism(int clsv);
-void write_status_sm(char *status);
-void write_stop_sm(int v);
-void write_runnumber_sm(int v);
-
-#endif
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_defs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_defs.h
deleted file mode 120000
index c5062e03f..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_defs.h
+++ /dev/null
@@ -1 +0,0 @@
-../commonFiles/sls_detector_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_funcs.h
deleted file mode 120000
index 844b67129..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_detector_funcs.h
+++ /dev/null
@@ -1 +0,0 @@
-../commonFiles/sls_detector_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_defs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_defs.h
deleted file mode 120000
index 1de31caf5..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_defs.h
+++ /dev/null
@@ -1 +0,0 @@
-../../slsReceiverSoftware/include/sls_receiver_defs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_funcs.h
deleted file mode 120000
index c2ea4ded9..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/sls_receiver_funcs.h
+++ /dev/null
@@ -1 +0,0 @@
-../../slsReceiverSoftware/include/sls_receiver_funcs.h
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/stop_server.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/stop_server.c
deleted file mode 100755
index e3c8ff7e1..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/stop_server.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* A simple server in the internet domain using TCP
- The port number is passed as an argument */
-
-
-#include "sls_detector_defs.h"
-
-
-#include "communication_funcs.h"
-#include "firmware_funcs.h"
-
-
-int sockfd;
-
-int main(int argc, char *argv[])
-{
- int portno;
- int retval=0;
-
- portno = DEFAULT_PORTNO;
-
-
- bindSocket(portno);
- if (getServerError())
- return -1;
-
-
-
- /* waits for connection */
- while(retval!=GOODBYE) {
-#ifdef VERBOSE
- printf("\n");
-#endif
-#ifdef VERY_VERBOSE
- printf("Stop server: waiting for client call\n");
-#endif
- acceptConnection();
- retval=stopStateMachine();
- closeConnection();
- }
-
- exitServer();
- printf("Goodbye!\n");
-
- return 0;
-}
-
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.c b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.c
deleted file mode 100755
index 9a28b9b4a..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.c
+++ /dev/null
@@ -1,749 +0,0 @@
-#ifndef PICASSOD
-#include "server_defs.h"
-#else
-#include "picasso_defs.h"
-#endif
-#include "trimming_funcs.h"
-#include "mcb_funcs.h"
-#include "firmware_funcs.h"
-#include
-
-
-
-extern int nModX;
-//extern int *values;
-
-extern const int nChans;
-extern const int nChips;
-extern const int nDacs;
-extern const int nAdcs;
-
-
-int trim_fixed_settings(int countlim, int par2, int im)
-{
-
- int retval=OK;
-#ifdef VERBOSE
- printf("Trimming with fixed settings\n");
-#endif
-#ifdef VIRTUAL
- return OK;
-#endif
-
- if (par2<=0)
- retval=trim_with_level(countlim, im);
- else
- retval=trim_with_median(countlim,im);
-
-
- return retval;
-}
-
-
-int trim_with_noise(int countlim, int nsigma, int im)
-{
-
-
- int retval=OK, retval1=OK, retval2=OK;
-#ifdef VERBOSE
- printf("Trimming using noise\n");
-#endif
-#ifdef VIRTUAL
- return OK;
-#endif
-
- /* threshold scan */
-
-#ifdef VERBOSE
- printf("chosing vthresh and vtrim.....");
-#endif
- retval1=choose_vthresh_and_vtrim(countlim,nsigma, im);
-
-#ifdef VERBOSE
- printf("trimming with noise.....\n");
-#endif
- retval2=trim_with_level(countlim, im);
-
-#ifdef DEBUGOUT
- printf("done\n");
-#endif
- if (retval1==OK && retval2==OK)
- retval=OK;
- else
- retval=FAIL;
-
- return retval;
-
-}
-
-int trim_with_beam(int countlim, int nsigma, int im) //rpc
-{
-
-
- int retval=OK, retval1=OK, retval2=OK;
-
- printf("Trimming using beam\n");
- //return OK;
-#ifdef VIRTUAL
- printf("Trimming using beam\n");
- return OK;
-#endif
- /* threshold scan */
-#ifdef DEBUGOUT
- printf("chosing vthresh and vtrim.....");
-#endif
-
- retval1=choose_vthresh_and_vtrim(countlim,nsigma,im);
- retval2=trim_with_median(TRIM_DR, im);
-
-#ifdef DEBUGOUT
- printf("done\n");
-#endif
-
- if (retval1==OK && retval2==OK)
- retval=OK;
- else
- retval=FAIL;
-
- return retval;
-
-}
-
-
-int trim_improve(int maxit, int par2, int im) //rpc
-{
-
- int retval=OK, retval1=OK, retval2=OK;
-
-
-#ifdef VERBOSE
- printf("Improve the trimming\n");
-#endif
-#ifdef VIRTUAL
- return OK;
-#endif
-
-
- if (par2!=0 && im==ALLMOD)
- retval1=choose_vthresh();
-
- retval2=trim_with_median(2*maxit+1, im);
-#ifdef DEBUGOUT
- printf("done\n");
-#endif
- if (retval1==OK && retval2==OK)
- retval=OK;
- else
- retval=FAIL;
-
- return retval;
-
-}
-
-int calcthr_from_vcal(int vcal) {
- int thrmin;
- //thrmin=140+3*vcal/5;
- thrmin=180+3*vcal/5;
- return thrmin;
-}
-
-int calccal_from_vthr(int vthr) {
- int vcal;
- vcal=5*(vthr-140)/3;
- return vcal;
-}
-
-int choose_vthresh_and_vtrim(int countlim, int nsigma, int im) {
- int retval=OK;
-#ifdef MCB_FUNCS
- int modma, modmi, nm;
- int thr, thrstep=5, nthr=31;
-
- int *fifodata;
-
- double vthreshmean, vthreshSTDev;
- int *thrmi, *thrma;
- double c;
- double b=BVTRIM;
- double a=AVTRIM;
- int *trim;
- int ich, imod, ichan;
- int nvalid=0;
- u_int32_t *scan;
- int ithr;
- sls_detector_channel myChan;
-
-
-
- setFrames(1);
- // setNMod(getNModBoard());
-
- if (im==ALLMOD){
- modmi=0;
- modma=nModX;
- } else {
- modmi=im;
- modma=im+1;
- }
- nm=modma-modmi;
-
- trim=malloc(sizeof(int)*nChans*nChips*nModX);
- thrmi=malloc(sizeof(int)*nModX);
- thrma=malloc(sizeof(int)*nModX);
-
-
- for (ich=0; ichcountlim && trim[ich]==-1) {
-//commented out by dhanya trim[ich]=getDACbyIndexDACU(VTHRESH,imod);
-#ifdef VERBOSE
- // printf("yes: %d %d %d\n",ich,ithr,scan[ich]);
-#endif
- }
-#ifdef VERBOSE
- /* else {
- printf("no: %d %d %d\n",ich,ithr,scan[ich]);
- }*/
-#endif
- }
- }
- free(scan);
- }
-
- for (imod=modmi; imodthrmi[imod] && trim[ich]0) {
- vthreshmean=vthreshmean/nvalid;
- //commented out by dhanya vthreshSTDev=sqrt((vthreshSTDev/nvalid)-vthreshmean*vthreshmean);
- } else {
- vthreshmean=thrmi[imod];
- vthreshSTDev=nthr*thrstep;
- printf("No valid channel for module %d\n",imod);
- retval=FAIL;
- }
-
-#ifdef DEBUGOUT
- printf("module= %d nvalid = %d mean=%f RMS=%f\n",imod, nvalid, vthreshmean,vthreshSTDev);
-#endif
- // *vthresh=round(vthreshmean-nsigma*vthreshSTDev);
- thr=(int)(vthreshmean-nsigma*vthreshSTDev);
- if (thr<0 || thr>(DAC_DR-1)) {
- thr=thrmi[imod]/2;
- printf("Can't find correct threshold for module %d\n",imod);
- retval=FAIL;
- }
-//commented out by dhanya initDACbyIndexDACU(VTHRESH,thr,imod);
-#ifdef VERBOSE
- printf("vthresh=%d \n",thr);
-#endif
- c=CVTRIM-2.*nsigma*vthreshSTDev/63.;
- //commented out by dhanya thr=(int)((-b-sqrt(b*b-4*a*c))/(2*a));
- if (thr<500 || thr>(DAC_DR-1)) {
- thr=750;
- printf("Can't find correct trimbit size for module %d\n",imod);
- retval=FAIL;
- }
-
- //commented out by dhanya initDACbyIndexDACU(VTRIM,thr,imod);
-
-#ifdef VERBOSE
- printf("vtrim=%d \n",thr);
-#endif
-
- }
- free(trim);
- free(thrmi);
- free(thrma);
-
-#endif
- return retval;
-}
-
-
-
-
-
-int trim_with_level(int countlim, int im) {
- int ich, itrim, ichan, ichip, imod;
- u_int32_t *scan;
- int *inttrim;
- int modma, modmi, nm;
- int retval=OK;
- int *fifodata;
- sls_detector_channel myChan;
- printf("trimming module number %d", im);
-
-
-#ifdef MCB_FUNCS
- setFrames(1);
- // setNMod(getNModBoard());
-
- if (im==ALLMOD){
- modmi=0;
- modma=nModX;
- } else {
- modmi=im;
- modma=im+1;
- }
- nm=modma-modmi;
-
- inttrim=malloc(sizeof(int)*nChips*nChans*nModX);
- printf("countlim=%d\n",countlim);
- for (ich=0; ichcountlim){
- inttrim[ich]=itrim;
- if (scan[ich]>2*countlim && itrim>0) {
- //if (scan[ich]>2*countlim || itrim==0) {
- inttrim[ich]=itrim-1;
- }
-#ifdef VERBOSE
- printf("Channel %d trimbit %d counted %d (%08x) countlim %d\n",ich,itrim,scan[ich],fifodata[ich],countlim);
-#endif
- }
- }
-#ifdef VERBOSE
- /* else
- printf("Channel %d trimbit %d counted %d countlim %d\n",ich,itrim,scan[ich],countlim);*/
-#endif
- }
- }
- free(scan);
- }
-
- for (imod=modmi; imod0)
- direction[ichan]=1;
- else
- direction[ichan]=-1;
- }
- //commented out by dhanya vthresh=getDACbyIndexDACU(VTHRESH,imod);
- if ( direction[ichan]!=-3) {
- if (abs(diff)>abs(olddiff[ichan])) {
- vthresh=vthresh-direction[ichan];
- if (vthresh>(DAC_DR-1)) {
- vthresh=(DAC_DR-1);
- printf("can't equalize threshold for module %d\n", ichan);
- retval=FAIL;
- }
- if (vthresh<0) {
- vthresh=0;
- printf("can't equalize threshold for module %d\n", ichan);
- retval=FAIL;
- }
- direction[ichan]=-3;
- } else {
- vthresh=vthresh+direction[ichan];
- olddiff[ichan]=diff;
- change_flag=1;
- }
-//commented out by dhanya initDACbyIndex(VTHRESH,vthresh, ichan);
- }
- }
- iteration++;
- free(scan);
- free(scan1);
- }
-#endif
- return retval;
-}
-
-
-
-
-
-int trim_with_median(int stop, int im) {
-
-
- int retval=OK;
-
-#ifdef MCB_FUNCS
- int ichan, imod, ichip, ich;
- u_int32_t *scan, *scan1;
- int *olddiff, *direction;
- int med, diff;
- int change_flag=1;
- int iteration=0;
- int me[nModX], me1[nModX];
- int modma, modmi, nm;
- int trim;
- int *fifodata;
-
- setFrames(1);
- // setNMod(getNModBoard());
-
- if (im==ALLMOD){
- modmi=0;
- modma=nModX;
- } else {
- modmi=im;
- modma=im+1;
- }
- nm=modma-modmi;
-
- olddiff=malloc(4*nModX*nChips*nChans);
- direction=malloc(4*nModX*nChips*nChans);
- for (imod=modmi; imod0) {
- direction[ichan]=1;
- } else {
- direction[ichan]=-1;
- }
- }
- if ( direction[ichan]!=-3) {
- if (abs(diff)>abs(olddiff[ichan])) {
- trim=getTrimbit(imod,ichip,ich)+direction[ichan];
- printf("%d old diff %d < new diff %d %d - trimbit %d\n",ichan, olddiff[ichan], diff, direction[ichan], trim);
- direction[ichan]=-3;
- } else {
- trim=getTrimbit(imod,ichip,ich)-direction[ichan];
- olddiff[ichan]=diff;
- change_flag=1;
- }
- if (trim>TRIM_DR) {
- trim=63;
- printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
- retval=FAIL;
- }
- if (trim<0) {
- printf("can't trim channel %d chip %d module %d to trim %d\n",ich, ichip, imod, trim);
- trim=0;
- retval=FAIL;
- }
- initChannel(trim,0,0,1,0,0,imod);
- }
- }
- }
- }
- iteration++;
- free(scan);
- free(scan1);
- }
- free(olddiff);
- free(direction);
-#endif
- return retval;
-}
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.h b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.h
deleted file mode 100755
index 42ecea24a..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/trimming_funcs.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef TRIMMING_FUNCS_H
-#define TRIMMING_FUNCS_H
-
-#include "sls_detector_defs.h"
-
-int trim_fixed_settings(int countlim, int par2, int imod);
-int trim_with_noise(int countlim, int nsigma, int imod);
-int trim_with_beam(int countlim, int nsigma, int imod);
-int trim_improve(int maxit, int par2, int imod);
-int calcthr_from_vcal(int vcal);
-int calccal_from_vthr(int vthr);
-int choose_vthresh_and_vtrim(int countlim, int nsigma, int imod);
-
-int choose_vthresh();
-int trim_with_level(int countlim, int imod);
-int trim_with_median(int stop, int imod);
-int calcthr_from_vcal(int vcal);
-int calccal_from_vthr(int vthr);
-
-#endif
diff --git a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh b/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh
deleted file mode 100755
index cea04b2de..000000000
--- a/slsDetectorSoftware/slsDetectorServers/moenchDetectorServer/updateGitVersion.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-SERVER=moenchDetectorServer
-MAINDIR=slsDetectorsPackage
-SPECDIR=slsDetectorSoftware/$SERVER
-TMPFILE=gitInfoMoenchTmp.h
-INCLFILE=gitInfoMoench.h
-
-
-#evaluate the variables
-EVALFILE=../../evalVersionVariables.sh
-source $EVALFILE
-
-
-#get modified date
-#RDATE1='git log --pretty=format:"%ci" -1'
-RDATE1="find . -type f -exec stat --format '%Y :%y %n' '{}' \; | sort -nr | cut -d: -f2- | egrep -v 'gitInfo|.git|updateGitVersion|.o' | head -n 1"
-RDATE=`eval $RDATE1`
-NEWDATE=$(sed "s/-//g" <<< $RDATE | awk '{print $1;}')
-NEWDATE=${NEWDATE/#/0x}
-
-
-#get old date from INCLFILE
-OLDDATE=$(more $INCLFILE | grep '#define GITDATE' | awk '{print $3}')
-
-
-#update INCLFILE if changes
-if [ "$OLDDATE" != "$NEWDATE" ]; then
- echo Path: ${MAINDIR}/${SPECDIR} $'\n'URL: ${GITREPO} $'\n'Repository Root: ${GITREPO} $'\n'Repsitory UUID: ${REPUID} $'\n'Revision: ${FOLDERREV} $'\n'Branch: ${BRANCH} $'\n'Last Changed Author: ${AUTH1}_${AUTH2} $'\n'Last Changed Rev: ${REV} $'\n'Last Changed Date: ${RDATE} > gitInfo.txt
- cd ../../
- ./genVersionHeader.sh $SPECDIR/gitInfo.txt $SPECDIR/$TMPFILE $SPECDIR/$INCLFILE
- cd $WD
-fi
\ No newline at end of file
diff --git a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h
index b10be6845..262b9f71c 100644
--- a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h
+++ b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h
@@ -29,24 +29,22 @@ u_int32_t testFpga(void);
int testBus(void);
#endif
-#if defined(MYTHEND) || defined(JUNGFRAUD) || defined(MYTHEN3D)
-int moduleTest( enum digitalTestMode arg, int imod);
+#ifdef MYTHEN3D
+int moduleTest( enum digitalTestMode arg);
#endif
-#if defined(MYTHEND) || defined(JUNGFRAUD)
+#ifdef JUNGFRAUD
int detectorTest( enum digitalTestMode arg);
#endif
// Ids
int64_t getDetectorId(enum idMode arg);
u_int64_t getFirmwareVersion();
-#ifdef MYTHEND
-int64_t getModuleId(enum idMode arg, int imod);
-#elif JUNGFRAUD
+#ifdef JUNGFRAUD
u_int64_t getFirmwareAPIVersion();
u_int16_t getHardwareVersionNumber();
u_int16_t getHardwareSerialNumber();
#endif
-#ifndef MYTHEN3D
+#if !defined(MYTHEN3D) || !defined(EIGERD)
u_int32_t getDetectorNumber();
#endif
u_int64_t getDetectorMAC();
@@ -96,9 +94,7 @@ int getPhase();
void configureASICTimer();
#endif
-// parameters - nmod, dr, roi
-int setNMod(int nm, enum dimension dim); // mythen specific, but for detector compatibility as a get
-int getNModBoard(enum dimension arg); // mythen specific, but for detector compatibility as a get
+// parameters - dr, roi
int setDynamicRange(int dr);
#ifdef GOTTHARD
int setROI(int n, ROI arg[], int *retvalsize, int *ret);
@@ -106,12 +102,9 @@ int setROI(int n, ROI arg[], int *retvalsize, int *ret);
// parameters - readout
int setSpeed(enum speedVariable arg, int val);
-#if defined(EIGERD) || defined(MYTHEND)
+#ifdef EIGERD
enum readOutFlags setReadOutFlags(enum readOutFlags val);
#endif
-#ifdef MYTHEND
-int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
-#endif
// parameters - timer
#ifdef JUNGFRAUD
@@ -121,27 +114,22 @@ int64_t setTimer(enum timerIndex ind, int64_t val);
int64_t getTimeLeft(enum timerIndex ind);
-// parameters - channel, chip, module, settings
-#ifdef MYTHEND
-int setChannel(sls_detector_channel myChan);
-int getChannel(sls_detector_channel *myChan);
-int setChip(sls_detector_chip myChip);
-int getChip(sls_detector_chip *myChip);
-#endif
+// parameters - module, settings
+
#ifdef EIGERD
int setModule(sls_detector_module myMod, int delay);
#else
int setModule(sls_detector_module myMod);
#endif
int getModule(sls_detector_module *myMod);
-enum detectorSettings setSettings(enum detectorSettings sett, int imod);
+enum detectorSettings setSettings(enum detectorSettings sett);
enum detectorSettings getSettings();
// parameters - threshold
-#if defined(MYTHEND) || defined(EIGERD)
-int getThresholdEnergy(int imod);
-int setThresholdEnergy(int ev, int imod);
+#ifdef EIGERD
+int getThresholdEnergy();
+int setThresholdEnergy(int ev);
#endif
// parameters - dac, adc, hv
@@ -161,34 +149,30 @@ int dacToPower(int value, int chip);
extern void setAdc(int addr, int val); // AD9257.h
#endif
-void setDAC(enum DACINDEX ind, int val, int imod, int mV, int retval[]);
+void setDAC(enum DACINDEX ind, int val, int mV, int retval[]);
#ifdef MYTHEN3D
int getVLimit();
void setDacRegister(int dacnum,int dacvalue);
int getDacRegister(int dacnum);
#endif
#ifndef MYTHEN3D
-int getADC(enum ADCINDEX ind, int imod);
+int getADC(enum ADCINDEX ind);
#endif
-#if !defined(MYTHEN3D) && !defined(MYTHEND)
+#ifndef MYTHEN3D
int setHighVoltage(int val);
#endif
// parameters - timing, extsig
-#ifdef MYTHEND
-enum externalSignalFlag getExtSignal(int signalindex);
-enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
-#endif
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
// configure mac
#ifdef JUNGFRAUD
long int calcChecksum(int sourceip, int destip);
#endif
-#if !defined(MYTHEN3D) && !defined(MYTHEND)
+#ifndef MYTHEN3D
int configureMAC(uint32_t destip, uint64_t destmac, uint64_t sourcemac, uint32_t sourceip, uint32_t udpport, uint32_t udpport2, int ival);
#endif
#if defined(JUNGFRAUD) || defined(EIGERD)
@@ -220,7 +204,7 @@ extern int writeFPGAProgram(char* fpgasrc, size_t fsize, FILE* filefp); // prog
// eiger specific - iodelay, 10g, pulse, rate, temp, activate, delay nw parameter
#elif EIGERD
-int setIODelay(int val, int imod);
+int setIODelay(int val);
int enableTenGigabitEthernet(int val);
int setCounterBit(int val);
int pulsePixel(int n, int x, int y);
@@ -270,22 +254,15 @@ u_int32_t runBusy(void);
int copyModule(sls_detector_module *destMod, sls_detector_module *srcMod);
int calculateDataBytes();
int getTotalNumberOfChannels();
-int getTotalNumberOfChips();
-int getTotalNumberOfModules();
-int getNumberOfChannelsPerModule();
-int getNumberOfChipsPerModule();
-int getNumberOfDACsPerModule();
-int getNumberOfADCsPerModule();
+int getNumberOfChips();
+int getNumberOfDACs();
+int getNumberOfADCs();
#ifdef EIGERD
-int getNumberOfGainsPerModule();
-int getNumberOfOffsetsPerModule();
+int getNumberOfGains();
+int getNumberOfOffsets();
#endif
int getNumberOfChannelsPerChip();
-// sync
-enum masterFlags setMaster(enum masterFlags arg);
-enum synchronizationMode setSynchronization(enum synchronizationMode arg);
-
#endif
diff --git a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c
index 8cd09f2b1..9f282abf2 100755
--- a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c
+++ b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.c
@@ -17,16 +17,10 @@ extern char thisClientIP[INET_ADDRSTRLEN];
extern int differentClients;
//defined in the detector specific Makefile
-#ifdef MYTHEND
-const enum detectorType myDetectorType=MYTHEN;
-#elif GOTTHARDD
+#ifdef GOTTHARDD
const enum detectorType myDetectorType=GOTTHARD;
#elif EIGERD
const enum detectorType myDetectorType=EIGER;
-#elif PICASSOD
-const enum detectorType myDetectorType=PICASSO;
-#elif MOENCHD
-const enum detectorType myDetectorType=MOENCH;
#elif JUNGFRAUD
const enum detectorType myDetectorType=JUNGFRAU;
#elif MYTHEN3D
@@ -132,41 +126,24 @@ int decode_function(int file_des) {
const char* getFunctionName(enum detFuncs func) {
switch (func) {
case F_EXEC_COMMAND: return "F_EXEC_COMMAND";
- case F_GET_ERROR: return "F_GET_ERROR";
case F_GET_DETECTOR_TYPE: return "F_GET_DETECTOR_TYPE";
- case F_SET_NUMBER_OF_MODULES: return "F_SET_NUMBER_OF_MODULES";
- case F_GET_MAX_NUMBER_OF_MODULES: return "F_GET_MAX_NUMBER_OF_MODULES";
case F_SET_EXTERNAL_SIGNAL_FLAG: return "F_SET_EXTERNAL_SIGNAL_FLAG";
case F_SET_EXTERNAL_COMMUNICATION_MODE: return "F_SET_EXTERNAL_COMMUNICATION_MODE";
case F_GET_ID: return "F_GET_ID";
case F_DIGITAL_TEST: return "F_DIGITAL_TEST";
- case F_ANALOG_TEST: return "F_ANALOG_TEST";
- case F_ENABLE_ANALOG_OUT: return "F_ENABLE_ANALOG_OUT";
- case F_CALIBRATION_PULSE: return "F_CALIBRATION_PULSE";
case F_SET_DAC: return "F_SET_DAC";
case F_GET_ADC: return "F_GET_ADC";
case F_WRITE_REGISTER: return "F_WRITE_REGISTER";
case F_READ_REGISTER: return "F_READ_REGISTER";
- case F_WRITE_MEMORY: return "F_WRITE_MEMORY";
- case F_READ_MEMORY: return "F_READ_MEMORY";
- case F_SET_CHANNEL: return "F_SET_CHANNEL";
- case F_GET_CHANNEL: return "F_GET_CHANNEL";
- case F_SET_ALL_CHANNELS: return "F_SET_ALL_CHANNELS";
- case F_SET_CHIP: return "F_SET_CHIP";
- case F_GET_CHIP: return "F_GET_CHIP";
- case F_SET_ALL_CHIPS: return "F_SET_ALL_CHIPS";
case F_SET_MODULE: return "F_SET_MODULE";
case F_GET_MODULE: return "F_GET_MODULE";
- case F_SET_ALL_MODULES: return "F_SET_ALL_MODULES";
case F_SET_SETTINGS: return "F_SET_SETTINGS";
case F_GET_THRESHOLD_ENERGY: return "F_GET_THRESHOLD_ENERGY";
- case F_SET_THRESHOLD_ENERGY: return "F_SET_THRESHOLD_ENERGY";
case F_START_ACQUISITION: return "F_START_ACQUISITION";
case F_STOP_ACQUISITION: return "F_STOP_ACQUISITION";
case F_START_READOUT: return "F_START_READOUT";
case F_GET_RUN_STATUS: return "F_GET_RUN_STATUS";
case F_START_AND_READ_ALL: return "F_START_AND_READ_ALL";
- case F_READ_FRAME: return "F_READ_FRAME";
case F_READ_ALL: return "F_READ_ALL";
case F_SET_TIMER: return "F_SET_TIMER";
case F_GET_TIME_LEFT: return "F_GET_TIME_LEFT";
@@ -174,7 +151,6 @@ const char* getFunctionName(enum detFuncs func) {
case F_SET_READOUT_FLAGS: return "F_SET_READOUT_FLAGS";
case F_SET_ROI: return "F_SET_ROI";
case F_SET_SPEED: return "F_SET_SPEED";
- case F_EXECUTE_TRIMMING: return "F_EXECUTE_TRIMMING";
case F_EXIT_SERVER: return "F_EXIT_SERVER";
case F_LOCK_SERVER: return "F_LOCK_SERVER";
case F_GET_LAST_CLIENT_IP: return "F_GET_LAST_CLIENT_IP";
@@ -182,8 +158,6 @@ const char* getFunctionName(enum detFuncs func) {
case F_UPDATE_CLIENT: return "F_UPDATE_CLIENT";
case F_CONFIGURE_MAC: return "F_CONFIGURE_MAC";
case F_LOAD_IMAGE: return "F_LOAD_IMAGE";
- case F_SET_MASTER: return "F_SET_MASTER";
- case F_SET_SYNCHRONIZATION_MODE: return "F_SET_SYNCHRONIZATION_MODE";
case F_READ_COUNTER_BLOCK: return "F_READ_COUNTER_BLOCK";
case F_RESET_COUNTER_BLOCK: return "F_RESET_COUNTER_BLOCK";
case F_CALIBRATE_PEDESTAL: return "F_CALIBRATE_PEDESTAL";
@@ -203,7 +177,6 @@ const char* getFunctionName(enum detFuncs func) {
case F_POWER_CHIP: return "F_POWER_CHIP";
case F_ACTIVATE: return "F_ACTIVATE";
case F_PREPARE_ACQUISITION: return "F_PREPARE_ACQUISITION";
- case F_CLEANUP_ACQUISITION: return "F_CLEANUP_ACQUISITION";
case F_THRESHOLD_TEMP: return "F_THRESHOLD_TEMP";
case F_TEMP_CONTROL: return "F_TEMP_CONTROL";
case F_TEMP_EVENT: return "F_TEMP_EVENT";
@@ -218,41 +191,24 @@ const char* getFunctionName(enum detFuncs func) {
void function_table() {
flist[F_EXEC_COMMAND] = &exec_command;
- flist[F_GET_ERROR] = &get_error;
flist[F_GET_DETECTOR_TYPE] = &get_detector_type;
- flist[F_SET_NUMBER_OF_MODULES] = &set_number_of_modules;
- flist[F_GET_MAX_NUMBER_OF_MODULES] = &get_max_number_of_modules;
flist[F_SET_EXTERNAL_SIGNAL_FLAG] = &set_external_signal_flag;
flist[F_SET_EXTERNAL_COMMUNICATION_MODE] = &set_external_communication_mode;
flist[F_GET_ID] = &get_id;
flist[F_DIGITAL_TEST] = &digital_test;
- flist[F_ANALOG_TEST] = &analog_test;
- flist[F_ENABLE_ANALOG_OUT] = &enable_analog_out;
- flist[F_CALIBRATION_PULSE] = &calibration_pulse;
flist[F_SET_DAC] = &set_dac;
flist[F_GET_ADC] = &get_adc;
flist[F_WRITE_REGISTER] = &write_register;
flist[F_READ_REGISTER] = &read_register;
- flist[F_WRITE_MEMORY] = &write_memory;
- flist[F_READ_MEMORY] = &read_memory;
- flist[F_SET_CHANNEL] = &set_channel;
- flist[F_GET_CHANNEL] = &get_channel;
- flist[F_SET_ALL_CHANNELS] = &set_all_channels;
- flist[F_SET_CHIP] = &set_chip;
- flist[F_GET_CHIP] = &get_chip;
- flist[F_SET_ALL_CHIPS] = &set_all_chips;
flist[F_SET_MODULE] = &set_module;
flist[F_GET_MODULE] = &get_module;
- flist[F_SET_ALL_MODULES] = &set_all_modules;
flist[F_SET_SETTINGS] = &set_settings;
flist[F_GET_THRESHOLD_ENERGY] = &get_threshold_energy;
- flist[F_SET_THRESHOLD_ENERGY] = &set_threshold_energy;
flist[F_START_ACQUISITION] = &start_acquisition;
flist[F_STOP_ACQUISITION] = &stop_acquisition;
flist[F_START_READOUT] = &start_readout;
flist[F_GET_RUN_STATUS] = &get_run_status;
flist[F_START_AND_READ_ALL] = &start_and_read_all;
- flist[F_READ_FRAME] = &read_frame;
flist[F_READ_ALL] = &read_all;
flist[F_SET_TIMER] = &set_timer;
flist[F_GET_TIME_LEFT] = &get_time_left;
@@ -260,7 +216,6 @@ void function_table() {
flist[F_SET_READOUT_FLAGS] = &set_readout_flags;
flist[F_SET_ROI] = &set_roi;
flist[F_SET_SPEED] = &set_speed;
- flist[F_EXECUTE_TRIMMING] = &execute_trimming;
flist[F_EXIT_SERVER] = &exit_server;
flist[F_LOCK_SERVER] = &lock_server;
flist[F_GET_LAST_CLIENT_IP] = &get_last_client_ip;
@@ -268,8 +223,6 @@ void function_table() {
flist[F_UPDATE_CLIENT] = &update_client;
flist[F_CONFIGURE_MAC] = &configure_mac;
flist[F_LOAD_IMAGE] = &load_image;
- flist[F_SET_MASTER] = &set_master;
- flist[F_SET_SYNCHRONIZATION_MODE] = &set_synchronization;
flist[F_READ_COUNTER_BLOCK] = &read_counter_block;
flist[F_RESET_COUNTER_BLOCK] = &reset_counter_block;
flist[F_CALIBRATE_PEDESTAL] = &calibrate_pedestal;
@@ -289,7 +242,6 @@ void function_table() {
flist[F_POWER_CHIP] = &power_chip;
flist[F_ACTIVATE] = &set_activate;
flist[F_PREPARE_ACQUISITION] = &prepare_acquisition;
- flist[F_CLEANUP_ACQUISITION] = &cleanup_acquisition;
flist[F_THRESHOLD_TEMP] = &threshold_temp;
flist[F_TEMP_CONTROL] = &temp_control;
flist[F_TEMP_EVENT] = &temp_event;
@@ -333,7 +285,7 @@ int M_nofunc(int file_des){
}
-
+// Jungfrau program mode
int M_nofuncMode(int file_des){
int ret=FAIL,ret1=FAIL;
int n=0;
@@ -396,24 +348,6 @@ int exec_command(int file_des) {
-int get_error(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Get Error) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
int get_detector_type(int file_des) {
int ret=OK,ret1=OK;
@@ -443,102 +377,6 @@ int get_detector_type(int file_des) {
-int set_number_of_modules(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=0;
- int arg[2]={-1,-1};
- sprintf(mess,"set number of modules failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- enum dimension dim=arg[0];
- int nm=arg[1];
-
- // execute action
-#ifdef VERBOSE
- printf("Setting the number of modules in dimension %d to %d\n",dim,nm );
-#endif
- if (lockStatus && differentClients && nm!=GET_FLAG) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
- retval=setNMod(nm, dim);
- dataBytes=calculateDataBytes();
- }
-#endif
-
- if (retval==nm || nm==GET_FLAG) {
- ret=OK;
- if (differentClients)
- ret=FORCE_UPDATE;
- } else
- ret=FAIL;
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_max_number_of_modules(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- enum dimension arg=0;
- sprintf(mess,"get max number of modules failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
-#ifdef VERBOSE
- printf("Getting the max number of modules in dimension %d \n",arg);
-#endif
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=getNModBoard(arg);
-#endif
-#ifdef VERBOSE
- printf("Max number of module in dimension %d is %d\n",arg,retval );
-#endif
- if (differentClients && ret==OK) {
- ret=FORCE_UPDATE;
- }
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
int set_external_signal_flag(int file_des) {
int ret=OK,ret1=OK;
@@ -546,7 +384,7 @@ int set_external_signal_flag(int file_des) {
enum externalSignalFlag retval=GET_EXTERNAL_SIGNAL_FLAG;
sprintf(mess,"set external signal flag failed\n");
-#ifndef MYTHEND
+#ifndef GOTTHARDD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@@ -681,7 +519,6 @@ int get_id(int file_des) {
int ret=OK,ret1=OK;
int n=0;
enum idMode arg=0;
- int imod=-1;
int64_t retval=-1;
sprintf(mess,"get id failed\n");
@@ -689,11 +526,6 @@ int get_id(int file_des) {
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
- if (arg == MODULE_SERIAL_NUMBER) {
- n = receiveData(file_des,&imod,sizeof(imod),INT32);
- if (n < 0) return printSocketReadError();
- }
-
// execute action
#ifdef VERBOSE
printf("Getting id %d\n", arg);
@@ -701,22 +533,6 @@ int get_id(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST
switch (arg) {
-#ifdef MYTHEND
- case MODULE_SERIAL_NUMBER:
- case MODULE_FIRMWARE_VERSION:
-#ifdef VERBOSE
- printf("of module %d\n", imod);
-#endif
-
- if (imod>=0 && imod=0 && imod 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int enable_analog_out(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Enable Analog Out) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int calibration_pulse(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Calibration Pulse) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
int set_dac(int file_des) {
int ret=OK,ret1=OK;
int n=0;
- int arg[3]={-1,-1,-1};
+ int arg[2]={-1,-1};
int val=-1;
enum dacIndex ind=0;
- int imod=-1;
int retval[2]={-1,-1};
int mV=0;
sprintf(mess,"set DAC failed\n");
@@ -944,22 +673,11 @@ int set_dac(int file_des) {
n = receiveData(file_des,arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
ind=arg[0];
- imod=arg[1];
- mV=arg[2];
+ mV=arg[1];
n = receiveData(file_des,&val,sizeof(val),INT32);
if (n < 0) return printSocketReadError();
- // checks
-#ifdef MYTHEND
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
-#endif
// check if dac exists for this detector
enum DACINDEX idac=0;
#ifdef JUNGFRAUD
@@ -971,15 +689,7 @@ int set_dac(int file_des) {
idac = ind;
#else
switch (ind) {
-#ifdef MYTHEND
- case TRIMBIT_SIZE: //ind = VTRIM;
- case THRESHOLD:
- case SHAPER1:
- case SHAPER2:
- case CALIBRATION_PULSE:
- case PREAMP:
- break;
-#elif GOTTHARDD
+#ifdef GOTTHARDD
case G_VREF_DS :
break;
case G_VCASCN_PB:
@@ -1164,7 +874,7 @@ int set_dac(int file_des) {
// execute action
#ifdef VERBOSE
- printf("Setting DAC %d of module %d to %d \n", idac, imod, val);
+ printf("Setting DAC %d to %d \n", idac, val);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
int temp;
@@ -1177,7 +887,7 @@ int set_dac(int file_des) {
#ifdef EIGERD
//iodelay
if(ind == IO_DELAY)
- retval[0] = setIODelay(val,imod);
+ retval[0] = setIODelay(val);
//high voltage
else
#endif
@@ -1255,7 +965,7 @@ int set_dac(int file_des) {
}
}
#endif
- setDAC(idac,val,imod,mV,retval);
+ setDAC(idac,val,mV,retval);
#ifdef EIGERD
if(val != -1) {
//changing dac changes settings to undefined
@@ -1266,7 +976,7 @@ int set_dac(int file_des) {
case VCMP_RR:
case VRF:
case VCP:
- setSettings(UNDEFINED,-1);
+ setSettings(UNDEFINED);
cprintf(RED,"Settings has been changed to undefined (changed specific dacs)\n");
break;
default:
@@ -1284,7 +994,7 @@ int set_dac(int file_des) {
ret = OK;
} else {
ret = FAIL;
- sprintf(mess,"Setting dac %d of module %d: wrote %d but read %d\n", idac, imod, val, temp);
+ sprintf(mess,"Setting dac %d : wrote %d but read %d\n", idac, val, temp);
cprintf(RED, "Warning: %s", mess);
}
}
@@ -1322,10 +1032,9 @@ int set_dac(int file_des) {
int get_adc(int file_des) {
int ret=OK,ret1=OK;
int n=0;
- int arg[2]={-1,-1};
+ int arg=-1;
int retval=-1;
enum dacIndex ind=0;
- int imod=-1;
sprintf(mess,"get ADC failed\n");
#ifdef MYTHEN3D
@@ -1338,20 +1047,9 @@ int get_adc(int file_des) {
#else
// receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
+ n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
- ind=arg[0];
- imod=arg[1];
-
-#ifdef MYTHEND
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules() || imod<0) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
-#endif
+ ind=arg;
enum ADCINDEX iadc=0;
switch (ind) {
@@ -1397,11 +1095,11 @@ int get_adc(int file_des) {
}
#ifdef VERBOSE
- printf("Getting ADC %d of module %d\n", iadc, imod);
+ printf("Getting ADC %d\n", iadc);
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK)
- retval=getADC(iadc,imod);
+ retval=getADC(iadc);
#endif
#ifdef VERBOSE
printf("ADC is %f\n", retval);
@@ -1531,370 +1229,6 @@ int read_register(int file_des) {
-int write_memory(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Write Memory) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-int read_memory(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Read Memory) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-int set_channel(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set channel failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set Channel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- sls_detector_channel myChan;
- n=receiveChannel(file_des, &myChan);
- if (n < 0) return printSocketReadError();
-
- // execute action
-#ifdef VERBOSE
- printf("Setting channel\n");
- printf("channel number is %d, chip number is %d, module number is %d, register is %lld\n", myChan.chan,myChan.chip, myChan.module, myChan.reg);
-#endif
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (myChan.chan>=getNumberOfChannelsPerChip()) {
- ret = FAIL;
- sprintf(mess,"channel number %d too large!\n",myChan.chan);
- cprintf(RED, "Warning: %s", mess);
- }
- else if (myChan.chip>=getNumberOfChipsPerModule()) {
- ret = FAIL;
- sprintf(mess,"chip number %d too large!\n",myChan.chip);
- cprintf(RED, "Warning: %s", mess);
- }
- else if (myChan.module>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"module number %d too large!\n",myChan.module);
- cprintf(RED, "Warning: %s", mess);
- }
- else
- retval=setChannel(myChan);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_channel(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sls_detector_channel retval;
- sprintf(mess,"get channel failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Get Channel) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int ichan=arg[0];
- int ichip=arg[1];
- int imod=arg[2];
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (ichan>=getNumberOfChannelsPerChip()) {
- ret=FAIL;
- sprintf(mess, "channel number %d too large!\n",myChan.chan);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.chan=ichan;
- if (ichip>=getNumberOfChipsPerModule()) {
- ret=FAIL;
- sprintf(mess, "chip number %d too large!\n",myChan.chip);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.chip=ichip;
-
- if (imod>=getTotalNumberOfModules()) {
- ret=FAIL;
- sprintf(mess, "module number %d too large!\n",myChan.module);
- cprintf(RED, "Warning: %s", mess);
- } else {
- retval.module=imod;
- ret=getChannel(&retval);
-#ifdef VERBOSE
- printf("Returning channel %d %d %d, 0x%llx\n", retval.chan, retval.chip, retval.mod, (retval.reg));
-#endif
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- ret=sendChannel(file_des, &retval);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-int set_all_channels(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set All Channels) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-int set_chip(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set chip failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Set Chip) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
- sls_detector_chip myChip;
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- myChip.nchan=getNumberOfChannelsPerChip();
- int *ch(int*)malloc((myChip.nchan)*sizeof(int));
- myChip.chanregs=ch;
-
- // receive arguments
- n=receiveChip(file_des, &myChip);
-#ifdef VERBOSE
- printf("Chip received\n");
-#endif
- if(n < 0) return FAIL;
-
- // execute action
- if (differentClients==1 && lockStatus==1) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
- else{
-#ifdef VERBOSE
- printf("Setting chip\n");
- printf("chip number is %d, module number is %d, register is %d, nchan %d\n",myChip.chip, myChip.module, myChip.reg, myChip.nchan);
-#endif
- if (myChip.chip>=getNumberOfChipsPerModule()) {
- ret = FAIL;
- sprintf(mess,"chip number %d too large!\n",myChan.chip);
- cprintf(RED, "Warning: %s", mess);
- }
- else if (myChip.module>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"module number %d too large!\n",myChan.module);
- cprintf(RED, "Warning: %s", mess);
- }
- else
- retval=setChip(myChip);
- }
- free(ch);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- n += sendData(file_des,&retval,sizeof(retval),INT32);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int get_chip(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sls_detector_chip retval;
- sprintf(mess,"get chip failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Get Chip) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[2]={-1,-1};
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- int ichip=arg[0];
- int imod=arg[1];
-
- // execute action
- if (ichip>=getNumberOfChipsPerModule()) {
- ret = FAIL;
- sprintf(mess,"channel number %d too large!\n",myChan.chan);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.chip=ichip;
-
- if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"module number %d too large!\n",imod);
- cprintf(RED, "Warning: %s", mess);
- } else
- retval.module=imod;
-
- if (ret==OK)
- ret=getChip(&retval);
-#endif
-#ifdef VERBOSE
- printf("Returning chip %d %d\n", ichip, imod);
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret!=FAIL) {
- ret=sendChip(file_des, &retval);
- } else {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-int set_all_chips(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set All Chips) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
int set_module(int file_des) {
int ret=OK,ret1=OK;
int n=0;
@@ -1924,16 +1258,16 @@ int set_module(int file_des) {
int *myChip = NULL;
int *myChan = NULL;
- myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
- if (getNumberOfDACsPerModule() > 0 && myDac == NULL) {
+ myDac=(int*)malloc(getNumberOfDACs()*sizeof(int));
+ if (getNumberOfDACs() > 0 && myDac == NULL) {
ret = FAIL;
sprintf(mess,"could not allocate dacs\n");
cprintf(RED, "Warning: %s", mess);
}
else {
myModule.dacs=myDac;
- myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int));
- if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) {
+ myAdc=(int*)malloc(getNumberOfADCs()*sizeof(int));
+ if (getNumberOfADCs() > 0 && myAdc == NULL) {
ret = FAIL;
sprintf(mess,"could not allocate adcs\n");
cprintf(RED, "Warning: %s", mess);
@@ -1945,16 +1279,16 @@ int set_module(int file_des) {
myModule.chipregs=NULL;
myModule.chanregs=NULL;
#else
- myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
- if (getNumberOfChipsPerModule() > 0 && myChip == NULL) {
+ myChip=(int*)malloc(getNumberOfChips()*sizeof(int));
+ if (getNumberOfChips() > 0 && myChip == NULL) {
ret = FAIL;
sprintf(mess,"could not allocate chips\n");
cprintf(RED, "Warning: %s", mess);
}
else {
myModule.chipregs=myChip;
- myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
- if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) {
+ myChan=(int*)malloc(getTotalNumberOfChannels()*sizeof(int));
+ if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
ret = FAIL;
sprintf(mess,"could not allocate chans\n");
cprintf(RED, "Warning: %s", mess);
@@ -1962,10 +1296,10 @@ int set_module(int file_des) {
else {
myModule.chanregs=myChan;
#endif
- myModule.nchip=getNumberOfChipsPerModule();
- myModule.nchan=getNumberOfChannelsPerModule();
- myModule.ndac=getNumberOfDACsPerModule();
- myModule.nadc=getNumberOfADCsPerModule();
+ myModule.nchip=getNumberOfChips();
+ myModule.nchan=getTotalNumberOfChannels();
+ myModule.ndac=getNumberOfDACs();
+ myModule.nadc=getNumberOfADCs();
// receive arguments
@@ -1981,8 +1315,8 @@ int set_module(int file_des) {
);
if (n<0) return FAIL;
#ifdef VERBOSE
- printf("module number is %d,register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",
- myModule.module, myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset);
+ printf("module number register is %d, nchan %d, nchip %d, ndac %d, nadc %d, gain %f, offset %f\n",
+ myModule.reg, myModule.nchan, myModule.nchip, myModule.ndac, myModule.nadc, myModule.gain,myModule.offset);
#endif
#ifdef EIGERD
n = receiveData(file_des,&myIODelay,sizeof(myIODelay),INT32);
@@ -2006,15 +1340,6 @@ int set_module(int file_des) {
//check settings index
if (ret==OK) {
-#ifdef MYTHEND
- if (myModule.module>=getNModBoard()) {
- ret = FAIL;
- sprintf(mess,"Module Number to Set Module (%d) is too large\n", myModule.module);
- cprintf(RED, "Warning: %s", mess);
- }
- if (myModule.module<0)
- myModule.module=ALLMOD;
-#endif
#if defined(JUNGFRAUD) || defined(EIGERD)
switch(myModule.reg){
case GET_SETTINGS:
@@ -2056,10 +1381,10 @@ int set_module(int file_des) {
ret=setModule(myModule, myIODelay);
//set threshhold
if (myEV >= 0)
- setThresholdEnergy(myEV,-1);
+ setThresholdEnergy(myEV);
else {
//changes settings to undefined (loading a random trim file)
- setSettings(UNDEFINED,-1);
+ setSettings(UNDEFINED);
cprintf(RED,"Settings has been changed to undefined (random trim file)\n");
}
//rate correction
@@ -2124,25 +1449,18 @@ int set_module(int file_des) {
int get_module(int file_des) {
int ret=OK,ret1=OK;
int n=0;
- int arg=-1;
- int imod=-1;
sls_detector_module myModule;
sprintf(mess,"get module failed\n");
#ifdef MYTHEN3D
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Get Module) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
+ //to receive any arguments
+ while (n > 0)
+ n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+ ret = FAIL;
+ sprintf(mess,"Function (Get Module) is not implemented for this detector\n");
+ cprintf(RED, "Warning: %s", mess);
#else
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
- imod=arg;
-
// execute action
#ifdef SLS_DETECTOR_FUNCTION_LIST
int *myDac=NULL;
@@ -2150,64 +1468,56 @@ int get_module(int file_des) {
int *myChip = NULL;
int *myChan = NULL;
- if (imod<0 || imod>getTotalNumberOfModules()) {
+ myDac=(int*)malloc(getNumberOfDACs()*sizeof(int));
+ if (getNumberOfDACs() > 0 && myDac == NULL) {
ret = FAIL;
- sprintf(mess,"Module Index (%d) is out of range\n", imod);
+ sprintf(mess,"could not allocate dacs\n");
cprintf(RED, "Warning: %s", mess);
}
else {
- myDac=(int*)malloc(getNumberOfDACsPerModule()*sizeof(int));
- if (getNumberOfDACsPerModule() > 0 && myDac == NULL) {
+ myModule.dacs=myDac;
+ myAdc=(int*)malloc(getNumberOfADCs()*sizeof(int));
+ if (getNumberOfADCs() > 0 && myAdc == NULL) {
ret = FAIL;
- sprintf(mess,"could not allocate dacs\n");
+ sprintf(mess,"could not allocate adcs\n");
cprintf(RED, "Warning: %s", mess);
}
else {
- myModule.dacs=myDac;
- myAdc=(int*)malloc(getNumberOfADCsPerModule()*sizeof(int));
- if (getNumberOfADCsPerModule() > 0 && myAdc == NULL) {
+ myModule.adcs=myAdc;
+ //no chips and chans allocated for jungfrau, too much memory
+#ifdef JUNGFRAUD
+ myModule.chipregs=NULL;
+ myModule.chanregs=NULL;
+#else
+ myChip=(int*)malloc(getNumberOfChips()*sizeof(int));
+ if (getNumberOfChips() > 0 && myChip == NULL) {
ret = FAIL;
- sprintf(mess,"could not allocate adcs\n");
+ sprintf(mess,"could not allocate chips\n");
cprintf(RED, "Warning: %s", mess);
}
else {
- myModule.adcs=myAdc;
- //no chips and chans allocated for jungfrau, too much memory
-#ifdef JUNGFRAUD
- myModule.chipregs=NULL;
- myModule.chanregs=NULL;
-#else
- myChip=(int*)malloc(getNumberOfChipsPerModule()*sizeof(int));
- if (getNumberOfChipsPerModule() > 0 && myChip == NULL) {
+ myModule.chipregs=myChip;
+ myChan=(int*)malloc(getTotalNumberOfChannels()*sizeof(int));
+ if (getTotalNumberOfChannels() > 0 && myChan == NULL) {
ret = FAIL;
- sprintf(mess,"could not allocate chips\n");
+ sprintf(mess,"could not allocate chans\n");
cprintf(RED, "Warning: %s", mess);
}
else {
- myModule.chipregs=myChip;
- myChan=(int*)malloc(getNumberOfChannelsPerModule()*sizeof(int));
- if (getNumberOfChannelsPerModule() > 0 && myChan == NULL) {
- ret = FAIL;
- sprintf(mess,"could not allocate chans\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
- myModule.chanregs=myChan;
+ myModule.chanregs=myChan;
#endif
- myModule.nchip=getNumberOfChipsPerModule();
- myModule.nchan=getNumberOfChannelsPerModule();
- myModule.ndac=getNumberOfDACsPerModule();
- myModule.nadc=getNumberOfADCsPerModule();
- myModule.module=imod;
- getModule(&myModule);
+ myModule.nchip=getNumberOfChips();
+ myModule.nchan=getTotalNumberOfChannels();
+ myModule.ndac=getNumberOfDACs();
+ myModule.nadc=getNumberOfADCs();
+ getModule(&myModule);
#ifdef VERBOSE
- printf("Returning module %d of register %x\n", imod, myModule.reg);
+ printf("Returning module of register %x\n", myModule.reg);
#endif
#ifndef JUNGFRAUD
- }
}
-#endif
}
+#endif
}
}
#endif
@@ -2246,32 +1556,14 @@ int get_module(int file_des) {
-int set_all_modules(int file_des) {
- int ret=FAIL,ret1=FAIL;
- int n=0;
- sprintf(mess,"Function (Set All Modules) is not implemented for this detector\n");
- cprintf(RED, "Error: %s", mess);
-
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- n = sendData(file_des,mess,MAX_STR_LENGTH,OTHER);
-
- // return ok / fail
- return ret;
-}
-
int set_settings(int file_des) {
int ret=OK,ret1=OK;
int n=0;
- int arg[2]={-1,-1};
+ int arg=-1;
int retval=-1;
- int imod=-1;
enum detectorSettings isett=-1;
sprintf(mess,"set settings failed\n");
@@ -2287,8 +1579,7 @@ int set_settings(int file_des) {
// receive arguments
n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
- isett=arg[0];
- imod=arg[1];
+ isett=arg;
// execute action
if (differentClients && lockStatus && isett!=GET_SETTINGS) {
@@ -2298,13 +1589,6 @@ int set_settings(int file_des) {
}
#ifdef SLS_DETECTOR_FUNCTION_LIST
-#ifdef MYTHEND
- if ( (ret != FAIL) && (imod>=getTotalNumberOfModules())) {
- ret = FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
switch(isett) {
case GET_SETTINGS:
case UNINITIALIZED:
@@ -2341,9 +1625,9 @@ int set_settings(int file_des) {
if (ret != FAIL) {
#ifdef VERBOSE
- printf("Changing settings of module %d to %d\n", imod, isett);
+ printf("Changing settings to %d\n", isett);
#endif
- retval=setSettings(isett, imod);
+ retval=setSettings(isett);
#ifdef VERBOSE
printf("Settings changed to %d\n", isett);
#endif
@@ -2351,7 +1635,7 @@ int set_settings(int file_des) {
ret=OK;
} else {
ret = FAIL;
- sprintf(mess,"Changing settings of module %d: wrote %d but read %d\n", imod, isett, retval);
+ sprintf(mess,"Changing settings : wrote %d but read %d\n", isett, retval);
cprintf(RED, "Warning: %s", mess);
}
}
@@ -2396,35 +1680,21 @@ int get_threshold_energy(int file_des) {
int retval=-1;
sprintf(mess,"get threshold energy failed\n");
-#if !defined(MYTHEND) && !defined(EIGERD)
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
+#ifndef EIGERD
ret = FAIL;
sprintf(mess,"Function (Get Threshold Energy) is not implemented for this detector\n");
cprintf(RED, "Warning: %s", mess);
#else
- // receive arguments
- int imod=-1;
- n = receiveData(file_des,&imod,sizeof(imod),INT32);
- if (n < 0) return printSocketReadError();
-
// execute action
#ifdef VERBOSE
- printf("Getting threshold energy of module %d\n", imod);
+ printf("Getting threshold energy \n");
#endif
#ifdef SLS_DETECTOR_FUNCTION_LIST
- if (imod>=getTotalNumberOfModules()) {
- ret=FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- }
- else {
- retval=getThresholdEnergy(imod);
+ retval=getThresholdEnergy();
#ifdef VERBOSE
printf("Threshold is %d eV\n", retval);
#endif
- }
#endif
if (ret==OK && differentClients)
ret=FORCE_UPDATE;
@@ -2447,75 +1717,6 @@ int get_threshold_energy(int file_des) {
-int set_threshold_energy(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- int retval=-1;
- sprintf(mess,"set thhreshold energy failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
-#ifdef EIGERD
- sprintf(mess,"Function (Set Threshold Energy) is only implemented via Set Settings for this detector\n");
-#else
- sprintf(mess,"Function (Set Threshold Energy) is not implemented for this detector\n");
-#endif
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // receive arguments
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int ethr=arg[0];
- int imod=arg[1];
- enum detectorSettings isett=arg[2];
- if (differentClients && lockStatus) {
- ret=FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (imod>=getTotalNumberOfModules()) {
- ret=FAIL;
- sprintf(mess,"Module number %d out of range\n",imod);
- }
- else {
- printf("Setting threshold energy of module %d to %d eV with settings %d\n", imod, ethr, isett);
- retval=setThresholdEnergy(ethr, imod);
-#ifdef VERBOSE
- printf("Threshold set to %d eV\n", retval);
-#endif
- if (retval!=ethr) {
- ret=FAIL;
- sprintf(mess,"Setting threshold of module %d: wrote %d but read %d\n", imod, ethr, retval);
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
int start_acquisition(int file_des) {
@@ -2701,10 +1902,10 @@ int start_and_read_all(int file_des) {
-int read_frame(int file_des) {
+int read_all(int file_des) {
int dataret1=FAIL, dataret=FAIL;
int n=0;
- sprintf(mess, "read frame failed\n");
+ sprintf(mess, "read all frame failed\n");
// execute action
if (differentClients && lockStatus) {
@@ -2746,22 +1947,6 @@ int read_frame(int file_des) {
-int read_all(int file_des) {
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- while(read_frame(file_des)==OK) {
-#ifdef VERBOSE
- printf("frame read\n");
-#endif
- ;
- }
-#endif
-#ifdef VERBOSE
- printf("Frames finished or failed\n");
-#endif
- return OK;
-}
-
-
int set_timer(int file_des) {
@@ -2826,11 +2011,7 @@ int set_timer(int file_des) {
retval = setTimer(ind,tns);
break;
#endif
-#ifdef MYTHEN
- case PROBES_NUMBER:
- case GATES_NUMBER:
- case DELAY_AFTER_TRIGGER:
-#elif JUNGFRAUD
+#ifdef JUNGFRAUD
case DELAY_AFTER_TRIGGER:
#elif MYTHEN3D
case DELAY_AFTER_TRIGGER:
@@ -2851,17 +2032,6 @@ int set_timer(int file_des) {
break;
}
-
-#if defined(MYTHEND) || defined(GOTTHARD)
- if (ret == OK && ind==FRAME_NUMBER) {
- ret=allocateRAM();
- if (ret!=OK) {
- ret = FAIL;
- sprintf(mess,"Could not allocate RAM for %lld frames\n", tns);
- cprintf(RED, "%s", mess);
- }
- }
-#endif
}
#endif
if (ret==OK && differentClients)
@@ -2918,8 +2088,6 @@ int get_time_left(int file_des) {
#ifdef EIGERD
case MEASURED_PERIOD:
case MEASURED_SUBPERIOD:
-#elif MYTHEND
- case PROBES_NUMBER:
#elif JUNGFRAUD
case FRAMES_FROM_START:
case FRAMES_FROM_START_PG:
@@ -3086,7 +2254,7 @@ int set_readout_flags(int file_des) {
enum readOutFlags retval=-1;
sprintf(mess,"set readout flags failed\n");
-#if !defined(MYTHEND) && !defined(EIGERD)
+#ifndef EIGERD
//to receive any arguments
while (n > 0)
n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
@@ -3113,12 +2281,7 @@ int set_readout_flags(int file_des) {
#endif
switch(arg) {
case GET_READOUT_FLAGS:
-#ifdef MYTHEND
- case TOT_MODE:
- case NORMAL_READOUT:
- case STORE_IN_RAM:
- case CONTINOUS_RO:
-#elif EIGERD
+#ifdef EIGERD
case STORE_IN_RAM:
case CONTINOUS_RO:
case PARALLEL:
@@ -3303,13 +2466,7 @@ int set_speed(int file_des) {
}
break;
#endif
-#ifdef MYTHEND
- case CLOCK_DIVIDER:
- case WAIT_STATES:
- case SET_SIGNAL_LENGTH:
- case TOT_CLOCK_DIVIDER:
- case TOT_DUTY_CYCLE:
-#elif EIGERD
+#ifdef EIGERD
case CLOCK_DIVIDER:
#elif JUNGFRAUD
case CLOCK_DIVIDER:
@@ -3353,92 +2510,6 @@ int set_speed(int file_des) {
-int execute_trimming(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- sprintf(mess,"execute trimming failed\n");
-
-#ifndef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Execute Trimming) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- int retval=-1;
-
- // receive arguments
- enum trimMode mode=0;
- int arg[3]={-1,-1,-1};
- n = receiveData(file_des,&mode,sizeof(mode),INT32);
- if (n < 0) return printSocketReadError();
-
- n = receiveData(file_des,arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- int imod, par1,par2;
- imod=arg[0];
- par1=arg[1];
- par2=arg[2];
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else if (imod>=getTotalNumberOfModules()) {
- ret = FAIL;
- sprintf(mess,"Module Number (%d) is out of range\n");
- cprintf(RED, "Warning: %s", mess);
- }
- else {
-#ifdef VERBOSE
- printf("trimming module %d mode %d, parameters %d %d \n",imod,mode, par1, par2);
-#endif
- switch(mode) {
- case NOISE_TRIMMING:
- case BEAM_TRIMMING:
- case IMPROVE_TRIMMING:
- case FIXEDSETTINGS_TRIMMING:
- retval=executeTrimming(mode, par1, par2, imod);
- if ((ret!=OK) && (retval>0)) {
- ret=FAIL;
- sprintf(mess,"Could not trim %d channels\n", retval);
- cprintf(RED, "Warning: %s", mess);
- }
- break;
- default:
- ret = FAIL;
- sprintf(mess,"Trimming Mode (%d) is not implemented for this detector\n", (int) mode);
- cprintf(RED, "Warning: %s", mess);
- break;
- }
-
- }
-#endif
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
-
-
-
int exit_server(int file_des) {
int ret=FAIL;
@@ -3594,20 +2665,6 @@ int send_update(int file_des) {
if (n < 0) return printSocketReadError();
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- nm=setNMod(GET_FLAG,X);
-#endif
- n = sendData(file_des,&nm,sizeof(nm),INT32);
- if (n < 0) return printSocketReadError();
-
-
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- nm=setNMod(GET_FLAG,Y);
-#endif
- n = sendData(file_des,&nm,sizeof(nm),INT32);
- if (n < 0) return printSocketReadError();
-
-
#ifdef SLS_DETECTOR_FUNCTION_LIST
nm=setDynamicRange(GET_FLAG);
#endif
@@ -3623,13 +2680,13 @@ int send_update(int file_des) {
#ifdef SLS_DETECTOR_FUNCTION_LIST
- t=setSettings(GET_SETTINGS, GET_FLAG);
+ t=setSettings(GET_SETTINGS);
#endif
n = sendData(file_des,&t,sizeof(t),INT32);
if (n < 0) return printSocketReadError();
-#if defined(MYTHEND) || defined(EIGERD)
+#ifdef EIGERD
#ifdef SLS_DETECTOR_FUNCTION_LIST
nm=getThresholdEnergy(GET_FLAG);
#endif
@@ -3692,15 +2749,6 @@ int send_update(int file_des) {
#endif
-#ifdef MYTHEND
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- retval=setTimer(PROBES_NUMBER,GET_FLAG);
-#endif
- n = sendData(file_des,&retval,sizeof(int64_t),INT64);
- if (n < 0) return printSocketReadError();
-#endif
-
-
#ifdef SLS_DETECTOR_FUNCTION_LIST
retval=setTimer(CYCLES_NUMBER,GET_FLAG);
#endif
@@ -3726,15 +2774,6 @@ int configure_mac(int file_des) {
int retval=-100;
sprintf(mess,"configure mac failed\n");
-#ifdef MYTHEND
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- strcpy(mess,"Function (Configure MAC) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
// receive arguments
char arg[6][50];
memset(arg,0,sizeof(arg));
@@ -3790,7 +2829,7 @@ int configure_mac(int file_des) {
printf("detipad %x\n",detipad);
printf("udp port2:0x%x\n",udpport2);
printf("\n");
- printf("Configuring MAC of module %d at port %x\n", imod, udpport);
+ printf("Configuring MAC at port %x\n", udpport);
#if defined(JUNGFRAUD) || defined(EIGERD)
printf("Position: [%d,%d,%d]\n", pos[0],pos[1],pos[2]);
@@ -3855,7 +2894,7 @@ int configure_mac(int file_des) {
#endif
if (differentClients)
ret=FORCE_UPDATE;
-#endif
+
// ret could be swapped during sendData
ret1 = ret;
@@ -3960,105 +2999,6 @@ int load_image(int file_des) {
-int set_master(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum masterFlags arg=GET_MASTER;
- enum masterFlags retval=GET_MASTER;
- sprintf(mess,"set master failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && ((int)arg!=(int)GET_MASTER)) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting master flags to %d\n",arg);
-#endif
- retval=setMaster(arg);
- if (retval==GET_MASTER)
- ret=FAIL;
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
-
-
-
-int set_synchronization(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- enum synchronizationMode arg=GET_SYNCHRONIZATION_MODE;
- enum synchronizationMode retval=GET_SYNCHRONIZATION_MODE;
- sprintf(mess,"synchronization mode failed\n");
-
- // receive arguments
- n = receiveData(file_des,&arg,sizeof(arg),INT32);
- if (n < 0) return printSocketReadError();
-
- // execute action
- if (differentClients && lockStatus && ((int)arg!=(int)GET_SYNCHRONIZATION_MODE)) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {
-#ifdef VERBOSE
- printf("setting master flags to %d\n",arg);
-#endif
- retval=setSynchronization(arg);
- if (retval==GET_SYNCHRONIZATION_MODE)
- ret=FAIL;
-
- if (ret==OK && differentClients)
- ret=FORCE_UPDATE;
- }
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- } else
- n += sendData(file_des,&retval,sizeof(retval),INT32);
-
- // return ok / fail
- return ret;
-}
-
-
-
-
int read_counter_block(int file_des) {
int ret=OK,ret1=OK;
@@ -4335,7 +3275,7 @@ int set_all_trimbits(int file_des){
if(arg >= 0){
ret = setAllTrimbits(arg);
//changes settings to undefined
- setSettings(UNDEFINED,-1);
+ setSettings(UNDEFINED);
cprintf(RED,"Settings has been changed to undefined (change all trimbits)\n");
}
retval = getAllTrimbits();
@@ -4864,7 +3804,7 @@ int set_rate_correct(int file_des) {
tau_ns = getDefaultSettingsTau_in_nsec();
else if(tau_ns > 0){
//changing tau to a user defined value changes settings to undefined
- setSettings(UNDEFINED,-1);
+ setSettings(UNDEFINED);
cprintf(RED,"Settings has been changed to undefined (tau changed)\n");
}
@@ -5419,50 +4359,6 @@ int prepare_acquisition(int file_des) {
}
-int cleanup_acquisition(int file_des) {
- int ret=OK,ret1=OK;
- int n=0;
- strcpy(mess,"prepare acquisition failed\n");
-
-#ifndef GOTTHARDD
- //to receive any arguments
- while (n > 0)
- n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER);
- ret = FAIL;
- sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
-#else
-
- // execute action
- if (differentClients && lockStatus) {
- ret = FAIL;
- sprintf(mess,"Detector locked by %s\n",lastClientIP);
- cprintf(RED, "Warning: %s", mess);
- }
-#ifdef SLS_DETECTOR_FUNCTION_LIST
- else {//to be implemented when used here
- ret = FAIL;
- sprintf(mess,"Function (Cleanup Acquisition) is not implemented for this detector\n");
- cprintf(RED, "Warning: %s", mess);
- }
-#endif
- if(ret==OK && differentClients)
- ret=FORCE_UPDATE;
-#endif
-
- // ret could be swapped during sendData
- ret1 = ret;
- // send ok / fail
- n = sendData(file_des,&ret1,sizeof(ret),INT32);
- // send return argument
- if (ret==FAIL) {
- n += sendData(file_des,mess,sizeof(mess),OTHER);
- }
-
- // return ok / fail
- return ret;
-}
-
@@ -5480,14 +4376,14 @@ int threshold_temp(int file_des) {
sprintf(mess,"Function (Threshold Temp) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
- int arg[2]={-1,-1};
+ int arg=-1;
int val=-1;
// receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
+ n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
- val=arg[0];
- //ignoring imod
+
+ val=arg;
if (val > MAX_THRESHOLD_TEMP_VAL) {
ret=FAIL;
sprintf(mess,"Threshold Temp %d should be in range: 0 - %d\n", val, MAX_THRESHOLD_TEMP_VAL);
@@ -5542,15 +4438,13 @@ int temp_control(int file_des) {
sprintf(mess,"Function (Temperature control) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
- int arg[2]={-1,-1};
+ int arg=-1;
int val=-1;
// receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
+ n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
- val=arg[0];
- //ignoring imod
-
+ val=arg;
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
@@ -5599,14 +4493,13 @@ int temp_event(int file_des) {
sprintf(mess,"Function (Temperature Event) is not implemented for this detector\n");
cprintf(RED, "%s", mess);
#else
- int arg[2]={-1,-1};
+ int arg=-1;
int val=-1;
// receive arguments
- n = receiveData(file_des,arg,sizeof(arg),INT32);
+ n = receiveData(file_des,&arg,sizeof(arg),INT32);
if (n < 0) return printSocketReadError();
- val=arg[0];
- //ignoring imod
+ val=arg;
#ifdef SLS_DETECTOR_FUNCTION_LIST
if (ret==OK) {
diff --git a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h
index a4bbaeb64..7722bbe7b 100755
--- a/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h
+++ b/slsDetectorSoftware/slsDetectorServers/slsDetectorServer/slsDetectorServer_funcs.h
@@ -17,41 +17,24 @@ int M_nofuncMode(int);
// functions called by client
int exec_command(int);
-int get_error(int);
int get_detector_type(int);
-int set_number_of_modules(int);
-int get_max_number_of_modules(int);
int set_external_signal_flag(int);
int set_external_communication_mode(int);
int get_id(int);
int digital_test(int);
-int analog_test(int);
-int enable_analog_out(int);
-int calibration_pulse(int);
int set_dac(int);
int get_adc(int);
int write_register(int);
int read_register(int);
-int write_memory(int);
-int read_memory(int);
-int set_channel(int);
-int get_channel(int);
-int set_all_channels(int);
-int set_chip(int);
-int get_chip(int);
-int set_all_chips(int);
int set_module(int);
int get_module(int);
-int set_all_modules(int);
int set_settings(int);
int get_threshold_energy(int);
-int set_threshold_energy(int);
int start_acquisition(int);
int stop_acquisition(int);
int start_readout(int);
int get_run_status(int);
int start_and_read_all(int);
-int read_frame(int);
int read_all(int);
int set_timer(int);
int get_time_left(int);
@@ -59,7 +42,6 @@ int set_dynamic_range(int);
int set_readout_flags(int);
int set_roi(int);
int set_speed(int);
-int execute_trimming(int);
int exit_server(int);
int lock_server(int);
int get_last_client_ip(int);
@@ -68,8 +50,6 @@ int update_client(int);
int send_update(int);
int configure_mac(int);
int load_image(int);
-int set_master(int);
-int set_synchronization(int);
int read_counter_block(int);
int reset_counter_block(int);
int calibrate_pedestal(int);
@@ -89,7 +69,6 @@ int reset_fpga(int);
int power_chip(int);
int set_activate(int);
int prepare_acquisition(int);
-int cleanup_acquisition(int);
int threshold_temp(int);
int temp_control(int);
int temp_event(int);
diff --git a/slsSupportLib/include/communication_funcs.c b/slsSupportLib/include/communication_funcs.c
index 487b2c66e..2954b895d 100755
--- a/slsSupportLib/include/communication_funcs.c
+++ b/slsSupportLib/include/communication_funcs.c
@@ -361,40 +361,6 @@ int receiveData(int file_des, void* buf,int length, intType itype){
-
-
-
-
-
-
-
-
-
-
-
-int sendChannel(int file_des, sls_detector_channel *myChan) {
- int ts=0;
- //sendDataOnly(file_des,myChan, sizeof(sls_detector_channel));
- ts+=sendData(file_des,&(myChan->chan),sizeof(myChan->chan),INT32);
- ts+=sendData(file_des,&(myChan->chip),sizeof(myChan->chip),INT32);
- ts+=sendData(file_des,&(myChan->module),sizeof(myChan->module),INT32);
- ts+=sendData(file_des,&(myChan->reg),sizeof(myChan->reg),INT64);
- return ts;
-}
-
-int sendChip(int file_des, sls_detector_chip *myChip) {
- int ts=0;
- //ts+=sendDataOnly(file_des,myChip,sizeof(sls_detector_chip));
- ts+=sendData(file_des,&(myChip->chip),sizeof(myChip->chip),INT32);
- ts+=sendData(file_des,&(myChip->module),sizeof(myChip->module),INT32);
- ts+=sendData(file_des,&(myChip->nchan),sizeof(myChip->nchan),INT32);
- ts+=sendData(file_des,&(myChip->reg),sizeof(myChip->reg),INT32);
- ts+=sendData(file_des,(myChip->chanregs),sizeof(myChip->chanregs),INT32);
- ts+=sendData(file_des,myChip->chanregs,myChip->nchan*sizeof(int),INT32);
- return ts;
-}
-
-
int sendModule(int file_des, sls_detector_module *myMod) {
return sendModuleGeneral(file_des, myMod, 1);
}
@@ -410,7 +376,6 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
int nAdcs=myMod->nadc;
int nDacs=myMod->ndac;
//ts+= sendDataOnly(file_des,myMod,sizeof(sls_detector_module));
- ts+=sendData(file_des,&(myMod->module),sizeof(myMod->module),INT32);
ts+=sendData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32);
ts+=sendData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32);
ts+=sendData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32);
@@ -429,90 +394,38 @@ int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll) {
ts+=sendData(file_des,&(myMod->offset), sizeof(myMod->offset),OTHER);
#ifdef VERBOSE
- printf("module %d of size %d sent\n",myMod->module, ts);
+ printf("module of size %d sent\n",ts);
#endif
- ts+= sendData(file_des,myMod->dacs,sizeof(dacs_t)*nDacs,INT32);
+ ts+= sendData(file_des,myMod->dacs,sizeof(int)*nDacs,INT32);
#ifdef VERBOSE
- printf("dacs %d of size %d sent\n",myMod->module, ts);
+ printf("dacs of size %d sent\n",ts);
int idac;
for (idac=0; idac< nDacs; idac++)
printf("dac %d is %d\n",idac,(int)myMod->dacs[idac]);
#endif
- ts+= sendData(file_des,myMod->adcs,sizeof(dacs_t)*nAdcs,INT32);
+ ts+= sendData(file_des,myMod->adcs,sizeof(int)*nAdcs,INT32);
#ifdef VERBOSE
- printf("adcs %d of size %d sent\n",myMod->module, ts);
+ printf("adcs of size %d sent\n", ts);
#endif
/*some detectors dont require sending all trimbits etc.*/
if(sendAll){
ts+=sendData(file_des,myMod->chipregs,sizeof(int)*nChips,INT32);
#ifdef VERBOSE
- printf("chips %d of size %d sent\n",myMod->module, ts);
+ printf("chips of size %d sent\n", ts);
#endif
ts+=sendData(file_des,myMod->chanregs,sizeof(int)*nChans,INT32);
#ifdef VERBOSE
- printf("chans %d of size %d sent - %d\n",myMod->module, ts, myMod->nchan);
+ printf("chans of size %d sent - %d\n", ts, myMod->nchan);
#endif
}
#ifdef VERBOSE
- printf("module %d of size %d sent register %x\n",myMod->module, ts, myMod->reg);
+ printf("module of size %d sent register %x\n", ts, myMod->reg);
#endif
return ts;
}
-int receiveChannel(int file_des, sls_detector_channel *myChan) {
- int ts=0;
- //receiveDataOnly(file_des,myChan,sizeof(sls_detector_channel));
- ts+=receiveData(file_des,&(myChan->chan),sizeof(myChan->chan),INT32);
- ts+=receiveData(file_des,&(myChan->chip),sizeof(myChan->chip),INT32);
- ts+=receiveData(file_des,&(myChan->module),sizeof(myChan->module),INT32);
- ts+=receiveData(file_des,&(myChan->reg),sizeof(myChan->reg),INT32);
- return ts;
-}
-
-int receiveChip(int file_des, sls_detector_chip* myChip) {
-
- int *ptr=myChip->chanregs;
- int ts=0;
- int nChans, nchanold=myChip->nchan, chdiff;
-
- //ts+= receiveDataOnly(file_des,myChip,sizeof(sls_detector_chip));
- ts+=receiveData(file_des,&(myChip->chip),sizeof(myChip->chip),INT32);
- ts+=receiveData(file_des,&(myChip->module),sizeof(myChip->module),INT32);
- ts+=receiveData(file_des,&(myChip->nchan),sizeof(myChip->nchan),INT32);
- ts+=receiveData(file_des,&(myChip->reg),sizeof(myChip->reg),INT32);
- ts+=receiveData(file_des,(myChip->chanregs),sizeof(myChip->chanregs),INT32);
-
- myChip->chanregs=ptr;
- nChans=myChip->nchan;
- chdiff=nChans-nchanold;
- if (nchanold!=nChans) {
- printf("wrong number of channels received!\n");
- }
-
-
-#ifdef VERBOSE
- printf("chip structure received\n");
- printf("now receiving %d channels\n", nChans);
-#endif
-
- if (chdiff<=0)
- ts+=receiveData(file_des,myChip->chanregs, sizeof(int)*nChans,INT32);
- else {
- ptr=(int*)malloc(chdiff*sizeof(int));
- myChip->nchan=nchanold;
- ts+=receiveData(file_des,myChip->chanregs, sizeof(int)*nchanold,INT32);
- ts+=receiveData(file_des,ptr, sizeof(int)*chdiff,INT32);
- free(ptr);
- return FAIL;
- }
-
-#ifdef VERBOSE
- printf("chip's channels received\n");
-#endif
- return ts;
-}
int receiveModule(int file_des, sls_detector_module* myMod) {
@@ -521,8 +434,8 @@ int receiveModule(int file_des, sls_detector_module* myMod) {
int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll) {
int ts=0;
- dacs_t *dacptr=myMod->dacs;
- dacs_t *adcptr=myMod->adcs;
+ int *dacptr=myMod->dacs;
+ int *adcptr=myMod->adcs;
int *chipptr=myMod->chipregs, *chanptr=myMod->chanregs;
int nChips, nchipold=myMod->nchip, nchipdiff;
int nChans, nchanold=myMod->nchan, nchandiff;
@@ -532,7 +445,6 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
int id=0;
#endif
// ts+= receiveDataOnly(file_des,myMod,sizeof(sls_detector_module));
- ts+=receiveData(file_des,&(myMod->module),sizeof(myMod->module),INT32);
ts+=receiveData(file_des,&(myMod->serialnumber),sizeof(myMod->serialnumber),INT32);
ts+=receiveData(file_des,&(myMod->nchan),sizeof(myMod->nchan),INT32);
ts+=receiveData(file_des,&(myMod->nchip),sizeof(myMod->nchip),INT32);
@@ -604,7 +516,7 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
printf("received %d adcs\n",nAdcs);
#endif
if (ndacdiff<=0) {
- ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*nDacs,INT32);
+ ts+=receiveData(file_des,myMod->dacs, sizeof(int)*nDacs,INT32);
#ifdef VERBOSE
printf("dacs received\n");
int id;
@@ -614,24 +526,24 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
#endif
} else {
- dacptr=(dacs_t*)malloc(ndacdiff*sizeof(dacs_t));
+ dacptr=(int*)malloc(ndacdiff*sizeof(int));
myMod->ndac=ndold;
- ts+=receiveData(file_des,myMod->dacs, sizeof(dacs_t)*ndold,INT32);
- ts+=receiveData(file_des,dacptr, sizeof(dacs_t)*ndacdiff,INT32);
+ ts+=receiveData(file_des,myMod->dacs, sizeof(int)*ndold,INT32);
+ ts+=receiveData(file_des,dacptr, sizeof(int)*ndacdiff,INT32);
free(dacptr);
return FAIL;
}
if (nadcdiff<=0) {
- ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*nAdcs,INT32);
+ ts+=receiveData(file_des,myMod->adcs, sizeof(int)*nAdcs,INT32);
#ifdef VERBOSE
printf("adcs received\n");
#endif
} else {
- adcptr=(dacs_t*)malloc(nadcdiff*sizeof(dacs_t));
+ adcptr=(int*)malloc(nadcdiff*sizeof(int));
myMod->nadc=naold;
- ts+=receiveData(file_des,myMod->adcs, sizeof(dacs_t)*naold,INT32);
- ts+=receiveData(file_des,adcptr, sizeof(dacs_t)*nadcdiff,INT32);
+ ts+=receiveData(file_des,myMod->adcs, sizeof(int)*naold,INT32);
+ ts+=receiveData(file_des,adcptr, sizeof(int)*nadcdiff,INT32);
free(adcptr);
return FAIL;
}
@@ -669,7 +581,7 @@ int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveA
}
}
#ifdef VERBOSE
- printf("received module %d of size %d register %x\n",myMod->module,ts,myMod->reg);
+ printf("received module of size %d register %x\n",ts,myMod->reg);
#endif
return ts;
diff --git a/slsSupportLib/include/communication_funcs.h b/slsSupportLib/include/communication_funcs.h
index e4e3fac27..4d41098cd 100755
--- a/slsSupportLib/include/communication_funcs.h
+++ b/slsSupportLib/include/communication_funcs.h
@@ -39,12 +39,8 @@ int receiveDataOnly(int file_des, void* buf,int length);
int getServerError(int socketDescriptor);
-int sendChannel(int file_des, sls_detector_channel *myChan);
-int sendChip(int file_des, sls_detector_chip *myChip);
int sendModule(int file_des, sls_detector_module *myMod);
int sendModuleGeneral(int file_des, sls_detector_module *myMod, int sendAll);
-int receiveChannel(int file_des, sls_detector_channel *myChan);
-int receiveChip(int file_des, sls_detector_chip* myChip);
int receiveModule(int file_des, sls_detector_module* myMod);
int receiveModuleGeneral(int file_des, sls_detector_module* myMod, int receiveAll);
diff --git a/slsSupportLib/include/sls_detector_defs.h b/slsSupportLib/include/sls_detector_defs.h
index a6f21665a..876da5437 100755
--- a/slsSupportLib/include/sls_detector_defs.h
+++ b/slsSupportLib/include/sls_detector_defs.h
@@ -213,11 +213,8 @@ enum idMode{
detector digital test modes
*/
enum digitalTestMode {
- CHIP_TEST, /**< test chips */
- MODULE_FIRMWARE_TEST, /**< test module firmware */
DETECTOR_FIRMWARE_TEST, /**< test detector system firmware */
- DETECTOR_MEMORY_TEST, /**< test detector system memory */
- DETECTOR_SOFTWARE_TEST, /**< test detector system software */
+ DETECTOR_BUS_TEST, /**< test detector system CPU-FPGA bus */
DIGITAL_BIT_TEST /**< gotthard digital bit test */
};
diff --git a/slsSupportLib/include/sls_detector_funcs.h b/slsSupportLib/include/sls_detector_funcs.h
index 0a0022f04..648622b81 100644
--- a/slsSupportLib/include/sls_detector_funcs.h
+++ b/slsSupportLib/include/sls_detector_funcs.h
@@ -9,118 +9,65 @@
#define SLS_DETECTOR_FUNCS_H
enum detFuncs{
-
- // General purpose functions
F_EXEC_COMMAND=0, /**< command is executed */
- F_GET_ERROR, /**< return detector error status */
-
- // configuration functions
F_GET_DETECTOR_TYPE, /**< return detector type */
- F_SET_NUMBER_OF_MODULES, /**< set/get number of installed modules */
- F_GET_MAX_NUMBER_OF_MODULES, /**< get maximum number of installed modules */
F_SET_EXTERNAL_SIGNAL_FLAG, /**< set/get flag for external signal */
F_SET_EXTERNAL_COMMUNICATION_MODE, /**< set/get external communication mode (obsolete) */
-
- // Tests and identification
F_GET_ID, /**< get detector id of version */
F_DIGITAL_TEST, /**< digital test of the detector */
- F_ANALOG_TEST, /**