mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-26 16:20:03 +02:00
added stop server, the implementation part of the class, and edited slsDetectorServer to include the correct slsDetectorFunctionList.h
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@266 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
ae9b39fba3
commit
aefdcaa82e
746
slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c
Normal file
746
slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.c
Normal file
@ -0,0 +1,746 @@
|
|||||||
|
//#ifdef SLS_DETECTOR_FUNCTION_LIST
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int setNMod(int nm, enum dimension dim){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int getNModBoard(enum dimension arg){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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){
|
||||||
|
//template setMaster from firmware_funcs.c
|
||||||
|
/*
|
||||||
|
int i;
|
||||||
|
switch(f) {
|
||||||
|
case NO_MASTER:
|
||||||
|
// switch of gates or triggers
|
||||||
|
masterMode=NO_MASTER;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IS_MASTER:
|
||||||
|
// configure gate or trigger out
|
||||||
|
masterMode=IS_MASTER;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
switch (syncMode) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
|
break;
|
||||||
|
case MASTER_GATES:
|
||||||
|
setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
|
||||||
|
break;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
|
||||||
|
break;
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IS_SLAVE:
|
||||||
|
// configure gate or trigger in
|
||||||
|
masterMode=IS_SLAVE;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
switch (syncMode) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
|
break;
|
||||||
|
case MASTER_GATES:
|
||||||
|
setFPGASignal(i,GATE_IN_ACTIVE_HIGH);
|
||||||
|
break;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
||||||
|
break;
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
//do nothing
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(masterMode) {
|
||||||
|
case NO_MASTER:
|
||||||
|
return NO_MASTER;
|
||||||
|
|
||||||
|
|
||||||
|
case IS_MASTER:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
switch (syncMode) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
return IS_MASTER;
|
||||||
|
case MASTER_GATES:
|
||||||
|
if (getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
|
||||||
|
return IS_MASTER;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
if (getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return IS_MASTER;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
if (getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return IS_MASTER;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
default:
|
||||||
|
return NO_MASTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case IS_SLAVE:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
switch (syncMode) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
return IS_SLAVE;
|
||||||
|
case MASTER_GATES:
|
||||||
|
if (getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
|
||||||
|
return IS_SLAVE;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
if (getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
|
||||||
|
return IS_SLAVE;
|
||||||
|
else
|
||||||
|
return NO_MASTER;
|
||||||
|
default:
|
||||||
|
return NO_MASTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
return NO_MASTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum synchronizationMode setSynchronization(enum synchronizationMode arg){
|
||||||
|
/*
|
||||||
|
int i;
|
||||||
|
|
||||||
|
switch(s) {
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
syncMode=NO_SYNCHRONIZATION;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
setFPGASignal(i,SIGNAL_OFF);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// disable external signals?
|
||||||
|
case MASTER_GATES:
|
||||||
|
// configure gate in or out
|
||||||
|
syncMode=MASTER_GATES;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER)
|
||||||
|
setFPGASignal(i,GATE_OUT_ACTIVE_HIGH);
|
||||||
|
else if (masterMode==IS_SLAVE)
|
||||||
|
setFPGASignal(i,GATE_IN_ACTIVE_HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
// configure trigger in or out
|
||||||
|
syncMode=MASTER_TRIGGERS;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER)
|
||||||
|
setFPGASignal(i,TRIGGER_OUT_RISING_EDGE);
|
||||||
|
else if (masterMode==IS_SLAVE)
|
||||||
|
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
// configure trigger in or out
|
||||||
|
syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS;
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER)
|
||||||
|
setFPGASignal(i,RO_TRIGGER_OUT_RISING_EDGE);
|
||||||
|
else if (masterMode==IS_SLAVE)
|
||||||
|
setFPGASignal(i,TRIGGER_IN_RISING_EDGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
//do nothing
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (syncMode) {
|
||||||
|
|
||||||
|
case NO_SYNCHRONIZATION:
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
case MASTER_GATES:
|
||||||
|
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER && getFPGASignal(i)==GATE_OUT_ACTIVE_HIGH)
|
||||||
|
return MASTER_GATES;
|
||||||
|
else if (masterMode==IS_SLAVE && getFPGASignal(i)==GATE_IN_ACTIVE_HIGH)
|
||||||
|
return MASTER_GATES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
case MASTER_TRIGGERS:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER && getFPGASignal(i)==TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return MASTER_TRIGGERS;
|
||||||
|
else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
|
||||||
|
return MASTER_TRIGGERS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
case SLAVE_STARTS_WHEN_MASTER_STOPS:
|
||||||
|
for (i=0; i<4; i++) {
|
||||||
|
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
|
||||||
|
if (masterMode==IS_MASTER && getFPGASignal(i)==RO_TRIGGER_OUT_RISING_EDGE)
|
||||||
|
return SLAVE_STARTS_WHEN_MASTER_STOPS;
|
||||||
|
else if (masterMode==IS_SLAVE && getFPGASignal(i)==TRIGGER_IN_RISING_EDGE)
|
||||||
|
return SLAVE_STARTS_WHEN_MASTER_STOPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return NO_SYNCHRONIZATION;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
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,7 +1,7 @@
|
|||||||
/* 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 "server_funcs.h"
|
#include "slsDetectorServer_funcs.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
init_detector(b); //defined in server_funcs
|
init_detector(b); //defined in slsDetectorServer_funcs
|
||||||
|
|
||||||
|
|
||||||
sd=bindSocket(portno); //defined in communication_funcs
|
sd=bindSocket(portno); //defined in communication_funcs
|
||||||
@ -53,7 +53,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* assign function table */
|
/* assign function table */
|
||||||
function_table(); //defined in server_funcs
|
function_table(); //defined in slsDetectorServer_funcs
|
||||||
#ifdef VERBOSE
|
#ifdef VERBOSE
|
||||||
printf("function table assigned \n");
|
printf("function table assigned \n");
|
||||||
#endif
|
#endif
|
||||||
@ -72,7 +72,7 @@ int main(int argc, char *argv[])
|
|||||||
printf("Conenction accepted\n");
|
printf("Conenction accepted\n");
|
||||||
#endif
|
#endif
|
||||||
if (fd>0) {
|
if (fd>0) {
|
||||||
retval=decode_function(fd); //defined in server_funcs
|
retval=decode_function(fd); //defined in slsDetectorServer_funcs
|
||||||
#ifdef VERY_VERBOSE
|
#ifdef VERY_VERBOSE
|
||||||
printf("function executed\n");
|
printf("function executed\n");
|
||||||
#endif
|
#endif
|
||||||
|
41
slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c
Executable file
41
slsDetectorSoftware/slsDetectorServer/slsDetector_stopServer.c
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
/* 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"
|
||||||
|
|
||||||
|
|
||||||
|
int sockfd;
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int portno;
|
||||||
|
int retval=0;
|
||||||
|
|
||||||
|
portno = DEFAULT_PORTNO;
|
||||||
|
|
||||||
|
|
||||||
|
bindSocket(portno); //defined in communication_funcs
|
||||||
|
if (getServerError()) //defined in communication_funcs
|
||||||
|
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(); //defined in communication_funcs
|
||||||
|
retval=stopStateMachine();//defined in slsDetectorFirmare_funcs
|
||||||
|
closeConnection(); //defined in communication_funcs
|
||||||
|
}
|
||||||
|
|
||||||
|
exitServer(); //defined in communication_funcs
|
||||||
|
printf("Goodbye!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user