mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 01:58:00 +02:00
Internal timer added
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@39 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
@ -13,8 +13,7 @@ INSTMODE= 0777
|
||||
SRCS= server.c server_funcs.c communication_funcs.c firmware_funcs.c mcb_funcs.c trimming_funcs.c sharedmemory.c
|
||||
OBJS= $(SRCS:%.c=%.o)
|
||||
|
||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS
|
||||
#-DVERBOSE
|
||||
CFLAGS+= -Wall -DC_ONLY -DMCB_FUNCS -DVERBOSE
|
||||
#-DVERYVERBOSE
|
||||
#-Werror
|
||||
|
||||
|
@ -580,10 +580,14 @@ int64_t set64BitReg(int64_t value, int aLSB, int aMSB){
|
||||
int64_t get64BitReg(int aLSB, int aMSB){
|
||||
int64_t v64;
|
||||
u_int32_t vLSB,vMSB;
|
||||
vLSB=bus_r(aLSB);
|
||||
vMSB=bus_r(aMSB);
|
||||
vLSB=bus_r(aLSB);
|
||||
v64=vMSB;
|
||||
v64=(v64<<32) | vLSB;
|
||||
#ifdef VERBOSE
|
||||
printf("MSB %08x LSB %08x, %016llx\n", vMSB, vLSB, v64);
|
||||
#endif
|
||||
|
||||
return v64;
|
||||
}
|
||||
|
||||
@ -699,6 +703,23 @@ int64_t getProgress() {
|
||||
}
|
||||
|
||||
|
||||
int64_t getActualTime(){
|
||||
return get64BitReg(GET_ACTUAL_TIME_LSB_REG, GET_ACTUAL_TIME_MSB_REG)/(1E-9*CLK_FREQ);
|
||||
}
|
||||
|
||||
int64_t getMeasurementTime(){
|
||||
int64_t v=get64BitReg(GET_MEASUREMENT_TIME_LSB_REG, GET_MEASUREMENT_TIME_MSB_REG);
|
||||
int64_t mask=0x8000000000000000;
|
||||
if (v & mask ) {
|
||||
#ifdef VERBOSE
|
||||
printf("no measurement time left\n");
|
||||
#endif
|
||||
return -1E+9;
|
||||
} else
|
||||
return v/(1E-9*CLK_FREQ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int64_t getProbes(){
|
||||
u_int32_t shiftin=bus_r(GET_SHIFT_IN_REG);
|
||||
|
@ -78,7 +78,8 @@ int64_t getProbes();
|
||||
int64_t getProgress();
|
||||
int64_t setProgress();
|
||||
|
||||
|
||||
int64_t getActualTime();
|
||||
int64_t getMeasurementTime();
|
||||
|
||||
u_int32_t runBusy(void);
|
||||
u_int32_t runState(void);
|
||||
|
@ -54,8 +54,15 @@
|
||||
#define GET_TRAINS_LSB_REG 0x020000
|
||||
#define GET_TRAINS_MSB_REG 0x021000
|
||||
|
||||
|
||||
#define GET_SHIFT_IN_REG 0x022000
|
||||
|
||||
#define GET_MEASUREMENT_TIME_LSB_REG 0x023000
|
||||
#define GET_MEASUREMENT_TIME_MSB_REG 0x024000
|
||||
|
||||
#define GET_ACTUAL_TIME_LSB_REG 0x025000
|
||||
#define GET_ACTUAL_TIME_MSB_REG 0x026000
|
||||
|
||||
#define MOD_DACS1_REG 0x030000
|
||||
#define MOD_DACS2_REG 0x040000
|
||||
|
||||
|
@ -74,7 +74,7 @@ int decode_function() {
|
||||
#endif
|
||||
n = receiveDataOnly(&fnum,sizeof(fnum));
|
||||
if (n <= 0) {
|
||||
printf("ERROR reading from socket %d", n);
|
||||
printf("ERROR reading from socket %d\n", n);
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
@ -1965,6 +1965,12 @@ int get_time_left(int fnum) {
|
||||
case PROGRESS:
|
||||
retval=getProgress();
|
||||
break;
|
||||
case ACTUAL_TIME:
|
||||
retval=getActualTime();
|
||||
break;
|
||||
case MEASUREMENT_TIME:
|
||||
retval=getMeasurementTime();
|
||||
break;
|
||||
default:
|
||||
ret=FAIL;
|
||||
sprintf(mess,"timer index unknown %d\n",ind);
|
||||
@ -1976,12 +1982,21 @@ int get_time_left(int fnum) {
|
||||
printf("get time left failed\n");
|
||||
}
|
||||
|
||||
#ifdef VERBOSE
|
||||
|
||||
printf("time left on timer %d is %lld\n",ind, retval);
|
||||
#endif
|
||||
|
||||
n = sendDataOnly(&ret,sizeof(ret));
|
||||
if (ret!=OK) {
|
||||
n += sendDataOnly(mess,sizeof(mess));
|
||||
} else {
|
||||
n = sendDataOnly(&retval,sizeof(retval));
|
||||
}
|
||||
#ifdef VERBOSE
|
||||
|
||||
printf("data sent\n");
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
||||
|
Reference in New Issue
Block a user