timing functions changed

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@133 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
bergamaschi 2012-02-27 16:29:40 +00:00
parent 1064bd21ff
commit b755c533f0
13 changed files with 733 additions and 245 deletions

View File

@ -204,7 +204,7 @@ enum {
*/
enum externalSignalFlag {
GET_EXTERNAL_SIGNAL_FLAG=-1, /**<return flag for signal */
SIGNAL_OFF, /**<signal unused*/
SIGNAL_OFF, /**<signal unused - tristate*/
GATE_IN_ACTIVE_HIGH, /**<input gate active high*/
GATE_IN_ACTIVE_LOW, /**<input gate active low */
TRIGGER_IN_RISING_EDGE, /**<input exposure trigger on rising edge */
@ -216,24 +216,25 @@ enum externalSignalFlag {
TRIGGER_OUT_RISING_EDGE, /**<output trigger rising edge at start of exposure */
TRIGGER_OUT_FALLING_EDGE, /**<output trigger falling edge at start of exposure */
RO_TRIGGER_OUT_RISING_EDGE, /**<output trigger rising edge at start of readout */
RO_TRIGGER_OUT_FALLING_EDGE /**<output trigger falling edge at start of readout */
RO_TRIGGER_OUT_FALLING_EDGE, /**<output trigger falling edge at start of readout */
OUTPUT_LOW, /**< output always low */
OUTPUT_HIGH, /**< output always high */
MASTER_SLAVE_SYNCHRONIZATION /**< reserved for master/slave synchronization in multi detector systems */
};
/**
communication mode using external signals (obsolete: it will be authomatically determined by the external signal flags)
\see ::externalSignalFlag
communication mode using external signals
*/
enum externalCommunicationMode{
GET_EXTERNAL_COMMUNICATION_MODE=-1,
AUTO,
TRIGGER_EXPOSURE,
TRIGGER_READOUT,
TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE,
GATE_FIX_NUMBER,
GATE_FIX_DURATION,
GATE_WITH_START_TRIGGER,
GATE_COINCIDENCE_WITH_INTERNAL_ENABLE
GET_EXTERNAL_COMMUNICATION_MODE=-1,/**<return flag for communication mode */
AUTO_TIMING, /**< internal timing */
TRIGGER_EXPOSURE, /**< trigger mode i.e. exposure is triggered */
TRIGGER_READOUT, /**< stop trigger mode i.e. readout is triggered by external signal */
TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE, /**< still to be implemented */
GATE_FIX_NUMBER, /**< gated and reads out after a fixxed number of gates */
GATE_FIX_DURATION, /**< still to be implemented */
GATE_WITH_START_TRIGGER, /**< gated with start trigger */
GATE_COINCIDENCE_WITH_INTERNAL_ENABLE /**< still to be implemented */
};
/**
detector IDs/versions
@ -429,7 +430,7 @@ enum masterFlags {
/** synchronization in a multidetector structure, if any */
enum synchronizationMode {
GET_SYNCHRONIZATION_MODE=-1, /**< the multidetector will return its synchronization mode */
NONE, /**< all detectors are independent (no cabling) */
NO_SYNCHRONIZATION, /**< all detectors are independent (no cabling) */
MASTER_GATES, /**< the master gates the other detectors */
MASTER_TRIGGERS, /**< the master triggers the other detectors */
SLAVE_STARTS_WHEN_MASTER_STOPS /**< the slave acquires when the master finishes, to avoid deadtime */

View File

@ -554,63 +554,61 @@ int multiSlsDetector::removeSlsDetector(int pos) {
int multiSlsDetector::setMaster(int i) {
if (i>=0 && i<thisMultiDetector->numberOfDetectors)
if (detectors[i])
thisMultiDetector->masterPosition=i;
switch (thisMultiDetector->syncMode) {
case MASTER_GATES:
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition) {
if (detectors[i]) {
detectors[i]->setExternalSignalFlags(GATE_IN_ACTIVE_HIGH, 0);
detectors[i]->setTimer(GATES_NUMBER, 1);
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 1);
}
} else {
detectors[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2);
int ret=-1, slave=0;
masterFlags f;
if (i>=0 && i<thisMultiDetector->numberOfDetectors) {
if (detectors[i]) {
thisMultiDetector->masterPosition=i;
detectors[i]->setMaster(IS_MASTER);
}
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
if (i!=id) {
if (detectors[id]) {
detectors[id]->setMaster(IS_SLAVE);
}
}
}
} else if (i==-2) {
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
if (detectors[id]) {
detectors[id]->setMaster(NO_MASTER);
}
}
break;
case MASTER_TRIGGERS:
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition) {
if (detectors[i]) {
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 0);
detectors[i]->setExternalSignalFlags(TRIGGER_IN_RISING_EDGE, 1);
}
} else {
detectors[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2);
}
}
break;
case SLAVE_STARTS_WHEN_MASTER_STOPS:
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
if (i!=thisMultiDetector->masterPosition) {
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 0);
detectors[i]->setExternalSignalFlags(TRIGGER_IN_FALLING_EDGE, 1);
} else {
detectors[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2);
}
}
}
break;
default:
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 0);
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 1);
}
}
}
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
if (detectors[id]) {
f=detectors[id]->setMaster(GET_MASTER);
switch (f) {
case NO_MASTER:
if (ret!=-1)
ret=-2;
break;
case IS_MASTER:
if (ret==-1)
ret=id;
else
ret=-2;
break;
case IS_SLAVE:
slave=1;
default:
ret=-2;
}
}
}
if (slave>0 && ret<0)
ret=-2;
if (ret<0)
ret=-1;
thisMultiDetector->masterPosition=ret;
return thisMultiDetector->masterPosition;
}
@ -629,71 +627,22 @@ int multiSlsDetector::setMaster(int i) {
\returns current syncronization mode
*/
synchronizationMode multiSlsDetector::setSynchronization(synchronizationMode sync) {
if (sync>GET_SYNCHRONIZATION_MODE) {
switch (sync) {
case MASTER_GATES:
synchronizationMode ret=GET_SYNCHRONIZATION_MODE, ret1=GET_SYNCHRONIZATION_MODE;
for (int id=0; id<thisMultiDetector->numberOfDetectors; id++) {
if (detectors[id]) {
ret1=detectors[id]->setSynchronization(sync);
if (id==0)
ret=ret1;
else if (ret!=ret1)
ret=GET_SYNCHRONIZATION_MODE;
if (thisMultiDetector->masterPosition>=0 && thisMultiDetector->masterPosition<thisMultiDetector->numberOfDetectors) {
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition) {
if (detectors[i]) {
detectors[i]->setExternalSignalFlags(GATE_IN_ACTIVE_HIGH, 0);
detectors[i]->setTimer(GATES_NUMBER, 1);
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 1);
}
} else {
detectors[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2);
}
}
thisMultiDetector->syncMode=sync;
}
break;
case MASTER_TRIGGERS:
if (thisMultiDetector->masterPosition>=0 && thisMultiDetector->masterPosition<thisMultiDetector->numberOfDetectors) {
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition) {
if (detectors[i]) {
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 0);
detectors[i]->setExternalSignalFlags(TRIGGER_IN_RISING_EDGE, 1);
}
} else {
detectors[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2);
}
}
thisMultiDetector->syncMode=sync;
}
break;
case SLAVE_STARTS_WHEN_MASTER_STOPS:
if (thisMultiDetector->masterPosition>=0 && thisMultiDetector->masterPosition<thisMultiDetector->numberOfDetectors) {
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
if (i!=thisMultiDetector->masterPosition) {
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 0);
detectors[i]->setExternalSignalFlags(TRIGGER_IN_FALLING_EDGE, 1);
}
} else {
detectors[i]->setExternalSignalFlags(GATE_OUT_ACTIVE_HIGH, 2);
}
}
thisMultiDetector->syncMode=sync;
}
break;
default:
for (int i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 0);
detectors[i]->setExternalSignalFlags(SIGNAL_OFF, 1);
}
}
thisMultiDetector->syncMode=sync;
}
}
}
thisMultiDetector->syncMode=ret;
return thisMultiDetector->syncMode;
@ -1261,53 +1210,21 @@ int64_t multiSlsDetector::setTimer(timerIndex index, int64_t t){
int64_t ret1=-100, ret;
if (index!=ACQUISITION_TIME) {
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
ret=detectors[i]->setTimer(index,t);
if (ret1==-100)
ret1=ret;
else if (ret!=ret1)
ret1=FAIL;
}
}
} else {
switch(thisMultiDetector->syncMode) {
case MASTER_GATES:
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (i!=thisMultiDetector->masterPosition)
if (detectors[i]) {
ret=detectors[i]->setTimer(GATES_NUMBER,1);
}
}
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
ret=detectors[i]->setTimer(index,t);
if (ret1==-100)
ret1=ret;
else if (ret!=ret1)
ret1=FAIL;
i=thisMultiDetector->masterPosition;
if (thisMultiDetector->masterPosition>=0) {
if (detectors[i]) {
ret=detectors[i]->setTimer(index,t);
ret1=ret;
}
}
break;
default:
for (i=0; i<thisMultiDetector->numberOfDetectors; i++) {
if (detectors[i]) {
ret=detectors[i]->setTimer(index,t);
if (ret1==-100)
ret1=ret;
else if (ret!=ret1)
ret1=FAIL;
}
}
}
}
// check return values!!!
thisMultiDetector->timerValue[index]=ret1;
return ret1;
};

