removed slsdetectoserver to revert to Annas basic form

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@569 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2013-05-21 15:09:35 +00:00
parent d8a1e20d80
commit 05a57ad3b0
15 changed files with 0 additions and 4403 deletions

View File

@ -1,26 +0,0 @@
CC =gcc
CLAGS += -Wall -DVIRTUAL -DDACS_INT -DSLS_DETECTOR_FUNCTION_LIST -DEIGERD
LDLIBS += -lm
PROGS = slsDetectorServer
DESTDIR ?= bin
INSTMODE = 0777
SRC_CLNT = slsDetectorServer.c slsDetectorServer_funcs.c communication_funcs.c slsDetector_firmware.c slsDetectorFunctionList.c
OBJS = $(SRC_CLNT:.cpp=.o)
all: clean $(PROGS)
boot: $(OBJS)
$(PROGS):
echo $(OBJS)
mkdir -p $(DESTDIR)
$(CC) $(SRC_CLNT) $(CLAGS) $(LDLIBS) -o $@
mv $(PROGS) $(DESTDIR)
clean:
rm -rf $(DESTDIR)/$(PROGS) *.o

View File

@ -1 +0,0 @@
../commonFiles/communication_funcs.c

View File

@ -1 +0,0 @@
../commonFiles/communication_funcs.h

View File

@ -1,53 +0,0 @@
/*
* registers.h
*
* Created on: Jan 24, 2013
* Author: l_maliakal_d
*/
#ifndef REGISTERS_H_
#define REGISTERS_H_
#include "sls_detector_defs.h"
#define CSP0 0x90000000
#define MEM_SIZE 0xFFFFFFF
#define STATUS_REG 0x0a000
#define SET_FRAMES_LSB_REG 0x10000
#define SET_FRAMES_MSB_REG 0x11000
#define GET_FRAMES_LSB_REG 0x12000
#define GET_FRAMES_MSB_REG 0x13000
#define SET_EXPTIME_LSB_REG 0x14000
#define SET_EXPTIME_MSB_REG 0x15000
#define GET_EXPTIME_LSB_REG 0x16000
#define GET_EXPTIME_MSB_REG 0x17000
#define SET_GATES_LSB_REG 0x18000
#define SET_GATES_MSB_REG 0x19000
#define GET_GATES_LSB_REG 0x1a000
#define GET_GATES_MSB_REG 0x1b000
#define SET_PERIOD_LSB_REG 0x1c000
#define SET_PERIOD_MSB_REG 0x1d000
#define GET_PERIOD_LSB_REG 0x1e000
#define GET_PERIOD_MSB_REG 0x1f000
#define SET_DELAY_LSB_REG 0x20000
#define SET_DELAY_MSB_REG 0x21000
#define GET_DELAY_LSB_REG 0x22000
#define GET_DELAY_MSB_REG 0x23000
#define SET_TRAINS_LSB_REG 0x24000
#define SET_TRAINS_MSB_REG 0x25000
#define GET_TRAINS_LSB_REG 0x26000
#define GET_TRAINS_MSB_REG 0x27000
#endif /* REGISTERS_H_ */

View File

@ -1,802 +0,0 @@
#ifdef SLS_DETECTOR_FUNCTION_LIST
#include "slsDetectorFunctionList.h"
#include "slsDetectorServer_defs.h"
#include <stdio.h>
#include <string.h>
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;
}
int setNMod(int nm, enum dimension dim){
return 1;
}
int getNModBoard(enum dimension arg){
return 1;
}
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){
//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:
// 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;
}
#endif

View File

@ -1,106 +0,0 @@
#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>
#include <sys/mman.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
#include <asm/page.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdarg.h>
#include <unistd.h>
*/
/****************************************************
This functions are used by the slsDetectroServer_funcs interface.
Here are the definitions, but the actual implementation should be done for each single detector.
****************************************************/
int initializeDetector();
int setNMod(int nm, enum dimension dim);
int getNModBoard(enum dimension 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);
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 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);
int configureMAC(int ipad, long long int imacadd, long long int iservermacadd, int dtb);
int loadImage(enum imageType index, char *imageVals);
int readCounterBlock(int startACQ, char *counterVals);
int resetCounterBlock(int startACQ);
int calculateDataBytes();
int getTotalNumberOfChannels();
int getTotalNumberOfChips();
int getTotalNumberOfModules();
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

View File

