diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index e0d9f9e3e..83a661cee 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -45,6 +45,27 @@ /* Look at me register, read only */ #define LOOK_AT_ME_REG (0x005 * REG_OFFSET + BASE_CONTROL) //Not used in firmware or software, good to play with +/* Control RW register */ // assumed for MY3 +#define CONTROL_REG (0x021 * REG_OFFSET + BASE_CONTROL) + +#define CONTROL_STRT_ACQSTN_OFST (0) +#define CONTROL_STRT_ACQSTN_MSK (0x00000001 << CONTROL_STRT_ACQSTN_OFST) +#define CONTROL_STP_ACQSTN_OFST (1) +#define CONTROL_STP_ACQSTN_MSK (0x00000001 << CONTROL_STP_ACQSTN_OFST) +#define CONTROL_RN_BSY_OFST (2) // assumed for MY3 +#define CONTROL_RN_BSY_MSK (0x00000001 << CONTROL_RN_BSY_OFST) +#define CONTROL_STRT_EXPSR_OFST (6) +#define CONTROL_STRT_EXPSR_MSK (0x00000001 << CONTROL_STRT_EXPSR_OFST) +#define CONTROL_CRE_RST_OFST (10) +#define CONTROL_CRE_RST_MSK (0x00000001 << CONTROL_CRE_RST_OFST) +#define CONTROL_PRPHRL_RST_OFST (11) // Only GBE10? +#define CONTROL_PRPHRL_RST_MSK (0x00000001 << CONTROL_PRPHRL_RST_OFST) +// #define CONTROL_MMRY_RST_OFST (12) +// #define CONTROL_MMRY_RST_MSK (0x00000001 << CONTROL_MMRY_RST_OFST) +#define CONTROL_CLR_ACQSTN_FIFO_OFST (14) +#define CONTROL_CLR_ACQSTN_FIFO_MSK (0x00000001 << CONTROL_CLR_ACQSTN_FIFO_OFST) + + #define DTA_OFFSET_REG (0x104 * REG_OFFSET + BASE_CONTROL) /* Pattern Control FPGA registers --------------------------------------------------*/ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index fa60fa611..aa06381a5 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -942,6 +942,14 @@ int startStateMachine(){ FILE_LOG(logINFOGREEN, ("Virtual Acquisition started\n")); return OK; #endif + FILE_LOG(logINFOBLUE, ("Starting State Machine\n")); + // cleanFifos(); + + //start state machine + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STRT_ACQSTN_MSK | CONTROL_STRT_EXPSR_MSK); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STRT_ACQSTN_MSK & ~CONTROL_STRT_EXPSR_MSK); + + FILE_LOG(logINFO, ("Status Register: %08x\n",bus_r(STATUS_REG))); return OK; } @@ -996,6 +1004,12 @@ int stopStateMachine(){ virtual_stop = 0; return OK; #endif + //stop state machine + bus_w(CONTROL_REG, bus_r(CONTROL_REG) | CONTROL_STP_ACQSTN_MSK); + usleep(WAIT_TIME_US_STP_ACQ); + bus_w(CONTROL_REG, bus_r(CONTROL_REG) & ~CONTROL_STP_ACQSTN_MSK); + + FILE_LOG(logINFO, ("Status Register: %08x\n",bus_r(STATUS_REG))); return OK; } @@ -1009,6 +1023,17 @@ enum runStatus getRunStatus(){ return RUNNING; } #endif + FILE_LOG(logDEBUG1, ("Getting status\n")); + + uint32_t retval = bus_r(STATUS_REG); + FILE_LOG(logINFO, ("Status Register: %08x\n",retval)); + + // running + if(retval & CONTROL_RN_BSY_MSK) { + FILE_LOG(logINFOBLUE, ("Status: Running\n")); + return RUNNING; + + } return IDLE; } @@ -1021,18 +1046,28 @@ void readFrame(int *ret, char *mess){ FILE_LOG(logINFOGREEN, ("acquisition successfully finished\n")); return; #endif + + *ret = (int)OK; + // frames left to give status + int64_t retval = getTimeLeft(FRAME_NUMBER) + 1; + + if ( retval > 0) { + FILE_LOG(logERROR, ("No data and run stopped: %lld frames left\n",(long long int)retval)); + } else { + FILE_LOG(logINFOGREEN, ("Acquisition successfully finished\n")); + } + } u_int32_t runBusy() { #ifdef VIRTUAL return virtual_status; #endif -#ifdef VIRTUAL - u_int32_t s = (bus_r(STATUS_REG) & RUN_BUSY_MSK); + + u_int32_t s = (bus_r(CONTROL_REG) & CONTROL_RN_BSY_OFST); FILE_LOG(logDEBUG1, ("Status Register: %08x\n", s)); return s; -#endif - return -1; + } /* common */ diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index 29cccfab7..77c91357f 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -33,7 +33,7 @@ /** Other Definitions */ #define BIT16_MASK (0xFFFF) -#define DAC_NAMES "CASSH", "VTH2", "VRFSH", "VRFSHNPOL", "VIPREOUT", "VTH3", "VTH1", "VICIN", "CAS", "VRF", "VPH", "VIPRE", "VIINSH", "VPL", "VTRIM", "VDCSH" +#define DAC_NAMES "cassh", "vth2", "vshaper", "vshaperneg", "vipreout", "vth3", "vth1", "vicin", "cas", "vpreamp", "vph", "vipre", "viinsh", "vpl", "vtrim", "vdcsh" /* Enums */ enum CLKINDEX {RUN_CLK, TICK_CLK, SAMPLING_CLK, NUM_CLOCKS}; enum DACINDEX {CASSH, VTH2, VRFSH, VRFSHNPOL, VIPREOUT, VTH3, VTH1, VICIN, CAS, VRF, VPH, VIPRE, VIINSH, VPL, VTRIM, VDCSH}; @@ -58,6 +58,7 @@ enum DACINDEX {CASSH, VTH2, VRFSH, VRFSHNPOL, VIPREOUT, VTH3, VTH1, VICIN, CAS /* Defines in the Firmware */ #define MAX_PATTERN_LENGTH (0x2000) // maximum number of words (64bit) +#define WAIT_TIME_US_STP_ACQ (100) /* Struct Definitions */ typedef struct udp_header_struct { diff --git a/slsDetectorSoftware/src/slsDetectorCommand.cpp b/slsDetectorSoftware/src/slsDetectorCommand.cpp index a9810d505..f8ee3bbe6 100755 --- a/slsDetectorSoftware/src/slsDetectorCommand.cpp +++ b/slsDetectorSoftware/src/slsDetectorCommand.cpp @@ -1943,6 +1943,7 @@ std::string slsDetectorCommand::executeLine(int narg, const char * const args[], if (action == READOUT_ACTION) return cmdAcquire(narg, args, action, detPos); + size_t s = std::string(args[0]).find(':'); std::string key = std::string(args[0]).substr(0, s); // truncate at : diff --git a/slsSupportLib/include/versionAPI.h b/slsSupportLib/include/versionAPI.h index a1ece1458..88452f0a4 100644 --- a/slsSupportLib/include/versionAPI.h +++ b/slsSupportLib/include/versionAPI.h @@ -7,6 +7,6 @@ #define APICTB 0x190930 #define APIGOTTHARD 0x190930 #define APIEIGER 0x190930 -#define APIMYTHEN3 0x191008 #define APIGOTTHARD2 0x191008 +#define APIMYTHEN3 0x191008 #define APIJUNGFRAU 0x191008