This commit is contained in:
maliakal_d 2021-07-01 15:11:22 +02:00
commit cbdb05a3a8
30 changed files with 372 additions and 110 deletions

View File

@ -67,9 +67,6 @@ exposed to Python through pybind11.
.. autoclass:: readoutMode
:undoc-members:
.. autoclass:: masterFlags
:undoc-members:
.. autoclass:: burstMode
:undoc-members:

View File

@ -219,7 +219,7 @@ The enums can be found in slsdet.enums
>>> [e for e in dir(slsdet.enums) if not e.startswith('_')]
['burstMode', 'clockIndex', 'dacIndex',
'detectorSettings', 'detectorType', 'dimension', 'externalSignalFlag',
'fileFormat', 'frameDiscardPolicy', 'masterFlags',
'fileFormat', 'frameDiscardPolicy',
'readoutMode', 'runStatus', 'speedLevel', 'timingMode',
'timingSourceType']

View File

@ -12,7 +12,6 @@ dacIndex = _slsdet.slsDetectorDefs.dacIndex
detectorSettings = _slsdet.slsDetectorDefs.detectorSettings
clockIndex = _slsdet.slsDetectorDefs.clockIndex
readoutMode = _slsdet.slsDetectorDefs.readoutMode
masterFlags = _slsdet.slsDetectorDefs.masterFlags
burstMode = _slsdet.slsDetectorDefs.burstMode
timingSourceType = _slsdet.slsDetectorDefs.timingSourceType
M3_GainCaps = _slsdet.slsDetectorDefs.M3_GainCaps

View File

