mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 21:37:13 +02:00
modified the server so that it has a firmware class as well to read/write fpga
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@435 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -1,18 +1,80 @@
|
||||
//#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int initializeDetector(int b){
|
||||
//template initDetector from mcb_funcs.c and init_detector from server_funcs.c
|
||||
|
||||
//mapCSP0(); //from firmware_funcs.c
|
||||
//call testFpga(); //from firmware_funcs.c
|
||||
//memory allocation for detectorModules, chips, chans, dacs etc //from firmware_funcs.c
|
||||
//set dr, nmod //from firmware_funcs.c
|
||||
//set settings(GET_SETTINGS); //from mcb_funcs.c
|
||||
//call testRAM() //from firmware_funcs.c
|
||||
//call setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
//call setMaster(GET_MASTER);
|
||||
//call setSynchronization(GET_SYNCHRONIZATION_MODE);
|
||||
|
||||
extern int nModX;
|
||||
extern int nModBoard;
|
||||
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;
|
||||
dacs_t *detectorDacs=NULL;
|
||||
dacs_t *detectorAdcs=NULL;
|
||||
|
||||
|
||||
int initializeDetector(){
|
||||
|
||||
int imod;
|
||||
|
||||
int n=getNModBoard(X)*getNModBoard(Y);
|
||||
/*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; imod<n; imod++) {
|
||||
(detectorModules+imod)->dacs=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;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -30,183 +92,6 @@ int getNModBoard(enum dimension arg){
|
||||
|
||||
|
||||
|
||||
enum externalSignalFlag getExtSignal(int signalindex){
|
||||
//template getExtSignal from firmware_funcs.c
|
||||
//return signals[signalindex];
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag){
|
||||
//template setExtSignal from firmware_funcs.c
|
||||
|
||||
//in short..sets signals array, checks if agrees with timing mode, writes to fpga reg, calls synchronization and then settiming
|
||||
/*
|
||||
if (signalindex>=0 && signalindex<4) {
|
||||
signals[signalindex]=flag;
|
||||
#ifdef VERBOSE
|
||||
printf("settings signal variable number %d to value %04x\n", signalindex, signals[signalindex]);
|
||||
#endif
|
||||
// if output signal, set it!
|
||||
switch (flag) {
|
||||
case GATE_IN_ACTIVE_HIGH:
|
||||
case GATE_IN_ACTIVE_LOW:
|
||||
if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)//timingMode = AUTO_TIMING by default and is set in setTiming()
|
||||
setFPGASignal(signalindex,flag); //not implemented here, checks if flag within limits and writes to fpga reg
|
||||
else
|
||||
setFPGASignal(signalindex,SIGNAL_OFF);
|
||||
break;
|
||||
case TRIGGER_IN_RISING_EDGE:
|
||||
case TRIGGER_IN_FALLING_EDGE:
|
||||
if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER)
|
||||
setFPGASignal(signalindex,flag);
|
||||
else
|
||||
setFPGASignal(signalindex,SIGNAL_OFF);
|
||||
break;
|
||||
case RO_TRIGGER_IN_RISING_EDGE:
|
||||
case RO_TRIGGER_IN_FALLING_EDGE:
|
||||
if (timingMode==TRIGGER_READOUT)
|
||||
setFPGASignal(signalindex,flag);
|
||||
else
|
||||
setFPGASignal(signalindex,SIGNAL_OFF);
|
||||
break;
|
||||
case MASTER_SLAVE_SYNCHRONIZATION:
|
||||
setSynchronization(syncMode);//syncmode = NO_SYNCHRONIZATION by default and set with this function
|
||||
break;
|
||||
default:
|
||||
setFPGASignal(signalindex,mode);
|
||||
}
|
||||
|
||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
}
|
||||
*/
|
||||
return getExtSignal(signalindex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
|
||||
//template setTiming from firmware_funcs.c
|
||||
//template getFPGASignal from firmware_funcs.c
|
||||
|
||||
|
||||
//getFPGASignal(signalindex) used later on in this fucntion
|
||||
//gets flag from fpga reg, checks if flag within limits,
|
||||
//if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now)
|
||||
//else return flag
|
||||
|
||||
int ret=GET_EXTERNAL_COMMUNICATION_MODE;
|
||||
//sets timingmode variable
|
||||
//ensures that the signals are in acceptance with timing mode and according sets the timing 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)<GATE_OUT_ACTIVE_HIGH && signals[i]!=MASTER_SLAVE_SYNCHRONIZATION)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIGGER_EXPOSURE:
|
||||
timingMode=ti;
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case TRIGGER_READOUT:
|
||||
timingMode=ti;
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
case GATE_FIX_NUMBER:
|
||||
timingMode=ti;
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GATE_WITH_START_TRIGGER:
|
||||
timingMode=ti;
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,signals[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]!=MASTER_SLAVE_SYNCHRONIZATION) {
|
||||
if (getFPGASignal(i)==RO_TRIGGER_IN_RISING_EDGE || getFPGASignal(i)==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
rot=i;
|
||||
else if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH || getFPGASignal(i)==GATE_IN_ACTIVE_LOW)
|
||||
g=i;
|
||||
else if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE || getFPGASignal(i)==TRIGGER_IN_FALLING_EDGE)
|
||||
t=i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (g>=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;
|
||||
}
|
||||
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -262,20 +147,6 @@ int detectorTest( enum digitalTestMode arg){
|
||||
|
||||
|
||||
|
||||
int bus_w(int addr,int val){
|
||||
//template bus_w from firmware_funcs.c
|
||||
//writes to reg
|
||||
return Ok;
|
||||
}
|
||||
|
||||
|
||||
int bus_r(int addr){
|
||||
//template bus_r from firmware_funcs.c
|
||||
//reads reg
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
double setDAC(enum dacIndex ind, double val, int imod){
|
||||
@ -323,7 +194,7 @@ int getChip(sls_detector_chip *myChip){
|
||||
|
||||
int setModule(sls_detector_module myChan){
|
||||
//template initModulebyNumber() from mcb_funcs.c
|
||||
return myMod.reg;
|
||||
return OK;
|
||||
}
|
||||
|
||||
int getModule(sls_detector_module *myChan){
|
||||
@ -350,10 +221,10 @@ enum detectorSettings setSettings(enum detectorSettings sett, int imod){
|
||||
//template setSettings() from mcb_funcs.c
|
||||
//reads the dac registers from fpga to confirm which settings, if weird, undefined
|
||||
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
int startAcquisition(){
|
||||
int startStateMachine(){
|
||||
//template startStateMachine() from firmware_funcs.c
|
||||
/*
|
||||
fifoReset();
|
||||
@ -364,7 +235,7 @@ int startAcquisition(){
|
||||
}
|
||||
|
||||
|
||||
int stopAcquisition(){
|
||||
int stopStateMachine(){
|
||||
//template stopStateMachine() from firmware_funcs.c
|
||||
// send stop to fpga
|
||||
//if status = busy after 500us, return FAIL
|
||||
@ -463,9 +334,231 @@ int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int loadImage(enum imageType index, char *imageVals){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int readCounterBlock(int startACQ, char *counterVals){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int resetCounterBlock(int startACQ){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int calculateDataBytes(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels(){return 0;}
|
||||
int getTotalNumberOfChips(){return 0;}
|
||||
int getTotalNumberOfModules(){return 0;}
|
||||
int getNumberOfChannelsPerChip(){return 0;}
|
||||
int getNumberOfChannelsPerModule(){return 0;}
|
||||
int getNumberOfChipsPerModule(){return 0;}
|
||||
int getNumberOfDACsPerModule(){return 0;}
|
||||
int getNumberOfADCsPerModule(){return 0;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum externalSignalFlag getExtSignal(int signalindex){
|
||||
//template getExtSignal from firmware_funcs.c
|
||||
//return signals[signalindex];
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag){
|
||||
//template setExtSignal from firmware_funcs.c
|
||||
|
||||
//in short..sets signals array, checks if agrees with timing mode, writes to fpga reg, calls synchronization and then settiming
|
||||
/*
|
||||
if (signalindex>=0 && signalindex<4) {
|
||||
signals[signalindex]=flag;
|
||||
#ifdef VERBOSE
|
||||
printf("settings signal variable number %d to value %04x\n", signalindex, signals[signalindex]);
|
||||
#endif
|
||||
// if output signal, set it!
|
||||
switch (flag) {
|
||||
case GATE_IN_ACTIVE_HIGH:
|
||||
case GATE_IN_ACTIVE_LOW:
|
||||
if (timingMode==GATE_FIX_NUMBER || timingMode==GATE_WITH_START_TRIGGER)//timingMode = AUTO_TIMING by default and is set in setTiming()
|
||||
setFPGASignal(signalindex,flag); //not implemented here, checks if flag within limits and writes to fpga reg
|
||||
else
|
||||
setFPGASignal(signalindex,SIGNAL_OFF);
|
||||
break;
|
||||
case TRIGGER_IN_RISING_EDGE:
|
||||
case TRIGGER_IN_FALLING_EDGE:
|
||||
if (timingMode==TRIGGER_EXPOSURE || timingMode==GATE_WITH_START_TRIGGER)
|
||||
setFPGASignal(signalindex,flag);
|
||||
else
|
||||
setFPGASignal(signalindex,SIGNAL_OFF);
|
||||
break;
|
||||
case RO_TRIGGER_IN_RISING_EDGE:
|
||||
case RO_TRIGGER_IN_FALLING_EDGE:
|
||||
if (timingMode==TRIGGER_READOUT)
|
||||
setFPGASignal(signalindex,flag);
|
||||
else
|
||||
setFPGASignal(signalindex,SIGNAL_OFF);
|
||||
break;
|
||||
case MASTER_SLAVE_SYNCHRONIZATION:
|
||||
setSynchronization(syncMode);//syncmode = NO_SYNCHRONIZATION by default and set with this function
|
||||
break;
|
||||
default:
|
||||
setFPGASignal(signalindex,mode);
|
||||
}
|
||||
|
||||
setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
}
|
||||
*/
|
||||
return getExtSignal(signalindex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
|
||||
//template setTiming from firmware_funcs.c
|
||||
//template getFPGASignal from firmware_funcs.c
|
||||
|
||||
|
||||
//getFPGASignal(signalindex) used later on in this fucntion
|
||||
//gets flag from fpga reg, checks if flag within limits,
|
||||
//if( flag=SIGNAL_OFF and signals[signalindex]==MASTER_SLAVE_SYNCHRONIZATION), return -1, (ensures masterslaveflag !=off now)
|
||||
//else return flag
|
||||
|
||||
int ret=GET_EXTERNAL_COMMUNICATION_MODE;
|
||||
//sets timingmode variable
|
||||
//ensures that the signals are in acceptance with timing mode and according sets the timing 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)<GATE_OUT_ACTIVE_HIGH && signals[i]!=MASTER_SLAVE_SYNCHRONIZATION)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
case TRIGGER_EXPOSURE:
|
||||
timingMode=ti;
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case TRIGGER_READOUT:
|
||||
timingMode=ti;
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
case GATE_FIX_NUMBER:
|
||||
timingMode=ti;
|
||||
// if one of the signals is configured to be trigger, set it and unset possible gates
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GATE_WITH_START_TRIGGER:
|
||||
timingMode=ti;
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]==RO_TRIGGER_IN_RISING_EDGE || signals[i]==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,SIGNAL_OFF);
|
||||
else if (signals[i]==GATE_IN_ACTIVE_HIGH || signals[i]==GATE_IN_ACTIVE_LOW)
|
||||
setFPGASignal(i,signals[i]);
|
||||
else if (signals[i]==TRIGGER_IN_RISING_EDGE || signals[i]==TRIGGER_IN_FALLING_EDGE)
|
||||
setFPGASignal(i,signals[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
if (signals[i]!=MASTER_SLAVE_SYNCHRONIZATION) {
|
||||
if (getFPGASignal(i)==RO_TRIGGER_IN_RISING_EDGE || getFPGASignal(i)==RO_TRIGGER_IN_FALLING_EDGE)
|
||||
rot=i;
|
||||
else if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH || getFPGASignal(i)==GATE_IN_ACTIVE_LOW)
|
||||
g=i;
|
||||
else if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE || getFPGASignal(i)==TRIGGER_IN_FALLING_EDGE)
|
||||
t=i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (g>=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;
|
||||
}
|
||||
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
enum masterFlags setMaster(enum masterFlags arg){
|
||||
//template setMaster from firmware_funcs.c
|
||||
/*
|
||||
/*
|
||||
int i;
|
||||
switch(f) {
|
||||
case NO_MASTER:
|
||||
@ -588,7 +681,7 @@ enum masterFlags setMaster(enum masterFlags arg){
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
return NO_MASTER;
|
||||
}
|
||||
@ -596,7 +689,7 @@ enum masterFlags setMaster(enum masterFlags arg){
|
||||
|
||||
|
||||
enum synchronizationMode setSynchronization(enum synchronizationMode arg){
|
||||
/*
|
||||
/*
|
||||
int i;
|
||||
|
||||
switch(s) {
|
||||
@ -700,47 +793,10 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg){
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
*/
|
||||
return NO_SYNCHRONIZATION;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int loadImage(enum imageType index, char *imageVals){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
|
||||
int readCounterBlock(int startACQ, char *counterVals){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int resetCounterBlock(int startACQ){
|
||||
//detector specific.
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
int calculateDataBytes(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
int getTotalNumberOfChannels(){return 0;}
|
||||
int getTotalNumberOfChips(){return 0;}
|
||||
int getTotalNumberOfModules(){return 0;}
|
||||
int getNumberOfChannelsPerChip(){return 0;}
|
||||
int getNumberOfChannelsPerChip(){return 0;}
|
||||
int getNumberOfChannelsPerModule(){return 0;}
|
||||
int getNumberOfChipsPerModule(){return 0;}
|
||||
int getNumberOfDACsPerModule(){return 0;}
|
||||
int getNumberOfADCsPerModule(){return 0;}
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,6 +1,14 @@
|
||||
#ifndef SLS_DETECTOR_FUNCTION_LIST
|
||||
#define SLS_DETECTOR_FUNCTION_LIST
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
|
||||
#ifndef SLS_DETECTOR_FUNCTION_LIST_H
|
||||
#define SLS_DETECTOR_FUNCTION_LIST_H
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -15,6 +23,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
*/
|
||||
|
||||
/****************************************************
|
||||
This functions are used by the slsDetectroServer_funcs interface.
|
||||
@ -23,81 +32,48 @@ Here are the definitions, but the actual implementation should be done for each
|
||||
****************************************************/
|
||||
|
||||
|
||||
//if b>0 all the detector must be initialized, otherwise it is just the stop server
|
||||
int initializeDetector(int b);
|
||||
|
||||
/**
|
||||
sets number of modules
|
||||
\param nm number of modules (-1 gets)
|
||||
\param dim dimension
|
||||
\returns number of modules
|
||||
int initializeDetector();
|
||||
|
||||
|
||||
|
||||
will probably be changed in set ROI mask
|
||||
*/
|
||||
int setNMod(int nm, enum dimension dim);
|
||||
|
||||
/**
|
||||
returns the maximum number of modules in one dimension
|
||||
\param arg dimension
|
||||
\returns max number of modules of the baord
|
||||
*/
|
||||
int getNModBoard(enum dimension arg);
|
||||
|
||||
enum externalSignalFlag getExtSignal(int signalindex);
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
|
||||
int64_t getModuleId(enum idMode arg, int imod);
|
||||
int64_t getDetectorId(enum idMode arg);
|
||||
|
||||
|
||||
int moduleTest( enum digitalTestMode arg, int imod);
|
||||
int detectorTest( enum digitalTestMode arg);
|
||||
|
||||
//write register
|
||||
int bus_w(int addr,int val);
|
||||
//read register
|
||||
int bus_r(int addr);
|
||||
|
||||
double setDAC(enum dacIndex ind, double val, int imod);
|
||||
double getADC(enum dacIndex ind, int imod);
|
||||
|
||||
int setChannel(sls_detector_channel myChan);
|
||||
int getChannel(sls_detector_channel *myChan);
|
||||
|
||||
int setChip(sls_detector_chip myChip);
|
||||
int getChip(sls_detector_chip *myChip);
|
||||
|
||||
int setModule(sls_detector_module myChan);
|
||||
int getModule(sls_detector_module *myChan);
|
||||
int getThresholdEnergy(int imod);
|
||||
int setThresholdEnergy(int thr, int imod);
|
||||
|
||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
||||
|
||||
int startAcquisition();
|
||||
int stopAcquisition();
|
||||
|
||||
int startStateMachine();
|
||||
int stopStateMachine();
|
||||
int startReadOut();
|
||||
|
||||
|
||||
enum runStatus getRunStatus();
|
||||
char *readFrame(int *ret, char *mess);
|
||||
|
||||
|
||||
int64_t setTimer(enum timerIndex ind, int64_t val);
|
||||
int64_t getTimeLeft(enum timerIndex ind);
|
||||
int setDynamicRange(int dr);
|
||||
|
||||
|
||||
int setROI(int mask); //////?????????????????
|
||||
int getROI(int *mask); //////////?????????????????????
|
||||
|
||||
|
||||
int setSpeed(enum speedVariable arg, int val);
|
||||
enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
||||
|
||||
|
||||
int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
|
||||
enum masterFlags setMaster(enum masterFlags arg);
|
||||
enum synchronizationMode setSynchronization(enum synchronizationMode arg);
|
||||
|
||||
|
||||
|
||||
@ -112,11 +88,19 @@ int getTotalNumberOfChannels();
|
||||
int getTotalNumberOfChips();
|
||||
int getTotalNumberOfModules();
|
||||
int getNumberOfChannelsPerChip();
|
||||
int getNumberOfChannelsPerChip();
|
||||
int getNumberOfChannelsPerModule();
|
||||
int getNumberOfChipsPerModule();
|
||||
int getNumberOfDACsPerModule();
|
||||
int getNumberOfADCsPerModule();
|
||||
|
||||
|
||||
enum externalSignalFlag getExtSignal(int signalindex);
|
||||
enum externalSignalFlag setExtSignal(int signalindex, enum externalSignalFlag flag);
|
||||
enum externalCommunicationMode setTiming( enum externalCommunicationMode arg);
|
||||
enum masterFlags setMaster(enum masterFlags arg);
|
||||
enum synchronizationMode setSynchronization(enum synchronizationMode arg);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,12 @@
|
||||
/* 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 "slsDetectorServer_funcs.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
@ -1,6 +1,16 @@
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include "slsDetectorServer_funcs.h"
|
||||
#include "slsDetectorFunctionList.h"
|
||||
#include "slsDetector_firmware.h"
|
||||
#include "slsDetectorServer_defs.h"
|
||||
#include "communication_funcs.h"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Global variables
|
||||
@ -31,20 +41,39 @@ extern int differentClients;
|
||||
|
||||
|
||||
/* global variables for optimized readout */
|
||||
|
||||
char *dataretval=NULL;
|
||||
int dataret;
|
||||
char mess[1000];
|
||||
int dataBytes;
|
||||
|
||||
//defined for gotthard...should really be defined here?!?!?!
|
||||
int digitalTestBit = 0;
|
||||
|
||||
|
||||
|
||||
int init_detector(int b) {
|
||||
#ifdef VIRTUAL
|
||||
printf("This is a VIRTUAL detector\n");
|
||||
#endif
|
||||
|
||||
int init_detector( int b) {
|
||||
initializeDetector(b);
|
||||
mapCSP0();
|
||||
//only for control server
|
||||
if(b){
|
||||
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||
initializeDetector();
|
||||
//testFpga();
|
||||
//testRAM();
|
||||
//setSettings(GET_SETTINGS,-1);
|
||||
//Initialization
|
||||
//setFrames(1);
|
||||
//setTrains(1);
|
||||
//setExposureTime(1e6);
|
||||
//setPeriod(1e9);
|
||||
//setDelay(0);
|
||||
//setGates(0);
|
||||
//setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
||||
//setMaster(GET_MASTER);
|
||||
//setSynchronization(GET_SYNCHRONIZATION_MODE);
|
||||
#endif
|
||||
}
|
||||
strcpy(mess,"dummy message");
|
||||
strcpy(lastClientIP,"none");
|
||||
strcpy(thisClientIP,"none1");
|
||||
@ -122,16 +151,19 @@ int function_table() {
|
||||
flist[F_SET_SPEED]=&set_speed;
|
||||
flist[F_SET_READOUT_FLAGS]=&set_readout_flags;
|
||||
flist[F_EXECUTE_TRIMMING]=&execute_trimming;
|
||||
flist[F_CONFIGURE_MAC]=&configure_mac;
|
||||
flist[F_LOAD_IMAGE]=&load_image;
|
||||
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
||||
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
||||
|
||||
|
||||
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_SET_MASTER]=&set_master;
|
||||
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
||||
flist[F_CONFIGURE_MAC]=&configure_mac;
|
||||
flist[F_LOAD_IMAGE]=&load_image;
|
||||
flist[F_READ_COUNTER_BLOCK]=&read_counter_block;
|
||||
flist[F_RESET_COUNTER_BLOCK]=&reset_counter_block;
|
||||
|
||||
#ifdef VERBOSE
|
||||
/* for (i=0;i<256;i++){
|
||||
printf("function %d located at %x\n",i,flist[i]);
|
||||
@ -462,11 +494,11 @@ enum externalCommunicationMode{
|
||||
|
||||
ret=setTiming(arg);
|
||||
|
||||
/* switch(arg) { */
|
||||
/* default: */
|
||||
/* sprintf(mess,"The meaning of single signals should be set\n"); */
|
||||
/* retval=FAIL; */
|
||||
/* } */
|
||||
/* switch(arg) { */
|
||||
/* default: */
|
||||
/* sprintf(mess,"The meaning of single signals should be set\n"); */
|
||||
/* retval=FAIL; */
|
||||
/* } */
|
||||
|
||||
|
||||
#ifdef VERBOSE
|
||||
@ -575,8 +607,6 @@ int digital_test(int file_des) {
|
||||
int ret=OK;
|
||||
int imod=-1;
|
||||
int n=0;
|
||||
int ibit=0;
|
||||
int ow;
|
||||
int ival;
|
||||
enum digitalTestMode arg;
|
||||
|
||||
@ -627,11 +657,8 @@ int digital_test(int file_des) {
|
||||
sprintf(mess,"Error reading from socket\n");
|
||||
retval=FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
printf("with value %d\n", ival);
|
||||
#endif
|
||||
digitalTestBit = ival;
|
||||
retval=digitalTestBit;
|
||||
|
||||
retval=0;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -988,7 +1015,7 @@ int set_channel(int file_des) {
|
||||
ret=FAIL;
|
||||
sprintf(mess, "channel number %d too large!\n",myChan.chan);
|
||||
}
|
||||
if (myChan.chip>=getNumberOfChipPerModule()) {
|
||||
if (myChan.chip>=getNumberOfChipsPerModule()) {
|
||||
ret=FAIL;
|
||||
sprintf(mess, "chip number %d too large!\n",myChan.chip);
|
||||
}
|
||||
@ -1061,7 +1088,7 @@ int get_channel(int file_des) {
|
||||
sprintf(mess, "channel number %d too large!\n",ichan);
|
||||
} else
|
||||
retval.chan=ichan;
|
||||
if (ichip>=getNumberOfChipPerModule()) {
|
||||
if (ichip>=getNumberOfChipsPerModule()) {
|
||||
ret=FAIL;
|
||||
sprintf(mess, "chip number %d too large!\n",ichip);
|
||||
} else
|
||||
@ -1134,7 +1161,7 @@ int set_chip(int file_des) {
|
||||
#endif
|
||||
|
||||
|
||||
if (myChip.chip>=getNumberOfChipPerModule()) {
|
||||
if (myChip.chip>=getNumberOfChipsPerModule()) {
|
||||
ret=FAIL;
|
||||
sprintf(mess, "chip number %d too large!\n",myChip.chip);
|
||||
}
|
||||
@ -1195,7 +1222,7 @@ int get_chip(int file_des) {
|
||||
imod=arg[1];
|
||||
|
||||
|
||||
if (ichip>=getNumberOfChipPerModule()) {
|
||||
if (ichip>=getNumberOfChipsPerModule()) {
|
||||
ret=FAIL;
|
||||
sprintf(mess, "chip number %d too large!\n",ichip);
|
||||
} else
|
||||
@ -1239,11 +1266,11 @@ int set_module(int file_des) {
|
||||
sls_detector_module myModule;
|
||||
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int));
|
||||
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
||||
double *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||
double *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
||||
int *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||
int *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
||||
int retval, n;
|
||||
int ret=OK;
|
||||
int dr;//, ow;
|
||||
|
||||
|
||||
if (myDac)
|
||||
myModule.dacs=myDac;
|
||||
@ -1343,8 +1370,8 @@ int get_module(int file_des) {
|
||||
sls_detector_module myModule;
|
||||
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int));
|
||||
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
||||
double *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||
double *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
||||
int *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||
int *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
||||
|
||||
|
||||
if (myDac)
|
||||
@ -1622,7 +1649,7 @@ int start_acquisition(int file_des) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
ret=startAcquisition();
|
||||
ret=startStateMachine();
|
||||
}
|
||||
if (ret==FAIL)
|
||||
sprintf(mess,"Start acquisition failed\n");
|
||||
@ -1654,7 +1681,7 @@ int stop_acquisition(int file_des) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||
} else {
|
||||
ret=stopAcquisition();
|
||||
ret=stopStateMachine();
|
||||
}
|
||||
|
||||
if (ret==FAIL)
|
||||
@ -1709,7 +1736,6 @@ int get_run_status(int file_des) {
|
||||
int ret=OK;
|
||||
int n;
|
||||
|
||||
int retval;
|
||||
enum runStatus s;
|
||||
sprintf(mess,"getting run status\n");
|
||||
|
||||
@ -1809,7 +1835,7 @@ int start_and_read_all(int file_des) {
|
||||
}
|
||||
|
||||
|
||||
startStateAcquisition();
|
||||
startStateMachine();
|
||||
read_all(file_des);
|
||||
#ifdef VERBOSE
|
||||
printf("Frames finished\n");
|
||||
@ -1847,9 +1873,9 @@ int set_timer(int file_des) {
|
||||
printf(mess);
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf("setting timer %d to %lld ns\n",ind,tns);
|
||||
#endif
|
||||
#endif
|
||||
if (ret==OK) {
|
||||
|
||||
if (differentClients==1 && lockStatus==1 && tns!=-1) {
|
||||
@ -1858,18 +1884,26 @@ int set_timer(int file_des) {
|
||||
} 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:
|
||||
case CYCLES_NUMBER:
|
||||
retval=setTimer(ind, tns);
|
||||
retval=setGates(tns);
|
||||
break;
|
||||
case PROBES_NUMBER:
|
||||
if (myDetectorType==MYTHEN) {
|
||||
retval=setTimer(ind, tns);
|
||||
retval=setProbes(tns);
|
||||
break;
|
||||
case CYCLES_NUMBER:
|
||||
retval=setTrains(tns);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret=FAIL;
|
||||
sprintf(mess,"timer index unknown %d\n",ind);
|
||||
@ -1887,7 +1921,7 @@ int set_timer(int file_des) {
|
||||
printf("set timer failed\n");
|
||||
sprintf(mess, "set timer %d failed\n", ind);
|
||||
} else if (ind==FRAME_NUMBER) {
|
||||
ret=allocateRAM();
|
||||
/*ret=allocateRAM();*/
|
||||
if (ret!=OK)
|
||||
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
||||
}
|
||||
@ -1896,9 +1930,9 @@ int set_timer(int file_des) {
|
||||
if (ret==FAIL) {
|
||||
n = sendDataOnly(file_des,mess,sizeof(mess));
|
||||
} else {
|
||||
#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
printf("returning ok %d\n",sizeof(retval));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
n = sendDataOnly(file_des,&retval,sizeof(retval));
|
||||
}
|
||||
@ -2117,7 +2151,6 @@ int set_readout_flags(int file_des) {
|
||||
enum readOutFlags arg;
|
||||
int n;
|
||||
int ret=OK;
|
||||
int regret=OK;
|
||||
|
||||
|
||||
sprintf(mess,"can't set readout flags\n");
|
||||
@ -2214,7 +2247,7 @@ int execute_trimming(int file_des) {
|
||||
|
||||
if (imod>=getTotalNumberOfModules()) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Module number out of range\n",imod);
|
||||
sprintf(mess,"Module number out of range %d\n",imod);
|
||||
}
|
||||
|
||||
if (ret==OK) {
|
||||
@ -2385,7 +2418,7 @@ int send_update(int file_des) {
|
||||
enum detectorSettings t;
|
||||
int thr, n;
|
||||
// int it;
|
||||
int64_t retval, tns=-1;
|
||||
int64_t retval;/*, tns=-1;*/
|
||||
int nm;
|
||||
|
||||
|
||||
@ -2403,19 +2436,19 @@ int send_update(int file_des) {
|
||||
n = sendDataOnly(file_des,&t,sizeof(t));
|
||||
thr=getThresholdEnergy(-1);
|
||||
n = sendDataOnly(file_des,&thr,sizeof(thr));
|
||||
retval=setFrames(tns);
|
||||
/*retval=setFrames(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
retval=setExposureTime(tns);
|
||||
/*retval=setExposureTime(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
retval=setPeriod(tns);
|
||||
/*retval=setPeriod(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
retval=setDelay(tns);
|
||||
/*retval=setDelay(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
retval=setGates(tns);
|
||||
/*retval=setGates(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
retval=setProbes(tns);
|
||||
/*retval=setProbes(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
retval=setTrains(tns);
|
||||
/*retval=setTrains(tns);*/
|
||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||
|
||||
if (lockStatus==0) {
|
||||
@ -2537,7 +2570,7 @@ int configure_mac(int file_des) {
|
||||
int retval;
|
||||
int ret=OK;
|
||||
char arg[3][50];
|
||||
int n,i;
|
||||
int n;
|
||||
|
||||
int imod=0;//should be in future sent from client as -1, arg[2]
|
||||
int ipad;
|
||||
@ -2561,11 +2594,12 @@ int configure_mac(int file_des) {
|
||||
|
||||
if (imod>=getTotalNumberOfModules()) {
|
||||
ret=FAIL;
|
||||
sprintf(mess,"Module number out of range\n",imod);
|
||||
sprintf(mess,"Module number out of range %d\n",imod);
|
||||
}
|
||||
|
||||
|
||||
#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);
|
||||
@ -2586,7 +2620,7 @@ int configure_mac(int file_des) {
|
||||
#endif
|
||||
|
||||
if (ret==OK) {
|
||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);
|
||||
/*retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);*/
|
||||
if(retval==-1) ret=FAIL;
|
||||
}
|
||||
|
||||
@ -2697,7 +2731,7 @@ int read_counter_block(int file_des) {
|
||||
int n;
|
||||
int startACQ;
|
||||
//char *retval=NULL;
|
||||
char CounterVals[dataBytes];
|
||||
char CounterVals[NCHAN*NCHIP];
|
||||
|
||||
sprintf(mess,"Read counter block failed\n");
|
||||
|
||||
|
@ -1,24 +1,21 @@
|
||||
#ifndef SERVER_FUNCS_H
|
||||
#define SERVER_FUNCS_H
|
||||
#include <stdio.h>
|
||||
/*
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
*/
|
||||
#include "communication_funcs.h"
|
||||
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
#define GOODBYE -200
|
||||
|
||||
int sockfd;
|
||||
|
||||
int function_table();
|
||||
|
||||
int decode_function(int);
|
||||
|
||||
//if b>0 all the detector must be initialized, otherwise it is just the stop server
|
||||
int init_detector(int);
|
||||
|
||||
int M_nofunc(int);
|
||||
|
@ -1,8 +1,12 @@
|
||||
/* A simple server in the internet domain using TCP
|
||||
The port number is passed as an argument */
|
||||
#include "communication_funcs.h"
|
||||
#include "slsDetectorFirmare_funcs.h"
|
||||
|
||||
#include "slsDetectorFunctionList.h"/*#include "slsDetector_firmware.h" for the time being*/
|
||||
#include "slsDetectorServer_defs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int sockfd;
|
||||
|
||||
@ -10,12 +14,13 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int portno;
|
||||
int retval=0;
|
||||
int sd,fd;
|
||||
|
||||
portno = DEFAULT_PORTNO;
|
||||
|
||||
|
||||
bindSocket(portno); //defined in communication_funcs
|
||||
if (getServerError()) //defined in communication_funcs
|
||||
sd=bindSocket(portno); //defined in communication_funcs
|
||||
if (getServerError(sd)) //defined in communication_funcs
|
||||
return -1;
|
||||
|
||||
|
||||
@ -28,12 +33,12 @@ int main(int argc, char *argv[])
|
||||
#ifdef VERY_VERBOSE
|
||||
printf("Stop server: waiting for client call\n");
|
||||
#endif
|
||||
acceptConnection(); //defined in communication_funcs
|
||||
fd=acceptConnection(sd); //defined in communication_funcs
|
||||
retval=stopStateMachine();//defined in slsDetectorFirmare_funcs
|
||||
closeConnection(); //defined in communication_funcs
|
||||
closeConnection(fd); //defined in communication_funcs
|
||||
}
|
||||
|
||||
exitServer(); //defined in communication_funcs
|
||||
exitServer(sd); //defined in communication_funcs
|
||||
printf("Goodbye!\n");
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user