diff --git a/RELEASE.txt b/RELEASE.txt index 3f3cd4de3..12674731d 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -19,6 +19,8 @@ This document describes the differences between 4.1.0 and 4.0.2 releases. - software for eiger quad hardware integrated - command line framesl, cyclesl was printing in float + - eiger interrupt subframe flag + - eiger server reg command (+0x100 for left and +0x200 for right) @@ -39,6 +41,13 @@ This document describes the differences between 4.1.0 and 4.0.2 releases. 1. Command line quad integrates Eiger quad hardware + 2. Control flag to set last subframe to be interrupted depending on subexptime. + By default, it is disabled and will wait till the last sub frame has finished + exposing. + + 3. Left and Right FEB registers accessed independently using addr (+0x100 and +0x200) + respectively. + Receiver -------- diff --git a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h index 1d76e595b..ea3e045e3 100644 --- a/slsDetectorSoftware/commonFiles/sls_detector_funcs.h +++ b/slsDetectorSoftware/commonFiles/sls_detector_funcs.h @@ -124,6 +124,7 @@ enum detFuncs{ F_SOFTWARE_TRIGGER, /** < software trigger */ F_QUAD, + F_INTERRUPT_SUBFRAME, /* Always append functions hereafter!!! */ /* Always append functions before!!! */ diff --git a/slsDetectorSoftware/eigerDetectorServer/Beb.c b/slsDetectorSoftware/eigerDetectorServer/Beb.c index 62e168a4b..76e921984 100644 --- a/slsDetectorSoftware/eigerDetectorServer/Beb.c +++ b/slsDetectorSoftware/eigerDetectorServer/Beb.c @@ -1214,6 +1214,7 @@ void Beb_SetDetectorNumber(uint32_t detid) { int Beb_SetQuad(int val) { if (val >= 0) { + printf("Setting Quad to %d in Beb\n", val); Beb_quadEnable = (val == 0 ? 0 : 1); Beb_SetDetectorPosition(Beb_positions); } diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.c b/slsDetectorSoftware/eigerDetectorServer/FebControl.c index b686f020b..b31dcd642 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebControl.c +++ b/slsDetectorSoftware/eigerDetectorServer/FebControl.c @@ -2009,64 +2009,165 @@ int Feb_Control_SoftwareTrigger() { return 1; } +int Feb_Control_InterruptSubframe(int val) { + if (val >= 0) { + printf("Setting Interrupt Subframe to %d\n", val); + } + // they need to be written separately because the left and right registers have different values for this particular register + uint32_t offset = DAQ_REG_HRDWRE; + int top = Module_TopAddressIsValid(&modules[1]) ? 1 : 0; + uint32_t lvalue = 0; + uint32_t rvalue = 0; + // right + unsigned int addr = top ? Module_GetTopRightAddress (&modules[1]) : Module_GetBottomRightAddress (&modules[1]); + if (val >= 0) { + if(!Feb_Interface_ReadRegister(addr, offset, &rvalue)) { + cprintf(RED,"Could not read %s right interrupt subframe\n", top ? "top" : "bottom"); + return -1; + } + uint32_t data = ((val == 0) ? (rvalue &~ DAQ_REG_HRDWRE_INTRRPT_SF_MSK) : (rvalue | DAQ_REG_HRDWRE_INTRRPT_SF_MSK)); + if(!Feb_Interface_WriteRegister(addr, offset, data, 0, 0)) { + cprintf(RED,"Could not write 0x%x to %s right interrupt subframe addr 0x%x\n", data, top ? "top" : "bottom", offset); + return -1; + } + } + if(!Feb_Interface_ReadRegister(addr, offset, &rvalue)) { + cprintf(RED,"Could not read back %s right interrupt subframe\n", top ? "top" : "bottom"); + return -1; + } + + // left + addr = top ? Module_GetTopLeftAddress (&modules[1]) : Module_GetBottomLeftAddress (&modules[1]); + if (val >= 0) { + if(!Feb_Interface_ReadRegister(addr, offset, &lvalue)) { + cprintf(RED,"Could not read %s left interrupt subframe\n", top ? "top" : "bottom"); + return -1; + } + uint32_t data = ((val == 0) ? (lvalue &~ DAQ_REG_HRDWRE_INTRRPT_SF_MSK) : (lvalue | DAQ_REG_HRDWRE_INTRRPT_SF_MSK)); + if(!Feb_Interface_WriteRegister(addr, offset, data, 0, 0)) { + cprintf(RED,"Could not write 0x%x to %s left interrupt subframe addr 0x%x\n", data, top ? "top" : "bottom", offset); + return -1; + } + } + if(!Feb_Interface_ReadRegister(addr, offset, &lvalue)) { + cprintf(RED,"Could not read back %s left interrupt subframe\n", top ? "top" : "bottom"); + return -1; + } + // inconsistent + if (lvalue != rvalue) { + cprintf(RED, "Inconsistent values of interrupt subframe betweeen left and right\n"); + return -1; + } + return (lvalue & DAQ_REG_HRDWRE_INTRRPT_SF_MSK) >> DAQ_REG_HRDWRE_INTRRPT_SF_OFST; +} + +int Feb_Control_SetQuad(int val) { + // no bottom for quad + if (!Module_TopAddressIsValid(&modules[1])) { + return 0; + } + uint32_t offset = DAQ_REG_HRDWRE; + if (val >= 0) { + printf("Setting Quad to %d in Feb\n", val); + unsigned int addr = Module_GetTopRightAddress (&modules[1]); + uint32_t rvalue = 0; + if(!Feb_Interface_ReadRegister(addr, offset, &rvalue)) { + cprintf(RED,"Could not read top right quad reg\n"); + return -1; + } + uint32_t data = ((val == 0) ? (rvalue &~ DAQ_REG_HRDWRE_OW_MSK) : ((rvalue | DAQ_REG_HRDWRE_OW_MSK) &~ DAQ_REG_HRDWRE_TOP_MSK)); + if(!Feb_Interface_WriteRegister(addr, offset, data, 0, 0)) { + cprintf(RED,"Could not write 0x%x to top right quad addr 0x%x\n", data, offset); + return -1; + } + } + return 0; +} + uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data) { - uint32_t value=0; - if(Module_TopAddressIsValid(&modules[1])){ - if(!Feb_Interface_WriteRegister(Module_GetTopRightAddress (&modules[1]),offset, data,0, 0)) { - cprintf(RED,"Could not read tr value. Value read:%d\n", value); - value = 0; - } - if(!Feb_Interface_WriteRegister(Module_GetTopLeftAddress (&modules[1]),offset, data,0, 0)) { - cprintf(RED,"Could not read tl value. Value read:%d\n", value); - value = 0; - } - + uint32_t actualOffset = offset; + int left = 0; + int right = 0; + // both registers + if (offset < 0x100) { + left = 1; + right = 1; + } + // right registers only + else if (offset >= 0x200) { + right = 1; + actualOffset = offset - 0x200; } else { - if(!Feb_Interface_WriteRegister(Module_GetBottomRightAddress (&modules[1]),offset, data,0, 0)) { - cprintf(RED,"Could not read br value. Value read:%d\n", value); - value = 0; - } - if(!Feb_Interface_WriteRegister(Module_GetBottomLeftAddress (&modules[1]),offset, data,0, 0)) { - cprintf(RED,"Could not read bl value. Value read:%d\n", value); - value = 0; - } - + left = 1; + actualOffset = offset - 0x100; } + + int top = Module_TopAddressIsValid(&modules[1]) ? 1 : 0; + unsigned int addr = top ? Module_GetTopRightAddress (&modules[1]) : Module_GetBottomRightAddress (&modules[1]); + if (right) { + if(!Feb_Interface_WriteRegister(addr,actualOffset, data,0, 0)) { + cprintf(RED,"Could not write 0x%x to %s right addr 0x%x\n", data, top ? "top" : "bottom", actualOffset); + } + } + addr = top ? Module_GetTopLeftAddress (&modules[1]) : Module_GetBottomLeftAddress (&modules[1]); + if (left) { + if(!Feb_Interface_WriteRegister(addr,actualOffset, data,0, 0)) { + cprintf(RED,"Could not write 0x%x to %s left addr 0x%x\n", data, top ? "top" : "bottom", actualOffset); + } + } + return Feb_Control_ReadRegister(offset); } uint32_t Feb_Control_ReadRegister(uint32_t offset) { - uint32_t value=0; - uint32_t value1=0; - if(Module_TopAddressIsValid(&modules[1])){ - if(!Feb_Interface_ReadRegister(Module_GetTopRightAddress (&modules[1]),offset, &value)) { - cprintf(RED,"Could not read value. Value read:%d\n", value); - value = 0; - } - printf("Read top right addr: 0x%08x\n", value); - if(!Feb_Interface_ReadRegister(Module_GetTopLeftAddress (&modules[1]),offset, &value1)) { - cprintf(RED,"Could not read value. Value read:%d\n", value1); - value1 = 0; - } - printf("Read top left addr: 0x%08x\n", value1); - if (value != value1) - value = -1; - + uint32_t actualOffset = offset; + int left = 0; + int right = 0; + // both registers + if (offset < 0x100) { + left = 1; + right = 1; + } + // right registers only + else if (offset >= 0x200) { + right = 1; + actualOffset = offset - 0x200; } else { - if(!Feb_Interface_ReadRegister(Module_GetBottomRightAddress (&modules[1]),offset, &value)) { - cprintf(RED,"Could not read value. Value read:%d\n", value); - value = 0; - } - printf("Read bottom right addr: 0x%08x\n", value); - if(!Feb_Interface_ReadRegister(Module_GetBottomLeftAddress (&modules[1]),offset, &value1)) { - cprintf(RED,"Could not read value. Value read:%d\n", value1); - value1 = 0; - } - printf("Read bottom left addr: 0x%08x\n", value1); - if (value != value1) - value = -1; + left = 1; + actualOffset = offset - 0x100; } - return value; + uint32_t lvalue=0; + uint32_t rvalue=0; + int top = Module_TopAddressIsValid(&modules[1]) ? 1 : 0; + + unsigned int addr = top ? Module_GetTopRightAddress (&modules[1]) : Module_GetBottomRightAddress (&modules[1]); + if (right) { + if(!Feb_Interface_ReadRegister(addr, actualOffset, &rvalue)) { + cprintf(RED,"Could not read %s right addr 0x%x\n", top ? "top" : "bottom", actualOffset); + return -1; + } + printf("Read %s right addr: 0x%08x\n", top ? "top" : "bottom", rvalue); + if (!left) { + return rvalue; + } + } + + addr = top ? Module_GetTopLeftAddress (&modules[1]) : Module_GetBottomLeftAddress (&modules[1]); + if(left) { + if(!Feb_Interface_ReadRegister(addr, actualOffset, &lvalue)) { + cprintf(RED,"Could not read %s left addr 0x%x\n", top ? "top" : "bottom", actualOffset); + return -1; + } + printf("Read %s left addr: 0x%08x\n", top ? "top" : "bottom", lvalue); + if (!right) { + return lvalue; + } + } + if (lvalue != rvalue) { + cprintf(RED, "Inconsistent values betweeen left and right\n"); + return -1; + } + return lvalue; } diff --git a/slsDetectorSoftware/eigerDetectorServer/FebControl.h b/slsDetectorSoftware/eigerDetectorServer/FebControl.h index b20da4fab..4b87f9e80 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebControl.h +++ b/slsDetectorSoftware/eigerDetectorServer/FebControl.h @@ -204,6 +204,8 @@ int Feb_Control_GetModuleNumber(); int64_t Feb_Control_GetSubMeasuredPeriod(); int Feb_Control_SoftwareTrigger(); + int Feb_Control_InterruptSubframe(int val); + int Feb_Control_SetQuad(int val); uint32_t Feb_Control_WriteRegister(uint32_t offset, uint32_t data); uint32_t Feb_Control_ReadRegister(uint32_t offset); diff --git a/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h b/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h index 03db3a1bd..f26642454 100644 --- a/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h +++ b/slsDetectorSoftware/eigerDetectorServer/FebRegisterDefs.h @@ -20,6 +20,14 @@ #define DAQ_REG_SUBFRAME_EXPOSURES 6 #define DAQ_REG_SUBFRAME_PERIOD 7 //also pg and fifo status register +#define DAQ_REG_HRDWRE 12 + +#define DAQ_REG_HRDWRE_OW_OFST (0) +#define DAQ_REG_HRDWRE_OW_MSK (0x00000001 << DAQ_REG_HRDWRE_OW_OFST) +#define DAQ_REG_HRDWRE_TOP_OFST (1) +#define DAQ_REG_HRDWRE_TOP_MSK (0x00000001 << DAQ_REG_HRDWRE_TOP_OFST) +#define DAQ_REG_HRDWRE_INTRRPT_SF_OFST (3) +#define DAQ_REG_HRDWRE_INTRRPT_SF_MSK (0x00000001 << DAQ_REG_HRDWRE_INTRRPT_SF_OFST) #define DAQ_REG_RO_OFFSET 20 #define DAQ_REG_STATUS (DAQ_REG_RO_OFFSET + 0) //also pg and fifo status register @@ -29,6 +37,7 @@ + #define DAQ_CTRL_RESET 0x80000000 #define DAQ_CTRL_START 0x40000000 #define ACQ_CTRL_START 0x50000000 //this is 0x10000000 (acq) | 0x40000000 (daq) diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.1.0.24.0 b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.1.0.24.0 deleted file mode 100755 index 99b9a7d81..000000000 Binary files a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.1.0.24.0 and /dev/null differ diff --git a/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.1.0.24.1 b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.1.0.24.1 new file mode 100755 index 000000000..152e6317f Binary files /dev/null and b/slsDetectorSoftware/eigerDetectorServer/bin/eigerDetectorServerv4.1.0.24.1 differ diff --git a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c index d695b583e..84fd94f03 100644 --- a/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorSoftware/eigerDetectorServer/slsDetectorFunctionList.c @@ -1220,7 +1220,14 @@ int setDetectorPosition(int pos[]) { int setQuad(int val) { - return Beb_SetQuad(val); + int ret = Beb_SetQuad(val); + if (Feb_Control_SetQuad(val) == -1) + return -1; + return ret; +} + +int setInterruptSubframe(int val) { + return Feb_Control_InterruptSubframe(val); } diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp index 206bae13f..ecf4f14c1 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.cpp @@ -5440,3 +5440,7 @@ int multiSlsDetector::setQuad(int val) { val = 0; return callDetectorMember(&slsDetector::setQuad, val); } + +int multiSlsDetector::setInterruptSubframe(int val) { + return callDetectorMember(&slsDetector::setInterruptSubframe, val); +} \ No newline at end of file diff --git a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h index 1f11e1b1f..c6d940f8e 100644 --- a/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h +++ b/slsDetectorSoftware/multiSlsDetector/multiSlsDetector.h @@ -1876,6 +1876,13 @@ public: */ int setQuad(int val = -1); + /** + * Set or Get Interrupt last sub frame(Only for Eiger) + * @param val 1 if interrupt last subframe set, else 0, -1 gets + * @returns 1 if interrupt last subframe set, else 0, -1 different values + */ + int setInterruptSubframe(int val = -1); + private: /** diff --git a/slsDetectorSoftware/slsDetector/slsDetector.cpp b/slsDetectorSoftware/slsDetector/slsDetector.cpp index 91dd35fb3..e451d02e5 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetector.cpp @@ -9761,6 +9761,9 @@ int slsDetector::setQuad(int val) { int ret = FAIL; int retval = -1; +#ifdef VERBOSE + std::cout<<"Setting Quad to " <= 0) { if (thisDetector->onlineFlag==ONLINE_FLAG) { @@ -9803,3 +9806,32 @@ int slsDetector::setQuad(int val) { } return retval; } + +int slsDetector::setInterruptSubframe(int val) { + int fnum = F_INTERRUPT_SUBFRAME; + int ret = FAIL; + int retval = -1; + +#ifdef VERBOSE + std::cout<<"Setting Interrupt Sub frame to " <onlineFlag==ONLINE_FLAG) { + if (connectControl() == OK){ + controlSocket->SendDataOnly(&fnum,sizeof(fnum)); + controlSocket->SendDataOnly(&val,sizeof(val)); + controlSocket->ReceiveDataOnly(&ret,sizeof(ret)); + if (ret==FAIL){ + char mess[MAX_STR_LENGTH] = {}; + controlSocket->ReceiveDataOnly(mess,sizeof(mess)); + std::cout<< "Detector returned error: " << mess << std::endl; + setErrorMask((getErrorMask())|(SOME_ERROR)); + } + controlSocket->ReceiveDataOnly(&retval,sizeof(retval)); + disconnectControl(); + if (ret==FORCE_UPDATE) + updateDetector(); + } + } + + return retval; +} diff --git a/slsDetectorSoftware/slsDetector/slsDetector.h b/slsDetectorSoftware/slsDetector/slsDetector.h index 36b719595..4e70a30cb 100644 --- a/slsDetectorSoftware/slsDetector/slsDetector.h +++ b/slsDetectorSoftware/slsDetector/slsDetector.h @@ -2281,6 +2281,13 @@ public: */ int setQuad(int val = -1); + /** + * Set or Get Interrupt last sub frame(Only for Eiger) + * @param val 1 if interrupt last subframe set, else 0, -1 gets + * @returns 1 if interrupt last subframe set, else 0, -1 different values + */ + int setInterruptSubframe(int val = -1); + private: /** diff --git a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp index ced8c8d3b..d9051519b 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/slsDetector/slsDetectorCommand.cpp @@ -428,6 +428,14 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) { descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; ++i; + /*! \page config + - interruptsubframe [i] sets/gets the interrupt subframe flag. Setting it to 1 will interrupt the last subframe at the required exposure time. By default, this is disabled and set to 0, ie. it will wait for the last sub frame to finish exposing. Used for EIGER in 32 bit mode only. \c Returns \c (int). + */ + descrToFuncMap[i].m_pFuncName="interruptsubframe"; + descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdAdvanced; + ++i; + + /*! \page config - extsig:[i] [flag] sets/gets the mode of the external signal i. Options: \c off, \c gate_in_active_high, \c gate_in_active_low, \c trigger_in_rising_edge, \c trigger_in_falling_edge, \c ro_trigger_in_rising_edge, \c ro_trigger_in_falling_edge, \c gate_out_active_high, \c gate_out_active_low, \c trigger_out_rising_edge, \c trigger_out_falling_edge, \c ro_trigger_out_rising_edge, @@ -6062,7 +6070,18 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) { return string("unknown"); - } else if (cmd=="extsig") { + } else if (cmd=="interruptsubframe") { + myDet->setOnline(ONLINE_FLAG); + if (action==PUT_ACTION) { + int ival = -1; + if (!sscanf(args[1],"%d",&ival)) + return string("could not scan interrupt sub frame parameter " + string(args[1])); + myDet->setInterruptSubframe(ival); + } + char ans[100]; + sprintf(ans,"%d",myDet->setInterruptSubframe(-1)); + return std::string(ans); + } else if (cmd=="extsig") { externalSignalFlag flag=GET_EXTERNAL_SIGNAL_FLAG; int is=-1; if (sscanf(args[0],"extsig:%d",&is)) @@ -6162,6 +6181,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) { os << "extsig:i mode \t sets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl; os << "flags mode \t sets the readout flags to mode. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overlow, nooverflow, unknown." << std::endl; + os << "interruptsubframe flag \t sets the interrupt subframe flag. Setting it to 1 will interrupt the last subframe at the required exposure time. By default, this is disabled and set to 0, ie. it will wait for the last sub frame to finish exposing. Used for EIGER in 32 bit mode only." << std::endl; os << "programfpga f \t programs the fpga with file f (with .pof extension)." << std::endl; os << "resetfpga f \t resets fpga, f can be any value" << std::endl; @@ -6175,6 +6195,7 @@ string slsDetectorCommand::helpAdvanced(int narg, char *args[], int action) { os << "extsig:i \t gets the mode of the external signal i. can be \n \t \t \t off, \n \t \t \t gate_in_active_high, \n \t \t \t gate_in_active_low, \n \t \t \t trigger_in_rising_edge, \n \t \t \t trigger_in_falling_edge, \n \t \t \t ro_trigger_in_rising_edge, \n \t \t \t ro_trigger_in_falling_edge, \n \t \t \t gate_out_active_high, \n \t \t \t gate_out_active_low, \n \t \t \t trigger_out_rising_edge, \n \t \t \t trigger_out_falling_edge, \n \t \t \t ro_trigger_out_rising_edge, \n \t \t \t ro_trigger_out_falling_edge" << std::endl; os << "flags \t gets the readout flags. can be none, storeinram, tot, continous, parallel, nonparallel, safe, digital, analog_digital, overflow, nooverflow, unknown" << std::endl; + os << "interruptsubframe \t gets the interrupt subframe flag. Setting it to 1 will interrupt the last subframe at the required exposure time. By default, this is disabled and set to 0, ie. it will wait for the last sub frame to finish exposing. Used for EIGER in 32 bit mode only." << std::endl; os << "led \t returns led status (0 off, 1 on)" << std::endl; os << "powerchip \t gets if the chip has been powered on or off" << std::endl; os << "auto_comp_disable \t Currently not implemented. gets if the automatic comparator diable mode is enabled/disabled" << std::endl; diff --git a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h index 76a397c9d..eff6e4f69 100644 --- a/slsDetectorSoftware/slsDetector/slsDetectorUtils.h +++ b/slsDetectorSoftware/slsDetector/slsDetectorUtils.h @@ -1028,11 +1028,15 @@ virtual int setReceiverSilentMode(int i = -1)=0; */ virtual int setQuad(int val = -1) = 0; + /** + * Set or Get Interrupt last sub frame(Only for Eiger) + * @param val 1 if interrupt last subframe set, else 0, -1 gets + * @returns 1 if interrupt last subframe set, else 0, -1 different values + */ + virtual int setInterruptSubframe(int val = -1) = 0; + protected: - - static const int64_t thisSoftwareVersion=0x20141013; - //protected: diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h index 35be5c9ea..f45c92941 100644 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorFunctionList.h @@ -196,6 +196,7 @@ int setDetectorPosition(int pos[]); #endif #ifdef EIGERD int setQuad(int val); +int setInterruptSubframe(int val); #endif diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c index e906f1bea..a1b76f6d0 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.c @@ -212,6 +212,7 @@ const char* getFunctionName(enum detFuncs func) { case F_CHECK_VERSION: return "F_CHECK_VERSION"; case F_SOFTWARE_TRIGGER: return "F_SOFTWARE_TRIGGER"; case F_QUAD: return "F_QUAD"; + case F_INTERRUPT_SUBFRAME: return "F_INTERRUPT_SUBFRAME"; default: return "Unknown Function"; } @@ -299,6 +300,7 @@ void function_table() { flist[F_CHECK_VERSION] = &check_version; flist[F_SOFTWARE_TRIGGER] = &software_trigger; flist[F_QUAD] = &set_quad; + flist[F_INTERRUPT_SUBFRAME] = &set_interrupt_subframe; // check if (NUM_DET_FUNCTIONS >= TOO_MANY_FUNCTIONS_DEFINED) { @@ -5970,6 +5972,68 @@ int set_quad(int file_des) { if (ret==OK && differentClients) ret=FORCE_UPDATE; +#endif + + // ret could be swapped during sendData + ret1 = ret; + // send ok / fail + n = sendData(file_des,&ret1,sizeof(ret),INT32); + // send return argument + if (ret==FAIL) { + n += sendData(file_des,mess,sizeof(mess),OTHER); + } + n += sendData(file_des,&retval,sizeof(retval),INT32); + + // return ok / fail + return ret; +} + + +int set_interrupt_subframe(int file_des) { + int ret=OK,ret1=OK; + int n=0; + int retval=-1; + sprintf(mess,"Setting interrupt subframe failed\n"); + + // execute action +#ifndef EIGERD + //to receive any arguments + while (n > 0) + n = receiveData(file_des,mess,MAX_STR_LENGTH,OTHER); + ret = FAIL; + sprintf(mess,"Function (set_interrupt_subframe) is not implemented for this detector\n"); + cprintf(RED, "Warning: %s", mess); +#else + + // receive arguments + int arg=-1; + n = receiveData(file_des,&arg,sizeof(arg),INT32); + if (n < 0) return printSocketReadError(); + + // execute action + if (differentClients && lockStatus && arg!=-1) { + ret = FAIL; + sprintf(mess,"Detector locked by %s\n",lastClientIP); + cprintf(RED, "Warning: %s", mess); + } +#ifdef SLS_DETECTOR_FUNCTION_LIST + else { +#ifdef VERBOSE + printf("Setting Interrupt subframe :%d \n",arg); +#endif + retval=setInterruptSubframe(arg); +#ifdef VERBOSE + printf("retval Interrupt subframe :%d \n",retval); +#endif + if((arg != -1) && (retval != arg)) { + ret=FAIL; + cprintf(RED, "Warning: %s", mess); + } + } +#endif + if (ret==OK && differentClients) + ret=FORCE_UPDATE; + #endif // ret could be swapped during sendData diff --git a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h index 210a5636d..42d6f9f16 100755 --- a/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h +++ b/slsDetectorSoftware/slsDetectorServer/slsDetectorServer_funcs.h @@ -98,5 +98,6 @@ int storage_cell_start(int); int check_version(int); int software_trigger(int); int set_quad(int); +int set_interrupt_subframe(int); #endif