@ -428,9 +428,9 @@ void init_det(py::module &m) {
Detector::setNextFrameNumber,
py::arg(), py::arg() = Positions{})
.def("sendSoftwareTrigger",
(void (Detector::*)(sls::Positions)) &
(void (Detector::*)(const bool, sls::Positions)) &
Detector::sendSoftwareTrigger,
py::arg() = Positions{})
py::arg(), py::arg() = Positions{})
.def("getScan",
(Result<defs::scanParameters>(Detector::*)(sls::Positions) const) &
Detector::getScan,

View File

@ -255,12 +255,6 @@ void init_enums(py::module &m) {
.value("QUARTER_SPEED", slsDetectorDefs::speedLevel::QUARTER_SPEED)
.export_values();
py::enum_<slsDetectorDefs::masterFlags>(Defs, "masterFlags")
.value("NO_MASTER", slsDetectorDefs::masterFlags::NO_MASTER)
.value("IS_MASTER", slsDetectorDefs::masterFlags::IS_MASTER)
.value("IS_SLAVE", slsDetectorDefs::masterFlags::IS_SLAVE)
.export_values();
py::enum_<slsDetectorDefs::burstMode>(Defs, "burstMode")
.value("BURST_INTERNAL", slsDetectorDefs::burstMode::BURST_INTERNAL)
.value("BURST_EXTERNAL", slsDetectorDefs::burstMode::BURST_EXTERNAL)

View File

@ -253,12 +253,12 @@ int Beb_IsTransmitting(int *retval, int tengiga, int waitForDelay) {
int maxtimer = (MAX(MAX(l_txndelaycounter, l_framedelaycounter),
MAX(r_txndelaycounter, r_framedelaycounter))) /
100; // counter values in 10 ns
printf("Will wait for %d us\n", maxtimer);
printf("Beb: Will wait for %d us\n", maxtimer);
usleep(maxtimer);
}
// wait for 1 ms
else {
printf("Will wait for 1 ms\n");
printf("Beb: Will wait for 1 ms\n");
usleep(1 * 1000);
}
@ -1182,7 +1182,7 @@ int Beb_StopAcquisition() {
// open file pointer
int fd = Beb_open(&csp0base, XPAR_CMD_GENERATOR);
if (fd < 0) {
LOG(logERROR, ("Beb Stop Acquisition FAIL\n"));
LOG(logERROR, ("Beb Reset FAIL\n"));
return 0;
} else {
// find value
@ -1199,7 +1199,7 @@ int Beb_StopAcquisition() {
Beb_Write32(csp0base, (RIGHT_OFFSET + STOP_ACQ_OFFSET),
(valuer & (~STOP_ACQ_BIT)));
LOG(logINFO, ("Beb Stop Acquisition OK\n"));
LOG(logINFO, ("Beb: Reset done\n"));
// close file pointer
Beb_close(fd, csp0base);
}

View File

@ -709,6 +709,32 @@ int Feb_Control_AcquisitionInProgress() {
return STATUS_IDLE;
}
int Feb_Control_ProcessingInProgress() {
unsigned int regr = 0, regl = 0;
// deactivated should return end of processing
if (!Feb_Control_activated)
return IDLE;
if (!Feb_Interface_ReadRegister(Feb_Control_rightAddress, FEB_REG_STATUS,
&regr)) {
LOG(logERROR, ("Could not read right FEB_REG_STATUS to get feb "
"processing status\n"));
return STATUS_ERROR;
}
if (!Feb_Interface_ReadRegister(Feb_Control_leftAddress, FEB_REG_STATUS,
&regl)) {
LOG(logERROR, ("Could not read left FEB_REG_STATUS to get feb "
"processing status\n"));
return STATUS_ERROR;
}
// processing done
if ((regr | regl) & FEB_REG_STATUS_ACQ_DONE_MSK) {
return STATUS_IDLE;
}
// processing running
return STATUS_RUNNING;
}
int Feb_Control_AcquisitionStartedBit() {
unsigned int status_reg_r = 0, status_reg_l = 0;
// deactivated should return acquisition started/ready
@ -817,7 +843,7 @@ int Feb_Control_StartDAQOnlyNWaitForFinish(int sleep_time_us) {
}
int Feb_Control_Reset() {
LOG(logINFO, ("Reset daq\n"));
LOG(logINFO, ("Feb: Reset daq\n"));
if (Feb_Control_activated) {
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_CTRL, 0, 0, 0) ||
@ -996,38 +1022,136 @@ int Feb_Control_StartAcquisition() {
return 1;
}
int Feb_Control_StopAcquisition() { return Feb_Control_Reset(); }
int Feb_Control_SoftwareTrigger() {
int Feb_Control_StopAcquisition() {
if (Feb_Control_activated) {
// sends last frames from fifo
unsigned int orig_value = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
DAQ_REG_CHIP_CMDS, &orig_value)) {
LOG(logERROR, ("Could not read DAQ_REG_CHIP_CMDS to send software "
"trigger\n"));
DAQ_REG_CTRL, &orig_value)) {
LOG(logERROR, ("Could not read DAQ_REG_CTRL to stop acquisition "
"(send complete frames)\n"));
return 0;
}
unsigned int cmd = orig_value | DAQ_REG_CHIP_CMDS_INT_TRIGGER;
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_CTRL,
orig_value | DAQ_CTRL_STOP, 0, 0)) {
LOG(logERROR, ("Could not send last frames.\n"));
return 0;
}
LOG(logINFO, ("Feb: Command to Flush out images from fifo\n"));
// set trigger bit
LOG(logDEBUG1, ("Setting Trigger, Register:0x%x\n", cmd));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_CHIP_CMDS, cmd, 0, 0)) {
LOG(logERROR, ("Could not give software trigger\n"));
return 0;
// wait for feb processing to be done
int is_processing = Feb_Control_ProcessingInProgress();
int check_error = 0;
while (is_processing != STATUS_IDLE) {
usleep(500);
is_processing = Feb_Control_ProcessingInProgress();
// check error only 5 times (ensuring it is not something that
// happens sometimes)
if (is_processing == STATUS_ERROR) {
if (check_error == 5)
break;
check_error++;
} // reset check_error for next time
else
check_error = 0;
}
// unset trigger bit
LOG(logDEBUG1, ("Unsetting Trigger, Register:0x%x\n", orig_value));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_CHIP_CMDS, orig_value, 0, 0)) {
LOG(logERROR, ("Could not give software trigger\n"));
return 0;
}
LOG(logINFO, ("Software Internal Trigger Sent!\n"));
LOG(logINFO, ("Feb: Processing done (to stop acq)\n"));
return 0;
}
return 1;
}
int Feb_Control_IsReadyForTrigger(int *readyForTrigger) {
unsigned int addr[2] = {Feb_Control_leftAddress, Feb_Control_rightAddress};
unsigned int value[2] = {0, 0};
for (int i = 0; i < 2; ++i) {
if (!Feb_Interface_ReadRegister(addr[i], FEB_REG_STATUS, &value[i])) {
LOG(logERROR, ("Could not read %s FEB_REG_STATUS reg\n",
(i == 0 ? "left" : "right")));
return 0;
}
}
*readyForTrigger =
((value[0] | value[1]) & FEB_REG_STATUS_WAIT_FOR_TRGGR_MSK);
return 1;
}
int Feb_Control_SendSoftwareTrigger() {
// read old value in register
unsigned int orig_value = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_AddressToAll(),
DAQ_REG_CHIP_CMDS, &orig_value)) {
LOG(logERROR, ("Could not read DAQ_REG_CHIP_CMDS to send software "
"trigger\n"));
return 0;
}
unsigned int cmd = orig_value | DAQ_REG_CHIP_CMDS_INT_TRIGGER;
// set trigger bit
LOG(logDEBUG1, ("Setting Trigger, Register:0x%x\n", cmd));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_CHIP_CMDS, cmd, 0, 0)) {
LOG(logERROR, ("Could not give software trigger\n"));
return 0;
}
// unset trigger bit
LOG(logDEBUG1, ("Unsetting Trigger, Register:0x%x\n", orig_value));
if (!Feb_Interface_WriteRegister(Feb_Control_AddressToAll(),
DAQ_REG_CHIP_CMDS, orig_value, 0, 0)) {
LOG(logERROR, ("Could not give software trigger\n"));
return 0;
}
LOG(logINFO, ("Software Internal Trigger Sent!\n"));
return 1;
}
int Feb_Control_SoftwareTrigger(int block) {
if (Feb_Control_activated) {
// cant read reg
int readyForTrigger = 0;
if (!Feb_Control_IsReadyForTrigger(&readyForTrigger)) {
LOG(logERROR, ("Could not read FEB_REG_STATUS reg!\n"));
return 0;
}
// if not ready for trigger, throw
if (!readyForTrigger) {
LOG(logWARNING, ("Not yet ready for trigger!\n"));
return 0;
}
// send trigger to both fpgas
Feb_Control_SendSoftwareTrigger();
// wait for next trigger ready
if (block) {
LOG(logINFO, ("Blocking Software Trigger\n"));
int readyForTrigger = 0;
if (!Feb_Control_IsReadyForTrigger(&readyForTrigger)) {
LOG(logERROR, ("Could not read FEB_REG_STATUS reg after giving "
"trigger!\n"));
return 0;
}
while (!readyForTrigger) {
usleep(5000);
if (!Feb_Control_IsReadyForTrigger(&readyForTrigger)) {
LOG(logERROR, ("Could not read FEB_REG_STATUS reg after "
"giving trigger!\n"));
return 0;
}
}
LOG(logINFO, ("Done waiting (wait for trigger)!\n"));
}
}
return 1;
}
// parameters
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo) {
static unsigned int everything_but_bit_mode = DAQ_STATIC_BIT_PROGRAM |
@ -1883,15 +2007,15 @@ int Feb_Control_GetLeftFPGATemp() {
if (!Feb_Control_activated) {
return 0;
}
unsigned int temperature = 0;
unsigned int value = 0;
if (!Feb_Interface_ReadRegister(Feb_Control_leftAddress, FEB_REG_STATUS,
&temperature)) {
&value)) {
LOG(logERROR, ("Trouble reading FEB_REG_STATUS reg to get left feb "
"temperature\n"));
return 0;
}
temperature = temperature >> 16;
unsigned int temperature =
((value & FEB_REG_STATUS_TEMP_MSK) >> FEB_REG_STATUS_TEMP_OFST);
temperature =
((((float)(temperature) / 65536.0f) / 0.00198421639f) - 273.15f) *
1000; // Static conversation, copied from xps sysmon standalone driver

View File

@ -40,6 +40,7 @@ unsigned int *Feb_Control_GetTrimbits();
// acquisition
int Feb_Control_AcquisitionInProgress();
int Feb_Control_ProcessingInProgress();
int Feb_Control_AcquisitionStartedBit();
int Feb_Control_WaitForStartedFlag(int sleep_time_us, int prev_flag);
int Feb_Control_WaitForFinishedFlag(int sleep_time_us, int tempLock);
@ -55,7 +56,9 @@ int Feb_Control_PrepareForAcquisition();
void Feb_Control_PrintAcquisitionSetup();
int Feb_Control_StartAcquisition();
int Feb_Control_StopAcquisition();
int Feb_Control_SoftwareTrigger();
int Feb_Control_IsReadyForTrigger(int *readyForTrigger);
int Feb_Control_SendSoftwareTrigger();
int Feb_Control_SoftwareTrigger(int block);
// parameters
int Feb_Control_SetDynamicRange(unsigned int four_eight_sixteen_or_thirtytwo);

View File

@ -30,7 +30,16 @@
#define DAQ_REG_RO_OFFSET 20
#define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) // also pg and fifo status register
#define FEB_REG_STATUS (DAQ_REG_RO_OFFSET + 3)
#define FEB_REG_STATUS_WAIT_FOR_TRGGR_OFST (5)
#define FEB_REG_STATUS_WAIT_FOR_TRGGR_MSK (0x00000001 << FEB_REG_STATUS_WAIT_FOR_TRGGR_OFST)
#define FEB_REG_STATUS_ACQ_DONE_OFST (6)
#define FEB_REG_STATUS_ACQ_DONE_MSK (0x00000001 << FEB_REG_STATUS_ACQ_DONE_OFST)
#define FEB_REG_STATUS_TEMP_OFST (16)
#define FEB_REG_STATUS_TEMP_MSK (0x0000FFFF << FEB_REG_STATUS_TEMP_OFST)
#define MEAS_SUBPERIOD_REG (DAQ_REG_RO_OFFSET + 4)
#define MEAS_PERIOD_REG (DAQ_REG_RO_OFFSET + 5)
// clang-format on
@ -38,7 +47,8 @@
#define DAQ_CTRL_RESET 0x80000000
#define DAQ_CTRL_START 0x40000000
#define ACQ_CTRL_START 0x50000000 // this is 0x10000000 (acq) | 0x40000000 (daq)
#define DAQ_CTRL_STOP 0x00000000
#define DAQ_CTRL_STOP 0x08000000 // sends last complete frame
#define DAQ_CTRL_DONE 0x00000040 // data processing done in feb
// direct chip commands to the DAQ_REG_CHIP_CMDS register
#define DAQ_SET_STATIC_BIT 0x00000001

View File

@ -46,7 +46,6 @@ int on_dst = 0;
int dst_requested[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
enum masterFlags masterMode = IS_SLAVE;
int top = 0;
int master = 0;
int normal = 0;
@ -1415,6 +1414,8 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */
int isMaster() { return master; }
void setTiming(enum timingMode arg) {
int ret = 0;
switch (arg) {
@ -2444,29 +2445,53 @@ int stopStateMachine() {
return OK;
#else
sharedMemory_lockLocalLink();
if ((Feb_Control_StopAcquisition() != STATUS_IDLE) ||
(!Beb_StopAcquisition())) {
// sends last frames from fifo and wait for feb processing done
if ((Feb_Control_StopAcquisition() != STATUS_IDLE)) {
LOG(logERROR, ("failed to stop acquisition\n"));
sharedMemory_unlockLocalLink();
return FAIL;
}
sharedMemory_unlockLocalLink();
// wait for beb to finish sending packets
int isTransmitting = 1;
while (isTransmitting) {
// wait for beb to send out all packets
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) {
LOG(logERROR, ("failed to stop beb acquisition\n"));
return FAIL;
}
if (isTransmitting) {
printf("Transmitting...\n");
}
}
LOG(logINFO, ("Beb: Detector has sent all data (stop)\n"));
// reset feb and beb
sharedMemory_lockLocalLink();
Feb_Control_Reset();
sharedMemory_unlockLocalLink();
if (!Beb_StopAcquisition()) {
LOG(logERROR, ("failed to stop acquisition\n"));
return FAIL;
}
// ensure all have same starting frame numbers
uint64_t retval = 0;
if (Beb_GetNextFrameNumber(&retval, send_to_ten_gig) == -2) {
Beb_SetNextFrameNumber(retval + 1);
}
LOG(logINFOBLUE, ("Stopping state machine complete\n\n"));
return OK;
#endif
}
int softwareTrigger() {
int softwareTrigger(int block) {
#ifdef VIRTUAL
return OK;
#else
sharedMemory_lockLocalLink();
if (!Feb_Control_SoftwareTrigger()) {
if (!Feb_Control_SoftwareTrigger(block)) {
sharedMemory_unlockLocalLink();
return FAIL;
}
@ -2567,6 +2592,21 @@ void readFrame(int *ret, char *mess) {
// wait for detector to send
int isTransmitting = 1;
while (isTransmitting) {
// wait for feb processing to be done
sharedMemory_lockLocalLink();
int i = Feb_Control_ProcessingInProgress();
sharedMemory_unlockLocalLink();
if (i == STATUS_ERROR) {
strcpy(mess, "Could not read feb processing done register\n");
*ret = (int)FAIL;
return;
}
if (i == RUNNING) {
LOG(logINFOBLUE, ("Status: TRANSMITTING (feb processing)\n"));
isTransmitting = 1;
}
// wait for beb to send out all packets
if (Beb_IsTransmitting(&isTransmitting, send_to_ten_gig, 1) == FAIL) {
strcpy(mess, "Could not read delay counters\n");
*ret = (int)FAIL;
@ -2576,7 +2616,7 @@ void readFrame(int *ret, char *mess) {
printf("Transmitting...\n");
}
}
LOG(logINFO, ("Detector has sent all data\n"));
LOG(logINFO, ("Beb: Detector has sent all data (acquire)\n"));
LOG(logINFOGREEN, ("Acquisition successfully finished\n"));
#endif
}

View File

@ -55,7 +55,7 @@ int ipPacketSize = 0;
int udpPacketSize = 0;
// master slave configuration (for 25um)
int masterflags = NO_MASTER;
int master = 0;
int masterdefaultdelay = 62;
int patternphase = 0;
int adcphase = 0;
@ -364,6 +364,8 @@ void initStopServer() {
#ifdef VIRTUAL
sharedMemory_setStop(0);
#endif
// to get master from file
readConfigFile();
}
/* set up detector */
@ -621,14 +623,12 @@ int readConfigFile() {
// key is master/ slave flag
if (!strcasecmp(key, "masterflags")) {
if (!strcasecmp(value, "is_master")) {
masterflags = IS_MASTER;
master = 1;
LOG(logINFOBLUE, ("\tMaster\n"));
} else if (!strcasecmp(value, "is_slave")) {
masterflags = IS_SLAVE;
LOG(logINFOBLUE, ("\tSlave\n"));
} else if (!strcasecmp(value, "no_master")) {
masterflags = NO_MASTER;
LOG(logINFOBLUE, ("\tNo Master\n"));
} else if ((!strcasecmp(value, "is_slave")) ||
(!strcasecmp(value, "no_master"))) {
master = 0;
LOG(logINFOBLUE, ("\tSlave or No Master\n"));
} else {
LOG(logERROR,
("\tCould not scan masterflags %s value from config file\n",
@ -705,7 +705,7 @@ void setMasterSlaveConfiguration() {
return;
// master configuration
if (masterflags == IS_MASTER) {
if (master) {
// master default delay set, so reset delay
setDelayAfterTrigger(0);
@ -876,7 +876,7 @@ int setDelayAfterTrigger(int64_t val) {
return FAIL;
}
LOG(logINFO, ("Setting delay after trigger %lld ns\n", (long long int)val));
if (masterflags == IS_MASTER) {
if (master) {
val += masterdefaultdelay;
LOG(logINFO, ("\tActual Delay (master): %lld\n", (long long int)val));
}
@ -900,7 +900,7 @@ int setDelayAfterTrigger(int64_t val) {
int64_t getDelayAfterTrigger() {
int64_t retval =
get64BitReg(SET_DELAY_LSB_REG, SET_DELAY_MSB_REG) / (1E-9 * CLK_FREQ);
if (masterflags == IS_MASTER) {
if (master) {
LOG(logDEBUG1,
("\tActual Delay read (master): %lld\n", (long long int)retval));
retval -= masterdefaultdelay;
@ -924,7 +924,7 @@ int64_t getPeriodLeft() {
int64_t getDelayAfterTriggerLeft() {
int64_t retval =
get64BitReg(GET_DELAY_LSB_REG, GET_DELAY_MSB_REG) / (1E-9 * CLK_FREQ);
if (masterflags == IS_MASTER) {
if (master) {
LOG(logDEBUG1,
("\tGetting Actual delay (master): %lld\n", (long long int)retval));
retval -= masterdefaultdelay;
@ -1201,6 +1201,8 @@ int setHighVoltage(int val) {
/* parameters - timing, extsig */
int isMaster() { return master; }
void setTiming(enum timingMode arg) {
u_int32_t addr = EXT_SIGNAL_REG;
switch (arg) {
@ -1451,7 +1453,7 @@ int configureMAC() {
setExpTime(900 * 1000);
// take an image
if (masterflags == IS_MASTER)
if (master)
usleep(1 * 1000 * 1000); // required to ensure master starts
// acquisition only after slave has changed
// to basic parameters and is waiting

View File

@ -1395,12 +1395,13 @@ int setHighVoltage(int val) {
return highvoltage;
}
/* parameters - timing */
int isMaster() {
return !((bus_r(SYSTEM_STATUS_REG) & SYSTEM_STATUS_SLV_BRD_DTCT_MSK) >>
SYSTEM_STATUS_SLV_BRD_DTCT_OFST);
}
/* parameters - timing */
void setTiming(enum timingMode arg) {
if (!isMaster() && arg == AUTO_TIMING)

View File

@ -347,6 +347,9 @@ int getADC(enum ADCINDEX ind);
int setHighVoltage(int val);
// parameters - timing, extsig
#if defined(MYTHEN3D) || defined(EIGERD) || defined(GOTTHARDD)
int isMaster();
#endif
#ifdef GOTTHARD2D
void updatingRegisters();
#endif
@ -354,7 +357,6 @@ void setTiming(enum timingMode arg);
enum timingMode getTiming();
#ifdef MYTHEN3D
void setInitialExtSignals();
int isMaster();
int setGainCaps(int caps);
int getGainCaps();
int setChipStatusRegister(int csr);
@ -556,9 +558,12 @@ int startStateMachine();
void *start_timer(void *arg);
#endif
int stopStateMachine();
#if defined(EIGERD) || defined(MYTHEN3D)
#ifdef MYTHEN3D
int softwareTrigger();
#endif
#ifdef EIGERD
int softwareTrigger(int block);
#endif
#if defined(EIGERD) || defined(MYTHEN3D)
int startReadOut();
#endif

View File

@ -4096,16 +4096,29 @@ int check_version(int file_des) {
int software_trigger(int file_des) {
ret = OK;
memset(mess, 0, sizeof(mess));
int arg = -1;
if (receiveData(file_des, &arg, sizeof(arg), INT32) < 0)
return printSocketReadError();
LOG(logDEBUG1, ("Software Trigger (block: %d\n", arg));
LOG(logDEBUG1, ("Software Trigger\n"));
#if !defined(EIGERD) && !defined(MYTHEN3D)
functionNotImplemented();
#else
if (arg && myDetectorType == MYTHEN3) {
ret = FAIL;
strcpy(mess, "Blocking trigger not implemented for Mythen3. Please use non blocking trigger.\n");
LOG(logERROR, (mess));
}
// only set
if (Server_VerifyLock() == OK) {
else if (Server_VerifyLock() == OK) {
#ifdef MYTHEN3
ret = softwareTrigger();
#else
ret = softwareTrigger(arg);
#endif
if (ret == FAIL) {
sprintf(mess, "Could not send software trigger\n");
strcpy(mess, "Could not send software trigger\n");
LOG(logERROR, (mess));
}
LOG(logDEBUG1, ("Software trigger successful\n"));
@ -8145,7 +8158,7 @@ int get_master(int file_des) {
LOG(logDEBUG1, ("Getting master\n"));
#ifndef MYTHEN3D
#if !defined(MYTHEN3D) && !defined(EIGERD) && !defined(GOTTHARDD)
functionNotImplemented();
#else
retval = isMaster();

View File

@ -488,12 +488,14 @@ class Detector {
void stopReceiver();
/** Non blocking: start detector acquisition. Status changes to RUNNING or
* WAITING and automatically returns to idle at the end of acquisition. */
* WAITING and automatically returns to idle at the end of acquisition.
[Mythen3] Master starts acquisition first */
void startDetector();
/** [Mythen3] Non blocking: start detector readout of counters in chip.
* Status changes to TRANSMITTING and automatically returns to idle at the
* end of readout. */
* end of readout.
[Eiger] Master stops acquisition last */
void startDetectorReadout();
/** Non blocking: Abort detector acquisition. Status changes to IDLE or
@ -520,8 +522,10 @@ class Detector {
* numbers for different modules.*/
void setNextFrameNumber(uint64_t value, Positions pos = {});
/** [Eiger][Mythen3] Sends an internal software trigger to the detector */
void sendSoftwareTrigger(Positions pos = {});
/** [Eiger][Mythen3] Sends an internal software trigger to the detector
* block true if command blocks till frames are sent out from that trigger
*/
void sendSoftwareTrigger(const bool block = false, Positions pos = {});
Result<defs::scanParameters> getScan(Positions pos = {}) const;
@ -1316,6 +1320,7 @@ class Detector {
* (internal gating). Gate index: 0-2, -1 for all */
Result<std::array<ns, 3>> getGateDelayForAllGates(Positions pos = {}) const;
/** [Eiger][Mythen3][Gotthard1] via stop server **/
Result<bool> getMaster(Positions pos = {}) const;
// TODO! check if we really want to expose this !!!!!

View File

@ -1193,6 +1193,41 @@ std::string CmdProxy::Scan(int action) {
return os.str();
}
std::string CmdProxy::Trigger(int action) {
std::ostringstream os;
os << cmd << ' ';
if (action == defs::HELP_ACTION) {
if (cmd == "trigger") {
os << "[Eiger][Mythen3] Sends software trigger signal to detector";
} else if (cmd == "blockingtrigger") {
os << "[Eiger] Sends software trigger signal to detector and "
"blocks till "
"the frames are sent out for that trigger.";
} else {
throw sls::RuntimeError("unknown command " + cmd);
}
os << '\n';
} else if (action == slsDetectorDefs::GET_ACTION) {
throw sls::RuntimeError("Cannot get");
} else if (action == slsDetectorDefs::PUT_ACTION) {
if (det_id != -1) {
throw sls::RuntimeError("Cannot execute this at module level");
}
if (!args.empty()) {
WrongNumberOfParameters(0);
}
bool block = false;
if (cmd == "blockingtrigger") {
block = true;
}
det->sendSoftwareTrigger(block);
os << "successful\n";
} else {
throw sls::RuntimeError("Unknown action");
}
return os.str();
}
/* Network Configuration (Detector<->Receiver) */
std::string CmdProxy::UDPDestinationIP(int action) {

View File

@ -838,7 +838,7 @@ class CmdProxy {
{"rx_framescaught", &CmdProxy::rx_framescaught},
{"rx_missingpackets", &CmdProxy::rx_missingpackets},
{"nextframenumber", &CmdProxy::nextframenumber},
{"trigger", &CmdProxy::trigger},
{"trigger", &CmdProxy::Trigger},
{"scan", &CmdProxy::Scan},
{"scanerrmsg", &CmdProxy::scanerrmsg},
@ -899,6 +899,7 @@ class CmdProxy {
{"rx_zmqhwm", &CmdProxy::rx_zmqhwm},
/* Eiger Specific */
{"blockingtrigger", &CmdProxy::Trigger},
{"subexptime", &CmdProxy::subexptime},
{"subdeadtime", &CmdProxy::subdeadtime},
{"overflow", &CmdProxy::overflow},
@ -1094,6 +1095,7 @@ class CmdProxy {
std::string ReceiverStatus(int action);
std::string DetectorStatus(int action);
std::string Scan(int action);
std::string Trigger(int action);
/* Network Configuration (Detector<->Receiver) */
std::string UDPDestinationIP(int action);
std::string UDPDestinationIP2(int action);
@ -1461,10 +1463,6 @@ class CmdProxy {
"Stopping acquisition might result in "
"different frame numbers for different modules.");
EXECUTE_SET_COMMAND(
trigger, sendSoftwareTrigger,
"\n\t[Eiger][Mythen3] Sends software trigger signal to detector.");
GET_COMMAND(scanerrmsg, getScanErrorMessage,
"\n\tGets Scan error message if scan ended in error for non "
"blocking acquisitions.");

View File

@ -677,16 +677,16 @@ void Detector::startDetector() {
auto detector_type = getDetectorType().squash();
if (detector_type == defs::MYTHEN3 && size() > 1) {
auto is_master = getMaster();
std::vector<int> master;
int masterPosition = 0;
std::vector<int> slaves;
for (int i = 0; i < size(); ++i) {
if (is_master[i])
master.push_back(i);
masterPosition = i;
else
slaves.push_back(i);
}
pimpl->Parallel(&Module::startAcquisition, slaves);
pimpl->Parallel(&Module::startAcquisition, master);
pimpl->Parallel(&Module::startAcquisition, {masterPosition});
} else {
pimpl->Parallel(&Module::startAcquisition, {});
}
@ -725,8 +725,8 @@ void Detector::setNextFrameNumber(uint64_t value, Positions pos) {
pimpl->Parallel(&Module::setNextFrameNumber, pos, value);
}
void Detector::sendSoftwareTrigger(Positions pos) {
pimpl->Parallel(&Module::sendSoftwareTrigger, pos);
void Detector::sendSoftwareTrigger(const bool block, Positions pos) {
pimpl->Parallel(&Module::sendSoftwareTrigger, pos, block);
}
Result<defs::scanParameters> Detector::getScan(Positions pos) const {

View File

@ -776,7 +776,9 @@ void Module::setNextFrameNumber(uint64_t value) {
sendToDetector(F_SET_NEXT_FRAME_NUMBER, value, nullptr);
}
void Module::sendSoftwareTrigger() { sendToDetectorStop(F_SOFTWARE_TRIGGER); }
void Module::sendSoftwareTrigger(const bool block) {
sendToDetectorStop(F_SOFTWARE_TRIGGER, static_cast<int>(block), nullptr);
}
defs::scanParameters Module::getScan() const {
return sendToDetector<defs::scanParameters>(F_GET_SCAN);
@ -2006,7 +2008,7 @@ std::array<time::ns, 3> Module::getGateDelayForAllGates() const {
return sendToDetector<std::array<time::ns, 3>>(F_GET_GATE_DELAY_ALL_GATES);
}
bool Module::isMaster() const { return sendToDetector<int>(F_GET_MASTER); }
bool Module::isMaster() const { return sendToDetectorStop<int>(F_GET_MASTER); }
int Module::getChipStatusRegister() const {
return sendToDetector<int>(F_GET_CSR);

View File

@ -185,7 +185,7 @@ class Module : public virtual slsDetectorDefs {
std::vector<uint64_t> getNumMissingPackets() const;
uint64_t getNextFrameNumber() const;
void setNextFrameNumber(uint64_t value);
void sendSoftwareTrigger();
void sendSoftwareTrigger(const bool block);
defs::scanParameters getScan() const;
void setScan(const defs::scanParameters t);
std::string getScanErrorMessage() const;

View File

@ -1446,6 +1446,45 @@ TEST_CASE("trigger", "[.cmd]") {
}
}
TEST_CASE("blockingtrigger", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
REQUIRE_THROWS(proxy.Call("blockingtrigger", {}, -1, GET));
auto det_type = det.getDetectorType().squash();
if (det_type != defs::EIGER) {
REQUIRE_THROWS(proxy.Call("blockingtrigger", {}, -1, PUT));
} else if (det_type == defs::EIGER) {
auto prev_timing =
det.getTimingMode().tsquash("inconsistent timing mode in test");
auto prev_frames =
det.getNumberOfFrames().tsquash("inconsistent #frames in test");
auto prev_exptime =
det.getExptime().tsquash("inconsistent exptime in test");
auto prev_period =
det.getPeriod().tsquash("inconsistent period in test");
det.setTimingMode(defs::TRIGGER_EXPOSURE);
det.setNumberOfFrames(1);
det.setExptime(std::chrono::microseconds(200));
det.setPeriod(std::chrono::milliseconds(1));
auto nextframenumber =
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
det.startDetector();
{
std::ostringstream oss;
proxy.Call("blockingtrigger", {}, -1, PUT, oss);
REQUIRE(oss.str() == "blockingtrigger successful\n");
}
auto currentfnum =
det.getNextFrameNumber().tsquash("inconsistent frame nr in test");
REQUIRE(nextframenumber + 1 == currentfnum);
det.stopDetector();
det.setTimingMode(prev_timing);
det.setNumberOfFrames(prev_frames);
det.setExptime(prev_exptime);
det.setPeriod(prev_period);
}
}
TEST_CASE("clearbusy", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);

View File

@ -375,9 +375,6 @@ typedef struct {
/** chip speed */
enum speedLevel { FULL_SPEED, HALF_SPEED, QUARTER_SPEED };
/** hierarchy in multi-detector structure, if any */
enum masterFlags { NO_MASTER, IS_MASTER, IS_SLAVE };
/**
* burst mode for gotthard2
*/
@ -394,14 +391,14 @@ typedef struct {
*/
enum timingSourceType { TIMING_INTERNAL, TIMING_EXTERNAL };
//gain caps Mythen3
// gain caps Mythen3
enum M3_GainCaps {
M3_C10pre= 1<<7,
M3_C15sh = 1<<10,
M3_C30sh = 1<<11,
M3_C50sh = 1<<12,
M3_C225ACsh = 1<<13,
M3_C15pre = 1<<14,
M3_C10pre = 1 << 7,
M3_C15sh = 1 << 10,
M3_C30sh = 1 << 11,
M3_C50sh = 1 << 12,
M3_C225ACsh = 1 << 13,
M3_C15pre = 1 << 14,
};
#ifdef __cplusplus
@ -636,9 +633,6 @@ typedef struct {
#ifdef __cplusplus
// TODO! discuss this
#include <vector> //hmm... but currently no way around
namespace sls {

View File

@ -1,12 +1,13 @@
/** API versions */
#define GITBRANCH "developer"
#define APILIB 0x210225
#define APIRECEIVER 0x210225
#define APIGUI 0x210225
#define APICTB 0x210621
#define APIGOTTHARD 0x210621
#define APILIB 0x210225
#define APIRECEIVER 0x210225
#define APIGUI 0x210225
#define APICTB 0x210621
#define APIGOTTHARD 0x210621
#define APIGOTTHARD2 0x210621
#define APIJUNGFRAU 0x210621
#define APIMYTHEN3 0x210621
#define APIMOENCH 0x210621
#define APIEIGER 0x210621
#define APIJUNGFRAU 0x210621
#define APIMYTHEN3 0x210621
#define APIMOENCH 0x210621
#define APIEIGER 0x210701