mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-14 13:57: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
|
extern int nModX;
|
||||||
//memory allocation for detectorModules, chips, chans, dacs etc //from firmware_funcs.c
|
extern int nModBoard;
|
||||||
//set dr, nmod //from firmware_funcs.c
|
extern int dataBytes;
|
||||||
//set settings(GET_SETTINGS); //from mcb_funcs.c
|
extern int dynamicRange;
|
||||||
//call testRAM() //from firmware_funcs.c
|
const int nChans=NCHAN;
|
||||||
//call setTiming(GET_EXTERNAL_COMMUNICATION_MODE);
|
const int nChips=NCHIP;
|
||||||
//call setMaster(GET_MASTER);
|
const int nDacs=NDAC;
|
||||||
//call setSynchronization(GET_SYNCHRONIZATION_MODE);
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +92,291 @@ int getNModBoard(enum dimension arg){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int64_t getModuleId(enum idMode arg, int imod){
|
||||||
|
//DETECTOR_SERIAL_NUMBER
|
||||||
|
//DETECTOR_FIRMWARE_VERSION
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int64_t getDetectorId(enum idMode arg){
|
||||||
|
//DETECTOR_SOFTWARE_VERSION defined in slsDetector_defs.h?
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int moduleTest( enum digitalTestMode arg, int imod){
|
||||||
|
//template testShiftIn from mcb_funcs.c
|
||||||
|
|
||||||
|
//CHIP_TEST
|
||||||
|
//testShiftIn
|
||||||
|
//testShiftOut
|
||||||
|
//testShiftStSel
|
||||||
|
//testDataInOutMux
|
||||||
|
//testExtPulseMux
|
||||||
|
//testOutMux
|
||||||
|
//testFpgaMux
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int detectorTest( enum digitalTestMode arg){
|
||||||
|
//templates from firmware_funcs.c
|
||||||
|
|
||||||
|
//DETECTOR_FIRMWARE_TEST:testFpga()
|
||||||
|
//DETECTOR_MEMORY_TEST:testRAM()
|
||||||
|
//DETECTOR_BUS_TEST:testBus()
|
||||||
|
//DETECTOR_SOFTWARE_TEST:testFpga()
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double setDAC(enum dacIndex ind, double val, int imod){
|
||||||
|
//template initDACbyIndexDACU from mcb_funcs.c
|
||||||
|
|
||||||
|
//check that slsDetectorServer_funcs.c set_dac() has all the specific dac enums
|
||||||
|
//set dac and write to a register in fpga to remember dac value when server restarts
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double getADC(enum dacIndex ind, int imod){
|
||||||
|
//get adc value
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int setChannel(sls_detector_channel myChan){
|
||||||
|
//template initChannelByNumber() from mcb_funcs.c
|
||||||
|
|
||||||
|
return myChan.reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getChannel(sls_detector_channel *myChan){
|
||||||
|
//template getChannelbyNumber() from mcb_funcs.c
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int setChip(sls_detector_chip myChip){
|
||||||
|
//template initChipbyNumber() from mcb_funcs.c
|
||||||
|
return myChip.reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getChip(sls_detector_chip *myChip){
|
||||||
|
//template getChipbyNumber() from mcb_funcs.c
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setModule(sls_detector_module myChan){
|
||||||
|
//template initModulebyNumber() from mcb_funcs.c
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getModule(sls_detector_module *myChan){
|
||||||
|
//template getModulebyNumber() from mcb_funcs.c
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getThresholdEnergy(int imod){
|
||||||
|
//template getThresholdEnergy() from mcb_funcs.c
|
||||||
|
//depending on settings
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int setThresholdEnergy(int thr, int imod){
|
||||||
|
//template getThresholdEnergy() from mcb_funcs.c
|
||||||
|
//depending on settings
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 startStateMachine(){
|
||||||
|
//template startStateMachine() from firmware_funcs.c
|
||||||
|
/*
|
||||||
|
fifoReset();
|
||||||
|
now_ptr=(char*)ram_values;
|
||||||
|
//send start acquisition to fpga
|
||||||
|
*/
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int stopStateMachine(){
|
||||||
|
//template stopStateMachine() from firmware_funcs.c
|
||||||
|
// send stop to fpga
|
||||||
|
//if status = busy after 500us, return FAIL
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int startReadOut(){
|
||||||
|
//template startReadOut() from firmware_funcs.c
|
||||||
|
//send fpga start readout
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum runStatus getRunStatus(){
|
||||||
|
//template runState() from firmware_funcs.c
|
||||||
|
//get status from fpga
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char *readFrame(int *ret, char *mess){
|
||||||
|
//template fifo_read_event() from firmware_funcs.c
|
||||||
|
//checks if state machine running and if fifo has data(look_at_me_reg) and accordingly reads frame
|
||||||
|
// memcpy(now_ptr, values, dataBytes);
|
||||||
|
//returns ptr to values
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int64_t setTimer(enum timerIndex ind, int64_t val){
|
||||||
|
//template setDelay() from firmware_funcs.c
|
||||||
|
//writes to reg
|
||||||
|
//FRAME_NUMBER
|
||||||
|
//ACQUISITION_TIME
|
||||||
|
//FRAME_PERIOD
|
||||||
|
//DELAY_AFTER_TRIGGER
|
||||||
|
//GATES_NUMBER
|
||||||
|
//PROBES_NUMBER
|
||||||
|
//CYCLES_NUMBER
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int64_t getTimeLeft(enum timerIndex ind){
|
||||||
|
//template getDelay() from firmware_funcs.c
|
||||||
|
//reads from reg
|
||||||
|
//FRAME_NUMBER
|
||||||
|
//ACQUISITION_TIME
|
||||||
|
//FRAME_PERIOD
|
||||||
|
//DELAY_AFTER_TRIGGER
|
||||||
|
//GATES_NUMBER
|
||||||
|
//PROBES_NUMBER
|
||||||
|
//CYCLES_NUMBER
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int setDynamicRange(int dr){
|
||||||
|
//template setDynamicRange() from firmware_funcs.c
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int setROI(int mask){ //////?????????????????
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int getROI(int *mask){ //////////?????????????????????
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int setSpeed(enum speedVariable arg, int val){
|
||||||
|
//template setClockDivider() from firmware_funcs.c
|
||||||
|
//CLOCK_DIVIDER
|
||||||
|
//WAIT_STATES
|
||||||
|
//SET_SIGNAL_LENGTH
|
||||||
|
//TOT_CLOCK_DIVIDER
|
||||||
|
//TOT_DUTY_CYCLE
|
||||||
|
|
||||||
|
//returns eg getClockDivider from firmware_funcs.c
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum readOutFlags setReadOutFlags(enum readOutFlags val){
|
||||||
|
//template setStoreInRAM from firmware_funcs.c
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
|
||||||
|
// template trim_with_noise from trimming_funcs.c
|
||||||
|
return FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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){
|
enum externalSignalFlag getExtSignal(int signalindex){
|
||||||
//template getExtSignal from firmware_funcs.c
|
//template getExtSignal from firmware_funcs.c
|
||||||
//return signals[signalindex];
|
//return signals[signalindex];
|
||||||
@ -209,260 +556,6 @@ enum externalCommunicationMode setTiming( enum externalCommunicationMode arg){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t getModuleId(enum idMode arg, int imod){
|
|
||||||
//DETECTOR_SERIAL_NUMBER
|
|
||||||
//DETECTOR_FIRMWARE_VERSION
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int64_t getDetectorId(enum idMode arg){
|
|
||||||
//DETECTOR_SOFTWARE_VERSION defined in slsDetector_defs.h?
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int moduleTest( enum digitalTestMode arg, int imod){
|
|
||||||
//template testShiftIn from mcb_funcs.c
|
|
||||||
|
|
||||||
//CHIP_TEST
|
|
||||||
//testShiftIn
|
|
||||||
//testShiftOut
|
|
||||||
//testShiftStSel
|
|
||||||
//testDataInOutMux
|
|
||||||
//testExtPulseMux
|
|
||||||
//testOutMux
|
|
||||||
//testFpgaMux
|
|
||||||
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int detectorTest( enum digitalTestMode arg){
|
|
||||||
//templates from firmware_funcs.c
|
|
||||||
|
|
||||||
//DETECTOR_FIRMWARE_TEST:testFpga()
|
|
||||||
//DETECTOR_MEMORY_TEST:testRAM()
|
|
||||||
//DETECTOR_BUS_TEST:testBus()
|
|
||||||
//DETECTOR_SOFTWARE_TEST:testFpga()
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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){
|
|
||||||
//template initDACbyIndexDACU from mcb_funcs.c
|
|
||||||
|
|
||||||
//check that slsDetectorServer_funcs.c set_dac() has all the specific dac enums
|
|
||||||
//set dac and write to a register in fpga to remember dac value when server restarts
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double getADC(enum dacIndex ind, int imod){
|
|
||||||
//get adc value
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int setChannel(sls_detector_channel myChan){
|
|
||||||
//template initChannelByNumber() from mcb_funcs.c
|
|
||||||
|
|
||||||
return myChan.reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int getChannel(sls_detector_channel *myChan){
|
|
||||||
//template getChannelbyNumber() from mcb_funcs.c
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int setChip(sls_detector_chip myChip){
|
|
||||||
//template initChipbyNumber() from mcb_funcs.c
|
|
||||||
return myChip.reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int getChip(sls_detector_chip *myChip){
|
|
||||||
//template getChipbyNumber() from mcb_funcs.c
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int setModule(sls_detector_module myChan){
|
|
||||||
//template initModulebyNumber() from mcb_funcs.c
|
|
||||||
return myMod.reg;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getModule(sls_detector_module *myChan){
|
|
||||||
//template getModulebyNumber() from mcb_funcs.c
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getThresholdEnergy(int imod){
|
|
||||||
//template getThresholdEnergy() from mcb_funcs.c
|
|
||||||
//depending on settings
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int setThresholdEnergy(int thr, int imod){
|
|
||||||
//template getThresholdEnergy() from mcb_funcs.c
|
|
||||||
//depending on settings
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int startAcquisition(){
|
|
||||||
//template startStateMachine() from firmware_funcs.c
|
|
||||||
/*
|
|
||||||
fifoReset();
|
|
||||||
now_ptr=(char*)ram_values;
|
|
||||||
//send start acquisition to fpga
|
|
||||||
*/
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int stopAcquisition(){
|
|
||||||
//template stopStateMachine() from firmware_funcs.c
|
|
||||||
// send stop to fpga
|
|
||||||
//if status = busy after 500us, return FAIL
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int startReadOut(){
|
|
||||||
//template startReadOut() from firmware_funcs.c
|
|
||||||
//send fpga start readout
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum runStatus getRunStatus(){
|
|
||||||
//template runState() from firmware_funcs.c
|
|
||||||
//get status from fpga
|
|
||||||
return ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
char *readFrame(int *ret, char *mess){
|
|
||||||
//template fifo_read_event() from firmware_funcs.c
|
|
||||||
//checks if state machine running and if fifo has data(look_at_me_reg) and accordingly reads frame
|
|
||||||
// memcpy(now_ptr, values, dataBytes);
|
|
||||||
//returns ptr to values
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int64_t setTimer(enum timerIndex ind, int64_t val){
|
|
||||||
//template setDelay() from firmware_funcs.c
|
|
||||||
//writes to reg
|
|
||||||
//FRAME_NUMBER
|
|
||||||
//ACQUISITION_TIME
|
|
||||||
//FRAME_PERIOD
|
|
||||||
//DELAY_AFTER_TRIGGER
|
|
||||||
//GATES_NUMBER
|
|
||||||
//PROBES_NUMBER
|
|
||||||
//CYCLES_NUMBER
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int64_t getTimeLeft(enum timerIndex ind){
|
|
||||||
//template getDelay() from firmware_funcs.c
|
|
||||||
//reads from reg
|
|
||||||
//FRAME_NUMBER
|
|
||||||
//ACQUISITION_TIME
|
|
||||||
//FRAME_PERIOD
|
|
||||||
//DELAY_AFTER_TRIGGER
|
|
||||||
//GATES_NUMBER
|
|
||||||
//PROBES_NUMBER
|
|
||||||
//CYCLES_NUMBER
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int setDynamicRange(int dr){
|
|
||||||
//template setDynamicRange() from firmware_funcs.c
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int setROI(int mask){ //////?????????????????
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int getROI(int *mask){ //////////?????????????????????
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int setSpeed(enum speedVariable arg, int val){
|
|
||||||
//template setClockDivider() from firmware_funcs.c
|
|
||||||
//CLOCK_DIVIDER
|
|
||||||
//WAIT_STATES
|
|
||||||
//SET_SIGNAL_LENGTH
|
|
||||||
//TOT_CLOCK_DIVIDER
|
|
||||||
//TOT_DUTY_CYCLE
|
|
||||||
|
|
||||||
//returns eg getClockDivider from firmware_funcs.c
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum readOutFlags setReadOutFlags(enum readOutFlags val){
|
|
||||||
//template setStoreInRAM from firmware_funcs.c
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int executeTrimming(enum trimMode mode, int par1, int par2, int imod){
|
|
||||||
// template trim_with_noise from trimming_funcs.c
|
|
||||||
return FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
enum masterFlags setMaster(enum masterFlags arg){
|
enum masterFlags setMaster(enum masterFlags arg){
|
||||||
//template setMaster from firmware_funcs.c
|
//template setMaster from firmware_funcs.c
|
||||||
/*
|
/*
|
||||||
@ -706,41 +799,4 @@ enum synchronizationMode setSynchronization(enum synchronizationMode arg){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
#endif
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
#ifndef SLS_DETECTOR_FUNCTION_LIST
|
#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
#define 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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -15,6 +23,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
*/
|
||||||
|
|
||||||
/****************************************************
|
/****************************************************
|
||||||
This functions are used by the slsDetectroServer_funcs interface.
|
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);
|
|
||||||
|
|
||||||
/**
|
int initializeDetector();
|
||||||
sets number of modules
|
|
||||||
\param nm number of modules (-1 gets)
|
|
||||||
\param dim dimension
|
|
||||||
\returns number of modules
|
|
||||||
|
|
||||||
will probably be changed in set ROI mask
|
|
||||||
*/
|
|
||||||
int setNMod(int nm, enum dimension dim);
|
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);
|
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 getModuleId(enum idMode arg, int imod);
|
||||||
int64_t getDetectorId(enum idMode arg);
|
int64_t getDetectorId(enum idMode arg);
|
||||||
|
|
||||||
|
|
||||||
int moduleTest( enum digitalTestMode arg, int imod);
|
int moduleTest( enum digitalTestMode arg, int imod);
|
||||||
int detectorTest( enum digitalTestMode arg);
|
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 setDAC(enum dacIndex ind, double val, int imod);
|
||||||
double getADC(enum dacIndex ind, int imod);
|
double getADC(enum dacIndex ind, int imod);
|
||||||
|
|
||||||
int setChannel(sls_detector_channel myChan);
|
int setChannel(sls_detector_channel myChan);
|
||||||
int getChannel(sls_detector_channel *myChan);
|
int getChannel(sls_detector_channel *myChan);
|
||||||
|
|
||||||
int setChip(sls_detector_chip myChip);
|
int setChip(sls_detector_chip myChip);
|
||||||
int getChip(sls_detector_chip *myChip);
|
int getChip(sls_detector_chip *myChip);
|
||||||
|
|
||||||
int setModule(sls_detector_module myChan);
|
int setModule(sls_detector_module myChan);
|
||||||
int getModule(sls_detector_module *myChan);
|
int getModule(sls_detector_module *myChan);
|
||||||
int getThresholdEnergy(int imod);
|
int getThresholdEnergy(int imod);
|
||||||
int setThresholdEnergy(int thr, int imod);
|
int setThresholdEnergy(int thr, int imod);
|
||||||
|
|
||||||
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
enum detectorSettings setSettings(enum detectorSettings sett, int imod);
|
||||||
|
|
||||||
int startAcquisition();
|
|
||||||
int stopAcquisition();
|
int startStateMachine();
|
||||||
|
int stopStateMachine();
|
||||||
int startReadOut();
|
int startReadOut();
|
||||||
|
|
||||||
|
|
||||||
enum runStatus getRunStatus();
|
enum runStatus getRunStatus();
|
||||||
char *readFrame(int *ret, char *mess);
|
char *readFrame(int *ret, char *mess);
|
||||||
|
|
||||||
|
|
||||||
int64_t setTimer(enum timerIndex ind, int64_t val);
|
int64_t setTimer(enum timerIndex ind, int64_t val);
|
||||||
int64_t getTimeLeft(enum timerIndex ind);
|
int64_t getTimeLeft(enum timerIndex ind);
|
||||||
int setDynamicRange(int dr);
|
int setDynamicRange(int dr);
|
||||||
|
|
||||||
|
|
||||||
int setROI(int mask); //////?????????????????
|
int setROI(int mask); //////?????????????????
|
||||||
int getROI(int *mask); //////////?????????????????????
|
int getROI(int *mask); //////////?????????????????????
|
||||||
|
|
||||||
|
|
||||||
int setSpeed(enum speedVariable arg, int val);
|
int setSpeed(enum speedVariable arg, int val);
|
||||||
enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
enum readOutFlags setReadOutFlags(enum readOutFlags val);
|
||||||
|
|
||||||
|
|
||||||
int executeTrimming(enum trimMode mode, int par1, int par2, int imod);
|
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 getTotalNumberOfChips();
|
||||||
int getTotalNumberOfModules();
|
int getTotalNumberOfModules();
|
||||||
int getNumberOfChannelsPerChip();
|
int getNumberOfChannelsPerChip();
|
||||||
int getNumberOfChannelsPerChip();
|
|
||||||
int getNumberOfChannelsPerModule();
|
int getNumberOfChannelsPerModule();
|
||||||
int getNumberOfChipsPerModule();
|
int getNumberOfChipsPerModule();
|
||||||
int getNumberOfDACsPerModule();
|
int getNumberOfDACsPerModule();
|
||||||
int getNumberOfADCsPerModule();
|
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
|
#endif
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
/* A simple server in the internet domain using TCP
|
/* A simple server in the internet domain using TCP
|
||||||
The port number is passed as an argument */
|
The port number is passed as an argument */
|
||||||
|
|
||||||
|
#include "sls_detector_defs.h"
|
||||||
#include "communication_funcs.h"
|
#include "communication_funcs.h"
|
||||||
#include "slsDetectorServer_funcs.h"
|
#include "slsDetectorServer_funcs.h"
|
||||||
|
#include "slsDetectorServer_defs.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
#include "sls_detector_defs.h"
|
|
||||||
#include "slsDetectorServer_funcs.h"
|
#include "slsDetectorServer_funcs.h"
|
||||||
#include "slsDetectorFunctionList.h"
|
#include "slsDetectorFunctionList.h"
|
||||||
|
#include "slsDetector_firmware.h"
|
||||||
|
#include "slsDetectorServer_defs.h"
|
||||||
|
#include "communication_funcs.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
@ -31,20 +41,39 @@ extern int differentClients;
|
|||||||
|
|
||||||
|
|
||||||
/* global variables for optimized readout */
|
/* global variables for optimized readout */
|
||||||
|
|
||||||
char *dataretval=NULL;
|
char *dataretval=NULL;
|
||||||
int dataret;
|
int dataret;
|
||||||
char mess[1000];
|
char mess[1000];
|
||||||
int dataBytes;
|
int dataBytes;
|
||||||
|
|
||||||
//defined for gotthard...should really be defined here?!?!?!
|
|
||||||
int digitalTestBit = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int init_detector(int b) {
|
int init_detector(int b) {
|
||||||
initializeDetector(b);
|
#ifdef VIRTUAL
|
||||||
|
printf("This is a VIRTUAL detector\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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(mess,"dummy message");
|
||||||
strcpy(lastClientIP,"none");
|
strcpy(lastClientIP,"none");
|
||||||
strcpy(thisClientIP,"none1");
|
strcpy(thisClientIP,"none1");
|
||||||
@ -122,16 +151,19 @@ int function_table() {
|
|||||||
flist[F_SET_SPEED]=&set_speed;
|
flist[F_SET_SPEED]=&set_speed;
|
||||||
flist[F_SET_READOUT_FLAGS]=&set_readout_flags;
|
flist[F_SET_READOUT_FLAGS]=&set_readout_flags;
|
||||||
flist[F_EXECUTE_TRIMMING]=&execute_trimming;
|
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_LOCK_SERVER]=&lock_server;
|
||||||
flist[F_SET_PORT]=&set_port;
|
flist[F_SET_PORT]=&set_port;
|
||||||
flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip;
|
flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip;
|
||||||
flist[F_UPDATE_CLIENT]=&update_client;
|
flist[F_UPDATE_CLIENT]=&update_client;
|
||||||
flist[F_SET_MASTER]=&set_master;
|
flist[F_SET_MASTER]=&set_master;
|
||||||
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
|
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
|
#ifdef VERBOSE
|
||||||
/* for (i=0;i<256;i++){
|
/* for (i=0;i<256;i++){
|
||||||
printf("function %d located at %x\n",i,flist[i]);
|
printf("function %d located at %x\n",i,flist[i]);
|
||||||
@ -575,8 +607,6 @@ int digital_test(int file_des) {
|
|||||||
int ret=OK;
|
int ret=OK;
|
||||||
int imod=-1;
|
int imod=-1;
|
||||||
int n=0;
|
int n=0;
|
||||||
int ibit=0;
|
|
||||||
int ow;
|
|
||||||
int ival;
|
int ival;
|
||||||
enum digitalTestMode arg;
|
enum digitalTestMode arg;
|
||||||
|
|
||||||
@ -627,11 +657,8 @@ int digital_test(int file_des) {
|
|||||||
sprintf(mess,"Error reading from socket\n");
|
sprintf(mess,"Error reading from socket\n");
|
||||||
retval=FAIL;
|
retval=FAIL;
|
||||||
}
|
}
|
||||||
#ifdef VERBOSE
|
|
||||||
printf("with value %d\n", ival);
|
retval=0;
|
||||||
#endif
|
|
||||||
digitalTestBit = ival;
|
|
||||||
retval=digitalTestBit;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -988,7 +1015,7 @@ int set_channel(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess, "channel number %d too large!\n",myChan.chan);
|
sprintf(mess, "channel number %d too large!\n",myChan.chan);
|
||||||
}
|
}
|
||||||
if (myChan.chip>=getNumberOfChipPerModule()) {
|
if (myChan.chip>=getNumberOfChipsPerModule()) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess, "chip number %d too large!\n",myChan.chip);
|
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);
|
sprintf(mess, "channel number %d too large!\n",ichan);
|
||||||
} else
|
} else
|
||||||
retval.chan=ichan;
|
retval.chan=ichan;
|
||||||
if (ichip>=getNumberOfChipPerModule()) {
|
if (ichip>=getNumberOfChipsPerModule()) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess, "chip number %d too large!\n",ichip);
|
sprintf(mess, "chip number %d too large!\n",ichip);
|
||||||
} else
|
} else
|
||||||
@ -1134,7 +1161,7 @@ int set_chip(int file_des) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (myChip.chip>=getNumberOfChipPerModule()) {
|
if (myChip.chip>=getNumberOfChipsPerModule()) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess, "chip number %d too large!\n",myChip.chip);
|
sprintf(mess, "chip number %d too large!\n",myChip.chip);
|
||||||
}
|
}
|
||||||
@ -1195,7 +1222,7 @@ int get_chip(int file_des) {
|
|||||||
imod=arg[1];
|
imod=arg[1];
|
||||||
|
|
||||||
|
|
||||||
if (ichip>=getNumberOfChipPerModule()) {
|
if (ichip>=getNumberOfChipsPerModule()) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess, "chip number %d too large!\n",ichip);
|
sprintf(mess, "chip number %d too large!\n",ichip);
|
||||||
} else
|
} else
|
||||||
@ -1239,11 +1266,11 @@ int set_module(int file_des) {
|
|||||||
sls_detector_module myModule;
|
sls_detector_module myModule;
|
||||||
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int));
|
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int));
|
||||||
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
||||||
double *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
int *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||||
double *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
int *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
||||||
int retval, n;
|
int retval, n;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
int dr;//, ow;
|
|
||||||
|
|
||||||
if (myDac)
|
if (myDac)
|
||||||
myModule.dacs=myDac;
|
myModule.dacs=myDac;
|
||||||
@ -1343,8 +1370,8 @@ int get_module(int file_des) {
|
|||||||
sls_detector_module myModule;
|
sls_detector_module myModule;
|
||||||
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int));
|
int *myChip=malloc(getNumberOfChipsPerModule()*sizeof(int));
|
||||||
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
int *myChan=malloc(getNumberOfChannelsPerModule()*sizeof(int));
|
||||||
double *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
int *myDac=malloc(getNumberOfDACsPerModule()*sizeof(int));
|
||||||
double *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
int *myAdc=malloc(getNumberOfADCsPerModule()*sizeof(int));
|
||||||
|
|
||||||
|
|
||||||
if (myDac)
|
if (myDac)
|
||||||
@ -1622,7 +1649,7 @@ int start_acquisition(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
ret=startAcquisition();
|
ret=startStateMachine();
|
||||||
}
|
}
|
||||||
if (ret==FAIL)
|
if (ret==FAIL)
|
||||||
sprintf(mess,"Start acquisition failed\n");
|
sprintf(mess,"Start acquisition failed\n");
|
||||||
@ -1654,7 +1681,7 @@ int stop_acquisition(int file_des) {
|
|||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
sprintf(mess,"Detector locked by %s\n",lastClientIP);
|
||||||
} else {
|
} else {
|
||||||
ret=stopAcquisition();
|
ret=stopStateMachine();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret==FAIL)
|
if (ret==FAIL)
|
||||||
@ -1709,7 +1736,6 @@ int get_run_status(int file_des) {
|
|||||||
int ret=OK;
|
int ret=OK;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
int retval;
|
|
||||||
enum runStatus s;
|
enum runStatus s;
|
||||||
sprintf(mess,"getting run status\n");
|
sprintf(mess,"getting run status\n");
|
||||||
|
|
||||||
@ -1809,7 +1835,7 @@ int start_and_read_all(int file_des) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
startStateAcquisition();
|
startStateMachine();
|
||||||
read_all(file_des);
|
read_all(file_des);
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("Frames finished\n");
|
printf("Frames finished\n");
|
||||||
@ -1858,18 +1884,26 @@ int set_timer(int file_des) {
|
|||||||
} else {
|
} else {
|
||||||
switch(ind) {
|
switch(ind) {
|
||||||
case FRAME_NUMBER:
|
case FRAME_NUMBER:
|
||||||
|
retval=setFrames(tns);
|
||||||
|
break;
|
||||||
case ACQUISITION_TIME:
|
case ACQUISITION_TIME:
|
||||||
|
retval=setExposureTime(tns);
|
||||||
|
break;
|
||||||
case FRAME_PERIOD:
|
case FRAME_PERIOD:
|
||||||
|
retval=setPeriod(tns);
|
||||||
|
break;
|
||||||
case DELAY_AFTER_TRIGGER:
|
case DELAY_AFTER_TRIGGER:
|
||||||
|
retval=setDelay(tns);
|
||||||
|
break;
|
||||||
case GATES_NUMBER:
|
case GATES_NUMBER:
|
||||||
case CYCLES_NUMBER:
|
retval=setGates(tns);
|
||||||
retval=setTimer(ind, tns);
|
|
||||||
break;
|
break;
|
||||||
case PROBES_NUMBER:
|
case PROBES_NUMBER:
|
||||||
if (myDetectorType==MYTHEN) {
|
retval=setProbes(tns);
|
||||||
retval=setTimer(ind, tns);
|
break;
|
||||||
|
case CYCLES_NUMBER:
|
||||||
|
retval=setTrains(tns);
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"timer index unknown %d\n",ind);
|
sprintf(mess,"timer index unknown %d\n",ind);
|
||||||
@ -1887,7 +1921,7 @@ int set_timer(int file_des) {
|
|||||||
printf("set timer failed\n");
|
printf("set timer failed\n");
|
||||||
sprintf(mess, "set timer %d failed\n", ind);
|
sprintf(mess, "set timer %d failed\n", ind);
|
||||||
} else if (ind==FRAME_NUMBER) {
|
} else if (ind==FRAME_NUMBER) {
|
||||||
ret=allocateRAM();
|
/*ret=allocateRAM();*/
|
||||||
if (ret!=OK)
|
if (ret!=OK)
|
||||||
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
sprintf(mess, "could not allocate RAM for %lld frames\n", tns);
|
||||||
}
|
}
|
||||||
@ -2117,7 +2151,6 @@ int set_readout_flags(int file_des) {
|
|||||||
enum readOutFlags arg;
|
enum readOutFlags arg;
|
||||||
int n;
|
int n;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
int regret=OK;
|
|
||||||
|
|
||||||
|
|
||||||
sprintf(mess,"can't set readout flags\n");
|
sprintf(mess,"can't set readout flags\n");
|
||||||
@ -2214,7 +2247,7 @@ int execute_trimming(int file_des) {
|
|||||||
|
|
||||||
if (imod>=getTotalNumberOfModules()) {
|
if (imod>=getTotalNumberOfModules()) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Module number out of range\n",imod);
|
sprintf(mess,"Module number out of range %d\n",imod);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
@ -2385,7 +2418,7 @@ int send_update(int file_des) {
|
|||||||
enum detectorSettings t;
|
enum detectorSettings t;
|
||||||
int thr, n;
|
int thr, n;
|
||||||
// int it;
|
// int it;
|
||||||
int64_t retval, tns=-1;
|
int64_t retval;/*, tns=-1;*/
|
||||||
int nm;
|
int nm;
|
||||||
|
|
||||||
|
|
||||||
@ -2403,19 +2436,19 @@ int send_update(int file_des) {
|
|||||||
n = sendDataOnly(file_des,&t,sizeof(t));
|
n = sendDataOnly(file_des,&t,sizeof(t));
|
||||||
thr=getThresholdEnergy(-1);
|
thr=getThresholdEnergy(-1);
|
||||||
n = sendDataOnly(file_des,&thr,sizeof(thr));
|
n = sendDataOnly(file_des,&thr,sizeof(thr));
|
||||||
retval=setFrames(tns);
|
/*retval=setFrames(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
retval=setExposureTime(tns);
|
/*retval=setExposureTime(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
retval=setPeriod(tns);
|
/*retval=setPeriod(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
retval=setDelay(tns);
|
/*retval=setDelay(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
retval=setGates(tns);
|
/*retval=setGates(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
retval=setProbes(tns);
|
/*retval=setProbes(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
retval=setTrains(tns);
|
/*retval=setTrains(tns);*/
|
||||||
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
n = sendDataOnly(file_des,&retval,sizeof(int64_t));
|
||||||
|
|
||||||
if (lockStatus==0) {
|
if (lockStatus==0) {
|
||||||
@ -2537,7 +2570,7 @@ int configure_mac(int file_des) {
|
|||||||
int retval;
|
int retval;
|
||||||
int ret=OK;
|
int ret=OK;
|
||||||
char arg[3][50];
|
char arg[3][50];
|
||||||
int n,i;
|
int n;
|
||||||
|
|
||||||
int imod=0;//should be in future sent from client as -1, arg[2]
|
int imod=0;//should be in future sent from client as -1, arg[2]
|
||||||
int ipad;
|
int ipad;
|
||||||
@ -2561,11 +2594,12 @@ int configure_mac(int file_des) {
|
|||||||
|
|
||||||
if (imod>=getTotalNumberOfModules()) {
|
if (imod>=getTotalNumberOfModules()) {
|
||||||
ret=FAIL;
|
ret=FAIL;
|
||||||
sprintf(mess,"Module number out of range\n",imod);
|
sprintf(mess,"Module number out of range %d\n",imod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
|
int i;
|
||||||
printf("\ndigital_test_bit in server %d\t",digitalTestBit);
|
printf("\ndigital_test_bit in server %d\t",digitalTestBit);
|
||||||
printf("\nipadd %x\t",ipad);
|
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("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
|
#endif
|
||||||
|
|
||||||
if (ret==OK) {
|
if (ret==OK) {
|
||||||
retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);
|
/*retval=configureMAC(ipad,imacadd,iservermacadd,digitalTestBit);*/
|
||||||
if(retval==-1) ret=FAIL;
|
if(retval==-1) ret=FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2697,7 +2731,7 @@ int read_counter_block(int file_des) {
|
|||||||
int n;
|
int n;
|
||||||
int startACQ;
|
int startACQ;
|
||||||
//char *retval=NULL;
|
//char *retval=NULL;
|
||||||
char CounterVals[dataBytes];
|
char CounterVals[NCHAN*NCHIP];
|
||||||
|
|
||||||
sprintf(mess,"Read counter block failed\n");
|
sprintf(mess,"Read counter block failed\n");
|
||||||
|
|
||||||
|
@ -1,24 +1,21 @@
|
|||||||
#ifndef SERVER_FUNCS_H
|
#ifndef SERVER_FUNCS_H
|
||||||
#define SERVER_FUNCS_H
|
#define SERVER_FUNCS_H
|
||||||
#include <stdio.h>
|
|
||||||
/*
|
|
||||||
#include <sys/types.h>
|
#include "sls_detector_defs.h"
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
#include <stdlib.h>
|
||||||
*/
|
|
||||||
#include "communication_funcs.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define GOODBYE -200
|
|
||||||
|
|
||||||
int sockfd;
|
int sockfd;
|
||||||
|
|
||||||
int function_table();
|
int function_table();
|
||||||
|
|
||||||
int decode_function(int);
|
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 init_detector(int);
|
||||||
|
|
||||||
int M_nofunc(int);
|
int M_nofunc(int);
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
/* A simple server in the internet domain using TCP
|
/* A simple server in the internet domain using TCP
|
||||||
The port number is passed as an argument */
|
The port number is passed as an argument */
|
||||||
#include "communication_funcs.h"
|
#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;
|
int sockfd;
|
||||||
|
|
||||||
@ -10,12 +14,13 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int portno;
|
int portno;
|
||||||
int retval=0;
|
int retval=0;
|
||||||
|
int sd,fd;
|
||||||
|
|
||||||
portno = DEFAULT_PORTNO;
|
portno = DEFAULT_PORTNO;
|
||||||
|
|
||||||
|
|
||||||
bindSocket(portno); //defined in communication_funcs
|
sd=bindSocket(portno); //defined in communication_funcs
|
||||||
if (getServerError()) //defined in communication_funcs
|
if (getServerError(sd)) //defined in communication_funcs
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
@ -28,12 +33,12 @@ int main(int argc, char *argv[])
|
|||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("Stop server: waiting for client call\n");
|
printf("Stop server: waiting for client call\n");
|
||||||
#endif
|
#endif
|
||||||
acceptConnection(); //defined in communication_funcs
|
fd=acceptConnection(sd); //defined in communication_funcs
|
||||||
retval=stopStateMachine();//defined in slsDetectorFirmare_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");
|
printf("Goodbye!\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user