added nextframenumber for moench, ctb (also for virtual servers)

This commit is contained in:
2022-01-28 11:32:27 +01:00
parent f6e76145c1
commit 5a69c60205
12 changed files with 110 additions and 70 deletions

View File

@ -165,11 +165,9 @@
#define PATTERN_OUT_LSB_REG (0x20 << MEM_MAP_SHIFT)
#define PATTERN_OUT_MSB_REG (0x21 << MEM_MAP_SHIFT)
/* Frames From Start 64 bit RO register TODO */
//#define FRAMES_FROM_START_LSB_REG (0x22 << MEM_MAP_SHIFT) // Not
// used in FW #define FRAMES_FROM_START_MSB_REG (0x23 <<
// MEM_MAP_SHIFT)
//// Not used in FW
/* Frame number of next acquisition register (64 bit register) */
#define NEXT_FRAME_NUMB_LOCAL_LSB_REG (0x22 << MEM_MAP_SHIFT)
#define NEXT_FRAME_NUMB_LOCAL_MSB_REG (0x23 << MEM_MAP_SHIFT)
/* Frames From Start PG 64 bit RO register. Reset using CONTROL_CRST. TODO */
#define FRAMES_FROM_START_PG_LSB_REG (0x24 << MEM_MAP_SHIFT)

View File

@ -43,7 +43,6 @@ char initErrorMessage[MAX_STR_LENGTH];
#ifdef VIRTUAL
pthread_t pthread_virtual_tid;
int64_t virtual_currentFrameNumber = 2;
#endif
// 1g readout
@ -569,6 +568,7 @@ void setupDetector() {
setFrequency(ADC_CLK, DEFAULT_ADC_CLK);
setFrequency(DBIT_CLK, DEFAULT_DBIT_CLK);
setPhase(ADC_CLK, DEFAULT_ADC_PHASE_DEG, 1);
setNextFrameNumber(DEFAULT_STARTING_FRAME_NUMBER);
}
int updateDatabytesandAllocateRAM() {
@ -800,6 +800,20 @@ uint32_t getADCInvertRegister() {
}
/* parameters - timer */
int setNextFrameNumber(uint64_t value) {
LOG(logINFO,
("Setting next frame number: %llu\n", (long long unsigned int)value));
setU64BitReg(value, NEXT_FRAME_NUMB_LOCAL_LSB_REG,
NEXT_FRAME_NUMB_LOCAL_MSB_REG);
return OK;
}
int getNextFrameNumber(uint64_t *retval) {
*retval = getU64BitReg(NEXT_FRAME_NUMB_LOCAL_LSB_REG,
NEXT_FRAME_NUMB_LOCAL_MSB_REG);
return OK;
}
void setNumFrames(int64_t val) {
if (val > 0) {
LOG(logINFO, ("Setting number of frames %lld\n", (long long int)val));
@ -1664,11 +1678,14 @@ void *start_timer(void *arg) {
}
// Send data
uint64_t frameNr = 0;
getNextFrameNumber(&frameNr);
// loop over number of frames
for (int frameNr = 0; frameNr != numFrames; ++frameNr) {
for (int iframes = 0; iframes != numFrames; ++iframes) {
// check if manual stop
if (sharedMemory_getStop() == 1) {
setNextFrameNumber(frameNr + iframes + 1);
break;
}
@ -1686,7 +1703,7 @@ void *start_timer(void *arg) {
sls_detector_header *header = (sls_detector_header *)(packetData);
header->detType = (uint16_t)myDetectorType;
header->version = SLS_DETECTOR_HEADER_VERSION - 1;
header->frameNumber = virtual_currentFrameNumber;
header->frameNumber = frameNr + iframes;
header->packetNumber = i;
header->modId = 0;
header->row = detPos[X];
@ -1699,19 +1716,18 @@ void *start_timer(void *arg) {
sendUDPPacket(0, 0, packetData, packetSize);
}
LOG(logINFO, ("Sent frame: %d [%lld]\n", frameNr,
(long long unsigned int)virtual_currentFrameNumber));
LOG(logINFO, ("Sent frame: %d [%lld]\n", iframes, frameNr + iframes));
clock_gettime(CLOCK_REALTIME, &end);
int64_t timeNs =
((end.tv_sec - begin.tv_sec) * 1E9 + (end.tv_nsec - begin.tv_nsec));
// sleep for (period - exptime)
if (frameNr < numFrames) { // if there is a next frame
if (iframes < numFrames) { // if there is a next frame
if (periodNs > timeNs) {
usleep((periodNs - timeNs) / 1000);
}
}
++virtual_currentFrameNumber;
setNextFrameNumber(frameNr + numFrames);
}
closeUDPSocket(0);

View File

@ -78,18 +78,19 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
#define NCHANS_PER_ADC (25)
/** Default Parameters */
#define DEFAULT_PATTERN_FILE ("DefaultPattern_moench.txt")
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_NUM_SAMPLES (5000)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_PATTERN_FILE ("DefaultPattern_moench.txt")
#define DEFAULT_STARTING_FRAME_NUMBER (1)
#define DEFAULT_DATA_BYTES (NCHIP * NCHAN * NUM_BITS_PER_PIXEL)
#define DEFAULT_NUM_SAMPLES (5000)
#define DEFAULT_EXPTIME (0)
#define DEFAULT_NUM_FRAMES (1)
#define DEFAULT_NUM_CYCLES (1)
#define DEFAULT_PERIOD (1 * 1000 * 1000) // ns
#define DEFAULT_DELAY (0)
#define DEFAULT_HIGH_VOLTAGE (0)
#define DEFAULT_VLIMIT (-100)
#define DEFAULT_TIMING_MODE (AUTO_TIMING)
#define DEFAULT_TX_UDP_PORT (0x7e9a)
#define DEFAULT_RUN_CLK_AT_STARTUP (200) // 40
#define DEFAULT_ADC_CLK_AT_STARTUP (40) // 20
@ -104,6 +105,8 @@ enum CLKINDEX { RUN_CLK, ADC_CLK, SYNC_CLK, DBIT_CLK, NUM_CLOCKS };
#define DEFAULT_PIPELINE (15)
#define DEFAULT_SETTINGS (G4_HIGHGAIN)
#define UDP_HEADER_MAX_FRAME_VALUE (0xFFFFFFFFFFFF)
// settings
#define DEFAULT_PATMASK (0x00000C800000800AULL)
#define G1_HIGHGAIN_PATSETBIT (0x00000C0000008008ULL)