@ -1,96 +0,0 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "sls_detector_defs.h"
#include "communication_funcs.h"
#include "slsDetectorServer_funcs.h"
#include "slsDetectorServer_defs.h"
#include <stdio.h>
#include <stdlib.h>
extern int sockfd;
void error(char *msg)
{
perror(msg);
}
int main(int argc, char *argv[])
{
int portno, b;
char cmd[100];
int retval=OK;
int sd, fd;
if (argc==1) {
portno = DEFAULT_PORTNO;
sprintf(cmd,"%s %d &",argv[0],DEFAULT_PORTNO+1);
printf("opening control server on port %d\n",portno );
system(cmd);
b=1;
} else {
portno = DEFAULT_PORTNO+1;
if ( sscanf(argv[1],"%d",&portno) ==0) {
printf("could not open stop server: unknown port\n");
return 1;
}
b=0;
printf("opening stop server on port %d\n",portno);
}
init_detector(b); //defined in slsDetectorServer_funcs
sd=bindSocket(portno); //defined in communication_funcs
sockfd=sd;
if (getServerError(sd)) { //defined in communication_funcs
printf("server error!\n");
return -1;
}
/* assign function table */
function_table(); //defined in slsDetectorServer_funcs
#ifdef VERBOSE
printf("function table assigned \n");
#endif
/* waits for connection */
while(retval!=GOODBYE) {
#ifdef VERBOSE
printf("\n");
#endif
#ifdef VERY_VERBOSE
printf("Waiting for client call\n");
#endif
fd=acceptConnection(sockfd); //defined in communication_funcs
#ifdef VERY_VERBOSE
printf("Conenction accepted\n");
#endif
if (fd>0) {
retval=decode_function(fd); //defined in slsDetectorServer_funcs
#ifdef VERY_VERBOSE
printf("function executed\n");
#endif
closeConnection(fd); //defined in communication_funcs
#ifdef VERY_VERBOSE
printf("connection closed\n");
#endif
}
}
exitServer(sockfd); //defined in communication_funcs
printf("Goodbye!\n");
return 0;
}

View File

@ -1,31 +0,0 @@
/*
* slsDetectorServer_defs.h
*
* Created on: Jan 24, 2013
* Author: l_maliakal_d
*/
#ifndef SLSDETECTORSERVER_DEFS_H_
#define SLSDETECTORSERVER_DEFS_H_
#include "sls_detector_defs.h"
#include <stdint.h>
#define GOODBYE -200
#define NCHAN 1
#define NCHIP 1
#define NDAC 1
#define NADC 1
#define NMAXMODX 1
#define NMAXMODY 1
#define NMAXMOD NMAXMODX*NMAXMODY
#define NCHANS NCHAN*NCHIP*NMAXMOD
#define NDACS NDAC*NMAXMOD
#define DYNAMIC_RANGE 16
#define CLK_FREQ 100E+6
#endif /* SLSDETECTORSERVER_DEFS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -1,79 +0,0 @@
#ifndef SERVER_FUNCS_H
#define SERVER_FUNCS_H
#include "sls_detector_defs.h"
#include <stdlib.h>
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);
int exit_server(int);
// General purpose functions
int get_detector_type(int);
int set_number_of_modules(int);
int get_max_number_of_modules(int);
int exec_command(int);
int set_external_signal_flag(int);
int set_external_communication_mode(int);
int get_id(int);
int digital_test(int);
int write_register(int);
int read_register(int);
int set_dac(int);
int get_adc(int);
int set_channel(int);
int set_chip(int);
int set_module(int);
int get_channel(int);
int get_chip(int);
int get_module(int);
int get_threshold_energy(int);
int set_threshold_energy(int);
int set_settings(int);
int start_acquisition(int);
int stop_acquisition(int);
int start_readout(int);
int get_run_status(int);
int read_frame(int);
int read_all(int);
int start_and_read_all(int);
int set_timer(int);
int get_time_left(int);
int set_dynamic_range(int);
int set_roi(int);
int get_roi(int);
int set_speed(int);
int set_readout_flags(int);
int execute_trimming(int);
int lock_server(int);
int set_port(int);
int get_last_client_ip(int);
int set_master(int);
int set_synchronization(int);
int configure_mac(int);
int load_image(int);
int read_counter_block(int);
int reset_counter_block(int);
int update_client(int);
int send_update(int);
#endif

View File