View File

@ -293,7 +293,7 @@ class multiSlsDetector : public slsDetectorUtils {
/** sets the detector in position i as master of the structure (e.g. it gates the other detectors and therefore must be started as last. <BR> Assumes that signal 0 is gate in, signal 1 is trigger in, signal 2 is gate out
\param i position of master (-1 gets)
\param i position of master (-1 gets, -2 unset)
\return master's position (-1 none)
*/
int setMaster(int i=-1);
@ -874,6 +874,8 @@ class multiSlsDetector : public slsDetectorUtils {
externalSignalFlag setExternalSignalFlags(externalSignalFlag pol=GET_EXTERNAL_SIGNAL_FLAG , int signalindex=0);
int setReadOutFlags(readOutFlags flag=GET_READOUT_FLAGS);
externalCommunicationMode setExternalCommunicationMode(externalCommunicationMode pol=GET_EXTERNAL_COMMUNICATION_MODE);
/**

View File

@ -44,6 +44,10 @@ u_int32_t progressMask=0;
int ififostart, ififostop, ififostep, ififo;
int masterMode=NO_MASTER, syncMode=NO_SYNCHRONIZATION;
enum externalSignalFlag signals[4]={EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF, EXT_SIG_OFF};
#ifdef MCB_FUNCS
extern const int nChans;
@ -239,21 +243,66 @@ u_int32_t getTotDutyCycle() {
u_int32_t setExtSignal(int d, enum externalSignalFlag mode) {
int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING};
u_int32_t c;
int off=d*SIGNAL_OFFSET;
c=bus_r(EXT_SIGNAL_REG);
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0)
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
if (d>=0 && d<4) {
signals[d]=mode;
// if output signal, set it!
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=GATE_OUT_ACTIVE_HIGH && signals[d]!=MASTER_SLAVE_SYNCHRONIZATION)
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
}
return getExtSignal(d);
}
u_int32_t setFPGASignal(int d, enum externalSignalFlag mode) {
int modes[]={EXT_SIG_OFF, EXT_GATE_IN_ACTIVEHIGH, EXT_GATE_IN_ACTIVELOW,EXT_TRIG_IN_RISING,EXT_TRIG_IN_FALLING,EXT_RO_TRIG_IN_RISING, EXT_RO_TRIG_IN_FALLING,EXT_GATE_OUT_ACTIVEHIGH, EXT_GATE_OUT_ACTIVELOW, EXT_TRIG_OUT_RISING, EXT_TRIG_OUT_FALLING, EXT_RO_TRIG_OUT_RISING, EXT_RO_TRIG_OUT_FALLING};
u_int32_t c;
int off=d*SIGNAL_OFFSET;
c=bus_r(EXT_SIGNAL_REG);
if (mode<=RO_TRIGGER_OUT_FALLING_EDGE && mode>=0)
bus_w(EXT_SIGNAL_REG,((modes[mode])<<off)|(c&~(SIGNAL_MASK<<off)));
return getExtSignal(d);
}
int getExtSignal(int d) {
/* int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE}; */
/* int off=d*SIGNAL_OFFSET; */
/* int mode=((bus_r(EXT_SIGNAL_REG)&(SIGNAL_MASK<<off))>>off); */
/* if (mode<RO_TRIGGER_OUT_FALLING_EDGE) */
/* return modes[mode]; */
/* else */
/* return -1; */
if (d>=0 && d<4)
return signals[d];
else
return -1;
}
int getFPGASignal(int d) {
int modes[]={SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW,TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE,RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE,RO_TRIGGER_OUT_FALLING_EDGE};
int off=d*SIGNAL_OFFSET;
@ -261,12 +310,136 @@ int getExtSignal(int d) {
if (mode<RO_TRIGGER_OUT_FALLING_EDGE)
return modes[mode];
else
else
return -1;
}
/*
enum externalCommunicationMode{
GET_EXTERNAL_COMMUNICATION_MODE,
AUTO,
TRIGGER_EXPOSURE_SERIES,
TRIGGER_EXPOSURE_BURST,
TRIGGER_READOUT,
TRIGGER_COINCIDENCE_WITH_INTERNAL_ENABLE,
GATE_FIX_NUMBER,
GATE_FIX_DURATION,
GATE_WITH_START_TRIGGER,
GATE_COINCIDENCE_WITH_INTERNAL_ENABLE
};
*/
int setTiming(int ti) {
int ret=GET_EXTERNAL_COMMUNICATION_MODE;
int g=-1, t=-1, rot=-1;
int i;
switch (ti) {
case AUTO_TIMING:
// 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:
// 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:
// 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:
// 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:
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;
}
int setConfigurationRegister(int d) {
#ifdef VERBOSE
printf("Setting configuration register to %x",d);
@ -608,7 +781,11 @@ 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);
if (masterMode==IS_SLAVE && syncMode==MASTER_GATES)
setGates(1);
return set64BitReg(value,SET_EXPTIME_LSB_REG, SET_EXPTIME_MSB_REG)/(1E-9*CLK_FREQ);
}
int64_t getExposureTime(){
@ -715,6 +892,7 @@ int64_t getActualTime(){
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");
@ -1272,3 +1450,141 @@ int clearRAM() {
//#endif
return OK;
}
int setMaster(int f) {
int i, s;
switch(f) {
case NO_MASTER:
masterMode=NO_MASTER;
for (i=0; i<4; i++) {
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
setFPGASignal(i,SIGNAL_OFF);
}
}
case IS_MASTER:
// configure gate or trigger out
for (i=0; i<4; i++) {
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
masterMode=IS_MASTER;
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:
;
}
}
}
case IS_SLAVE:
// configure gate or trigger in
for (i=0; i<4; i++) {
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
masterMode=IS_SLAVE;
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:
;
}
}
}
// configure gate or trigger in
default:
//do nothing
;
}
return masterMode;
}
int setSynchronization(int s) {
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
for (i=0; i<4; i++) {
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
syncMode=MASTER_GATES;
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
for (i=0; i<4; i++) {
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
syncMode=MASTER_TRIGGERS;
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
for (i=0; i<4; i++) {
if (signals[i]==MASTER_SLAVE_SYNCHRONIZATION) {
syncMode=SLAVE_STARTS_WHEN_MASTER_STOPS;
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
;
}
return syncMode;
}

View File

@ -38,6 +38,17 @@ u_int32_t getTotClockDutyCycle();
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);
@ -109,6 +120,11 @@ int setStoreInRAM(int b);
int allocateRAM();
int clearRAM();
int setMaster(int f);
int setSynchronization(int s);
/*
u_int32_t setNBits(u_int32_t);

View File

@ -160,6 +160,9 @@
#define EXT_TRIG_OUT_FALLING 0xA
#define EXT_RO_TRIG_OUT_RISING 0xB
#define EXT_RO_TRIG_OUT_FALLING 0xC
#define EXT_OUT_LOW 0xD // to be implemented in firmware (and corrected in software)
#define EXT_OUT_HIGH 0xE // to be implemented in firmware (and corrected in software)
#define EXT_MASTER_SLAVE_SYNC 0xF // to be implemented in firmware (and corrected in software)

View File

@ -146,6 +146,8 @@ int function_table() {
flist[F_SET_PORT]=&set_port;
flist[F_GET_LAST_CLIENT_IP]=&get_last_client_ip;
flist[F_UPDATE_CLIENT]=&update_client;
flist[F_SET_MASTER]=&set_master;
flist[F_SET_SYNCHRONIZATION_MODE]=&set_synchronization;
#ifdef VERBOSE
/* for (i=0;i<256;i++){
printf("function %d located at %x\n",i,flist[i]);
@ -459,7 +461,7 @@ int set_external_signal_flag(int file_des) {
int set_external_communication_mode(int file_des) {
int n;
enum externalCommunicationMode arg, ret;
enum externalCommunicationMode arg, ret=GET_EXTERNAL_COMMUNICATION_MODE;
int retval=OK;
sprintf(mess,"Can't set external communication mode\n");
@ -485,14 +487,16 @@ enum externalCommunicationMode{
GATE_COINCIDENCE_WITH_INTERNAL_ENABLE
};
*/
ret=AUTO;
if (retval==OK) {
/* execute action */
switch(arg) {
default:
sprintf(mess,"The meaning of single signals should be set\n");
retval=FAIL;
}
ret=setTiming(arg);
/* switch(arg) { */
/* default: */
/* sprintf(mess,"The meaning of single signals should be set\n"); */
/* retval=FAIL; */
/* } */
#ifdef VERBOSE
@ -2666,3 +2670,92 @@ int update_client(int file_des) {
}
int set_master(int file_des) {
enum masterFlags retval=GET_MASTER;
enum masterFlags arg;
int n;
int ret=OK;
int regret=OK;
sprintf(mess,"can't set master flags\n");
n = receiveDataOnly(file_des,&arg,sizeof(arg));
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
#ifdef VERBOSE
printf("setting master flags to %d\n",arg);
#endif
if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else {
retval=setMaster(arg);
}
if (retval==GET_MASTER) {
ret=FAIL;
}
n = sendDataOnly(file_des,&ret,sizeof(ret));
if (ret==FAIL) {
n = sendDataOnly(file_des,mess,sizeof(mess));
} else {
n = sendDataOnly(file_des,&retval,sizeof(retval));
}
return ret;
}
int set_synchronization(int file_des) {
enum synchronizationMode retval=GET_MASTER;
enum synchronizationMode arg;
int n;
int ret=OK;
int regret=OK;
sprintf(mess,"can't set synchronization mode\n");
n = receiveDataOnly(file_des,&arg,sizeof(arg));
if (n < 0) {
sprintf(mess,"Error reading from socket\n");
ret=FAIL;
}
#ifdef VERBOSE
printf("setting master flags to %d\n",arg);
#endif
if (differentClients==1 && lockStatus==1 && arg!=GET_READOUT_FLAGS) {
ret=FAIL;
sprintf(mess,"Detector locked by %s\n",lastClientIP);
} else {
//ret=setStoreInRAM(0);
// initChipWithProbes(0,0,0, ALLMOD);
retval=setSynchronization(arg);
}
if (retval==GET_SYNCHRONIZATION_MODE) {
ret=FAIL;
}
n = sendDataOnly(file_des,&ret,sizeof(ret));
if (ret==FAIL) {
n = sendDataOnly(file_des,mess,sizeof(mess));
} else {
n = sendDataOnly(file_des,&retval,sizeof(retval));
}
return ret;
}

View File

@ -70,6 +70,8 @@ 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 update_client(int);
int send_update(int);

View File

@ -2960,19 +2960,17 @@ runStatus slsDetector::getRunStatus(){
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (stopSocket) {
if (stopSocket->Connect()>=0) {
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
} else {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
}
stopSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
if (stopSocket->Connect()>=0) {
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
stopSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
stopSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
} else {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
}
stopSocket->Disconnect();
}
}
}
return retval;
@ -3630,21 +3628,6 @@ int64_t slsDetector::getTimeLeft(timerIndex index){
std::cout<< "Getting timer "<< index << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
// if (controlSocket) {
// if (controlSocket->Connect()>=0) {
// controlSocket->SendDataOnly(&fnum,sizeof(fnum));
// controlSocket->SendDataOnly(&index,sizeof(index));
// controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
// if (ret!=OK) {
// controlSocket->ReceiveDataOnly(mess,sizeof(mess));
// std::cout<< "Detector returned error: " << mess << std::endl;
// } else {
// controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
// // thisDetector->timerValue[index]=retval;
// }
// controlSocket->Disconnect();
// }
// }
if (stopSocket) {
if (stopSocket->Connect()>=0) {
stopSocket->SendDataOnly(&fnum,sizeof(fnum));
@ -3655,7 +3638,6 @@ int64_t slsDetector::getTimeLeft(timerIndex index){
std::cout<< "Detector returned error: " << mess << std::endl;
} else {
stopSocket->ReceiveDataOnly(&retval,sizeof(retval));
// thisDetector->timerValue[index]=retval;
}
stopSocket->Disconnect();
}
@ -5478,3 +5460,91 @@ int slsDetector::testFunction(int times) {
/* returns if the detector is Master, slave or nothing
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
\returns master flag of the detector
*/
masterFlags slsDetector::setMaster(masterFlags flag) {
int fnum=F_SET_MASTER;
masterFlags retval=GET_MASTER;
char mess[100];
int ret=OK;
#ifdef VERBOSE
std::cout<< "Setting master flags to "<< flag << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (controlSocket) {
if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&flag,sizeof(flag));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
}
#ifdef VERBOSE
std::cout<< "Readout flag set to "<< retval << std::endl;
#endif
return retval;
}
/*
Sets/gets the synchronization mode of the various detectors
\param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NO_SYNCHRONIZATION, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
\returns current syncronization mode
*/
synchronizationMode slsDetector::setSynchronization(synchronizationMode flag) {
int fnum=F_SET_SYNCHRONIZATION_MODE;
synchronizationMode retval=GET_SYNCHRONIZATION_MODE;
char mess[100];
int ret=OK;
#ifdef VERBOSE
std::cout<< "Setting synchronization mode to "<< flag << std::endl;
#endif
if (thisDetector->onlineFlag==ONLINE_FLAG) {
if (controlSocket) {
if (controlSocket->Connect()>=0) {
controlSocket->SendDataOnly(&fnum,sizeof(fnum));
controlSocket->SendDataOnly(&flag,sizeof(flag));
controlSocket->ReceiveDataOnly(&ret,sizeof(ret));
if (ret==FAIL) {
controlSocket->ReceiveDataOnly(mess,sizeof(mess));
std::cout<< "Detector returned error: " << mess << std::endl;
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
}
controlSocket->Disconnect();
if (ret==FORCE_UPDATE)
updateDetector();
}
}
}
#ifdef VERBOSE
std::cout<< "Readout flag set to "<< retval << std::endl;
#endif
return retval;
}

View File

@ -1314,16 +1314,16 @@ typedef struct sharedSlsDetector {
\param flag can be GET_MASTER, NO_MASTER, IS_MASTER, IS_SLAVE
\returns master flag of the detector
*/
masterFlags setMaster(masterFlags flag){return GET_MASTER;};
masterFlags setMaster(masterFlags flag);
/**
Sets/gets the synchronization mode of the various detectors
\param sync syncronization mode
\param sync syncronization mode can be GET_SYNCHRONIZATION_MODE, NONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
\returns current syncronization mode
*/
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE){return GET_SYNCHRONIZATION_MODE;};
synchronizationMode setSynchronization(synchronizationMode sync=GET_SYNCHRONIZATION_MODE);
int loadImageToDetector(imageType index,string const fname);

View File

@ -748,8 +748,6 @@ class slsDetectorBase {
/**
set/get the external communication mode
obsolete \sa setExternalSignalFlags
\param pol value to be set \sa externalCommunicationMode
\returns current external communication mode
*/
@ -845,10 +843,10 @@ class slsDetectorBase {
*/
static detectorType getDetectorType(string const type){\
if (type=="Mythen") return MYTHEN;\
else if (type=="Pilatus") return PILATUS; \
else if (type=="Eiger") return EIGER; \
else if (type=="Gotthard") return GOTTHARD; \
else if (type=="Agipd") return AGIPD; \
if (type=="Pilatus") return PILATUS; \
if (type=="Eiger") return EIGER; \
if (type=="Gotthard") return GOTTHARD; \
if (type=="Agipd") return AGIPD; \
return GENERIC;};
@ -858,11 +856,11 @@ class slsDetectorBase {
\returns ONE, MASTER_GATES, MASTER_TRIGGERS, SLAVE_STARTS_WHEN_MASTER_STOPS
*/
static synchronizationMode getSyncType(string const type){\
if (type=="none") return NONE;\
else if (type=="gating") return MASTER_GATES;\
else if (type=="trigger") return MASTER_TRIGGERS; \
else if (type=="complementary") return SLAVE_STARTS_WHEN_MASTER_STOPS; \
else return GET_SYNCHRONIZATION_MODE; \
if (type=="none") return NO_SYNCHRONIZATION;\
if (type=="gating") return MASTER_GATES;\
if (type=="trigger") return MASTER_TRIGGERS; \
if (type=="complementary") return SLAVE_STARTS_WHEN_MASTER_STOPS; \
return GET_SYNCHRONIZATION_MODE; \
};
/** returns synchronization type string from index
@ -871,7 +869,7 @@ class slsDetectorBase {
*/
static string getSyncType(synchronizationMode s ){\
switch(s) { \
case NONE: return string("none"); \
case NO_SYNCHRONIZATION: return string("none"); \
case MASTER_GATES: return string("gating"); \
case MASTER_TRIGGERS: return string("trigger"); \
case SLAVE_STARTS_WHEN_MASTER_STOPS: return string("complementary"); \
@ -881,8 +879,8 @@ class slsDetectorBase {
/** returns string from external signal type index
\param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE
\returns string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, unknown
\param f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG
\returns string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
*/
static string externalSignalType(externalSignalFlag f){\
switch(f) { \
@ -897,8 +895,11 @@ class slsDetectorBase {
case GATE_OUT_ACTIVE_LOW: return string( "gate_out_active_low"); \
case TRIGGER_OUT_RISING_EDGE: return string( "trigger_out_rising_edge"); \
case TRIGGER_OUT_FALLING_EDGE: return string( "trigger_out_falling_edge"); \
case RO_TRIGGER_OUT_RISING_EDGE: return string( "ro_trigger_out_rising_edge");\
case RO_TRIGGER_OUT_RISING_EDGE: return string( "ro_trigger_out_rising_edge"); \
case RO_TRIGGER_OUT_FALLING_EDGE: return string( "ro_trigger_out_falling_edge"); \
case MASTER_SLAVE_SYNCHRONIZATION: return string("sync"); \
case OUTPUT_LOW: return string("gnd"); \
case OUTPUT_HIGH: return string("vcc"); \
default: return string( "unknown"); \
} };
@ -906,26 +907,28 @@ class slsDetectorBase {
/** returns external signal type index from string
\param string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, unknown
\returns f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, =TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE,GET_EXTERNAL_SIGNAL_FLAG (if unknown)
\param string off, gate_in_active_high, gate_in_active_low, trigger_in_rising_edge, trigger_in_falling_edge, ro_trigger_in_rising_edge, ro_trigger_in_falling_edge, gate_out_active_high, gate_out_active_low, trigger_out_rising_edge, trigger_out_falling_edge, ro_trigger_out_rising_edge, ro_trigger_out_falling_edge, gnd, vcc, sync, unknown
\returns f can be SIGNAL_OFF, GATE_IN_ACTIVE_HIGH, GATE_IN_ACTIVE_LOW, TRIGGER_IN_RISING_EDGE, TRIGGER_IN_FALLING_EDGE, RO_TRIGGER_IN_RISING_EDGE, RO_TRIGGER_IN_FALLING_EDGE, GATE_OUT_ACTIVE_HIGH, GATE_OUT_ACTIVE_LOW, TRIGGER_OUT_RISING_EDGE, TRIGGER_OUT_FALLING_EDGE, RO_TRIGGER_OUT_RISING_EDGE, RO_TRIGGER_OUT_FALLING_EDGE, OUTPUT_LOW, OUTPUT_HIGH, MASTER_SLAVE_SYNCHRONIZATION, GET_EXTERNAL_SIGNAL_FLAG (if unknown)
*/
static externalSignalFlag externalSignalType(string sval){\
externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG;\
if (sval=="off") flag=SIGNAL_OFF;\
else if (sval=="gate_in_active_high") flag=GATE_IN_ACTIVE_HIGH; \
else if (sval=="gate_in_active_low") flag=GATE_IN_ACTIVE_LOW;\
else if (sval=="trigger_in_rising_edge") flag=TRIGGER_IN_RISING_EDGE;\
else if (sval=="trigger_in_falling_edge") flag=TRIGGER_IN_FALLING_EDGE;\
else if (sval=="ro_trigger_in_rising_edge") flag=RO_TRIGGER_IN_RISING_EDGE;\
else if (sval=="ro_trigger_in_falling_edge") flag=RO_TRIGGER_IN_FALLING_EDGE;\
else if (sval=="gate_out_active_high") flag=GATE_OUT_ACTIVE_HIGH;\
else if (sval=="gate_out_active_low") flag=GATE_OUT_ACTIVE_LOW;\
else if (sval=="trigger_out_rising_edge") flag=TRIGGER_OUT_RISING_EDGE;\
else if (sval=="trigger_out_falling_edge") flag=TRIGGER_OUT_FALLING_EDGE;\
else if (sval=="ro_trigger_out_rising_edge") flag=RO_TRIGGER_OUT_RISING_EDGE;\
else if (sval=="ro_trigger_out_falling_edge") flag=RO_TRIGGER_OUT_FALLING_EDGE;\
return flag;};
if (sval=="off") return SIGNAL_OFF;\
if (sval=="gate_in_active_high") return GATE_IN_ACTIVE_HIGH; \
if (sval=="gate_in_active_low") return GATE_IN_ACTIVE_LOW;\
if (sval=="trigger_in_rising_edge") return TRIGGER_IN_RISING_EDGE;\
if (sval=="trigger_in_falling_edge") return TRIGGER_IN_FALLING_EDGE;\
if (sval=="ro_trigger_in_rising_edge") return RO_TRIGGER_IN_RISING_EDGE;\
if (sval=="ro_trigger_in_falling_edge") return RO_TRIGGER_IN_FALLING_EDGE;\
if (sval=="gate_out_active_high") return GATE_OUT_ACTIVE_HIGH;\
if (sval=="gate_out_active_low") return GATE_OUT_ACTIVE_LOW;\
if (sval=="trigger_out_rising_edge") return TRIGGER_OUT_RISING_EDGE;\
if (sval=="trigger_out_falling_edge") return TRIGGER_OUT_FALLING_EDGE;\
if (sval=="ro_trigger_out_rising_edge") return RO_TRIGGER_OUT_RISING_EDGE;\
if (sval=="ro_trigger_out_falling_edge") return RO_TRIGGER_OUT_FALLING_EDGE;\
if (sval=="sync") return MASTER_SLAVE_SYNCHRONIZATION;\
if (sval=="gnd") return OUTPUT_LOW;\
if (sval=="vcc") return OUTPUT_HIGH;\
return GET_EXTERNAL_SIGNAL_FLAG ;};
/** returns synchronization type string from index
@ -959,7 +962,40 @@ class slsDetectorBase {
default: return string("undefined"); \
}};
/**
returns external communication mode string from index
\param f can be AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
\returns auto, trigger, ro_trigger, gating, triggered_gating, unknown
*/
static string externalCommunicationType(externalCommunicationMode f){ \
switch(f) { \
case AUTO_TIMING: return string( "auto"); \
case TRIGGER_EXPOSURE: return string("trigger"); \
case TRIGGER_READOUT: return string("ro_trigger"); \
case GATE_FIX_NUMBER: return string("gating"); \
case GATE_WITH_START_TRIGGER: return string("triggered_gating"); \
default: return string( "unknown"); \
} };
/**
returns external communication mode index from string
\param s can be auto, trigger, ro_trigger, gating, triggered_gating
\returns AUTO_TIMING, TRIGGER_EXPOSURE, TRIGGER_READOUT, GATE_FIX_NUMBER, GATE_WITH_START_TRIGGER, GET_EXTERNAL_COMMUNICATION_MODE
*/
static externalCommunicationMode externalCommunicationType(string sval){\
if (sval=="auto") return AUTO_TIMING;\
if (sval=="trigger") return TRIGGER_EXPOSURE; \
if (sval=="ro_trigger") return TRIGGER_READOUT;\
if (sval=="gating") return GATE_FIX_NUMBER;\
if (sval=="triggered_gating") return GATE_WITH_START_TRIGGER;\
return GET_EXTERNAL_COMMUNICATION_MODE;};
};
#endif

View File

@ -475,6 +475,10 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorBase *det) {
/* r/w timers */
descrToFuncMap[i].m_pFuncName="timing"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTiming;
i++;
descrToFuncMap[i].m_pFuncName="exptime"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdTimer;
i++;
@ -2644,6 +2648,32 @@ string slsDetectorCommand::helpADC(int narg, char *args[], int action) {
return os.str();
}
string slsDetectorCommand::cmdTiming(int narg, char *args[], int action){
#ifdef VERBOSE
cout << string("Executing command ")+string(args[0])+string(" ( ")+cmd+string(" )\n");
#endif
if (action==HELP_ACTION) {
return helpTiming(narg,args,HELP_ACTION);
}
myDet->setOnline(ONLINE_FLAG);
if (action==PUT_ACTION) {
if (myDet->externalCommunicationType(string(args[1]))== GET_EXTERNAL_COMMUNICATION_MODE) return helpTiming(narg,args, action);
myDet->setExternalCommunicationMode(myDet->externalCommunicationType(string(args[1])));
}
return myDet->externalCommunicationType(myDet->setExternalCommunicationMode());
}
string slsDetectorCommand::helpTiming(int narg, char *args[], int action){
ostringstream os;
if (action==GET_ACTION || action==HELP_ACTION)
os << string("sync \t gets the synchronization mode of the structure\n");
if (action==PUT_ACTION || action==HELP_ACTION)
os << string("sync mode \t sets synchronization mode of the structure. Cane be none, gating, trigger, complementary \n");
return os.str();
}
string slsDetectorCommand::cmdTimer(int narg, char *args[], int action) {

View File

@ -74,6 +74,7 @@ class slsDetectorCommand {
static string helpRegister(int narg, char *args[], int action);
static string helpDAC(int narg, char *args[], int action);
static string helpTimer(int narg, char *args[], int action);
static string helpTiming(int narg, char *args[], int action);
static string helpTimeLeft(int narg, char *args[], int action);
static string helpSpeed(int narg, char *args[], int action);
static string helpAdvanced(int narg, char *args[], int action);
@ -197,6 +198,7 @@ class slsDetectorCommand {
string cmdDAC(int narg, char *args[], int action);
string cmdTiming(int narg, char *args[], int action);
string cmdTimer(int narg, char *args[], int action);