@ -1,170 +0,0 @@
#include "sls_detector_defs.h"
#include "slsDetector_firmware.h"
#include "slsDetectorServer_defs.h"
#include "registers.h"
#include <stdio.h>
#include <string.h>
u_int32_t CSP0BASE;
int nModBoard;
int nModY = NMAXMOD;
int nModX = NMAXMOD;
int dynamicRange= DYNAMIC_RANGE;
int dataBytes = NMAXMOD*NCHIP*NCHAN*2;
int masterMode = NO_MASTER;
int syncMode = NO_SYNCHRONIZATION;
int timingMode = AUTO_TIMING;
#ifdef SLS_DETECTOR_FUNCTION_LIST
extern const int nChans;
extern const int nChips;
extern const int nDacs;
extern const int nAdcs;
#endif
#ifndef SLS_DETECTOR_FUNCTION_LIST
const int nChans = NCHAN;
const int nChips = NCHIP;
const int nDacs = NDAC;
const int nAdcs = NADC;
#endif
int mapCSP0(void) {
printf("Mapping memory\n");
#ifdef VIRTUAL
CSP0BASE = (u_int32_t)malloc(MEM_SIZE);
printf("memory allocated\n");
#endif
printf("CSPOBASE=from %08x to %x\n",CSP0BASE,CSP0BASE+MEM_SIZE);
return OK;
}
u_int32_t bus_w(u_int32_t offset, u_int32_t data) {
volatile u_int32_t *ptr1;
ptr1=(u_int32_t*)(CSP0BASE+offset);
*ptr1=data;
return OK;
}
u_int32_t bus_r(u_int32_t offset) {
volatile u_int32_t *ptr1;
ptr1=(u_int32_t*)(CSP0BASE+offset);
return *ptr1;
}
int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
int64_t v64;
u_int32_t vLSB,vMSB;
if (value!=-1) {
vLSB=value&(0xffffffff);
bus_w(aLSB,vLSB);
v64=value>> 32;
vMSB=v64&(0xffffffff);
bus_w(aMSB,vMSB);
}
return get64BitReg(aLSB, aMSB);
}
int64_t get64BitReg(int aLSB, int aMSB){
int64_t v64;
u_int32_t vLSB,vMSB;
vLSB=bus_r(aLSB);
vMSB=bus_r(aMSB);
v64=vMSB;
v64=(v64<<32) | vLSB;
return v64;
}
int64_t setFrames(int64_t value){
return set64BitReg(value, SET_FRAMES_LSB_REG, SET_FRAMES_MSB_REG);
}
int64_t getFrames(){
return get64BitReg(GET_FRAMES_LSB_REG, GET_FRAMES_MSB_REG);
}
int64_t setExposureTime(int64_t value){
/* time is in ns */
if (value!=-1)
value*=(1E-9*CLK_FREQ);
return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t getExposureTime(){
return get64BitReg(GET_EXPTIME_LSB_REG, GET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t setGates(int64_t value){
return set64BitReg(value, SET_GATES_LSB_REG, SET_GATES_MSB_REG);
}
int64_t getGates(){
return get64BitReg(GET_GATES_LSB_REG, GET_GATES_MSB_REG);
}
int64_t setPeriod(int64_t value){
/* time is in ns */
if (value!=-1)
value*=(1E-9*CLK_FREQ);
return set64BitReg(value,SET_PERIOD_LSB_REG, SET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t getPeriod(){
return get64BitReg(GET_PERIOD_LSB_REG, GET_PERIOD_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t setDelay(int64_t value){
/* time is in ns */
if (value!=-1) {
value*=(1E-9*CLK_FREQ);
}
return set64BitReg(value,SET_DELAY_LSB_REG, SET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t getDelay(){
return get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t setTrains(int64_t value){
return set64BitReg(value, SET_TRAINS_LSB_REG, SET_TRAINS_MSB_REG);
}
int64_t getTrains(){
return get64BitReg(GET_TRAINS_LSB_REG, GET_TRAINS_MSB_REG);
}
int64_t setProbes(int64_t value){
return 0;
}
int64_t getProbes(){
return 0;
}

View File

@ -1,171 +0,0 @@
/*
* slsDetector_firmware.h
*
* Created on: Jan 24, 2013
* Author: l_maliakal_d
*/
#ifndef SLSDETECTOR_FIRMWARE_H_
#define SLSDETECTOR_FIRMWARE_H_
#include "sls_detector_defs.h"
#include <stdlib.h>
//memory
int mapCSP0(void);
u_int32_t bus_w(u_int32_t offset, u_int32_t data);
u_int32_t bus_r(u_int32_t offset);
//Acquisition Parameters
int64_t set64BitReg(int64_t value, int aLSB, int aMSB);
int64_t get64BitReg(int aLSB, int aMSB);
int64_t setFrames(int64_t value);
int64_t getFrames();
int64_t setExposureTime(int64_t value);
int64_t getExposureTime();
int64_t setGates(int64_t value);
int64_t getGates();
int64_t setDelay(int64_t value);
int64_t getDelay();
int64_t setPeriod(int64_t value);
int64_t getPeriod();
int64_t setTrains(int64_t value);
int64_t getTrains();
int64_t setProbes(int64_t value);
int64_t getProbes();
/*
u_int16_t bus_w16(u_int32_t offset, u_int16_t data);//aldos function
u_int32_t bus_r(u_int32_t offset);
int setPhaseShiftOnce();
int cleanFifo();
int setDAQRegister(int adcval);
u_int32_t putout(char *s, int modnum);
u_int32_t readin(int modnum);
u_int32_t setClockDivider(int d);
u_int32_t getClockDivider();
u_int32_t setSetLength(int d);
u_int32_t getSetLength();
u_int32_t setWaitStates(int d);
u_int32_t getWaitStates();
u_int32_t setTotClockDivider(int d);
u_int32_t getTotClockDivider();
u_int32_t setTotDutyCycle(int d);
u_int32_t getTotDutyCycle();
u_int32_t setExtSignal(int d, enum externalSignalFlag mode);
int getExtSignal(int d);
u_int32_t setFPGASignal(int d, enum externalSignalFlag mode);
int getFPGASignal(int d);
int setTiming(int t);
int setConfigurationRegister(int d);
int setToT(int d);
int setContinousReadOut(int d);
int startReceiver(int d);
int setDACRegister(int idac, int val, int imod);
int getTemperature(int tempSensor,int imod);
int initHighVoltage(int val,int imod);
int initConfGain(int isettings,int val,int imod);
int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int ival, int adc,int udpport);
int getAdcConfigured();
u_int64_t getDetectorNumber();
u_int32_t getFirmwareVersion();
int testFifos(void);
u_int32_t testFpga(void);
u_int32_t testRAM(void);
int testBus(void);
int setDigitalTestBit(int ival);
int64_t getProgress();
int64_t setProgress();
int64_t getActualTime();
int64_t getMeasurementTime();
u_int32_t runBusy(void);
u_int32_t runState(void);
u_int32_t dataPresent(void);
int startStateMachine();
int stopStateMachine();
int startReadOut();
u_int32_t fifoReset(void);
u_int32_t fifoReadCounter(int fifonum);
u_int32_t fifoReadStatus();
u_int32_t fifo_full(void);
u_int32_t* fifo_read_event();
u_int32_t* decode_data(int* datain);
//u_int32_t move_data(u_int64_t* datain, u_int64_t* dataout);
int setDynamicRange(int dr);
int getDynamicRange();
int getNModBoard();
int setNMod(int n);
int setStoreInRAM(int b);
int allocateRAM();
int clearRAM();
int setMaster(int f);
int setSynchronization(int s);
int loadImage(int index, short int ImageVals[]);
int readCounterBlock(int startACQ, short int CounterVals[]);
int resetCounterBlock(int startACQ);
u_int32_t setNBits(u_int32_t);
u_int32_t getNBits();
*/
/*
//move to mcb_funcs?
int readOutChan(int *val);
u_int32_t getModuleNumber(int modnum);
int testShiftIn(int imod);
int testShiftOut(int imod);
int testShiftStSel(int imod);
int testDataInOut(int num, int imod);
int testExtPulse(int imod);
int testExtPulseMux(int imod, int ow);
int testDataInOutMux(int imod, int ow, int num);
int testOutMux(int imod);
int testFpgaMux(int imod);
int calibration_sensor(int num, int *values, int *dacs) ;
int calibration_chip(int num, int *values, int *dacs);
*/
#endif /* SLSDETECTOR_FIRMWARE_H_ */

View File

@ -1,46 +0,0 @@
/* A simple server in the internet domain using TCP
The port number is passed as an argument */
#include "communication_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 main(int argc, char *argv[])
{
int portno;
int retval=0;
int sd,fd;
portno = DEFAULT_PORTNO;
sd=bindSocket(portno); //defined in communication_funcs
if (getServerError(sd)) //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
fd=acceptConnection(sd); //defined in communication_funcs
retval=stopStateMachine();//defined in slsDetectorFirmare_funcs
closeConnection(fd); //defined in communication_funcs
}
exitServer(sd); //defined in communication_funcs
printf("Goodbye!\n");
return 0;
}

View File

@ -1 +0,0 @@
../commonFiles/sls_detector_defs.h

View File

@ -1 +0,0 @@
../commonFiles/sls_detector_funcs.h