From 09b2084f92b2b14f0a0aad3b6b4d7b46bd605279 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Fri, 16 Aug 2024 09:48:10 +0200 Subject: [PATCH 01/13] b2b: porting to new common-lib --- modules/b2b/fw/Makefile | 2 +- modules/b2b/fw/b2b-cbu.c | 10 +++------- modules/b2b/fw/b2b-kd.c | 13 ++++++------- modules/b2b/fw/b2b-pm-stub.c | 10 +++------- modules/b2b/fw/b2b-pm.c | 11 ++++------- modules/b2b/include/b2b.h | 3 +-- modules/b2b/include/b2blib.h | 2 +- modules/b2b/x86/b2b-analyzer.c | 2 +- modules/b2b/x86/b2b-archiver.c | 2 +- modules/b2b/x86/b2b-client-sys.c | 2 +- modules/b2b/x86/b2b-jitter-check.cpp | 2 +- modules/b2b/x86/b2b-mon.c | 2 +- modules/b2b/x86/b2b-serv-kickdiag.cpp | 2 +- modules/b2b/x86/b2b-serv-raw.cpp | 2 +- modules/b2b/x86/b2b-serv-sys.c | 2 +- modules/b2b/x86/b2b-sim.c | 2 +- modules/b2b/x86/b2b-viewer.c | 2 +- modules/b2b/x86/b2blib.c | 9 ++++----- modules/common-libs/include/common-fwlib.h | 2 +- 19 files changed, 34 insertions(+), 48 deletions(-) diff --git a/modules/b2b/fw/Makefile b/modules/b2b/fw/Makefile index 49ab5dff7..9ee27dfbf 100644 --- a/modules/b2b/fw/Makefile +++ b/modules/b2b/fw/Makefile @@ -12,7 +12,7 @@ RAM_SIZE := $(shell cat $(PLATFMAKEFILE) | grep -m1 RAM_SIZE | cut -d'= SHARED_SIZE ?= 8K USRCPUCLK ?= 125000 -VERSION = 00.07.02 +VERSION = 00.07.04 .DEFAULT_GOAL := fwbin diff --git a/modules/b2b/fw/b2b-cbu.c b/modules/b2b/fw/b2b-cbu.c index 7553d2633..362b83b44 100644 --- a/modules/b2b/fw/b2b-cbu.c +++ b/modules/b2b/fw/b2b-cbu.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 06-Oct-2023 + * version : 15-Aug-2024 * * firmware implementing the CBU (Central Bunch-To-Bucket Unit) * NB: units of variables are [ns] unless explicitely mentioned as suffix @@ -35,7 +35,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 23-April-2019 ********************************************************************************************/ -#define B2BCBU_FW_VERSION 0x000702 // make this consistent with makefile +#define B2BCBU_FW_VERSION 0x000704 // make this consistent with makefile // standard includes #include @@ -128,7 +128,6 @@ volatile float *pSharedGetCTrigExt; // pointer to a "user defined" u32 regis volatile float *pSharedGetCTrigInj; // pointer to a "user defined" u32 register; here: correction for trigger injection ('injction kicker knob') [ns] volatile uint32_t *pSharedGetTBeatHi; // pointer to a "user defined" u32 register; here: period of beating, high bits [as] volatile uint32_t *pSharedGetTBeatLo; // pointer to a "user defined" u32 register; here: period of beating, low bits -volatile int32_t *pSharedGetComLatency;// pointer to a "user defined" u32 register; here: latency for messages received via ECA [ns] // important for b2b system uint32_t gid; // GID used for transfer @@ -242,7 +241,6 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) pSharedGetCTrigInj = (float *)(pShared + (B2B_SHARED_GET_CTRIGINJ >> 2)); pSharedGetTBeatHi = (uint32_t *)(pShared + (B2B_SHARED_GET_TBEATHI >> 2)); pSharedGetTBeatLo = (uint32_t *)(pShared + (B2B_SHARED_GET_TBEATLO >> 2)); - pSharedGetComLatency = (int32_t *)(pShared + (B2B_SHARED_GET_COMLATENCY >> 2)); // find address of CPU from external perspective idx = 0; @@ -465,7 +463,6 @@ uint32_t extern_entryActionOperation() *pSharedGetCTrigInj = 0x0; *pSharedGetTBeatHi = 0x0; *pSharedGetTBeatLo = 0x0; - *pSharedGetComLatency = 0x0; return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -1310,7 +1307,7 @@ int main(void) { fwlib_publishStatusArray(statusArray); pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat); + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /*chk: set values of nLate and offsDone */ // update get values *pSharedGetGid = gid; @@ -1327,7 +1324,6 @@ int main(void) { *pSharedGetCTrigInj = fwlib_tps2tfns(cTrigInj_t); *pSharedGetTBeatHi = (uint32_t)((TBeat_as >> 32) & 0xffffffff); *pSharedGetTBeatLo = (uint32_t)( TBeat_as & 0xffffffff); - *pSharedGetComLatency = comLatency; } // while return (1); // this should never happen ... diff --git a/modules/b2b/fw/b2b-kd.c b/modules/b2b/fw/b2b-kd.c index 4ee05bdfb..0bb96f71e 100644 --- a/modules/b2b/fw/b2b-kd.c +++ b/modules/b2b/fw/b2b-kd.c @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 22-Dec-2022 + * version : 15-Aug-2024 * * firmware required for kicker and related diagnostics * @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 19-November-2020 ********************************************************************************************/ -#define B2BPM_FW_VERSION 0x000702 // make this consistent with makefile +#define B2BPM_FW_VERSION 0x000704 // make this consistent with makefile // standard includes #include @@ -72,13 +72,14 @@ volatile uint32_t *pSharedGettKickDMon; // pointer to a "user defined" u32 re volatile uint32_t *pSharedGettKickDProbe; // pointer to a "user defined" u32 register; here: delay of probe signal volatile uint32_t *pSharedGetKickSid; // pointer to a "user defined" u32 register; here: SID of last kicker event volatile uint32_t *pSharedGetKickGid; // pointer to a "user defined" u32 register; here: GID of last kicker event -volatile int32_t *pSharedGetComLatency; // pointer to a "user defined" u32 register; here: latency for messages received via ECA uint32_t *cpuRamExternal; // external address (seen from host bridge) of this CPU's RAM uint64_t statusArray; // all status infos are ORed bit-wise into statusArray, statusArray is then published uint32_t nTransfer; // # of transfers uint32_t transStat; // status of transfer, here: meanDelta of 'poor mans fit' +int32_t comLatency; // latency for messages received via ECA [ns] + // typical init for lm32 @@ -110,7 +111,6 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) pSharedGettKickDProbe = (uint32_t *)(pShared + (B2B_SHARED_GET_DKPROBE >> 2)); pSharedGetKickSid = (uint32_t *)(pShared + (B2B_SHARED_GET_SID >> 2)); pSharedGetKickGid = (uint32_t *)(pShared + (B2B_SHARED_GET_GID >> 2)); - pSharedGetComLatency = (int32_t *)(pShared + (B2B_SHARED_GET_COMLATENCY >> 2)); // find address of CPU from external perspective idx = 0; @@ -212,7 +212,6 @@ uint32_t extern_entryActionOperation() *pSharedGettKickDProbe = 0x0; *pSharedGetKickSid = 0x0; *pSharedGetKickGid = 0x0; - *pSharedGetComLatency = 0x0; return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -291,7 +290,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time *pSharedGetKickSid = recSid; *pSharedGettKickTrigHi = (uint32_t)((tKickTrig >> 32) & 0xffffffff); *pSharedGettKickTrigLo = (uint32_t)( tKickTrig & 0xffffffff); - *pSharedGetComLatency = (int32_t)(getSysTime() - recDeadline); + comLatency = (int32_t)(getSysTime() - recDeadline); // we must do this here, as doing this os B2B_ECADO_TLUINPUT2 would be too late @@ -453,7 +452,7 @@ int main(void) { fwlib_publishStatusArray(statusArray); pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat); + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /* chk: set nLate, offsDone */ } // while return(1); // this should never happen ... diff --git a/modules/b2b/fw/b2b-pm-stub.c b/modules/b2b/fw/b2b-pm-stub.c index 239e2533b..540d09165 100644 --- a/modules/b2b/fw/b2b-pm-stub.c +++ b/modules/b2b/fw/b2b-pm-stub.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 23-Nov-2023 + * version : 15-Aug-2024 * * firmware required for measuring the h=1 phase for ring machine * @@ -38,7 +38,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 ********************************************************************************************/ -#define B2BPMSTUB_FW_VERSION 0x000703 // make this consistent with makefile +#define B2BPMSTUB_FW_VERSION 0x000704 // make this consistent with makefile //standard includes #include @@ -75,7 +75,6 @@ volatile uint32_t *pSharedGetSid; // pointer to a "user defined" u32 regis volatile uint32_t *pSharedGetTH1Hi; // pointer to a "user defined" u32 register; here: period of h=1, high bits volatile uint32_t *pSharedGetTH1Lo; // pointer to a "user defined" u32 register; here: period of h=1, low bits volatile uint32_t *pSharedGetNH; // pointer to a "user defined" u32 register; here: harmonic number -volatile int32_t *pSharedGetComLatency;// pointer to a "user defined" u32 register; here: latency for messages received via ECA uint32_t *cpuRamExternal; // external address (seen from host bridge) of this CPU's RAM @@ -115,7 +114,6 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) pSharedGetTH1Hi = (uint32_t *)(pShared + (B2B_SHARED_GET_TH1EXTHI >> 2)); // for simplicity: use 'EXT' for data pSharedGetTH1Lo = (uint32_t *)(pShared + (B2B_SHARED_GET_TH1EXTLO >> 2)); pSharedGetNH = (uint32_t *)(pShared + (B2B_SHARED_GET_NHEXT >> 2)); - pSharedGetComLatency = (int32_t *)(pShared + (B2B_SHARED_GET_COMLATENCY >> 2)); // find address of CPU from external perspective idx = 0; @@ -209,7 +207,6 @@ uint32_t extern_entryActionOperation() *pSharedGetNH = 0x0; *pSharedGetGid = 0x0; *pSharedGetSid = 0x0; - *pSharedGetComLatency = 0x0; return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -557,8 +554,7 @@ int main(void) { fwlib_publishStatusArray(statusArray); pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat); - *pSharedGetComLatency = comLatency; + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /* chk: set values of nLate and offsDone */ } // while return(1); // this should never happen ... diff --git a/modules/b2b/fw/b2b-pm.c b/modules/b2b/fw/b2b-pm.c index 62a5dd4ee..8e5cafb7d 100644 --- a/modules/b2b/fw/b2b-pm.c +++ b/modules/b2b/fw/b2b-pm.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 15-Nov-2023 + * version : 15-Aug-2024 * * firmware required for measuring the h=1 phase for ring machine * @@ -42,7 +42,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 ********************************************************************************************/ -#define B2BPM_FW_VERSION 0x000702 // make this consistent with makefile +#define B2BPM_FW_VERSION 0x000704 // make this consistent with makefile // standard includes #include @@ -79,7 +79,6 @@ volatile uint32_t *pSharedGetSid; // pointer to a "user defined" u32 regis volatile uint32_t *pSharedGetTH1Hi; // pointer to a "user defined" u32 register; here: period of h=1, high bits volatile uint32_t *pSharedGetTH1Lo; // pointer to a "user defined" u32 register; here: period of h=1, low bits volatile uint32_t *pSharedGetNH; // pointer to a "user defined" u32 register; here: harmonic number -volatile int32_t *pSharedGetComLatency;// pointer to a "user defined" u32 register; here: latency for messages received via ECA uint32_t *cpuRamExternal; // external address (seen from host bridge) of this CPU's RAM @@ -122,7 +121,7 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) pSharedGetTH1Hi = (uint32_t *)(pShared + (B2B_SHARED_GET_TH1EXTHI >> 2)); // for simplicity: use 'EXT' for data pSharedGetTH1Lo = (uint32_t *)(pShared + (B2B_SHARED_GET_TH1EXTLO >> 2)); pSharedGetNH = (uint32_t *)(pShared + (B2B_SHARED_GET_NHEXT >> 2)); - pSharedGetComLatency = (int32_t *)(pShared + (B2B_SHARED_GET_COMLATENCY >> 2)); + // find address of CPU from external perspective idx = 0; find_device_multi(&found_clu, &idx, 1, GSI, LM32_CB_CLUSTER); @@ -217,7 +216,6 @@ uint32_t extern_entryActionOperation() *pSharedGetNH = 0x0; *pSharedGetGid = 0x0; *pSharedGetSid = 0x0; - *pSharedGetComLatency = 0x0; return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -718,8 +716,7 @@ int main(void) { fwlib_publishStatusArray(statusArray); pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat); - *pSharedGetComLatency = comLatency; + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /* chk: set values of offsDone and comLatency */ } // while return(1); // this should never happen ... diff --git a/modules/b2b/include/b2b.h b/modules/b2b/include/b2b.h index 975e8aecb..616d3834c 100644 --- a/modules/b2b/include/b2b.h +++ b/modules/b2b/include/b2b.h @@ -155,8 +155,7 @@ #define B2B_SHARED_GET_CTRIGINJ (B2B_SHARED_GET_CTRIGEXT + _32b_SIZE_) // correction for trigger injection ('injction kicker knob') [ns, float] #define B2B_SHARED_GET_TBEATHI (B2B_SHARED_GET_CTRIGINJ + _32b_SIZE_) // period of beating, high bits #define B2B_SHARED_GET_TBEATLO (B2B_SHARED_GET_TBEATHI + _32b_SIZE_) // period of beating, low bits -#define B2B_SHARED_GET_COMLATENCY (B2B_SHARED_GET_TBEATLO + _32b_SIZE_) // latency for messages received from via ECA (tDeadline - tNow)) [ns] -#define B2B_SHARED_GET_TKTRIGHI (B2B_SHARED_GET_COMLATENCY + _32b_SIZE_) // time of kicker trigger signal, high bits [ns] +#define B2B_SHARED_GET_TKTRIGHI (B2B_SHARED_GET_TBEATLO + _32b_SIZE_) // time of kicker trigger signal, high bits [ns] #define B2B_SHARED_GET_TKTRIGLO (B2B_SHARED_GET_TKTRIGHI + _32b_SIZE_) // time of kicker trigger signal, low bits [ns] #define B2B_SHARED_GET_DKMON (B2B_SHARED_GET_TKTRIGLO + _32b_SIZE_) // delay of kicker monitor signal [ns], delay is measured from kicker trigger signal #define B2B_SHARED_GET_DKPROBE (B2B_SHARED_GET_DKMON + _32b_SIZE_) // delay of kicker probe signal [ns], delay is measured from kicker trigger signal diff --git a/modules/b2b/include/b2blib.h b/modules/b2b/include/b2blib.h index 6d5b71087..863a71cfa 100644 --- a/modules/b2b/include/b2blib.h +++ b/modules/b2b/include/b2blib.h @@ -41,7 +41,7 @@ extern "C" { #endif -#define B2BLIB_VERSION 0x000702 +#define B2BLIB_VERSION 0x000704 // (error) codes; duplicated to avoid the need of joining bel_projects and acc git repos #define B2BLIB_STATUS_OK 0 // OK diff --git a/modules/b2b/x86/b2b-analyzer.c b/modules/b2b/x86/b2b-analyzer.c index 76a574241..64bcedb01 100644 --- a/modules/b2b/x86/b2b-analyzer.c +++ b/modules/b2b/x86/b2b-analyzer.c @@ -36,7 +36,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_ANALYZER_VERSION 0x000702 +#define B2B_ANALYZER_VERSION 0x000704 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-archiver.c b/modules/b2b/x86/b2b-archiver.c index b91c0892a..cc8c69c32 100644 --- a/modules/b2b/x86/b2b-archiver.c +++ b/modules/b2b/x86/b2b-archiver.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_ARCHIVER_VERSION 0x000703 +#define B2B_ARCHIVER_VERSION 0x000704 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-client-sys.c b/modules/b2b/x86/b2b-client-sys.c index 4d53a01dd..eeb7d575d 100644 --- a/modules/b2b/x86/b2b-client-sys.c +++ b/modules/b2b/x86/b2b-client-sys.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_CLIENT_SYS_VERSION 0x000702 +#define B2B_CLIENT_SYS_VERSION 0x000704 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-jitter-check.cpp b/modules/b2b/x86/b2b-jitter-check.cpp index 6e72f2469..c49b6cc1b 100644 --- a/modules/b2b/x86/b2b-jitter-check.cpp +++ b/modules/b2b/x86/b2b-jitter-check.cpp @@ -37,7 +37,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_JITTER_CHECK_VERSION 0x000702 +#define B2B_JITTER_CHECK_VERSION 0x000704 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-mon.c b/modules/b2b/x86/b2b-mon.c index f7469b61f..a9f7e9cd2 100644 --- a/modules/b2b/x86/b2b-mon.c +++ b/modules/b2b/x86/b2b-mon.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_MON_VERSION 0x000702 +#define B2B_MON_VERSION 0x000704 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-serv-kickdiag.cpp b/modules/b2b/x86/b2b-serv-kickdiag.cpp index 3995c602d..05ff5d2bb 100644 --- a/modules/b2b/x86/b2b-serv-kickdiag.cpp +++ b/modules/b2b/x86/b2b-serv-kickdiag.cpp @@ -37,7 +37,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERV_KICKD_VERSION 0x000702 +#define B2B_SERV_KICKD_VERSION 0x000704 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-serv-raw.cpp b/modules/b2b/x86/b2b-serv-raw.cpp index 1bc84f01b..706c1fdb2 100644 --- a/modules/b2b/x86/b2b-serv-raw.cpp +++ b/modules/b2b/x86/b2b-serv-raw.cpp @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERV_RAW_VERSION 0x000702 +#define B2B_SERV_RAW_VERSION 0x000704 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-serv-sys.c b/modules/b2b/x86/b2b-serv-sys.c index 5de1f584b..8ba8d1b42 100644 --- a/modules/b2b/x86/b2b-serv-sys.c +++ b/modules/b2b/x86/b2b-serv-sys.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERVSYS_VERSION 0x000702 +#define B2B_SERVSYS_VERSION 0x000704 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-sim.c b/modules/b2b/x86/b2b-sim.c index 1a12e092b..1c19cfc29 100644 --- a/modules/b2b/x86/b2b-sim.c +++ b/modules/b2b/x86/b2b-sim.c @@ -35,7 +35,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2BSIM_VERSION 0x000702 +#define B2BSIM_VERSION 0x000704 #define MAXSAMPLES 1000 #define MAXDATA 10000000 diff --git a/modules/b2b/x86/b2b-viewer.c b/modules/b2b/x86/b2b-viewer.c index d121d4173..3d973dc86 100644 --- a/modules/b2b/x86/b2b-viewer.c +++ b/modules/b2b/x86/b2b-viewer.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_VIEWER_VERSION 0x000702 +#define B2B_VIEWER_VERSION 0x000704 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2blib.c b/modules/b2b/x86/b2blib.c index 687af4a7a..759c51031 100644 --- a/modules/b2b/x86/b2blib.c +++ b/modules/b2b/x86/b2blib.c @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 18-Oct-2023 + * version : 15-Aug-2024 * * library for b2b * @@ -401,7 +401,6 @@ uint32_t b2b_firmware_open(uint64_t *ebDevice, const char* devName, uint32_t cpu b2b_get_cPhase = lm32_base + SHARED_OFFS + B2B_SHARED_GET_CPHASE; b2b_get_cTrigExt = lm32_base + SHARED_OFFS + B2B_SHARED_GET_CTRIGEXT; b2b_get_cTrigInj = lm32_base + SHARED_OFFS + B2B_SHARED_GET_CTRIGINJ; - b2b_get_comLatency = lm32_base + SHARED_OFFS + B2B_SHARED_GET_COMLATENCY; // do this just at the very end *ebDevice = (uint64_t)eb_device; @@ -539,13 +538,13 @@ uint32_t b2b_common_read(uint64_t ebDevice, uint64_t *statusArray, uint32_t *sta eb_device_t eb_device; uint64_t dummy64a, dummy64b, dummy64c; - uint32_t dummy32a, dummy32c, dummy32d, dummy32e; + uint32_t dummy32a, dummy32c, dummy32d, dummy32e, dummy32f, dummy32g, dummy32h; if (!ebDevice) return COMMON_STATUS_EB; eb_device = (eb_device_t)ebDevice; - if ((eb_status = comlib_readDiag(eb_device, statusArray, state, version, &dummy64a, &dummy32a, nBadStatus, nBadState, &dummy64b, &dummy64c, - nTransfer, &dummy32c, &dummy32d, &dummy32e, printDiag)) != COMMON_STATUS_OK) return COMMON_STATUS_EB; + if ((eb_status = comlib_readDiag(eb_device, statusArray, state, version, &dummy64a, &dummy32a, nBadStatus, nBadState, &dummy64b, &dummy64c, nTransfer, &dummy32c, + &dummy32d, &dummy32e, &dummy32f, &dummy32g, &dummy32h, printDiag)) != COMMON_STATUS_OK) return COMMON_STATUS_EB; return COMMON_STATUS_OK; } // b2b_status_read diff --git a/modules/common-libs/include/common-fwlib.h b/modules/common-libs/include/common-fwlib.h index e9226d5ec..e6edabe15 100644 --- a/modules/common-libs/include/common-fwlib.h +++ b/modules/common-libs/include/common-fwlib.h @@ -123,7 +123,7 @@ void fwlib_publishStatusArray(uint64_t statusArray // status array (each bit // publish status of ongoing transfer void fwlib_publishTransferStatus(uint32_t nTransfer, // # of transfers - uint32_t nInject, // # of injections within current transferr + uint32_t nInject, // # of injections within current transfer uint32_t transStat, // status of ongoing transfer uint32_t nLate, // number of messages that could not be delivered in time uint32_t offsDone, // offset event deadline to time when we are done [ns] From ada639ac55c598db8f04dd72498b0056451a1925 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Fri, 16 Aug 2024 13:52:08 +0200 Subject: [PATCH 02/13] b2b: porting to new common-lib continued . --- modules/b2b/fw/b2b-cbu.c | 53 ++++++++++++++++++------------- modules/b2b/fw/b2b-kd.c | 60 +++++++++++++++++++++++------------- modules/b2b/fw/b2b-pm-stub.c | 6 ++-- modules/b2b/fw/b2b-pm.c | 32 +++++++++++++------ 4 files changed, 96 insertions(+), 55 deletions(-) diff --git a/modules/b2b/fw/b2b-cbu.c b/modules/b2b/fw/b2b-cbu.c index 362b83b44..5ae31803b 100644 --- a/modules/b2b/fw/b2b-cbu.c +++ b/modules/b2b/fw/b2b-cbu.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 15-Aug-2024 + * version : 16-Aug-2024 * * firmware implementing the CBU (Central Bunch-To-Bucket Unit) * NB: units of variables are [ns] unless explicitely mentioned as suffix @@ -168,8 +168,12 @@ int32_t nPhaseResult; // number of received phase result, requ uint64_t statusArray; // all status infos are ORed bit-wise into statusArray, statusArray is then published uint32_t nTransfer; // # of transfers uint32_t transStat; // status of ongoing transfer -int32_t comLatency; // latency for messages received via ECA [ns] uint32_t mState; // state of 'miniFSM' +int32_t comLatency; // latency for messages received via ECA [ns] +int32_t offsDone; // offset deadline WR message to time when we are done [ns] +int32_t maxComLatency; +uint32_t maxOffsDone; +uint32_t nLate; // # of late messages // flags uint32_t flagClearAllSid; // data for all SIDs shall be cleared @@ -284,10 +288,14 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) // clears all statistics void extern_clearDiag() { - statusArray = 0x0; - nTransfer = 0x0; - transStat = 0x0; - comLatency = 0x0; + statusArray = 0x0; + nTransfer = 0x0; + transStat = 0x0; + nLate = 0x0; + comLatency = 0x0; + maxComLatency = 0x0; + offsDone = 0x0; + maxOffsDone = 0x0; } // extern_clearDiag @@ -464,6 +472,12 @@ uint32_t extern_entryActionOperation() *pSharedGetTBeatHi = 0x0; *pSharedGetTBeatLo = 0x0; + nLate = 0x0; + comLatency = 0x0; + maxComLatency = 0x0; + offsDone = 0x0; + maxOffsDone = 0x0; + return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -973,20 +987,11 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT * 1000, &recDeadline, &recId, &recParam, &recTef, &flagIsLate, &flagIsEarly, &flagIsConflict, &flagIsDelayed); - /*if (flagIsLate) { - tmp32 = (uint32_t)(getSysTime() - recDeadline); - pp_printf("late event....\n"); - pp_printf("late by %u\n", tmp32); - tmp32 = (uint32_t)(recId >> 32) & 0xffffffff; - pp_printf("late event is idhi 0x%08x\n", tmp32); - tmp32 = (uint32_t)(recId) & 0xffffffff; - pp_printf("late event is idlo 0x%08x\n", tmp32); - } // if flag late */ + if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); switch (ecaAction) { case B2B_ECADO_B2B_START : // received: CMD_B2B_START from DM; B2B transfer starts - comLatency = (int32_t)(getSysTime() - recDeadline); recGid = (uint32_t)((recId >> 48) & 0x0fff); recSid = (uint32_t)((recId >> 20) & 0x0fff); recBpid = (uint32_t)((recId >> 6) & 0x3fff); @@ -1202,8 +1207,9 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o if (mState == B2B_MFSM_EXTTRIG ) { sendGid = getTrigGid(1); if (!sendGid) return COMMON_STATUS_OUTOFRANGE; - tTrigExt = tTrig + cTrigExt_t.ns; // trigger correctionl; chk: sub-ns part - tmpf = (float)(getSysTime() - tCBS) / 1000.0; // time from CBS to now [us] + tTrigExt = tTrig + cTrigExt_t.ns; // trigger correction; chk: sub-ns part + offsDone = getSysTime() - tCBS; + tmpf = (float)offsDone / 1000.0; // time from CBS to now [us] //tmp32 = (uint32_t)tmpf; pp_printf("sid %d, fin-cbs %u\n", sid, tmp32); offsetFin_us = fwlib_float2half(tmpf); if (tTrigExt < getSysTime() + (uint64_t)(COMMON_LATELIMIT)) { // we are too late! @@ -1240,7 +1246,10 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o if (flagClearAllSid) {clearAllSid(); flagClearAllSid = 0;} // check for late event - if ((status == COMMON_STATUS_OK) && flagIsLate) status = B2B_STATUS_LATEMESSAGE; + if ((status == COMMON_STATUS_OK) && flagIsLate) { + status = B2B_STATUS_LATEMESSAGE; + nLate++; + } // if status // check WR sync state; worst case, do this last if (fwlib_wrCheckSyncState() == COMMON_STATUS_WRBADSYNC) return COMMON_STATUS_WRBADSYNC; @@ -1305,9 +1314,11 @@ int main(void) { if ((pubState == COMMON_STATE_OPREADY) && (actState != COMMON_STATE_OPREADY)) fwlib_incBadStateCnt(); fwlib_publishStatusArray(statusArray); - pubState = actState; + pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /*chk: set values of nLate and offsDone */ + if (comLatency > maxComLatency) maxComLatency = comLatency; + if (offsDone > maxOffsDone) maxOffsDone = offsDone; + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, nLate, maxOffsDone, maxComLatency); // update get values *pSharedGetGid = gid; diff --git a/modules/b2b/fw/b2b-kd.c b/modules/b2b/fw/b2b-kd.c index 0bb96f71e..0ee8316ab 100644 --- a/modules/b2b/fw/b2b-kd.c +++ b/modules/b2b/fw/b2b-kd.c @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 15-Aug-2024 + * version : 16-Aug-2024 * * firmware required for kicker and related diagnostics * @@ -79,7 +79,10 @@ uint64_t statusArray; // all status infos are ORed bit-wise uint32_t nTransfer; // # of transfers uint32_t transStat; // status of transfer, here: meanDelta of 'poor mans fit' int32_t comLatency; // latency for messages received via ECA [ns] - +int32_t offsDone; // offset deadline WR message to time when we are done [ns] +int32_t maxComLatency; +uint32_t maxOffsDone; +uint32_t nLate; // # of late messages // typical init for lm32 @@ -153,9 +156,15 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) // clear project specific diagnostics void extern_clearDiag() { - statusArray = 0x0; - nTransfer = 0; - transStat = 0; + statusArray = 0x0; + nTransfer = 0; + transStat = 0; + nLate = 0x0; + comLatency = 0x0; + maxComLatency = 0x0; + offsDone = 0x0; + maxOffsDone = 0x0; + } // extern_clearDiag @@ -213,6 +222,12 @@ uint32_t extern_entryActionOperation() *pSharedGetKickSid = 0x0; *pSharedGetKickGid = 0x0; + nLate = 0x0; + comLatency = 0x0; + maxComLatency = 0x0; + offsDone = 0x0; + maxOffsDone = 0x0; + return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -235,7 +250,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time uint32_t flagIsDelayed; // flag 'delayed' uint32_t ecaAction; // action triggered by event received from ECA uint64_t recDeadline; // deadline received - uint64_t reqDeadline; // deadline requested by sender + static uint64_t reqDeadline; // deadline requested by sender uint64_t recEvtId; // evt ID received uint64_t recParam; // param received uint32_t recTEF; // TEF received @@ -260,13 +275,16 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time static uint32_t flagSendMessage; // flag: a message shall be sent int64_t dKickMon; // delay of kicker monitor signal with respect to kicker trigger signal - int64_t dKickProbe; // delay of kicker probe signal with respect to kicker trigger signal + int64_t dKickProbe; // delay of kicker probe signal with respect to kicker trigger signal + uint64_t sysTime; // helper variable status = actStatus; transStat = 0x0; ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT*1000, &recDeadline, &recEvtId, &recParam, &recTEF, &flagIsLate, &flagIsEarly, &flagIsConflict, &flagIsDelayed); + if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); + // this switch statement mainly serves for collecting data; received data are marked by flags switch (ecaAction) { case B2B_ECADO_B2B_TRIGGEREXT : // this is an OR, no 'break' on purpose @@ -290,13 +308,6 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time *pSharedGetKickSid = recSid; *pSharedGettKickTrigHi = (uint32_t)((tKickTrig >> 32) & 0xffffffff); *pSharedGettKickTrigLo = (uint32_t)( tKickTrig & 0xffffffff); - comLatency = (int32_t)(getSysTime() - recDeadline); - - - // we must do this here, as doing this os B2B_ECADO_TLUINPUT2 would be too late - // hence, we receive probe signals only if the kicker fires after it has been triggered - //fwlib_ioCtrlSetGate(1, 0); chk // enable input gate probe signal extraction - //fwlib_ioCtrlSetGate(1, 3); chk // enable input gate probe signal injection break; // B2B_ECADO_B2B_TRIGGERINJ @@ -368,16 +379,15 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time sendDeadline = tKickTrig + (uint64_t)(2 * COMMON_AHEADT); // data shall become true 1ms after trigger event // if we are too late, reschedule message; this will happen in case there is no monitor signal from the electronics - if (getSysTime() > (sendDeadline - COMMON_AHEADT)) { - sendDeadline = getSysTime() + COMMON_AHEADT; + sysTime = getSysTime(); + if (sysTime > (sendDeadline - COMMON_AHEADT)) { + sendDeadline = sysTime + COMMON_AHEADT; status = B2B_STATUS_NOKICK; // ohps, too late! } // if getSysTime fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, 0, 0); - //fwlib_ioCtrlSetGate(0, 0); chk // disable input gates - //fwlib_ioCtrlSetGate(0, 3); chk - + offsDone = sysTime - reqDeadline; *pSharedGettKickDMon = dKickMon; *pSharedGettKickDProbe = dKickProbe; transStat = flagsError; @@ -386,8 +396,12 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time } // if flagSendMessage // check for late event - if ((status == COMMON_STATUS_OK) && flagIsLate) status = B2B_STATUS_LATEMESSAGE; - + // check for late event + if ((status == COMMON_STATUS_OK) && flagIsLate) { + status = B2B_STATUS_LATEMESSAGE; + nLate++; + } // if status + // check WR sync state if (fwlib_wrCheckSyncState() == COMMON_STATUS_WRBADSYNC) return COMMON_STATUS_WRBADSYNC; else return status; @@ -452,7 +466,9 @@ int main(void) { fwlib_publishStatusArray(statusArray); pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /* chk: set nLate, offsDone */ + if (comLatency > maxComLatency) maxComLatency = comLatency; + if (offsDone > maxOffsDone) maxOffsDone = offsDone; + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, nLate, maxOffsDone, maxComLatency); } // while return(1); // this should never happen ... diff --git a/modules/b2b/fw/b2b-pm-stub.c b/modules/b2b/fw/b2b-pm-stub.c index 540d09165..1e5e2fa2e 100644 --- a/modules/b2b/fw/b2b-pm-stub.c +++ b/modules/b2b/fw/b2b-pm-stub.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 15-Aug-2024 + * version : 16-Aug-2024 * * firmware required for measuring the h=1 phase for ring machine * @@ -340,6 +340,8 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT * 1000, &recDeadline, &recEvtId, &recParam, &recTEF, &flagIsLate, &flagEarly, &flagConflict, &flagDelayed); + if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); + switch (ecaAction) { // the following two cases handle H=1 group DDS phase measurement case B2B_ECADO_B2B_PMEXT : // this is an OR, no 'break' on purpose @@ -347,8 +349,6 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time case B2B_ECADO_B2B_PMINJ : if (!sendEvtNo) sendEvtNo = B2B_ECADO_B2B_PRINJ; - comLatency = (int32_t)(getSysTime() - recDeadline); - *pSharedGetTH1Hi = (uint32_t)((recParam >> 32) & 0x00ffffff); // lower 56 bit used as period *pSharedGetTH1Lo = (uint32_t)( recParam & 0xffffffff); *pSharedGetNH = (uint32_t)((recParam>> 56) & 0xff ); // upper 8 bit used as harmonic number diff --git a/modules/b2b/fw/b2b-pm.c b/modules/b2b/fw/b2b-pm.c index 8e5cafb7d..9cb9c0724 100644 --- a/modules/b2b/fw/b2b-pm.c +++ b/modules/b2b/fw/b2b-pm.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 15-Aug-2024 + * version : 16-Aug-2024 * * firmware required for measuring the h=1 phase for ring machine * @@ -85,7 +85,12 @@ uint32_t *cpuRamExternal; // external address (seen from host brid uint64_t statusArray; // all status infos are ORed bit-wise into statusArray, statusArray is then published uint32_t nTransfer; // # of transfers uint32_t transStat; // status of transfer, here: meanDelta of 'poor mans fit' -int32_t comLatency; // latency for messages received via ECA +int32_t comLatency; // latency for messages received via ECA [ns] +int32_t offsDone; // offset deadline WR message to time when we are done [ns] +int32_t maxComLatency; +uint32_t maxOffsDone; +uint32_t nLate; // # of late messages + // for phase measurement uint64_t tStamp[B2B_NSAMPLES]; // timestamp samples @@ -164,10 +169,14 @@ void initSharedMem(uint32_t *reqState, uint32_t *sharedSize) // clear project specific diagnostics void extern_clearDiag() { - statusArray = 0x0; - nTransfer = 0; - transStat = 0; - comLatency = 0x0; + statusArray = 0x0; + nTransfer = 0; + transStat = 0; + nLate = 0x0; + comLatency = 0x0; + maxComLatency = 0x0; + offsDone = 0x0; + maxOffsDone = 0x0; } // extern_clearDiag @@ -217,6 +226,12 @@ uint32_t extern_entryActionOperation() *pSharedGetGid = 0x0; *pSharedGetSid = 0x0; + nLate = 0x0; + comLatency = 0x0; + maxComLatency = 0x0; + offsDone = 0x0; + maxOffsDone = 0x0; + return COMMON_STATUS_OK; } // extern_entryActionOperation @@ -485,6 +500,8 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT * 1000, &recDeadline, &recEvtId, &recParam, &recTEF, &flagIsLate, &flagIsEarly, &flagIsConflict, &flagIsDelayed); + if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); + switch (ecaAction) { // the following two cases handle h=1 group DDS phase measurement case B2B_ECADO_B2B_PMEXT : // this is an OR, no 'break' on purpose @@ -492,8 +509,6 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time case B2B_ECADO_B2B_PMINJ : if (!sendEvtNo) sendEvtNo = B2B_ECADO_B2B_PRINJ; //t1 = getSysTime(); - comLatency = (int32_t)(getSysTime() - recDeadline); - *pSharedGetTH1Hi = (uint32_t)((recParam >> 32) & 0x000fffff); // lower 52 bit used as period *pSharedGetTH1Lo = (uint32_t)( recParam & 0xffffffff); *pSharedGetNH = (uint32_t)((recParam>> 56) & 0xff ); // upper 8 bit used as harmonic number @@ -508,7 +523,6 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time flagPMError = 0x0; tH1_t.ns = 0x6fffffffffffffff; // bogus number, might help for debugging chk - nSamples = B2B_NSAMPLES; if (TH1_as > 2500000000000) nSamples = B2B_NSAMPLES >> 1; // use only 1/2 for nue < 400 kHz: 80us@400kHz and B2B_NSAMPLES=32 if (TH1_as > 5000000000000) nSamples = B2B_NSAMPLES >> 2; // use only 1/4 for nue < 200 kHz: 80us@200kHz and B2B_NSAMPLES=32 From 80b30454ee8df59c2c6f427e1b9de70dbdc5c8b8 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Fri, 16 Aug 2024 15:03:24 +0200 Subject: [PATCH 03/13] b2b: remove option '-s' from sys-client --- modules/b2b/x86/b2b-client-sys.c | 76 ++++++++++++++------------------ 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/modules/b2b/x86/b2b-client-sys.c b/modules/b2b/x86/b2b-client-sys.c index eeb7d575d..996bc9043 100644 --- a/modules/b2b/x86/b2b-client-sys.c +++ b/modules/b2b/x86/b2b-client-sys.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 27-Sep-2023 + * version : 16-Aug-2023 * * subscribes to and displays status of a b2b system (CBU, PM, KD ...) * @@ -154,7 +154,6 @@ static void help(void) { fprintf(stderr, "\n"); fprintf(stderr, " -h display this help and exit\n"); fprintf(stderr, " -e display version\n"); - fprintf(stderr, " -s subscribe and display system info\n"); fprintf(stderr, " -o print info only once and exit (useful with '-s')\n"); fprintf(stderr, "\n"); fprintf(stderr, "Use this tool to display system information on the B2B system\n"); @@ -323,7 +322,6 @@ int main(int argc, char** argv) { // char *tail; int getVersion; - int subscribe; int once; char userInput; @@ -335,18 +333,14 @@ int main(int argc, char** argv) { program = argv[0]; getVersion = 0; - subscribe = 0; once = 0; quit = 0; - while ((opt = getopt(argc, argv, "seho")) != -1) { + while ((opt = getopt(argc, argv, "eho")) != -1) { switch (opt) { case 'e': getVersion = 1; break; - case 's': - subscribe = 1; - break; case 'o': once = 1; break; @@ -385,40 +379,38 @@ int main(int argc, char** argv) { buildHeader(environment); if (getVersion) printf("%s: version %s\n", program, b2b_version_text(B2B_CLIENT_SYS_VERSION)); - if (subscribe) { - printf("b2b-client-sys: starting client using prefix %s\n", prefix); - sleep(1); - dicSubscribeServices(prefix); - - while (!quit) { - if (once) {sleep(1); quit=1;} // wait a bit to get the values - printServices(once); - if (!quit) { - sysId = 0xffff; - userInput = comlib_term_getChar(); - switch (userInput) { - case 'a' ... 'f' : - sysId = userInput - 87; // no break on purpose - case '0' ... '9' : - if (sysId == 0xffff) sysId = userInput - 48; // ugly - dicCmdClearDiag(prefix, sysId); - dicCmdClearJitterChk(prefix, sysId); - break; - case 'h' : - printHelpText(); - break; - case 'q' : - quit = 1; - break; - case 's' : - printStatusText(); - break; - default : - usleep(1000000); - } // switch - } // if !quit - } // while - } // if subscribe + printf("b2b-client-sys: starting client using prefix %s\n", prefix); + sleep(1); + dicSubscribeServices(prefix); + + while (!quit) { + if (once) {sleep(1); quit=1;} // wait a bit to get the values + printServices(once); + if (!quit) { + sysId = 0xffff; + userInput = comlib_term_getChar(); + switch (userInput) { + case 'a' ... 'f' : + sysId = userInput - 87; // no break on purpose + case '0' ... '9' : + if (sysId == 0xffff) sysId = userInput - 48; // ugly + dicCmdClearDiag(prefix, sysId); + dicCmdClearJitterChk(prefix, sysId); + break; + case 'h' : + printHelpText(); + break; + case 'q' : + quit = 1; + break; + case 's' : + printStatusText(); + break; + default : + usleep(1000000); + } // switch + } // if !quit + } // while return exitCode; } From b4bf2f9c9cbb39305202af98a3affc0a1d40dd18 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Fri, 16 Aug 2024 15:05:09 +0200 Subject: [PATCH 04/13] b2b: remove option '-s' from sys-client . --- modules/b2b/app/start-app-b2b-int-sys-mon.sh | 2 +- modules/b2b/app/start-app-b2b-pro-sys-mon.sh | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/b2b/app/start-app-b2b-int-sys-mon.sh b/modules/b2b/app/start-app-b2b-int-sys-mon.sh index dea359076..359ca5d81 100755 --- a/modules/b2b/app/start-app-b2b-int-sys-mon.sh +++ b/modules/b2b/app/start-app-b2b-int-sys-mon.sh @@ -11,4 +11,4 @@ BASEDIR=$(cd "${SCRIPTDIR}/.." >/dev/null; pwd) # script for starting the b2b system viewer on INT export DIM_DNS_NODE=asl105 export LD_LIBRARY_PATH=${BASEDIR}/lib -xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys -s int +xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys int diff --git a/modules/b2b/app/start-app-b2b-pro-sys-mon.sh b/modules/b2b/app/start-app-b2b-pro-sys-mon.sh index 76603c814..e31cf951b 100755 --- a/modules/b2b/app/start-app-b2b-pro-sys-mon.sh +++ b/modules/b2b/app/start-app-b2b-pro-sys-mon.sh @@ -11,5 +11,4 @@ BASEDIR=$(cd "${SCRIPTDIR}/.." >/dev/null; pwd) # script for starting the b2b system viewer on INT export DIM_DNS_NODE=asl105 export LD_LIBRARY_PATH=${BASEDIR}/lib -xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys\ - -s pro +xterm -T 'b2b system status' -fa monaco -fs 10 -e ${BASEDIR}/bin/b2b-client-sys pro From 362e127ff53a9a640fe1e4586c3e01ee4be8a25f Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Fri, 16 Aug 2024 16:14:23 +0200 Subject: [PATCH 05/13] b2b: adapt build script for apps to acc9 --- modules/b2b/app/buildApp.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/b2b/app/buildApp.sh b/modules/b2b/app/buildApp.sh index 0a5ef00ff..a49f4ae65 100755 --- a/modules/b2b/app/buildApp.sh +++ b/modules/b2b/app/buildApp.sh @@ -6,7 +6,7 @@ # './buildApp.sh $HOME/consoleApps/b2b b2b-pro-transfer-mon b2b-mon' SW=../x86 -USRPATH=/common/usr/timing/b2b/centos7 +USRPATH=/common/usr/timing/b2b/rocky9 APPBUILD=$1/$2/current NAME=$2 BIN=$3 From 5eea4a4b0a26f5cd6dfe31f167f7d657606101cc Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Mon, 19 Aug 2024 16:08:41 +0200 Subject: [PATCH 06/13] b2b: porting to new common-lib continued .. --- modules/b2b/fw/Makefile | 2 +- modules/b2b/fw/b2b-cbu.c | 12 ++++++++---- modules/b2b/fw/b2b-kd.c | 6 +++--- modules/b2b/fw/b2b-pm.c | 31 +++++++++++++++++++++---------- modules/b2b/include/b2blib.h | 3 +-- modules/b2b/x86/b2b-ctl.c | 28 +++------------------------- modules/b2b/x86/b2b-ui.c | 8 +++----- modules/b2b/x86/b2blib.c | 34 +++++++++++++++------------------- 8 files changed, 55 insertions(+), 69 deletions(-) diff --git a/modules/b2b/fw/Makefile b/modules/b2b/fw/Makefile index 9ee27dfbf..b0004f8a8 100644 --- a/modules/b2b/fw/Makefile +++ b/modules/b2b/fw/Makefile @@ -12,7 +12,7 @@ RAM_SIZE := $(shell cat $(PLATFMAKEFILE) | grep -m1 RAM_SIZE | cut -d'= SHARED_SIZE ?= 8K USRCPUCLK ?= 125000 -VERSION = 00.07.04 +VERSION = 00.07.05 .DEFAULT_GOAL := fwbin diff --git a/modules/b2b/fw/b2b-cbu.c b/modules/b2b/fw/b2b-cbu.c index 5ae31803b..9a9a2c4f4 100644 --- a/modules/b2b/fw/b2b-cbu.c +++ b/modules/b2b/fw/b2b-cbu.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 16-Aug-2024 + * version : 19-Aug-2024 * * firmware implementing the CBU (Central Bunch-To-Bucket Unit) * NB: units of variables are [ns] unless explicitely mentioned as suffix @@ -35,7 +35,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 23-April-2019 ********************************************************************************************/ -#define B2BCBU_FW_VERSION 0x000704 // make this consistent with makefile +#define B2BCBU_FW_VERSION 0x000705 // make this consistent with makefile // standard includes #include @@ -987,11 +987,11 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT * 1000, &recDeadline, &recId, &recParam, &recTef, &flagIsLate, &flagIsEarly, &flagIsConflict, &flagIsDelayed); - if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); - switch (ecaAction) { case B2B_ECADO_B2B_START : // received: CMD_B2B_START from DM; B2B transfer starts + comLatency = (int32_t)(getSysTime() - recDeadline); + recGid = (uint32_t)((recId >> 48) & 0x0fff); recSid = (uint32_t)((recId >> 20) & 0x0fff); recBpid = (uint32_t)((recId >> 6) & 0x3fff); @@ -1077,6 +1077,8 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o case B2B_ECADO_B2B_PREXT : // received: measured phase from extraction machine if (mode < B2B_MODE_B2E) return status; // ignore informative phase result + comLatency = (int32_t)(getSysTime() - recDeadline); + tmpf = (float)(getSysTime() - tCBS) / 1000.0; // time from CBS to now [us] offsetPrr_us = fwlib_float2half(tmpf); // -> half precision recGid = (uint32_t)((recId >> 48) & 0xfff ); @@ -1102,6 +1104,8 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o case B2B_ECADO_B2B_PRINJ : // received: measured phase from injection machine if (mode < B2B_MODE_B2B) return status; // ignore informative phase result + comLatency = (int32_t)(getSysTime() - recDeadline); + tmpf = (float)(getSysTime() - tCBS) / 1000.0; // time from CBS to now [us] offsetPrr_us = fwlib_float2half(tmpf); // -> half precision recGid = (uint32_t)((recId >> 48) & 0xfff ); diff --git a/modules/b2b/fw/b2b-kd.c b/modules/b2b/fw/b2b-kd.c index 0ee8316ab..7e16a45e5 100644 --- a/modules/b2b/fw/b2b-kd.c +++ b/modules/b2b/fw/b2b-kd.c @@ -283,8 +283,6 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT*1000, &recDeadline, &recEvtId, &recParam, &recTEF, &flagIsLate, &flagIsEarly, &flagIsConflict, &flagIsDelayed); - if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); - // this switch statement mainly serves for collecting data; received data are marked by flags switch (ecaAction) { case B2B_ECADO_B2B_TRIGGEREXT : // this is an OR, no 'break' on purpose @@ -292,6 +290,8 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time // this is ugly, but ... if (ecaAction == B2B_ECADO_B2B_TRIGGEREXT) flagIsExt = 1; else flagIsExt = 0; + + comLatency = (int32_t)(getSysTime() - recDeadline); reqDeadline = recDeadline + (uint64_t)B2B_PRETRIGGERTR;// ECA is configured to pre-trigger ahead of time!!! @@ -312,7 +312,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time break; // B2B_ECADO_B2B_TRIGGERINJ case B2B_ECADO_TLUINPUT2 : // received monitor signal from kicker electronics - + comLatency = (int32_t)(getSysTime() - recDeadline); tKickMon = recDeadline; flagRecMon = 1; diff --git a/modules/b2b/fw/b2b-pm.c b/modules/b2b/fw/b2b-pm.c index 9cb9c0724..6eed04154 100644 --- a/modules/b2b/fw/b2b-pm.c +++ b/modules/b2b/fw/b2b-pm.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 16-Aug-2024 + * version : 19-Aug-2024 * * firmware required for measuring the h=1 phase for ring machine * @@ -469,6 +469,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time uint64_t sendParam; // parameter to send uint32_t sendTEF; // TEF to send uint32_t sendEvtNo; // EvtNo to send + uint64_t sysTime; // phase measurement uint32_t nInput; // # of timestamps @@ -500,7 +501,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time ecaAction = fwlib_wait4ECAEvent(COMMON_ECATIMEOUT * 1000, &recDeadline, &recEvtId, &recParam, &recTEF, &flagIsLate, &flagIsEarly, &flagIsConflict, &flagIsDelayed); - if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); + //if (ecaAction != B2B_ECADO_TIMEOUT) comLatency = (int32_t)(getSysTime() - recDeadline); switch (ecaAction) { // the following two cases handle h=1 group DDS phase measurement @@ -508,6 +509,8 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time sendEvtNo = B2B_ECADO_B2B_PREXT; case B2B_ECADO_B2B_PMINJ : if (!sendEvtNo) sendEvtNo = B2B_ECADO_B2B_PRINJ; + comLatency = (int32_t)(getSysTime() - recDeadline); + //t1 = getSysTime(); *pSharedGetTH1Hi = (uint32_t)((recParam >> 32) & 0x000fffff); // lower 52 bit used as period *pSharedGetTH1Lo = (uint32_t)( recParam & 0xffffffff); @@ -552,11 +555,13 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, sendTEF, 0); //t2 = getSysTime(); // send something to ECA (for monitoring purposes) chk do something useful here + sysTime = getSysTime(); sendEvtId = fwlib_buildEvtidV1(0xfff, ecaAction, 0, recSid, recBpid, 0x0); sendParam = 0xdeadbeef; - sendDeadline = getSysTime(); // produces a late action but allows explicit monitoring of processing time + sendDeadline = sysTime; // produces a late action but allows explicit monitoring of processing time fwlib_ecaWriteTM(sendDeadline, sendEvtId, sendParam, 0, 1); // force late message + offsDone = sysTime - recDeadline; transStat = tH1_t.dps; nTransfer++; @@ -570,7 +575,7 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time case B2B_ECADO_B2B_TRIGGEREXT : // this is an OR, no 'break' on purpose case B2B_ECADO_B2B_TRIGGERINJ : // this case only makes sense if cases B2B_ECADO_B2B_PMEXT/INJ succeeded if (!flagPMError) { - + comLatency = (int32_t)(getSysTime() - recDeadline); reqDeadline = recDeadline + (uint64_t)B2B_PRETRIGGERTR; // ECA is configured to pre-trigger ahead of time!!! nInput = 0; TWait = (int64_t)((reqDeadline - (TMeas >> 1)) - getSysTime()); // time how long we should wait before starting the measurement @@ -614,9 +619,10 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time case B2B_ECADO_B2B_PDEXT : // this is an OR, no 'break' on purpose sendEvtNo = B2B_ECADO_B2B_DIAGEXT; case B2B_ECADO_B2B_PDINJ : - if (!sendEvtNo) - sendEvtNo = B2B_ECADO_B2B_DIAGINJ; - + if (!sendEvtNo) sendEvtNo = B2B_ECADO_B2B_DIAGINJ; + + comLatency = (int32_t)(getSysTime() - recDeadline); + recGid = (uint32_t)((recEvtId >> 48) & 0xfff ); recSid = (uint32_t)((recEvtId >> 20) & 0xfff ); recBpid = (uint32_t)((recEvtId >> 6) & 0x3fff ); @@ -661,11 +667,14 @@ uint32_t doActionOperation(uint64_t *tAct, // actual time break; // case B2B_ECADO_B2B_PDEXT/INJ default : // flush ECA queue - flagIsLate = 0; // ingore late events + flagIsLate = 0; // ignore late events in this case } // switch ecaAction // check for late event - if ((status == COMMON_STATUS_OK) && flagIsLate) status = B2B_STATUS_LATEMESSAGE; + if ((status == COMMON_STATUS_OK) && flagIsLate) { + status = B2B_STATUS_LATEMESSAGE; + nLate++; + } // if status // check WR sync state if (fwlib_wrCheckSyncState() == COMMON_STATUS_WRBADSYNC) return COMMON_STATUS_WRBADSYNC; @@ -730,7 +739,9 @@ int main(void) { fwlib_publishStatusArray(statusArray); pubState = actState; fwlib_publishState(pubState); - fwlib_publishTransferStatus(nTransfer, 0x0, transStat, 0x0, 0x0, comLatency); /* chk: set values of offsDone and comLatency */ + if (comLatency > maxComLatency) maxComLatency = comLatency; + if (offsDone > maxOffsDone) maxOffsDone = offsDone; + fwlib_publishTransferStatus(nTransfer, 0x0, transStat, nLate, maxOffsDone, maxComLatency); } // while return(1); // this should never happen ... diff --git a/modules/b2b/include/b2blib.h b/modules/b2b/include/b2blib.h index 863a71cfa..713375875 100644 --- a/modules/b2b/include/b2blib.h +++ b/modules/b2b/include/b2blib.h @@ -41,7 +41,7 @@ extern "C" { #endif -#define B2BLIB_VERSION 0x000704 +#define B2BLIB_VERSION 0x000705 // (error) codes; duplicated to avoid the need of joining bel_projects and acc git repos #define B2BLIB_STATUS_OK 0 // OK @@ -320,7 +320,6 @@ extern "C" { double *cPhase, // correction of phase [ns] double *cTrigExt, // correction of extraction kicker trigger [ns] double *cTrigInj, // correction of injection kicker trigger [ns] - int32_t *comLatency, // communication latency [ns] int printFlag // prints info on b2b firmware properties to stdout ); diff --git a/modules/b2b/x86/b2b-ctl.c b/modules/b2b/x86/b2b-ctl.c index 90deb33c5..f1048f79e 100644 --- a/modules/b2b/x86/b2b-ctl.c +++ b/modules/b2b/x86/b2b-ctl.c @@ -130,26 +130,6 @@ void printTransfer(uint32_t nTransfer, uint32_t sid, uint32_t gid, uint32_t mode } // printTransfer -void printDiags(uint32_t sid, uint32_t gid, uint32_t mode, uint64_t TH1Ext, uint32_t nHExt, uint64_t TH1Inj, uint32_t nHInj, uint64_t TBeat, double cPhase, double cTrigExt, double cTrigInj, int32_t comLatency) -{ - printf("\n\n"); - printf("b2b: statistics ...\n\n"); - - printf("GID : %012u\n" , gid); - printf("SID : %012u\n" , sid); - printf("mode : %012u\n" , mode); - printf("period h=1 extraction : %012.6f ns\n", (double)TH1Ext/1000000000.0); - printf("period h=1 injection : %012.6f ns\n", (double)TH1Inj/1000000000.0); - printf("harmonic number extr. : %012d\n" , nHExt); - printf("harmonic number inj. : %012d\n" , nHInj); - printf("period of beating : %012.6f us\n", (double)TBeat/1000000000000.0); - printf("corr. matching : %012.3f\n" , cPhase); - printf("corr. trigger extr : %012.3f\n" , cTrigExt); - printf("corr. trigger inj : %012.3f\n" , cTrigInj); - printf("communication latency : %012.3f us\n", (double)comLatency/1000.0); -} // printDiags - - int main(int argc, char** argv) { const char* devName; const char* command; @@ -175,7 +155,6 @@ int main(int argc, char** argv) { double getcTrigExt; // trigger correction extraction double getcTrigInj; // trigger correction injection uint64_t getTBeat; // period [as] of frequency beating - int32_t getcomLatency; // message latency from ECA uint32_t actState = COMMON_STATE_UNKNOWN; // actual state of gateway uint32_t actNTransfer; // actual number of transfers @@ -254,7 +233,7 @@ int main(int argc, char** argv) { if (getInfo) { // status - b2b_info_read(ebDevice, &getsid, &getgid, &getmode, &getTH1Ext, &getnHExt, &getTH1Inj, &getnHInj, &getTBeat, &getcPhase, &getcTrigExt, &getcTrigInj, &getcomLatency, 0); + b2b_info_read(ebDevice, &getsid, &getgid, &getmode, &getTH1Ext, &getnHExt, &getTH1Inj, &getnHInj, &getTBeat, &getcPhase, &getcTrigExt, &getcTrigInj, 0); b2b_common_read(ebDevice, &statusArray, &state, &nBadStatus, &nBadState, &verFw, &nTransfer, 0); printTransferHeader(); @@ -309,8 +288,7 @@ int main(int argc, char** argv) { for (i = COMMON_STATUS_OK + 1; i<(int)(sizeof(statusArray)*8); i++) { if ((statusArray >> i) & 0x1) printf(" status bit is set : %s\n", b2b_status_text(i)); } // for i - b2b_info_read(ebDevice, &getsid, &getgid, &getmode, &getTH1Ext, &getnHExt, &getTH1Inj, &getnHInj, &getTBeat, &getcPhase, &getcTrigExt, &getcTrigInj, &getcomLatency, 0); - printDiags(getsid, getgid, getmode, getTH1Ext, getnHExt, getTH1Inj, getnHInj, getTBeat, getcPhase, getcTrigExt, getcTrigInj, getcomLatency); + b2b_info_read(ebDevice, &getsid, &getgid, &getmode, &getTH1Ext, &getnHExt, &getTH1Inj, &getnHInj, &getTBeat, &getcPhase, &getcTrigExt, &getcTrigInj, 1); } // "diag" if (!strcasecmp(command, "submit")) { @@ -352,7 +330,7 @@ if (snoop) { if ((actNTransfer != nTransfer) && (logLevel <= COMMON_LOGLEVEL_ONCE)) {printFlag = 1; actNTransfer = nTransfer;} if (printFlag) { - b2b_info_read(ebDevice, &getsid, &getgid, &getmode, &getTH1Ext, &getnHExt, &getTH1Inj, &getnHInj, &getTBeat, &getcPhase, &getcTrigExt, &getcTrigInj, &getcomLatency, 0); + b2b_info_read(ebDevice, &getsid, &getgid, &getmode, &getTH1Ext, &getnHExt, &getTH1Inj, &getnHInj, &getTBeat, &getcPhase, &getcTrigExt, &getcTrigInj, 0); printTransfer(nTransfer, getsid, getgid, getmode); printf(", %s (%6u), ", comlib_stateText(state), nBadState); if ((statusArray >> COMMON_STATUS_OK) & 0x1) printf("OK (%6u)\n", nBadStatus); diff --git a/modules/b2b/x86/b2b-ui.c b/modules/b2b/x86/b2b-ui.c index dca72d2b6..a11376dfe 100644 --- a/modules/b2b/x86/b2b-ui.c +++ b/modules/b2b/x86/b2b-ui.c @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 09-May-2023 + * version : 19-Aug-2029 * * user interface for B2B * @@ -492,7 +492,6 @@ void menuMonitor(uint64_t ebDevice, ring_t ring) uint32_t sid, gid, mode, nHExt, nHInj; uint64_t TH1Ext, TH1Inj, TBeat; double cPhase, cTrigExt, cTrigInj; - int32_t comLatency; int j=0; static struct termios oldt, newt; @@ -526,7 +525,7 @@ void menuMonitor(uint64_t ebDevice, ring_t ring) // read and display data j++; printf("%d ...\n\n", j); - b2b_info_read(ebDevice, &sid, &gid, &mode, &TH1Ext, &nHExt, &TH1Inj, &nHInj, &TBeat, &cPhase, &cTrigExt, &cTrigInj, &comLatency, 1); + b2b_info_read(ebDevice, &sid, &gid, &mode, &TH1Ext, &nHExt, &TH1Inj, &nHInj, &TBeat, &cPhase, &cTrigExt, &cTrigInj, 1); // check for any character.... // get current terminal settings @@ -566,7 +565,6 @@ void menuRing(ring_t ring) uint64_t dummy64a, dummy64b, dummy64c; uint32_t dummy32a, dummy32b, dummy32c, dummy32d, dummy32e; double dummy32f, dummy32g, dummy32h; - int32_t dummy32i; // open connection to firmware getEbDevice(ring, ebDevName); @@ -602,7 +600,7 @@ void menuRing(ring_t ring) break; case 3 : b2b_common_read(ebDevice, &dummy64a, &dummy32a, &dummy32b, &dummy32c, &dummy32d, &dummy32e, 1); - b2b_info_read(ebDevice, &dummy32a, &dummy32b, &dummy32c, &dummy64a, &dummy32d, &dummy64b, &dummy32e, &dummy64c, &dummy32f, &dummy32g, &dummy32h, &dummy32i, 1); + b2b_info_read(ebDevice, &dummy32a, &dummy32b, &dummy32c, &dummy64a, &dummy32d, &dummy64b, &dummy32e, &dummy64c, &dummy32f, &dummy32g, &dummy32h, 1); getchar(); break; case 4 : diff --git a/modules/b2b/x86/b2blib.c b/modules/b2b/x86/b2blib.c index 759c51031..0ea793c7d 100644 --- a/modules/b2b/x86/b2blib.c +++ b/modules/b2b/x86/b2blib.c @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 15-Aug-2024 + * version : 19-Aug-2024 * * library for b2b * @@ -109,7 +109,6 @@ eb_address_t b2b_get_TBeatLo; // period of beating, low bits eb_address_t b2b_get_cPhase; // phase correction eb_address_t b2b_get_cTrigExt; // kicker correction extraction eb_address_t b2b_get_cTrigInj; // kicker correction injection -eb_address_t b2b_get_comLatency; // latency for message transfer via ECA #define WAITCMDDONE COMMON_DEFAULT_TIMEOUT * 1000 // use default timeout and convert to us to be sure the command is processed @@ -452,26 +451,25 @@ uint32_t b2b_version_library(uint32_t *version) } // b2b_version_library -void b2b_printDiag(uint32_t sid, uint32_t gid, uint32_t mode, uint64_t TH1Ext, uint32_t nHExt, uint64_t TH1Inj, uint32_t nHInj, uint64_t TBeat, float cPhase, float cTrigExt, float cTrigInj, int32_t comLatency) +void b2b_printDiag(uint32_t sid, uint32_t gid, uint32_t mode, uint64_t TH1Ext, uint32_t nHExt, uint64_t TH1Inj, uint32_t nHInj, uint64_t TBeat, float cPhase, float cTrigExt, float cTrigInj) { printf("b2b: info ...\n\n"); - printf("SID : %012u\n" , sid); - printf("GID : %012u\n" , gid); - printf("mode : %012u\n" , mode); - printf("period h=1 extraction : %012.6f ns\n", (double)TH1Ext/1000000000.0); - printf("period h=1 injection : %012.6f ns\n", (double)TH1Inj/1000000000.0); - printf("harmonic number extr. : %012d\n" , nHExt); - printf("harmonic number inj. : %012d\n" , nHInj); - printf("period of beating : %012.6f us\n", (double)TBeat/1000000000000.0); - printf("adjust RF-phase : %012.3f ns\n", cPhase); - printf("adjust ext kicker : %012.3f ns\n", cTrigExt); - printf("adjust inj kicker : %012.3f ns\n", cTrigInj); - printf("communication latency : %012.3f us\n", (double)comLatency/1000.0); + printf("SID : %012u\n" , sid); + printf("GID : %012u\n" , gid); + printf("mode : %012u\n" , mode); + printf("period h=1 extraction : %012.6f ns\n", (double)TH1Ext/1000000000.0); + printf("period h=1 injection : %012.6f ns\n", (double)TH1Inj/1000000000.0); + printf("harmonic number extr. : %012d\n" , nHExt); + printf("harmonic number inj. : %012d\n" , nHInj); + printf("period of beating : %012.6f us\n", (double)TBeat/1000000000000.0); + printf("adjust RF-phase : %012.3f ns\n", cPhase); + printf("adjust ext kicker : %012.3f ns\n", cTrigExt); + printf("adjust inj kicker : %012.3f ns\n", cTrigInj); } // b2b_printDiags -uint32_t b2b_info_read(uint64_t ebDevice, uint32_t *sid, uint32_t *gid, uint32_t *mode, uint64_t *TH1Ext, uint32_t *nHExt, uint64_t *TH1Inj, uint32_t *nHInj, uint64_t *TBeat, double *cPhase, double*cTrigExt, double *cTrigInj, int32_t *comLatency, int printFlag) +uint32_t b2b_info_read(uint64_t ebDevice, uint32_t *sid, uint32_t *gid, uint32_t *mode, uint64_t *TH1Ext, uint32_t *nHExt, uint64_t *TH1Inj, uint32_t *nHInj, uint64_t *TBeat, double *cPhase, double*cTrigExt, double *cTrigInj, int printFlag) { eb_cycle_t eb_cycle; eb_status_t eb_status; @@ -501,7 +499,6 @@ uint32_t b2b_info_read(uint64_t ebDevice, uint32_t *sid, uint32_t *gid, uint32_t eb_cycle_read(eb_cycle, b2b_get_cPhase, EB_BIG_ENDIAN|EB_DATA32, &(data[11])); eb_cycle_read(eb_cycle, b2b_get_cTrigExt, EB_BIG_ENDIAN|EB_DATA32, &(data[12])); eb_cycle_read(eb_cycle, b2b_get_cTrigInj, EB_BIG_ENDIAN|EB_DATA32, &(data[13])); - eb_cycle_read(eb_cycle, b2b_get_comLatency, EB_BIG_ENDIAN|EB_DATA32, &(data[14])); if ((eb_status = eb_cycle_close(eb_cycle)) != EB_OK) return COMMON_STATUS_EB; *gid = data[0]; @@ -524,9 +521,8 @@ uint32_t b2b_info_read(uint64_t ebDevice, uint32_t *sid, uint32_t *gid, uint32_t tmp.data = data[13]; // see above ... *cTrigInj = (double)(tmp.f); fCTrigInj = tmp.f; - *comLatency = data[14]; - if (printFlag) b2b_printDiag(*sid, *gid, *mode, *TH1Ext, *nHExt, *TH1Inj, *nHInj, *TBeat, fCPhase, fCTrigExt, fCTrigInj, *comLatency); + if (printFlag) b2b_printDiag(*sid, *gid, *mode, *TH1Ext, *nHExt, *TH1Inj, *nHInj, *TBeat, fCPhase, fCTrigExt, fCTrigInj); return COMMON_STATUS_OK; } // b2b_info_read From 8ad30a4f8d9c4c449d654362fc5f77958bc1f894 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Thu, 22 Aug 2024 15:01:35 +0200 Subject: [PATCH 07/13] b2b: major cleanup about kicker data (building is ok, but functionality is certainly broken) --- modules/b2b/include/b2b.h | 1 + modules/b2b/include/b2blib.h | 8 +- modules/b2b/x86/b2b-archiver.c | 42 ++++----- modules/b2b/x86/b2b-mon.c | 130 ++++++-------------------- modules/b2b/x86/b2b-serv-kickdiag.cpp | 50 ++++++++-- modules/b2b/x86/b2b-serv-raw.cpp | 128 +++++++++++++++++++++++-- 6 files changed, 216 insertions(+), 143 deletions(-) diff --git a/modules/b2b/include/b2b.h b/modules/b2b/include/b2b.h index 616d3834c..0952555ef 100644 --- a/modules/b2b/include/b2b.h +++ b/modules/b2b/include/b2b.h @@ -84,6 +84,7 @@ #define SIS18_RING 0x12c // LSA GID #define ESR_RING 0x154 // LSA GID #define CRYRING_RING 0x0d2 // LSA GID +#define SIS100_RING 0x136 // LSA GID #define SIS18_B2B_EXTRACT 0x3a0 // GID: SIS18 simple extraction #define SIS18_B2B_ESR 0x3a1 // GID: SIS18 to ESR #define SIS18_B2B_SIS100 0x3a2 // GID: SIS18 to SIS100 diff --git a/modules/b2b/include/b2blib.h b/modules/b2b/include/b2blib.h index 713375875..a29422f3c 100644 --- a/modules/b2b/include/b2blib.h +++ b/modules/b2b/include/b2blib.h @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 20-Nov-2023 + * version : 21-Aug-2024 * * library for b2b * @@ -82,10 +82,12 @@ extern "C" { uint32_t ext_h; // extraction: harmonic number of rf float ext_cTrig; // extraction: correction for extraction kicker [ns] uint32_t ext_sid; // extraction: ID of extraction sequence (redundant) + uint32_t ext_gid; // extraction: GID of extraction machine (redundant) uint64_t inj_T; // injection : ... uint32_t inj_h; float inj_cTrig; uint32_t inj_sid; + uint32_t inj_gid; float cPhase; // phase correction for b2b mode } setval_t; @@ -97,6 +99,8 @@ extern "C" { float ext_phaseSysmaxErr; // extraction: maximum systematic error of phase [ns] float ext_dKickMon; // extraction: offset electronics monitor signal [ns] float ext_dKickProb; // extraction: offset magnet probe signal [ns] + float ext_dKickProbLen; // extraction: length of magnet probe signal [ns] + float ext_dKickProbLevel; // extraction: level of comparator for magent probe signal [%] float ext_diagPhase; // extraction: offset from expected h=1 to actual h=1 signal [ns] float ext_diagMatch; // extraction: offset from calculated 'phase match' to actual h=1 signal [ns] uint64_t inj_phase; // injection : ... @@ -105,6 +109,8 @@ extern "C" { float inj_phaseSysmaxErr; float inj_dKickMon; float inj_dKickProb; + float inj_dKickProbLen; + float inj_dKickProbLevel; float inj_diagPhase; float inj_diagMatch; uint32_t flagEvtRec; // flag for events received; pme, pmi, pre, pri, kte, kti, kde, kdi, pde, pdi, start, stop diff --git a/modules/b2b/x86/b2b-archiver.c b/modules/b2b/x86/b2b-archiver.c index cc8c69c32..33b52e0aa 100644 --- a/modules/b2b/x86/b2b-archiver.c +++ b/modules/b2b/x86/b2b-archiver.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 19-Jan-2024 + * version : 21-Aug-2024 * * archives set and get values to data files * @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_ARCHIVER_VERSION 0x000704 +#define B2B_ARCHIVER_VERSION 0x000705 // standard includes #include // getopt @@ -69,15 +69,11 @@ char nan_str[] = "nan"; setval_t dicSetval[B2B_NSID]; getval_t dicGetval[B2B_NSID]; diagval_t dicDiagval[B2B_NSID]; -double dicKickLenExt[B2B_NSID]; // hackish, should be integrated into s.th. like getval -double dicKickCompLvlExt[B2B_NSID]; // hackish, should be integrated into s.th. like getval char dicPName[B2B_NSID][DIMMAXSIZE]; uint32_t dicSetvalId[B2B_NSID]; uint32_t dicGetvalId[B2B_NSID]; uint32_t dicDiagvalId[B2B_NSID]; -uint32_t dicKickLenExtId[B2B_NSID]; -uint32_t dicKickCompLvlExtId[B2B_NSID]; uint32_t dicPNameId[B2B_NSID]; // global variables @@ -109,7 +105,7 @@ static void help(void) { // header String for file char * headerString() { - return "patternName; time_CBS_UTC; sid; mode; ext_T [as]; ext_h; ext_cTrig; inj_T; inj_h; inj_cTrig; cPhase; ext_phase; ext_phaseFract; ext_phaseErr; ext_maxsysErr; ext_dKickMon; ext_kickCompLvl; ext_dkickProb; ext_kickLen; ext_diagPhase; ext_diag_Match; inj_phase; inj_phaseFract; inj_phaseErr; inj_maxsysErr; inj_dKickMon; inj_dKickProb; inj_diagPhase; inj_diagMatch; received PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; error PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; late PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; fin-CBS; prr-CBS; t0E-CBS; t0I-CBS; kte-CBS; kti-CBS; ext_nueGet; ext_dNueGet; inj_nueGet; inj_dNueGet"; + return "patternName; time_CBS_UTC; ext_gid; ext_sid; mode; ext_T [as]; ext_h; ext_cTrig; inj_T; inj_h; inj_cTrig; cPhase; ext_phase; ext_phaseFract; ext_phaseErr; ext_maxsysErr; ext_dKickMon; ext_dkickProb; ext_kickLen; ext_kickLevel; ext_diagPhase; ext_diag_Match; inj_gid; inj_sid; inj_phase; inj_phaseFract; inj_phaseErr; inj_maxsysErr; inj_dKickMon; inj_dKickProb; inj_kickLen; inj_kickLevel; inj_diagPhase; inj_diagMatch; received PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; error PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; late PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; fin-CBS; prr-CBS; t0E-CBS; t0I-CBS; kte-CBS; kti-CBS; ext_nueGet; ext_dNueGet; inj_nueGet; inj_dNueGet"; } // headerString // receive get values @@ -117,7 +113,6 @@ void recGetvalue(long *tag, diagval_t *address, int *size) { #define STRMAXLEN 2048 uint32_t sid; - uint32_t mode; double cor; double act; char tCBS[256];; @@ -138,14 +133,12 @@ void recGetvalue(long *tag, diagval_t *address, int *size) if ((sid < 0) || (sid >= B2B_NSID)) return; if (!flagSetValid[sid]) return; flagGetValid[sid] = (*size != sizeof(uint32_t)); - mode = dicSetval[sid].mode; - //if (mode < 1) return; // b2b 'off', no need to write data; but maybe it is interesting to see when facility was executed withouot b2b - + strftime(tCBS, 52, "%d-%b-%Y_%H:%M:%S", gmtime(&(utc_secs[sid]))); // set values new = strSetval; - new += sprintf(new, "%s.%03d; %d; %d", tCBS, utc_msecs[sid], sid, mode); + new += sprintf(new, "%s.%03d; %x; %d; %d", tCBS, utc_msecs[sid], dicSetval[sid].ext_gid, sid, dicSetval[sid].mode); if (dicSetval[sid].ext_T == -1) new += sprintf(new, "; %s" , nan_str); else new += sprintf(new, "; %lu" , dicSetval[sid].ext_T); if (dicSetval[sid].ext_h == -1) new += sprintf(new, "; %s" , nan_str); @@ -161,14 +154,14 @@ void recGetvalue(long *tag, diagval_t *address, int *size) // get values new = strGetval; if (dicGetval[sid].ext_phase == -1) new += sprintf(new, "; %s" , nan_str); - else new += sprintf(new, "; %lu" , dicGetval[sid].ext_phase); - new += sprintf(new, "; %7.3f" , dicGetval[sid].ext_phaseFract); - new += sprintf(new, "; %7.3f" , dicGetval[sid].ext_phaseErr); - new += sprintf(new, "; %5.3f" , dicGetval[sid].ext_phaseSysmaxErr); - new += sprintf(new, "; %7.1f" , dicGetval[sid].ext_dKickMon); - new += sprintf(new, "; %7.3f" , dicKickCompLvlExt[sid]); - new += sprintf(new, "; %7.1f" , dicGetval[sid].ext_dKickProb); - new += sprintf(new, "; %7.1f" , dicKickLenExt[sid]); + else new += sprintf(new, "; %lu" , dicGetval[sid].ext_phase); + new += sprintf(new, "; %7.3f" , dicGetval[sid].ext_phaseFract); + new += sprintf(new, "; %7.3f" , dicGetval[sid].ext_phaseErr); + new += sprintf(new, "; %5.3f" , dicGetval[sid].ext_phaseSysmaxErr); + new += sprintf(new, "; %7.1f" , dicGetval[sid].ext_dKickMon); + new += sprintf(new, "; %7.1f" , dicGetval[sid].ext_dKickProb); + new += sprintf(new, "; %7.1f" , dicGetval[sid].ext_dKickProbLen); + new += sprintf(new, "; %7.3f" , dicGetval[sid].ext_dKickProbLevel); if (isnan(dicGetval[sid].ext_diagPhase) || (dicSetval[sid].ext_T == -1)) new += sprintf(new, "; %s" , nan_str); else { @@ -184,6 +177,7 @@ void recGetvalue(long *tag, diagval_t *address, int *size) new += sprintf(new, "; %8.3f", act); } // else isnan + new += sprintf(new, "; %d; %d", dicSetval[sid].inj_gid, dicSetval[sid].inj_sid); if (dicGetval[sid].inj_phase == -1) new += sprintf(new, "; %s" , nan_str); else new += sprintf(new, "; %lu", dicGetval[sid].inj_phase); new += sprintf(new, "; %7.3f" , dicGetval[sid].inj_phaseFract); @@ -191,6 +185,8 @@ void recGetvalue(long *tag, diagval_t *address, int *size) new += sprintf(new, "; %5.3f" , dicGetval[sid].inj_phaseSysmaxErr); new += sprintf(new, "; %7.1f" , dicGetval[sid].inj_dKickMon); new += sprintf(new, "; %7.1f" , dicGetval[sid].inj_dKickProb); + new += sprintf(new, "; %7.1f" , dicGetval[sid].inj_dKickProbLen); + new += sprintf(new, "; %7.3f" , dicGetval[sid].inj_dKickProbLevel); if (isnan(dicGetval[sid].inj_diagPhase) || (dicSetval[sid].inj_T == -1)) new += sprintf(new, "; %s" , nan_str); else { @@ -258,12 +254,6 @@ void dicSubscribeServices(char *prefix) sprintf(name, "%s-cal_diag_sid%02d", prefix, i); dicDiagvalId[i] = dic_info_service_stamped(name, MONITORED, 0, &(dicDiagval[i]), sizeof(diagval_t), 0, 0, &no_link_32, sizeof(uint32_t)); - sprintf(name, "%s-kdde_sid%02d_len", prefix, i); - dicKickLenExtId[i] = dic_info_service_stamped(name, MONITORED, 0, &(dicKickLenExt[i]), sizeof(double), 0 , 0, &no_link_dbl, sizeof(double)); - - sprintf(name, "%s-kse_setlevel", prefix); - dicKickCompLvlExtId[i] = dic_info_service_stamped(name, MONITORED, 0, &(dicKickCompLvlExt[i]), sizeof(double), 0 , 0, &no_link_dbl, sizeof(double)); - sleep (2); // data is taken upon callback of set-values; wait a bit until the other services have connected to their servers sprintf(name, "%s-raw_sid%02d_getval", prefix, i); diff --git a/modules/b2b/x86/b2b-mon.c b/modules/b2b/x86/b2b-mon.c index a9f7e9cd2..9bfcf7e06 100644 --- a/modules/b2b/x86/b2b-mon.c +++ b/modules/b2b/x86/b2b-mon.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 20-Nov-2023 + * version : 22-Aug-2024 * * subscribes to and displays status of many b2b transfers * @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_MON_VERSION 0x000704 +#define B2B_MON_VERSION 0x000705 // standard includes #include // getopt @@ -74,26 +74,12 @@ getval_t dicGetval[NALLSID]; // b2b get-values diagval_t dicDiagval[NALLSID]; // diagnostic (analyzed values) diagstat_t dicDiagstat[NALLSID]; // additional status data char dicPName[NALLSID][DIMMAXSIZE]; // pattern names -double dicLevelExtSis18; // actual comparator level of kicker probe signal -double dicLevelInjEsr; -double dicLevelExtEsr; -double dicLevelInjYr; -double dicLevelExtYr; -double dicKickLenExt[NALLSID]; -double dicKickLenInj[NALLSID]; uint32_t dicSetvalId[NALLSID]; uint32_t dicGetvalId[NALLSID]; uint32_t dicDiagvalId[NALLSID]; uint32_t dicDiagstatId[NALLSID]; uint32_t dicPNameId[NALLSID]; -uint32_t dicLevelExtSis18Id; -uint32_t dicLevelInjEsrId; -uint32_t dicLevelExtEsrId; -uint32_t dicLevelInjYrId; -uint32_t dicLevelExtYrId; -uint32_t dicKickLenExtId[NALLSID]; -uint32_t dicKickLenInjId[NALLSID]; #define TXTNA " N/A" #define TXTUNKWN "UNKWN" @@ -248,15 +234,10 @@ void buildPrintLine(uint32_t idx) char tmp5[32]; char tmp6[32]; double dtmp1; - double *pLevelExt; - double *pLevelInj; - double nueDiff; uint32_t sid; ring_t ringExt; - ring_t ringInj; - uint32_t idxInj; double cRingExt; double cRingInj; @@ -273,14 +254,12 @@ void buildPrintLine(uint32_t idx) // extraction ring name switch (ringExt) { - case SIS18 : sprintf(origin, "SIS18"); sprintf(tmp1, "ESR"); pLevelExt = &dicLevelExtSis18; pLevelInj = &dicLevelInjEsr; ringInj = ESR; cRingExt = 216; cRingInj = 108; break; - case ESR : sprintf(origin, "ESR"); sprintf(tmp1, "YR"); pLevelExt = &dicLevelExtEsr; pLevelInj = &dicLevelInjYr; ringInj = CRYRING; cRingExt = 108; cRingInj = 54; break; - case CRYRING : sprintf(origin, "YR"); sprintf(tmp1, " "); pLevelExt = &dicLevelExtYr; pLevelInj = NULL; ringInj = NORING; cRingExt = 54; cRingInj = NAN; break; - default : sprintf(origin, TXTUNKWN); sprintf(tmp1, " "); pLevelExt = NULL; pLevelInj = NULL; ringInj = NORING; cRingExt = NAN; cRingInj = NAN; break; + case SIS18 : sprintf(origin, "SIS18"); sprintf(tmp1, "ESR"); cRingExt = 216; cRingInj = 108; break; + case ESR : sprintf(origin, "ESR"); sprintf(tmp1, "YR"); cRingExt = 108; cRingInj = 54; break; + case CRYRING : sprintf(origin, "YR"); sprintf(tmp1, " "); cRingExt = 54; cRingInj = NAN; break; + default : sprintf(origin, TXTUNKWN); sprintf(tmp1, " "); cRingExt = NAN; cRingInj = NAN; break; } // switch ringExt - idxInj = (ringInj - 1) * 16 + dicSetval[idx].inj_sid; - // pattern name if (strlen(dicPName[idx]) == 0) sprintf(pattern, "%s", TXTUNKWN); // invalid else { @@ -293,12 +272,12 @@ void buildPrintLine(uint32_t idx) // destination switch (set_mode[idx]) { - case B2B_MODE_OFF : sprintf(dest, "---"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; pLevelExt = NULL; pLevelInj = NULL; break; - case B2B_MODE_BSE : sprintf(dest, "kicker"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; pLevelInj = NULL; break; - case B2B_MODE_B2E : sprintf(dest, "target"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; pLevelInj = NULL; break; - case B2B_MODE_B2C : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 1; break; - case B2B_MODE_B2B : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 1; flagExtTrig = 1; flagInjTrig = 1; break; - default: sprintf(dest, TXTUNKWN); flagTCBS = 0; flagOther = 0; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; pLevelExt = NULL; pLevelInj = NULL; break; + case B2B_MODE_OFF : sprintf(dest, "---"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; break; + case B2B_MODE_BSE : sprintf(dest, "kicker"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; break; + case B2B_MODE_B2E : sprintf(dest, "target"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; break; + case B2B_MODE_B2C : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 1; break; + case B2B_MODE_B2B : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 1; flagExtTrig = 1; flagInjTrig = 1; break; + default: sprintf(dest, TXTUNKWN); flagTCBS = 0; flagOther = 0; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; break; } // switch set_mode // ignore ancient timestamps @@ -362,12 +341,8 @@ void buildPrintLine(uint32_t idx) else sprintf(nueMeasInj, "---"); // comparator level for kicker probe signal - if (pLevelExt == NULL) sprintf(setLevelExt, "%s", "---"); - else if (*(uint32_t *)pLevelExt == no_link_32) sprintf(setLevelExt, "%s", "NOLINK"); - else sprintf(setLevelExt, "%6.2f", *pLevelExt); - if (pLevelInj == NULL) sprintf(setLevelInj, "%s", "---"); - else if (*(uint32_t *)pLevelInj == no_link_32) sprintf(setLevelInj, "%s", "NOLINK"); - else sprintf(setLevelInj, "%6.2f", *pLevelInj); + sprintf(setLevelExt, "%6.2f", dicGetval[idx].ext_dKickProbLevel); + sprintf(setLevelInj, "%6.2f", dicGetval[idx].inj_dKickProbLevel); } // if flagOther else { sprintf(extNue, "---"); @@ -391,12 +366,13 @@ void buildPrintLine(uint32_t idx) if ((dicGetval[idx].flagEvtRec >> 4) & 0x1) sprintf(tmp1, "%7.1f", convertUnit(set_extCTrig[idx] - dicDiagval[idx].ext_ddsOffAct, dicSetval[idx].ext_T)); else sprintf(tmp1, "%s", TXTERROR); // signal from output of kicker electronics - if (isnan(dicGetval[idx].ext_dKickMon)) sprintf(tmp2, "%s", TXTERROR); - else sprintf(tmp2, "%5.0f", convertUnit(dicGetval[idx].ext_dKickMon, dicSetval[idx].ext_T)); - if (isnan(dicGetval[idx].ext_dKickProb)) sprintf(tmp3, "%s", TXTUNKWN); - else sprintf(tmp3, "%5.0f", convertUnit(dicGetval[idx].ext_dKickProb,dicSetval[idx].ext_T)); - if (isnan(dicKickLenExt[idx])) sprintf(tmp4, "%s", TXTUNKWN); - else sprintf(tmp4, "%5.0f", convertUnit(dicKickLenExt[idx],dicSetval[idx].ext_T)); + if (isnan(dicGetval[idx].ext_dKickMon)) sprintf(tmp2, "%s", TXTERROR); + else sprintf(tmp2, "%5.0f", convertUnit(dicGetval[idx].ext_dKickMon, dicSetval[idx].ext_T)); + // signal from magent probes + if (isnan(dicGetval[idx].ext_dKickProb)) sprintf(tmp3, "%s", TXTUNKWN); + else sprintf(tmp3, "%5.0f", convertUnit(dicGetval[idx].ext_dKickProb,dicSetval[idx].ext_T)); + if (isnan(dicGetval[idx].ext_dKickProbLen)) sprintf(tmp4, "%s", TXTUNKWN); + else sprintf(tmp4, "%5.0f", convertUnit(dicGetval[idx].ext_dKickProbLen,dicSetval[idx].ext_T)); sprintf(extTrig, "%7.1f %7s %5s %5s %5s", convertUnit(set_extCTrig[idx], dicSetval[idx].ext_T), tmp1, tmp2, tmp3, tmp4); } // if flagExtTrig @@ -417,13 +393,13 @@ void buildPrintLine(uint32_t idx) else sprintf(tmp1, "%s", TXTERROR); // signal from output of kicker electronics - if (isnan(dicGetval[idx].inj_dKickMon)) sprintf(tmp2, "%s", TXTERROR); - else sprintf(tmp2, "%5.0f", convertUnit(dicGetval[idx].inj_dKickMon, dicSetval[idx].inj_T)); + if (isnan(dicGetval[idx].inj_dKickMon)) sprintf(tmp2, "%s", TXTERROR); + else sprintf(tmp2, "%5.0f", convertUnit(dicGetval[idx].inj_dKickMon,dicSetval[idx].inj_T)); // signal from magnet probes - if (isnan(dicGetval[idx].inj_dKickProb)) sprintf(tmp3, "%s", TXTUNKWN); - else sprintf(tmp3, "%5.0f", convertUnit(dicGetval[idx].inj_dKickProb, dicSetval[idx].inj_T)); - if (isnan(dicKickLenInj[idxInj])) sprintf(tmp6, "%s", TXTUNKWN); - else sprintf(tmp6, "%5.0f", convertUnit(dicKickLenInj[idxInj],dicSetval[idx].inj_T)); + if (isnan(dicGetval[idx].inj_dKickProb)) sprintf(tmp3, "%s", TXTUNKWN); + else sprintf(tmp3, "%5.0f", convertUnit(dicGetval[idx].inj_dKickProb,dicSetval[idx].inj_T)); + if (isnan(dicGetval[idx].inj_dKickProbLen)) sprintf(tmp6, "%s", TXTUNKWN); + else sprintf(tmp6, "%5.0f", convertUnit(dicGetval[idx].inj_dKickProbLen,dicSetval[idx].inj_T)); // difference to kicker electronics extraction if (isnan(dicGetval[idx].ext_dKickMon) || isnan(dicGetval[idx].inj_dKickMon)) @@ -433,10 +409,10 @@ void buildPrintLine(uint32_t idx) sprintf(tmp4, "%5.0f", convertUnit(dtmp1, dicSetval[idx].inj_T)); } // else isnan // difference to magnet probe extraction - if (isnan(dicGetval[idx].ext_dKickProb) || isnan(dicGetval[idx].inj_dKickProb) || isnan(dicKickLenInj[idxInj])) + if (isnan(dicGetval[idx].ext_dKickProb) || isnan(dicGetval[idx].inj_dKickProb) || isnan(dicGetval[idx].inj_dKickProbLen)) sprintf(tmp5, "%s", TXTUNKWN); else { - dtmp1 = set_injCTrig[idx] - set_extCTrig[idx] + dicGetval[idx].inj_dKickProb - dicGetval[idx].ext_dKickProb + dicKickLenInj[idxInj]; + dtmp1 = set_injCTrig[idx] - set_extCTrig[idx] + dicGetval[idx].inj_dKickProb - dicGetval[idx].ext_dKickProb + dicGetval[idx].inj_dKickProbLen; sprintf(tmp5, "%5.0f", convertUnit(dtmp1, dicSetval[idx].inj_T)); } // else isnan @@ -560,52 +536,6 @@ void dicSubscribeServices(char *prefix, uint32_t idx) } // dicSubscribeServices -// as the feature of kicker flattop length is still experimental, let's keep this in a dedicated routine; -// on the long run, this information could possibly be added to dicDiagval, or dicGetVal -void dicSubscribeKickLenServices(char *prefix, uint32_t idx) -{ - char name[DIMMAXSIZE]; - char ringName[32]; - ring_t ring; - uint32_t sid; - - idx2RingSid(idx, &ring, &sid); - switch (ring) { - case SIS18 : sprintf(ringName, "sis18"); break; - case ESR : sprintf(ringName, "esr"); break; - case CRYRING : sprintf(ringName, "yr"); break; - default : break; - } // switch ring - - sprintf(name, "%s_%s-kdde_sid%02d_len", prefix, ringName, sid); - /* printf("name %s\n", name); */ - dicKickLenExtId[idx] = dic_info_service_stamped(name, MONITORED, 0, &(dicKickLenExt[idx]), sizeof(double), 0 , 0, &no_link_dbl, sizeof(double)); - sprintf(name, "%s_%s-kddi_sid%02d_len", prefix, ringName, sid); - /* printf("name %s\n", name); */ - dicKickLenInjId[idx] = dic_info_service_stamped(name, MONITORED, 0, &(dicKickLenInj[idx]), sizeof(double), 0 , 0, &no_link_dbl, sizeof(double)); -} // dicSubscribeKicklenServices - - -void dicSubscribeLevelServices(char *prefix) -{ - char name[DIMMAXSIZE]; - - sprintf(name, "%s_sis18-kse_setlevel", prefix); - dicLevelExtSis18Id = dic_info_service_stamped(name, MONITORED, 0, &dicLevelExtSis18, sizeof(double), 0 , 0, &no_link_32, sizeof(no_link_str)); - - sprintf(name, "%s_esr-ksi_setlevel", prefix); - dicLevelInjEsrId = dic_info_service_stamped(name, MONITORED, 0, &dicLevelInjEsr , sizeof(double), 0 , 0, &no_link_32, sizeof(no_link_str)); - - sprintf(name, "%s_esr-kse_setlevel", prefix); - dicLevelExtEsrId = dic_info_service_stamped(name, MONITORED, 0, &dicLevelExtEsr , sizeof(double), 0 , 0, &no_link_32, sizeof(no_link_str)); - - sprintf(name, "%s_yr-ksi_setlevel", prefix); - dicLevelInjYrId = dic_info_service_stamped(name, MONITORED, 0, &dicLevelInjYr , sizeof(double), 0 , 0, &no_link_32, sizeof(no_link_str)); - - sprintf(name, "%s_yr-kse_setlevel", prefix); - dicLevelExtYrId = dic_info_service_stamped(name, MONITORED, 0, &dicLevelExtYr , sizeof(double), 0 , 0, &no_link_32, sizeof(no_link_str)); -} // dicSubscribeLevelServices - // clear status void clearStatus() { @@ -778,9 +708,7 @@ int main(int argc, char** argv) sprintf(printLineK[i], "not initialized"); sprintf(printLineN[i], "not initialized"); dicSubscribeServices(prefix, i); - dicSubscribeKickLenServices(prefix, i); } // for i - dicSubscribeLevelServices(prefix); buildHeader(); flagPrintNow = 1; diff --git a/modules/b2b/x86/b2b-serv-kickdiag.cpp b/modules/b2b/x86/b2b-serv-kickdiag.cpp index 05ff5d2bb..b52950e5e 100644 --- a/modules/b2b/x86/b2b-serv-kickdiag.cpp +++ b/modules/b2b/x86/b2b-serv-kickdiag.cpp @@ -3,7 +3,7 @@ * * created : 2023 * author : Dietrich Beck, GSI-Darmstadt - * version : 17-Nov-2023 + * version : 22-Aug-2024 * * publishes additional diagnostic data of the kicker @@ -37,7 +37,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERV_KICKD_VERSION 0x000704 +#define B2B_SERV_KICKD_VERSION 0x000705 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS @@ -88,15 +88,18 @@ static const char* program; // tags for kicker diag enum evtKTag{tagKRising, tagKFalling, tagKStart, tagKStop}; -// services +double no_link_dbl = NAN; // indicates "no link" for missing DIM services of type double + +// published services char disVersion[DIMCHARSIZE]; char disHostname[DIMCHARSIZE]; uint32_t disNTransfer; -double disRisingOffs[B2B_NSID]; // offset of first rising edge to B2B_TRIGGER -double disFallingOffs[B2B_NSID]; // offset of first falling edge to B2B_TRIGGER -uint32_t disRisingN[B2B_NSID]; // number of rising edges; expectation value is 1 -uint32_t disFallingN[B2B_NSID]; // number of falling edges; expectation value is 1 -double disLen[B2B_NSID]; // lengh of signal +double disRisingOffs[B2B_NSID]; // offset of first rising edge to B2B_TRIGGER +double disFallingOffs[B2B_NSID]; // offset of first falling edge to B2B_TRIGGER +uint32_t disRisingN[B2B_NSID]; // number of rising edges; expectation value is 1 +uint32_t disFallingN[B2B_NSID]; // number of falling edges; expectation value is 1 +double disLen[B2B_NSID]; // lengh of signal +double disSetLevel[B2B_NSID]; // set level of comparator for detection of probe signals uint32_t disVersionId = 0; uint32_t disHostnameId = 0; @@ -105,7 +108,13 @@ uint32_t disRisingOffsId[B2B_NSID]; uint32_t disFallingOffsId[B2B_NSID]; uint32_t disRisingNId[B2B_NSID]; uint32_t disFallingNId[B2B_NSID]; -uint32_t disLenId[B2B_NSID]; +uint32_t disLenId[B2B_NSID]; +uint32_t disSetLevelId[B2B_NSID]; + +// subscribed services +double dicSetLevel; // set level of comparator value for detection of probe signals + +uint32_t dicSetLevelId; // local variables @@ -165,6 +174,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, case tagKStop : flagActive = 0; if ((disRisingN[sid] > 0) && (disFallingN[sid] > 0)) disLen[sid] = disFallingOffs[sid] - disRisingOffs[sid]; + disSetLevel[sid] = dicSetLevel; disUpdateValues(sid); break; case tagKRising : @@ -238,6 +248,17 @@ void disAddServices(char *prefix) } // for i } // disAddServices + +// add all dim services +void dicSubscribeServices(char *prefix) +{ + char name[DIMMAXSIZE]; + + sprintf(name, "%s_setlevel", prefix); + //printf("name %s\n", name); + dicSetLevelId = dic_info_service_stamped(name, MONITORED, 0, &dicSetLevel, sizeof(double), 0, 0, &no_link_dbl, sizeof(double)); +} // dicSubscribeServices + using namespace saftlib; using namespace std; @@ -281,6 +302,7 @@ int main(int argc, char** argv) // char ringName[NAMELEN]; char prefix[NAMELEN*2]; + char comparatorPrefix[NAMELEN*2]; char disName[DIMMAXSIZE]; reqRing = SIS18_RING; // gid SIS18 @@ -409,6 +431,16 @@ int main(int argc, char** argv) sprintf(disName, "%s", prefix); dis_start_serving(disName); + + if (optind+1 < argc) { + if (!reqMode) sprintf(comparatorPrefix, "b2b_%s_%s-kse", argv[++optind], ringName); // extraction + else sprintf(comparatorPrefix, "b2b_%s_%s-ksi", argv[++optind], ringName); // injection + } + else sprintf(comparatorPrefix, "b2b_%s", ringName); + + printf("%s: subscribing to comparator server using prefix %s\n", program, comparatorPrefix); + + dicSubscribeServices(comparatorPrefix); try { // basic saftd stuff diff --git a/modules/b2b/x86/b2b-serv-raw.cpp b/modules/b2b/x86/b2b-serv-raw.cpp index 706c1fdb2..ae86fbd1e 100644 --- a/modules/b2b/x86/b2b-serv-raw.cpp +++ b/modules/b2b/x86/b2b-serv-raw.cpp @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERV_RAW_VERSION 0x000704 +#define B2B_SERV_RAW_VERSION 0x000705 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS @@ -82,7 +82,9 @@ static const char* program; #define DIMMAXSIZE 1024 // max size for service names #define NAMELEN 256 // max size for names -// services +double no_link_dbl = NAN; // indicates "no link" for missing DIM services of type double + +// services published char disVersion[DIMCHARSIZE]; char disState[DIMCHARSIZE]; char disHostname[DIMCHARSIZE]; @@ -99,6 +101,41 @@ uint32_t disNTransferId = 0; uint32_t disSetvalId[B2B_NSID]; uint32_t disGetvalId[B2B_NSID]; +// services subscribed +// +// aehem ... +// its a bit difficult to organize all combinations of injection machines; moreover, there are always new requirements +// let's use the brute force approach and subscribe to kicker information of all ring machines at GSI +double dicKickLevelSIS18Ext[B2B_NSID]; +double dicKickLevelESRInj[B2B_NSID]; +double dicKickLevelESRExt[B2B_NSID]; +double dicKickLevelYRInj[B2B_NSID]; +double dicKickLevelYRExt[B2B_NSID]; +double dicKickLevelSIS100Inj[B2B_NSID]; +double dicKickLevelSIS100Ext[B2B_NSID]; +double dicKickLenSIS18Ext[B2B_NSID]; +double dicKickLenESRInj[B2B_NSID]; +double dicKickLenESRExt[B2B_NSID]; +double dicKickLenYRInj[B2B_NSID]; +double dicKickLenYRExt[B2B_NSID]; +double dicKickLenSIS100Inj[B2B_NSID]; +double dicKickLenSIS100Ext[B2B_NSID]; + +uint32_t dicKickLevelSIS18ExtId[B2B_NSID]; +uint32_t dicKickLevelESRInjId[B2B_NSID]; +uint32_t dicKickLevelESRExtId[B2B_NSID]; +uint32_t dicKickLevelYRInjId[B2B_NSID]; +uint32_t dicKickLevelYRExtId[B2B_NSID]; +uint32_t dicKickLevelSIS100InjId[B2B_NSID]; +uint32_t dicKickLevelSIS100ExtId[B2B_NSID]; +uint32_t dicKickLenSIS18ExtId[B2B_NSID]; +uint32_t dicKickLenESRInjId[B2B_NSID]; +uint32_t dicKickLenESRExtId[B2B_NSID]; +uint32_t dicKickLenYRInjId[B2B_NSID]; +uint32_t dicKickLenYRExtId[B2B_NSID]; +uint32_t dicKickLenSIS100InjId[B2B_NSID]; +uint32_t dicKickLenSIS100ExtId[B2B_NSID]; + // local variables uint32_t reqExtRing; // requested extraction ring @@ -114,10 +151,12 @@ void initSetval(setval_t *setval) setval->ext_h = -1; setval->ext_cTrig = NAN; setval->ext_sid = -1; + setval->ext_gid = -1; setval->inj_T = -1; setval->inj_h = -1; setval->inj_cTrig = NAN; setval->inj_sid = -1; + setval->inj_gid = -1; setval->cPhase = NAN; } // initSetval @@ -130,6 +169,8 @@ void initGetval(getval_t *getval) getval->ext_phaseSysmaxErr = NAN; getval->ext_dKickMon = NAN; getval->ext_dKickProb = NAN; + getval->ext_dKickProbLen = NAN; + getval->ext_dKickProbLevel = NAN; getval->ext_diagPhase = NAN; getval->ext_diagMatch = NAN; getval->inj_phase = -1; @@ -138,6 +179,8 @@ void initGetval(getval_t *getval) getval->inj_phaseSysmaxErr = NAN; getval->inj_dKickMon = NAN; getval->inj_dKickProb = NAN; + getval->inj_dKickProbLen = NAN; + getval->inj_dKickProbLevel = NAN; getval->inj_diagPhase = NAN; getval->inj_diagMatch = NAN; getval->flagEvtRec = 0; @@ -211,7 +254,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, //printf("tag %d\n", tag); // mark message as received getval.flagEvtRec |= 0x1 << tag; - getval.flagEvtLate |= isLate << tag;; + getval.flagEvtLate |= isLate << tag; switch (tag) { case tagStart : @@ -222,6 +265,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, initSetval(&setval); setval.mode = 0; // in the simplest case mode is '0' (OFF) setval.ext_sid = sid; + setval.ext_gid = ((evtId & 0x0fff000000000000) >> 48); initGetval(&getval); getval.flagEvtRec = 0x1 << tag; @@ -235,6 +279,13 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, break; case tagPme : setval.mode = ((param & 0x00f0000000000000) >> 52); + switch(setval.ext_gid) { + case SIS18_B2B_ESR : setval.inj_gid = ESR_RING; break; + case SIS18_B2B_SIS100 : setval.inj_gid = SIS100_RING; break; + case ESR_B2B_CRYRING : setval.inj_gid = CRYRING_RING; break; + default : setval.inj_gid = -1; break; + } // switch gid + setval.ext_h = ((param & 0xff00000000000000) >> 56); setval.ext_T = ((param & 0x000fffffffffffff)); // [as] if (setval.mode > 0) { @@ -243,7 +294,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, } // if mode if (setval.mode > 2) { tmpf = comlib_half2float((uint16_t)( tef & 0x0000ffff)); // [us, hfloat]; chk for NAN? - setval.inj_cTrig = tmpf * 1000.0; // [ns] + setval.inj_cTrig = tmpf * 1000.0; // [ns] } // if mode break; case tagPmi : @@ -296,6 +347,14 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, else getval.ext_dKickMon = tmpu; flagErr = ((evtId & B2B_ERRFLAG_KDEXT) != 0); getval.flagEvtErr |= flagErr << tag; + + switch(setval.ext_gid) { + case SIS18_RING : getval.ext_dKickProbLen = dicKickLenSIS18Ext[setval.ext_sid]; getval.ext_dKickProbLevel = dicKickLevelSIS18Ext[setval.ext_sid]; break; + case ESR_RING : getval.ext_dKickProbLen = dicKickLenESRExt[setval.ext_sid]; getval.ext_dKickProbLevel = dicKickLevelESRExt[setval.ext_sid]; break; + case CRYRING_RING : getval.ext_dKickProbLen = dicKickLenYRExt[setval.ext_sid]; getval.ext_dKickProbLevel = dicKickLevelYRExt[setval.ext_sid]; break; + default : getval.ext_dKickProbLen = -1; getval.ext_dKickProbLevel = -1; break; + } // switch setval ext_gid + break; case tagKdi : // data types within parameter field are 'int' as this a. should be easy for the users b. granularity is 1ns only tmpu = (uint32_t)(param & 0x00000000ffffffff); @@ -306,6 +365,13 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, else getval.inj_dKickMon = tmpu; flagErr = ((evtId & B2B_ERRFLAG_KDINJ) != 0); getval.flagEvtErr |= flagErr << tag; + + switch(setval.inj_gid) { + case ESR_RING : getval.inj_dKickProbLen = dicKickLenESRInj[setval.inj_sid]; getval.inj_dKickProbLevel = dicKickLevelESRInj[setval.inj_sid]; break; + case CRYRING_RING : getval.inj_dKickProbLen = dicKickLenYRInj[setval.inj_sid]; getval.inj_dKickProbLevel = dicKickLevelYRInj[setval.inj_sid]; break; + default : getval.inj_dKickProbLen = -1; getval.inj_dKickProbLevel = -1; break; + } // switch setval ext_gid + break; case tagPde : // chk: consider changing 0x7fffffff to NAN in b2b-pm.c after beam time 2024 tmp.data = ((param & 0x00000000ffffffff)); @@ -381,18 +447,58 @@ void disAddServices(char *prefix) // set values for (i=0; i< B2B_NSID; i++) { sprintf(name, "%s-raw_sid%02d_setval", prefix, i); - disSetvalId[i] = dis_add_service(name, "I:1;X:1;I:1;F:1;I:1;X:1;I:1;F:1;I:1;F:1", &(disSetval[i]), sizeof(setval_t), 0, 0); + disSetvalId[i] = dis_add_service(name, "I:1;X:1;I:1;F:1;I:2;X:1;I:1;F:1;I:2;F:1", &(disSetval[i]), sizeof(setval_t), 0, 0); dis_set_timestamp(disSetvalId[i], 1, 0); } // for i // set values for (i=0; i< B2B_NSID; i++) { sprintf(name, "%s-raw_sid%02d_getval", prefix, i); - disGetvalId[i] = dis_add_service(name, "X:1;F:7;X:1;F:7;I:3;X:1;F:6", &(disGetval[i]), sizeof(getval_t), 0, 0); + disGetvalId[i] = dis_add_service(name, "X:1;F:9;X:1;F:9;I:3;X:1;F:6", &(disGetval[i]), sizeof(getval_t), 0, 0); dis_set_timestamp(disGetvalId[i], 1, 0); } // for i } // disAddServices + +// add all dim services +void dicSubscribeServices(char *prefix) +{ + char name[DIMMAXSIZE]; + int i; + + for (i=0; i Date: Thu, 22 Aug 2024 15:39:02 +0200 Subject: [PATCH 08/13] b2b: major cleanup about kicker data, bugfix --- modules/b2b/x86/b2b-serv-kickdiag.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/b2b/x86/b2b-serv-kickdiag.cpp b/modules/b2b/x86/b2b-serv-kickdiag.cpp index b52950e5e..2ba015568 100644 --- a/modules/b2b/x86/b2b-serv-kickdiag.cpp +++ b/modules/b2b/x86/b2b-serv-kickdiag.cpp @@ -245,6 +245,9 @@ void disAddServices(char *prefix) sprintf(name, "%s_sid%02d_len", prefix, i); disLenId[i] = dis_add_service(name, "D:1", &(disLen[i]), sizeof(double), 0, 0); + + sprintf(name, "%s_sid%02d_level", prefix, i); + disLenId[i] = dis_add_service(name, "D:1", &(disSetLevel[i]), sizeof(double), 0, 0); } // for i } // disAddServices From c00c3df9cbf5a7f58202bc9a31ef7aa360fa0fda Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Fri, 23 Aug 2024 14:32:30 +0200 Subject: [PATCH 09/13] b2b: major cleanup about kicker data, bugfix . --- modules/b2b/x86/b2b-serv-kickdiag.cpp | 49 ++++++++++++++------------- modules/b2b/x86/b2b-serv-raw.cpp | 19 +++++++---- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/modules/b2b/x86/b2b-serv-kickdiag.cpp b/modules/b2b/x86/b2b-serv-kickdiag.cpp index 2ba015568..9e56650b9 100644 --- a/modules/b2b/x86/b2b-serv-kickdiag.cpp +++ b/modules/b2b/x86/b2b-serv-kickdiag.cpp @@ -3,7 +3,7 @@ * * created : 2023 * author : Dietrich Beck, GSI-Darmstadt - * version : 22-Aug-2024 + * version : 23-Aug-2024 * * publishes additional diagnostic data of the kicker @@ -131,6 +131,7 @@ void initValues(uint32_t sid) disRisingN[sid] = 0; disFallingN[sid] = 0; disLen[sid] = NAN; + disSetLevel[sid] = NAN; } // initValues @@ -142,6 +143,7 @@ void disUpdateValues(uint32_t sid) dis_update_service(disRisingNId[sid]); dis_update_service(disFallingNId[sid]); dis_update_service(disLenId[sid]); + dis_update_service(disSetLevelId[sid]); disNTransfer++; dis_update_service(disNTransferId); @@ -170,20 +172,24 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, tStart = deadline.getTAI(); flagActive = 1; initValues(sid); + // printf("start %d\n", sid); break; case tagKStop : flagActive = 0; if ((disRisingN[sid] > 0) && (disFallingN[sid] > 0)) disLen[sid] = disFallingOffs[sid] - disRisingOffs[sid]; disSetLevel[sid] = dicSetLevel; disUpdateValues(sid); + //printf("stop %d, level %f\n", sid, disSetLevel[sid]); break; case tagKRising : disRisingN[sid]++; if (disRisingN[sid] == 1) disRisingOffs[sid] = (float)(deadline.getTAI() - tStart); + // printf("rising %d\n", sid); break; case tagKFalling : disFallingN[sid]++; if (disFallingN[sid] == 1) disFallingOffs[sid] = (float)(deadline.getTAI() - tStart); + // printf("falling, sid %d, N %d, offset %f\n", sid, disFallingN[sid], disFallingOffs[sid]); break; default : ; @@ -231,23 +237,23 @@ void disAddServices(char *prefix) // values for (i=0; i< B2B_NSID; i++) { - sprintf(name, "%s_sid%02d_risingoffs", prefix, i); - disRisingOffsId[i] = dis_add_service(name, "D:1", &(disRisingOffs[i]), sizeof(double), 0, 0); + sprintf(name, "%s_sid%02d_risingoffs", prefix, i); + disRisingOffsId[i] = dis_add_service(name, "D:1", &(disRisingOffs[i]), sizeof(double), 0, 0); - sprintf(name, "%s_sid%02d_risingN", prefix, i); - disRisingNId[i] = dis_add_service(name, "I:1", &(disRisingN[i]), sizeof(uint32_t), 0, 0); + sprintf(name, "%s_sid%02d_risingN", prefix, i); + disRisingNId[i] = dis_add_service(name, "I:1", &(disRisingN[i]), sizeof(uint32_t), 0, 0); sprintf(name, "%s_sid%02d_fallingoffs", prefix, i); disFallingOffsId[i] = dis_add_service(name, "D:1", &(disFallingOffs[i]), sizeof(double), 0, 0); - sprintf(name, "%s_sid%02d_fallingN", prefix, i); - disFallingNId[i] = dis_add_service(name, "I:1", &(disFallingN[i]), sizeof(uint32_t), 0, 0); + sprintf(name, "%s_sid%02d_fallingN", prefix, i); + disFallingNId[i] = dis_add_service(name, "I:1", &(disFallingN[i]), sizeof(uint32_t), 0, 0); - sprintf(name, "%s_sid%02d_len", prefix, i); - disLenId[i] = dis_add_service(name, "D:1", &(disLen[i]), sizeof(double), 0, 0); + sprintf(name, "%s_sid%02d_len", prefix, i); + disLenId[i] = dis_add_service(name, "D:1", &(disLen[i]), sizeof(double), 0, 0); - sprintf(name, "%s_sid%02d_level", prefix, i); - disLenId[i] = dis_add_service(name, "D:1", &(disSetLevel[i]), sizeof(double), 0, 0); + sprintf(name, "%s_sid%02d_level", prefix, i); + disSetLevelId[i] = dis_add_service(name, "D:1", &(disSetLevel[i]), sizeof(double), 0, 0); } // for i } // disAddServices @@ -258,7 +264,6 @@ void dicSubscribeServices(char *prefix) char name[DIMMAXSIZE]; sprintf(name, "%s_setlevel", prefix); - //printf("name %s\n", name); dicSetLevelId = dic_info_service_stamped(name, MONITORED, 0, &dicSetLevel, sizeof(double), 0, 0, &no_link_dbl, sizeof(double)); } // dicSubscribeServices @@ -301,6 +306,7 @@ int main(int argc, char** argv) // variables attach, remove char *deviceName = NULL; + char *envName = NULL; // char ringName[NAMELEN]; @@ -384,7 +390,10 @@ int main(int argc, char** argv) return 0; } // if optind + if (!(optind+1 < argc)) return 1; + deviceName = argv[optind]; + envName = argv[optind+1]; gethostname(disHostname, 32); switch(reqRing) { @@ -422,12 +431,9 @@ int main(int argc, char** argv) disNTransfer = 0; for (i=0; i< B2B_NSID; i++ ) initValues(i); - if (optind+1 < argc) { - if (!reqMode) sprintf(prefix, "b2b_%s_%s-kdde", argv[++optind], ringName); // extraction - else sprintf(prefix, "b2b_%s_%s-kddi", argv[++optind], ringName); // injection - } - else sprintf(prefix, "b2b_%s", ringName); - + if (!reqMode) sprintf(prefix, "b2b_%s_%s-kdde", envName, ringName); // extraction + else sprintf(prefix, "b2b_%s_%s-kddi", envName, ringName); // injection + printf("%s: starting server using prefix %s\n", program, prefix); disAddServices(prefix); @@ -435,11 +441,8 @@ int main(int argc, char** argv) sprintf(disName, "%s", prefix); dis_start_serving(disName); - if (optind+1 < argc) { - if (!reqMode) sprintf(comparatorPrefix, "b2b_%s_%s-kse", argv[++optind], ringName); // extraction - else sprintf(comparatorPrefix, "b2b_%s_%s-ksi", argv[++optind], ringName); // injection - } - else sprintf(comparatorPrefix, "b2b_%s", ringName); + if (!reqMode) sprintf(comparatorPrefix, "b2b_%s_%s-kse", envName, ringName); // extraction + else sprintf(comparatorPrefix, "b2b_%s_%s-ksi", envName, ringName); // injection printf("%s: subscribing to comparator server using prefix %s\n", program, comparatorPrefix); diff --git a/modules/b2b/x86/b2b-serv-raw.cpp b/modules/b2b/x86/b2b-serv-raw.cpp index ae86fbd1e..1178ff388 100644 --- a/modules/b2b/x86/b2b-serv-raw.cpp +++ b/modules/b2b/x86/b2b-serv-raw.cpp @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 20-Nov-2023 + * version : 22-Aug-2024 * * publishes raw data of the b2b system * @@ -233,6 +233,7 @@ void disUpdateSetval(uint32_t sid, uint64_t tStart, setval_t setval) static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, uint64_t param, uint32_t tef, uint32_t isLate, uint32_t isEarly, uint32_t isConflict, uint32_t isDelayed) { uint32_t recSid; // received SID + uint32_t recGid; // receiver GID int flagErr; static int flagActive; // flag: b2b is active @@ -246,6 +247,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, uint32_t tmpu; recSid = ((evtId & 0x00000000fff00000) >> 20); + recGid = ((evtId & 0x0fff000000000000) >> 48); // check ranges if (recSid > B2B_NSID) return; @@ -265,7 +267,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, initSetval(&setval); setval.mode = 0; // in the simplest case mode is '0' (OFF) setval.ext_sid = sid; - setval.ext_gid = ((evtId & 0x0fff000000000000) >> 48); + setval.ext_gid = recGid; initGetval(&getval); getval.flagEvtRec = 0x1 << tag; @@ -279,7 +281,7 @@ static void timingMessage(uint32_t tag, saftlib::Time deadline, uint64_t evtId, break; case tagPme : setval.mode = ((param & 0x00f0000000000000) >> 52); - switch(setval.ext_gid) { + switch(recGid) { case SIS18_B2B_ESR : setval.inj_gid = ESR_RING; break; case SIS18_B2B_SIS100 : setval.inj_gid = SIS100_RING; break; case ESR_B2B_CRYRING : setval.inj_gid = CRYRING_RING; break; @@ -468,6 +470,7 @@ void dicSubscribeServices(char *prefix) for (i=0; i Date: Tue, 27 Aug 2024 13:16:52 +0200 Subject: [PATCH 10/13] b2b: major cleanup about kicker data, bugfix ., set version number to 00.07.05 --- modules/b2b/fw/b2b-kd.c | 2 +- modules/b2b/fw/b2b-pm-stub.c | 2 +- modules/b2b/fw/b2b-pm.c | 2 +- modules/b2b/x86/b2b-analyzer.c | 2 +- modules/b2b/x86/b2b-archiver.c | 6 +++--- modules/b2b/x86/b2b-client-sys.c | 2 +- modules/b2b/x86/b2b-ctl.c | 2 +- modules/b2b/x86/b2b-jitter-check.cpp | 2 +- modules/b2b/x86/b2b-serv-sys.c | 2 +- modules/b2b/x86/b2b-sim.c | 2 +- modules/b2b/x86/b2b-viewer.c | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/b2b/fw/b2b-kd.c b/modules/b2b/fw/b2b-kd.c index 7e16a45e5..9c4c879cc 100644 --- a/modules/b2b/fw/b2b-kd.c +++ b/modules/b2b/fw/b2b-kd.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 19-November-2020 ********************************************************************************************/ -#define B2BPM_FW_VERSION 0x000704 // make this consistent with makefile +#define B2BPM_FW_VERSION 0x000705 // make this consistent with makefile // standard includes #include diff --git a/modules/b2b/fw/b2b-pm-stub.c b/modules/b2b/fw/b2b-pm-stub.c index 1e5e2fa2e..e908784fd 100644 --- a/modules/b2b/fw/b2b-pm-stub.c +++ b/modules/b2b/fw/b2b-pm-stub.c @@ -38,7 +38,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 ********************************************************************************************/ -#define B2BPMSTUB_FW_VERSION 0x000704 // make this consistent with makefile +#define B2BPMSTUB_FW_VERSION 0x000705 // make this consistent with makefile //standard includes #include diff --git a/modules/b2b/fw/b2b-pm.c b/modules/b2b/fw/b2b-pm.c index 6eed04154..47f4badba 100644 --- a/modules/b2b/fw/b2b-pm.c +++ b/modules/b2b/fw/b2b-pm.c @@ -42,7 +42,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 ********************************************************************************************/ -#define B2BPM_FW_VERSION 0x000704 // make this consistent with makefile +#define B2BPM_FW_VERSION 0x000705 // make this consistent with makefile // standard includes #include diff --git a/modules/b2b/x86/b2b-analyzer.c b/modules/b2b/x86/b2b-analyzer.c index 64bcedb01..d947f02b9 100644 --- a/modules/b2b/x86/b2b-analyzer.c +++ b/modules/b2b/x86/b2b-analyzer.c @@ -36,7 +36,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_ANALYZER_VERSION 0x000704 +#define B2B_ANALYZER_VERSION 0x000705 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-archiver.c b/modules/b2b/x86/b2b-archiver.c index 33b52e0aa..046564b0d 100644 --- a/modules/b2b/x86/b2b-archiver.c +++ b/modules/b2b/x86/b2b-archiver.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 21-Aug-2024 + * version : 27-Aug-2024 * * archives set and get values to data files * @@ -138,7 +138,7 @@ void recGetvalue(long *tag, diagval_t *address, int *size) // set values new = strSetval; - new += sprintf(new, "%s.%03d; %x; %d; %d", tCBS, utc_msecs[sid], dicSetval[sid].ext_gid, sid, dicSetval[sid].mode); + new += sprintf(new, "%s.%03d; 0x%x; %d; %d", tCBS, utc_msecs[sid], dicSetval[sid].ext_gid, sid, dicSetval[sid].mode); if (dicSetval[sid].ext_T == -1) new += sprintf(new, "; %s" , nan_str); else new += sprintf(new, "; %lu" , dicSetval[sid].ext_T); if (dicSetval[sid].ext_h == -1) new += sprintf(new, "; %s" , nan_str); @@ -177,7 +177,7 @@ void recGetvalue(long *tag, diagval_t *address, int *size) new += sprintf(new, "; %8.3f", act); } // else isnan - new += sprintf(new, "; %d; %d", dicSetval[sid].inj_gid, dicSetval[sid].inj_sid); + new += sprintf(new, "; 0x%x; %d", dicSetval[sid].inj_gid, dicSetval[sid].inj_sid); if (dicGetval[sid].inj_phase == -1) new += sprintf(new, "; %s" , nan_str); else new += sprintf(new, "; %lu", dicGetval[sid].inj_phase); new += sprintf(new, "; %7.3f" , dicGetval[sid].inj_phaseFract); diff --git a/modules/b2b/x86/b2b-client-sys.c b/modules/b2b/x86/b2b-client-sys.c index 996bc9043..7c7cd89c8 100644 --- a/modules/b2b/x86/b2b-client-sys.c +++ b/modules/b2b/x86/b2b-client-sys.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_CLIENT_SYS_VERSION 0x000704 +#define B2B_CLIENT_SYS_VERSION 0x000705 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-ctl.c b/modules/b2b/x86/b2b-ctl.c index f1048f79e..e5e9cc22b 100644 --- a/modules/b2b/x86/b2b-ctl.c +++ b/modules/b2b/x86/b2b-ctl.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 09-May-2023 + * version : 20-Aug-2024 * * Command-line interface for b2b * diff --git a/modules/b2b/x86/b2b-jitter-check.cpp b/modules/b2b/x86/b2b-jitter-check.cpp index c49b6cc1b..af1188be6 100644 --- a/modules/b2b/x86/b2b-jitter-check.cpp +++ b/modules/b2b/x86/b2b-jitter-check.cpp @@ -37,7 +37,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_JITTER_CHECK_VERSION 0x000704 +#define B2B_JITTER_CHECK_VERSION 0x000705 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-serv-sys.c b/modules/b2b/x86/b2b-serv-sys.c index 8ba8d1b42..fbd8f978f 100644 --- a/modules/b2b/x86/b2b-serv-sys.c +++ b/modules/b2b/x86/b2b-serv-sys.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERVSYS_VERSION 0x000704 +#define B2B_SERVSYS_VERSION 0x000705 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-sim.c b/modules/b2b/x86/b2b-sim.c index 1c19cfc29..eeeff6aff 100644 --- a/modules/b2b/x86/b2b-sim.c +++ b/modules/b2b/x86/b2b-sim.c @@ -35,7 +35,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2BSIM_VERSION 0x000704 +#define B2BSIM_VERSION 0x000705 #define MAXSAMPLES 1000 #define MAXDATA 10000000 diff --git a/modules/b2b/x86/b2b-viewer.c b/modules/b2b/x86/b2b-viewer.c index 3d973dc86..e629deffd 100644 --- a/modules/b2b/x86/b2b-viewer.c +++ b/modules/b2b/x86/b2b-viewer.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_VIEWER_VERSION 0x000704 +#define B2B_VIEWER_VERSION 0x000705 // standard includes #include // getopt From 033255dae8c702f6b8caceee75be5891b8d0f417 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Wed, 28 Aug 2024 13:22:20 +0200 Subject: [PATCH 11/13] b2b: merge 'phase shift' into current b2b branch --- modules/b2b/fw/Makefile | 2 +- modules/b2b/fw/b2b-cbu.c | 254 ++++++++++++++++++++----------- modules/b2b/fw/b2b-kd.c | 2 +- modules/b2b/fw/b2b-pm-stub.c | 2 +- modules/b2b/fw/b2b-pm.c | 2 +- modules/b2b/include/b2b.h | 40 +++-- modules/b2b/include/b2blib.h | 5 +- modules/b2b/x86/b2b-analyzer.c | 6 +- modules/b2b/x86/b2b-mon.c | 12 +- modules/b2b/x86/b2b-serv-raw.cpp | 2 +- modules/b2b/x86/b2b-ui.c | 4 +- modules/b2b/x86/b2b-viewer.c | 61 ++++++-- 12 files changed, 257 insertions(+), 135 deletions(-) diff --git a/modules/b2b/fw/Makefile b/modules/b2b/fw/Makefile index b0004f8a8..ebb082ce5 100644 --- a/modules/b2b/fw/Makefile +++ b/modules/b2b/fw/Makefile @@ -12,7 +12,7 @@ RAM_SIZE := $(shell cat $(PLATFMAKEFILE) | grep -m1 RAM_SIZE | cut -d'= SHARED_SIZE ?= 8K USRCPUCLK ?= 125000 -VERSION = 00.07.05 +VERSION = 00.08.00 .DEFAULT_GOAL := fwbin diff --git a/modules/b2b/fw/b2b-cbu.c b/modules/b2b/fw/b2b-cbu.c index 9a9a2c4f4..8bf8ec1a4 100644 --- a/modules/b2b/fw/b2b-cbu.c +++ b/modules/b2b/fw/b2b-cbu.c @@ -3,7 +3,7 @@ * * created : 2019 * author : Dietrich Beck, GSI-Darmstadt - * version : 19-Aug-2024 + * version : 28-Aug-2024 * * firmware implementing the CBU (Central Bunch-To-Bucket Unit) * NB: units of variables are [ns] unless explicitely mentioned as suffix @@ -35,7 +35,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 23-April-2019 ********************************************************************************************/ -#define B2BCBU_FW_VERSION 0x000705 // make this consistent with makefile +#define B2BCBU_FW_VERSION 0x000800 // make this consistent with makefile // standard includes #include @@ -149,6 +149,10 @@ uint64_t tCBS; // deadline of CMD_B2B_START uint16_t offsetPrr_us; // offset from CBS to to deadline of PRE [us, hfloat] uint32_t nGExt; // geometric harmonic number of extraction machine due to its circumference uint32_t nGInj; // geometric harmonic number of injections machine due to its circumference +b2bt_t pShiftExt; // phase shift value for extraction machine +b2bt_t pShiftInj; // phase shift value for injection machine +uint64_t tWantExt; // desired earliest time of extraction + // copies for nice trigger messages uint32_t flagsExt; // LSA flags extraction @@ -338,8 +342,12 @@ uint32_t setSubmit() // diable 'valid' flag here so that the corresponding setting is disabled in case of erronous settings setFlagValid[sid] = 0; - if (*pSharedSetMode >= B2B_MODE_B2C) flagInject = 1; - else flagInject = 0; + if (*pSharedSetMode == B2B_MODE_B2C || + *pSharedSetMode == B2B_MODE_B2BFBEAT || + *pSharedSetMode == B2B_MODE_B2BPSHIFTE || + *pSharedSetMode == B2B_MODE_B2BPSHIFTI + ) flagInject = 1; + else flagInject = 0; // in case of injection to another ring, we need to check for correct SID of extraction ring if (flagInject && (*pSharedSetSidEInj != sid)) return B2B_STATUS_BADSETTING; @@ -348,12 +356,14 @@ uint32_t setSubmit() // values required for extraction setMode[sid] = *pSharedSetMode; setGid[sid] = *pSharedSetGidExt; - setTH1Ext_as[sid] = (uint64_t)(*pSharedSetTH1ExtHi) << 32; - setTH1Ext_as[sid] |= (uint64_t)(*pSharedSetTH1ExtLo); + setTH1Ext_as[sid] = (uint64_t)(*pSharedSetTH1ExtHi) << 32; + setTH1Ext_as[sid] |= (uint64_t)(*pSharedSetTH1ExtLo); setNHExt[sid] = *pSharedSetNHExt; - setCTrigExt[sid] = *pSharedSetCTrigExt; + setCTrigExt[sid] = *pSharedSetCTrigExt; setNBuckExt[sid] = (int32_t)(*pSharedSetNBuckExt); setFFinTune[sid] = *pSharedSetFFinTune; + setCPhase[sid] = *pSharedSetCPhase; + // additional values required in case of injection into another ring if (flagInject) { @@ -365,7 +375,6 @@ uint32_t setSubmit() setTH1Inj_as[sid] = (uint64_t)(*pSharedSetTH1InjHi) << 32; setTH1Inj_as[sid] |= (uint64_t)(*pSharedSetTH1InjLo); setNHInj[sid] = *pSharedSetNHInj; - setCPhase[sid] = *pSharedSetCPhase; setCTrigInj[sid] = *pSharedSetCTrigInj; setNBuckInj[sid] = (int32_t)(*pSharedSetNBuckInj); setFMBTune[sid] = *pSharedSetFMBTune; @@ -376,7 +385,6 @@ uint32_t setSubmit() setLBpidInj[sid] = 0; setLParamInj[sid] = 0; setLParamInj[sid] = 0; - setCPhase[sid] = 0; setCTrigInj[sid] = 0; setNBuckInj[sid] = 0; setFMBTune[sid] = 0; @@ -828,30 +836,30 @@ uint32_t getNextMState(uint32_t mode, uint32_t actMState) { uint32_t nextMState = B2B_MFSM_NOTHING; switch (mode) { - case B2B_MODE_OFF : // off (slow extraction) + case B2B_MODE_OFF : // off (no or slow extraction) switch (actMState) { case B2B_MFSM_S0 : - nextMState = B2B_MFSM_EXTPS; + nextMState = B2B_MFSM_EXT_PMEAS_S; break; - case B2B_MFSM_EXTPS : + case B2B_MFSM_EXT_PMEAS_S : nextMState = B2B_MFSM_NOTHING; break; default : nextMState = B2B_MFSM_NOTHING; } // switch actMState mode OFF break; - case B2B_MODE_BSE : // kick on start event + case B2B_MODE_BSE : // trigger kicker (no synchronization to h=1 signal); might by useful for testing switch (actMState) { case B2B_MFSM_S0 : - nextMState = B2B_MFSM_EXTKICK; + nextMState = B2B_MFSM_EXT_TKICK_C; break; - case B2B_MFSM_EXTKICK : - nextMState = B2B_MFSM_EXTPS; + case B2B_MFSM_EXT_TKICK_C : + nextMState = B2B_MFSM_EXT_PMEAS_S; break; - case B2B_MFSM_EXTPS : - nextMState = B2B_MFSM_EXTTRIG; + case B2B_MFSM_EXT_PMEAS_S : + nextMState = B2B_MFSM_EXT_TRIG; break; - case B2B_MFSM_EXTTRIG : + case B2B_MFSM_EXT_TRIG : nextMState = B2B_MFSM_NOTHING; break; default: @@ -861,18 +869,18 @@ uint32_t getNextMState(uint32_t mode, uint32_t actMState) { case B2B_MODE_B2E : // bunch to extraction switch (actMState) { case B2B_MFSM_S0 : - nextMState = B2B_MFSM_EXTPS; + nextMState = B2B_MFSM_EXT_PMEAS_S; break; - case B2B_MFSM_EXTPS : - nextMState = B2B_MFSM_EXTPR; + case B2B_MFSM_EXT_PMEAS_S : + nextMState = B2B_MFSM_EXT_PMEAS_R; break; - case B2B_MFSM_EXTPR : - nextMState = B2B_MFSM_EXTBGT; + case B2B_MFSM_EXT_PMEAS_R : + nextMState = B2B_MFSM_EXT_TNEXTRF_C; break; - case B2B_MFSM_EXTBGT : - nextMState = B2B_MFSM_EXTTRIG; + case B2B_MFSM_EXT_TNEXTRF_C : + nextMState = B2B_MFSM_EXT_TRIG; break; - case B2B_MFSM_EXTTRIG : + case B2B_MFSM_EXT_TRIG : nextMState = B2B_MFSM_NOTHING; break; default : @@ -882,66 +890,90 @@ uint32_t getNextMState(uint32_t mode, uint32_t actMState) { case B2B_MODE_B2C : // bunch to coasting beam switch (actMState) { case B2B_MFSM_S0 : - nextMState = B2B_MFSM_EXTPS; + nextMState = B2B_MFSM_EXT_PMEAS_S; break; - case B2B_MFSM_EXTPS : - nextMState = B2B_MFSM_INJPS; + case B2B_MFSM_EXT_PMEAS_S : + nextMState = B2B_MFSM_INJ_PMEAS_S; break; - case B2B_MFSM_INJPS : - nextMState = B2B_MFSM_EXTPR; + case B2B_MFSM_INJ_PMEAS_S : + nextMState = B2B_MFSM_EXT_PMEAS_R; break; - case B2B_MFSM_EXTPR : - nextMState = B2B_MFSM_EXTBGT; + case B2B_MFSM_EXT_PMEAS_R : + nextMState = B2B_MFSM_EXT_TNEXTRF_C; break; - case B2B_MFSM_EXTBGT : - nextMState = B2B_MFSM_EXTTRIG; + case B2B_MFSM_EXT_TNEXTRF_C : + nextMState = B2B_MFSM_EXT_TRIG; break; - case B2B_MFSM_EXTTRIG : - nextMState = B2B_MFSM_INJTRIG ; + case B2B_MFSM_EXT_TRIG : + nextMState = B2B_MFSM_INJ_TRIG ; break; - case B2B_MFSM_INJTRIG : + case B2B_MFSM_INJ_TRIG : nextMState = B2B_MFSM_NOTHING; break; default : nextMState = B2B_MFSM_NOTHING; } // switch actMState mode B2C break; - case B2B_MODE_B2B : // bunch to bucket + case B2B_MODE_B2BFBEAT : // bunch to bucket, frequency beating switch (actMState) { case B2B_MFSM_S0 : - nextMState = B2B_MFSM_EXTPS; + nextMState = B2B_MFSM_EXT_PMEAS_S; break; - case B2B_MFSM_EXTPS : - nextMState = B2B_MFSM_INJPS; + case B2B_MFSM_EXT_PMEAS_S : + nextMState = B2B_MFSM_INJ_PMEAS_S; break; - case B2B_MFSM_INJPS : + case B2B_MFSM_INJ_PMEAS_S : nPhaseResult = 0; - nextMState = B2B_MFSM_BOTHPR; + nextMState = B2B_MFSM_ALL_PMEAS_R; break; - case B2B_MFSM_BOTHPR : // we have a diamond structure: we requested two phase measurements - nPhaseResult++; // but we don't know which result is received first; the simplest - if (nPhaseResult == 2) nextMState = B2B_MFSM_EXTMATCHT; // solution is to use a counter and count to 2 - else nextMState = B2B_MFSM_BOTHPR; + case B2B_MFSM_ALL_PMEAS_R : // we have a diamond structure: we requested two phase measurements + nPhaseResult++; // but we don't know which result is received first; the simplest + if (nPhaseResult == 2) nextMState = B2B_MFSM_EXT_TFBEAT_C; // solution is to use a counter and count to 2 + else nextMState = B2B_MFSM_ALL_PMEAS_R; break; - case B2B_MFSM_EXTMATCHT : - nextMState = B2B_MFSM_EXTTRIG; + case B2B_MFSM_EXT_TFBEAT_C : + nextMState = B2B_MFSM_EXT_TRIG; break; - case B2B_MFSM_EXTTRIG : - nextMState = B2B_MFSM_INJTRIG ; + case B2B_MFSM_EXT_TRIG : + nextMState = B2B_MFSM_INJ_TRIG ; break; - case B2B_MFSM_INJTRIG : + case B2B_MFSM_INJ_TRIG : nextMState = B2B_MFSM_NOTHING; break; default : nextMState = B2B_MFSM_NOTHING; } // switch actMState mode B2C break; + case B2B_MODE_B2EPSHIFT : // bunch to extraction; basically the same as mode B2B_MODE_B2E but with additional phase shift; might be useful for testing + switch (actMState) { + case B2B_MFSM_S0 : + nextMState = B2B_MFSM_EXT_PMEAS_S; + break; + case B2B_MFSM_EXT_PMEAS_S : + nextMState = B2B_MFSM_EXT_PMEAS_R; + break; + case B2B_MFSM_EXT_PMEAS_R : + nextMState = B2B_MFSM_EXT_PSHIFT_S; + break; + case B2B_MFSM_EXT_PSHIFT_S : + nextMState = B2B_MFSM_EXT_TNEXTRF_C; + break; + case B2B_MFSM_EXT_TNEXTRF_C : + nextMState = B2B_MFSM_EXT_TRIG; + break; + case B2B_MFSM_EXT_TRIG : + nextMState = B2B_MFSM_NOTHING; + break; + default : + nextMState = B2B_MFSM_NOTHING; + } // switch actMState mode B2EPSHIFT + break; default : nextMState = B2B_MFSM_NOTHING; } // switch mode - //if (!nextMState) pp_printf("mode %x, actMState %x\n", mode, actMState); + // pp_printf("mode %x, actMState %x nxtMState %x\n", mode, actMState, nextMState); return nextMState; } // getNextMState @@ -970,7 +1002,6 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o uint32_t recBpid; // BPID received uint32_t recRes; // reserved bits received uint64_t tMatch; // time when phases of injecion and extraction match - uint64_t tWantExt; // approximate time of extraction uint64_t tTrig; // time when kickers shall be triggered; uint64_t tTrigExt; // time when extraction kicker shall be triggered; tTrigExt = tTrig + cTrigExt; uint64_t tTrigInj; // time when injection kicker shall be triggered; tTrigInj = tTrig + cTrigInj; @@ -981,7 +1012,9 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o uint32_t tmp32; float tmpf; + fdat_t tmp; uint64_t t1, t2; + status = actStatus; @@ -1070,7 +1103,41 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o tCBS = recDeadline; getGeometricHarmonics(gid, &nGExt, &nGInj); - + + // initialize approximate/earliest trigger time + switch (mode) { + case B2B_MODE_BSE : // kick Start, simply trigger at eaerliest deadline; maybe useful for testing + case B2B_MODE_B2E : // fast extraction in phase gap; this is an OR, no 'break' on purpose + case B2B_MODE_B2C : // bunch to coasting beam; transfer between rings; this is an OR, no 'break' on purpose + case B2B_MODE_B2BFBEAT : // bunch to bucket using frequency beating; this is an OR, no 'break' on purpose + tWantExt = tCBS + B2B_KICKOFFSETMIN; + break; + case B2B_MODE_B2EPSHIFT : // phase shift followed by fast extraction in bunch gap; maybe useful for testing + case B2B_MODE_B2BPSHIFTE : // bunch to bucket using phase shift at extraction machine; this is an OR, no 'break' on purpose + case B2B_MODE_B2BPSHIFTI : // bunch to bucket using phase shift at injection machine; this is an OR, no 'break' on purpose + tWantExt = tCBS + B2B_KICKOFFSETPSHIFT; + break; + default : + tWantExt = tCBS; + break; + } // switch mode + + // initialize phase shift values + switch (mode) { + case B2B_MODE_B2EPSHIFT : + pShiftExt.ns = cPhase_t.ns; // chk: temporary solution; in the future this value might be available by a dedicated parameter + pShiftExt.ps = cPhase_t.ps; // chk: temporary solution; in the future this value might be available by a dedicated parameter + pShiftInj.ns = 0; + pShiftInj.ps = 0; + break; + default : + pShiftExt.ns = 0; + pShiftExt.ps = 0; + pShiftInj.ns = 0; + pShiftInj.ps = 0; + break; + } // switch mode + mState = getNextMState(mode, B2B_MFSM_S0); errorFlags = 0x0; break; @@ -1086,9 +1153,9 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o recRes = (uint32_t)(recId & 0x3f); // lowest 6 bit of EvtId // check, if received evtID is valid - if (recGid != gid) return COMMON_STATUS_OUTOFRANGE; - if (recSid != sid) return COMMON_STATUS_OUTOFRANGE; - if ((mState != B2B_MFSM_EXTPR) && (mState != B2B_MFSM_BOTHPR)) return COMMON_STATUS_OUTOFRANGE; + if (recGid != gid) return COMMON_STATUS_OUTOFRANGE; + if (recSid != sid) return COMMON_STATUS_OUTOFRANGE; + if ((mState != B2B_MFSM_EXT_PMEAS_R) && (mState != B2B_MFSM_ALL_PMEAS_R)) return COMMON_STATUS_OUTOFRANGE; // handling error bits if (recRes & B2B_ERRFLAG_PMEXT) errorFlags |= B2B_ERRFLAG_PMEXT; @@ -1103,11 +1170,10 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o break; case B2B_ECADO_B2B_PRINJ : // received: measured phase from injection machine - if (mode < B2B_MODE_B2B) return status; // ignore informative phase result - comLatency = (int32_t)(getSysTime() - recDeadline); - - tmpf = (float)(getSysTime() - tCBS) / 1000.0; // time from CBS to now [us] - offsetPrr_us = fwlib_float2half(tmpf); // -> half precision + if (mode < B2B_MODE_B2BFBEAT) return status; // ignore informative phase result + comLatency = (int32_t)(getSysTime() - recDeadline); + tmpf = (float)(getSysTime() - tCBS) / 1000.0; // time from CBS to now [us] + offsetPrr_us = fwlib_float2half(tmpf); // -> half precision recGid = (uint32_t)((recId >> 48) & 0xfff ); recSid = (uint32_t)((recId >> 20) & 0xfff ); recRes = (uint32_t)(recId & 0x3f); // lowest 6 bit of EvtId @@ -1115,7 +1181,7 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o // check, if received evtID is valid if (recGid != gid) return COMMON_STATUS_OUTOFRANGE; if (recSid != sid) return COMMON_STATUS_OUTOFRANGE; - if (mState != B2B_MFSM_BOTHPR) return COMMON_STATUS_OUTOFRANGE; + if (mState != B2B_MFSM_ALL_PMEAS_R) return COMMON_STATUS_OUTOFRANGE; // handling error bits if (recRes & B2B_ERRFLAG_PMINJ) errorFlags |= B2B_ERRFLAG_PMINJ; @@ -1136,14 +1202,14 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o } // switch ecaAction // trigger at earliest kicker deadline - if (mState == B2B_MFSM_EXTKICK) { - tTrig = tCBS + B2B_KICKOFFSETMIN; + if (mState == B2B_MFSM_EXT_TKICK_C) { + tTrig = tWantExt; transStat |= mState; mState = getNextMState(mode, mState); - } // B2B_MFSM_EXTKICK + } // B2B_MFSM_EXT_TKICK_C // request phase measurement of extraction - if (mState == B2B_MFSM_EXTPS) { + if (mState == B2B_MFSM_EXT_PMEAS_S) { tH1Ext_t.ns = 0x0; tH1Ext_t.ps = 0x0; tH1Ext_t.dps = 0x0; @@ -1159,10 +1225,10 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, sendTef, 0); transStat |= mState; mState = getNextMState(mode, mState); - } // B2B_MFSM_EXTPS + } // B2B_MFSM_EXT_PMEAS_S // request phase measurement of injection - if (mState == B2B_MFSM_INJPS) { + if (mState == B2B_MFSM_INJ_PMEAS_S) { tH1Inj_t.ns = 0x0; tH1Inj_t.ps = 0x0; tH1Inj_t.dps = 0x0; @@ -1177,24 +1243,38 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, sendTef, 0); transStat |= mState; mState = getNextMState(mode, mState); - } // B2B_MFSM_INJPS + } // B2B_MFSM_INJ_PMEAS_S + + // send phase shift request to low-level rf at extraction machine + if (mState == B2B_MFSM_EXT_PSHIFT_S) { + // send command: phase shift at extraction machine + sendEvtId = fwlib_buildEvtidV1(gid, B2B_ECADO_B2B_PSHIFTEXT, flagsExt, sidExt, bpidExt, 0); + // send param: low word: absolute phase shift value [degree, float] + // chk: N.B. this only works if the absolute phase shift so far is '0' + tmp.f = 360.0 * fwlib_tps2tfns(pShiftExt)/((float)TH1Ext_as / 1000000000.0);// phase shift [degree, float] + sendParam = (uint64_t)(tmp.data); + tmp.f = (float)B2B_PHASESHIFTTIME; // time for phase shift [ns, float] + sendParam |= (uint64_t)(tmp.data) << 32; + sendDeadline = getSysTime() + (uint64_t)COMMON_AHEADT; // use a conservative deadline + fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, 0, 0); + transStat |= mState; + mState = getNextMState(mode, mState); + } // B2B_MFSM_EXT_PSHIFT_S - // prepare fast extraction in bunch gap: calculate trigger time - if (mState == B2B_MFSM_EXTBGT) { - tWantExt = tCBS + B2B_KICKOFFSETMIN; - if (errorFlags) tTrig = tWantExt; // plan B + // prepare fast extraction at ~tWantExt; calculate time for next positive 0-crossing of h=1 signal + if (mState == B2B_MFSM_EXT_TNEXTRF_C) { + tWantExt = tWantExt + pShiftExt.ns; + if (errorFlags) tTrig = tWantExt; // plan B else if (calcExtTime(&tTrig, tWantExt) != COMMON_STATUS_OK) { - tTrig = tWantExt; // plan B + tTrig = tWantExt; // plan B errorFlags |= B2B_ERRFLAG_CBU; } // if NOT STATUS_OK - transStat |= mState; mState = getNextMState(mode, mState); - } // B2B_MFSM_EXTBGT + } // B2B_MFSM_EXT_TNEXTRF_C // prepare fast extraction with phase matching between both machines is achieved: calculate trigger time - if (mState == B2B_MFSM_EXTMATCHT) { - tWantExt = tCBS + B2B_KICKOFFSETMIN; + if (mState == B2B_MFSM_EXT_TFBEAT_C) { //tmp32 = (getSysTime() - tCBS); pp_printf("pre phase match %u\n", tmp32); if (errorFlags) {tTrig = tWantExt;/*pp_printf("b2b: error flags\n");*/} // plan B else if ((status = calcPhaseMatch(tWantExt, &tTrig, &TBeat_as)) != COMMON_STATUS_OK) { @@ -1205,10 +1285,10 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o transStat |= mState; mState = getNextMState(mode, mState); //tmp32 = (getSysTime() - tCBS); pp_printf("post phase match %u\n", tmp32); - } // B2B_MFSM_EXTMATCHT + } // B2B_MFSM_EXT_TFBEAT_C // trigger extraction kicker - if (mState == B2B_MFSM_EXTTRIG ) { + if (mState == B2B_MFSM_EXT_TRIG ) { sendGid = getTrigGid(1); if (!sendGid) return COMMON_STATUS_OUTOFRANGE; tTrigExt = tTrig + cTrigExt_t.ns; // trigger correction; chk: sub-ns part @@ -1227,10 +1307,10 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o fwlib_ebmWriteTM(sendDeadline, sendEvtId, sendParam, sendTef, 0); transStat |= mState; mState = getNextMState(mode, mState); - } // B2B_MFSM_EXTTRIG + } // B2B_MFSM_EXT_TRIG // trigger injection kicker - if (mState == B2B_MFSM_INJTRIG ) { + if (mState == B2B_MFSM_INJ_TRIG ) { sendGid = getTrigGid(0); if (!sendGid) return COMMON_STATUS_OUTOFRANGE; tTrigInj = tTrig + cTrigInj_t.ns; // trigger correction; chk: sub-ns part @@ -1245,7 +1325,7 @@ uint32_t doActionOperation(uint32_t actStatus) // actual status o } // else tTrigInj transStat |= mState; mState = getNextMState(mode, mState); - } // B2B_MFSM_TRIGINJ + } // B2B_MFSM_INJ_TRIG if (flagClearAllSid) {clearAllSid(); flagClearAllSid = 0;} diff --git a/modules/b2b/fw/b2b-kd.c b/modules/b2b/fw/b2b-kd.c index 9c4c879cc..1de93bbef 100644 --- a/modules/b2b/fw/b2b-kd.c +++ b/modules/b2b/fw/b2b-kd.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 19-November-2020 ********************************************************************************************/ -#define B2BPM_FW_VERSION 0x000705 // make this consistent with makefile +#define B2BPM_FW_VERSION 0x000800 // make this consistent with makefile // standard includes #include diff --git a/modules/b2b/fw/b2b-pm-stub.c b/modules/b2b/fw/b2b-pm-stub.c index e908784fd..ad41595ee 100644 --- a/modules/b2b/fw/b2b-pm-stub.c +++ b/modules/b2b/fw/b2b-pm-stub.c @@ -38,7 +38,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 ********************************************************************************************/ -#define B2BPMSTUB_FW_VERSION 0x000705 // make this consistent with makefile +#define B2BPMSTUB_FW_VERSION 0x000800 // make this consistent with makefile //standard includes #include diff --git a/modules/b2b/fw/b2b-pm.c b/modules/b2b/fw/b2b-pm.c index 47f4badba..5aa024bb8 100644 --- a/modules/b2b/fw/b2b-pm.c +++ b/modules/b2b/fw/b2b-pm.c @@ -42,7 +42,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 ********************************************************************************************/ -#define B2BPM_FW_VERSION 0x000705 // make this consistent with makefile +#define B2BPM_FW_VERSION 0x000800 // make this consistent with makefile // standard includes #include diff --git a/modules/b2b/include/b2b.h b/modules/b2b/include/b2b.h index 0952555ef..160dda963 100644 --- a/modules/b2b/include/b2b.h +++ b/modules/b2b/include/b2b.h @@ -44,6 +44,8 @@ #define B2B_ECADO_B2B_PDEXT 0x820 // internal command: perform phase diagnostic (extraction) #define B2B_ECADO_B2B_PDINJ 0x821 // internal command: perform phase diagnostic (injection) #define B2B_ECADO_B2B_INJKICKTEST 0x822 // internal command: perform injection kicker test +#define B2B_ECADO_B2B_PSHIFTEXT 0xfb0 // command: shift phase of low-level-rf (extraction); the number is temporary and should become official after the 2024 beamtime +#define B2B_ECADO_B2B_PSHIFTING 0xfb1 // command: shift phase of low-level-rf (injection); the number is temporary and should become official after the 2024 beamtime // commands from the outside #define B2B_CMD_CONFSUBMIT 11 // submit data written to DP RAM @@ -56,27 +58,33 @@ #define B2B_ERRFLAG_KDINJ 0x8 // error kick diagnostic injection #define B2B_ERRFLAG_CBU 0x10 // error central b2b unit -// B2B mode flags // required actions (informative) | ext trig | ext phase | inj trig | inj phase | -#define B2B_MODE_OFF 0 // off (slow extraction); phase meas. only | | (x) | | | -#define B2B_MODE_BSE 1 // CMD_B2B_START: trigger extraction kicker | x | (x) | | | -#define B2B_MODE_B2E 2 // simple bunch extraction 'fast extraction' | x | x | | | -#define B2B_MODE_B2C 3 // bunch to coasting transfer | x | x | x | (x) | -#define B2B_MODE_B2B 4 // bunch to bucket transfer | x | x | x | x | +// B2B mode flags // required actions (informative) | ext trig | ext phase | inj trig | inj phase | +#define B2B_MODE_OFF 0 // off (slow extraction); phase meas. only | | (x) | | | +#define B2B_MODE_BSE 1 // CMD_B2B_START: trigger extraction kicker | x | (x) | | | +#define B2B_MODE_B2E 2 // simple bunch extraction 'fast extraction' | x | x | | | +#define B2B_MODE_B2C 3 // bunch to coasting transfer | x | x | x | (x) | +#define B2B_MODE_B2BFBEAT 4 // bunch to bucket transfer, frequency beating | x | x | x | x | +#define B2B_MODE_B2EPSHIFT 5 // simple bunch extraction, phase shift test | x | x | | | +#define B2B_MODE_B2BPSHIFTE 6 // bunch to bucket transfer, phase shift extraction | x | x | x | x | +#define B2B_MODE_B2BPSHIFTI 7 // bunch to bucket transfer, phase shift injection | x | x | x | x | // B2B other flags #define B2B_FLAG_BEAMIN 0x8 // part of a timing message signaling a 'beam in event' // B2B states of 'miniFSM' #define B2B_MFSM_S0 0x1 // start state -#define B2B_MFSM_EXTPS 0x2 // phase measurement extraction, send request to PM -#define B2B_MFSM_EXTPR 0x4 // phase measurement extraction, receive data from PM -#define B2B_MFSM_EXTKICK 0x8 // calculate time for earliest kick (~ CMD_B2b_START) -#define B2B_MFSM_EXTBGT 0x10 // calculate time for extraction at next bunch gap -#define B2B_MFSM_EXTMATCHT 0x20 // calculate time for phase matching -#define B2B_MFSM_EXTTRIG 0x40 // trigger extraction kicker -#define B2B_MFSM_INJPS 0x80 // phase measurement injection, send request to PM -#define B2B_MFSM_BOTHPR 0x100 // phase measurement of extraction and injection, receive data from PM -#define B2B_MFSM_INJTRIG 0x200 // trigger injection kicker +#define B2B_MFSM_EXT_PMEAS_S 0x2 // phase measurement extraction, Send request to PM +#define B2B_MFSM_EXT_PMEAS_R 0x4 // phase measurement extraction, Receive data from PM +#define B2B_MFSM_EXT_TKICK_C 0x8 // Calculate time for earliest kick (~ CMD_B2B_START) +#define B2B_MFSM_EXT_TNEXTRF_C 0x10 // Calculate time for next positive zero crossing of h=1 signal +#define B2B_MFSM_EXT_TFBEAT_C 0x20 // Calculate time, when phases of both machines will match (b2b beating method) +#define B2B_MFSM_EXT_TRIG 0x40 // Trigger extraction kicker +#define B2B_MFSM_INJ_PMEAS_S 0x80 // phase measurement injection, Send request to PM +#define B2B_MFSM_ALL_PMEAS_R 0x100 // phase measurement of extraction and injection, Receive data from PM +#define B2B_MFSM_INJ_TRIG 0x200 // Trigger injection kicker +#define B2B_MFSM_EXT_PSHIFT_S 0x400 // phase shift extraction, Send request to low-level rf +#define B2B_MFSM_INJ_PSHIFT_S 0x800 // phase shift injection, Send request to low-level rf +#define B2B_MFSM_EXT_PSHIFT_C 0x1000 // Calculate value required for phase shift relative to low-level rf of extraction machine (b2b phase shift method) #define B2B_MFSM_NOTHING 0x100000 // nothing to do // group IDs @@ -100,6 +108,8 @@ #define B2B_PRETRIGGERINJKICK 300000 // offset [ns] used as pre-trigger on the injection kick event #define B2B_PRETRIGGERPR 250000 // offset [ns] used as pre-trigger on the PRINJ/PREXT event #define B2B_PRETRIGGERTR 20000 // offset [ns] used as pre-trigger on the trigger event +#define B2B_PHASESHIFTTIME 5000000 // time [ns] used for phase shifting of low-level rf +#define B2B_KICKOFFSETPSHIFT B2B_PHASESHIFTTIME + B2B_KICKOFFSETMIN + 1000000 // offset [ns] deadline of kicker trigger events relative to B2BS event when performing phase shifts #define B2B_AHEADT 300000 // more aggressive ahead interval for determining the deadline of a timing message #define B2B_ACCEPTKMON 10000 // timewindow [us]!!! in which monitor signal from kicker electronics is expected #define B2B_ACCEPTKPROBE 100 // timewindow [us]!!! in which signals from kicker magnet probe are expected diff --git a/modules/b2b/include/b2blib.h b/modules/b2b/include/b2blib.h index a29422f3c..45973eddc 100644 --- a/modules/b2b/include/b2blib.h +++ b/modules/b2b/include/b2blib.h @@ -4,6 +4,7 @@ * created : 2020 * author : Dietrich Beck, GSI-Darmstadt * version : 21-Aug-2024 + * version : 30-Jan-2024 * * library for b2b * @@ -41,7 +42,7 @@ extern "C" { #endif -#define B2BLIB_VERSION 0x000705 +#define B2BLIB_VERSION 0x000800 // (error) codes; duplicated to avoid the need of joining bel_projects and acc git repos #define B2BLIB_STATUS_OK 0 // OK @@ -72,7 +73,7 @@ extern "C" { enum tuneKnob{NOKNOB, TRIGEXT, TRIGINJ, PHASE}; typedef enum tuneKnob knob_t; - enum evtTag{tagPme, tagPmi, tagPre, tagPri, tagKte, tagKti, tagKde, tagKdi, tagPde, tagPdi, tagStart, tagStop}; + enum evtTag{tagPme, tagPmi, tagPre, tagPri, tagPse, tagPsi, tagKte, tagKti, tagKde, tagKdi, tagPde, tagPdi, tagStart, tagStop}; typedef enum evtTag evtTag_t; // data type set values; data are in 'native units' used by the lm32 firmware; NAN of unsigned integers is signaled by all bits set diff --git a/modules/b2b/x86/b2b-analyzer.c b/modules/b2b/x86/b2b-analyzer.c index d947f02b9..23087e067 100644 --- a/modules/b2b/x86/b2b-analyzer.c +++ b/modules/b2b/x86/b2b-analyzer.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 18-Oct-2023 + * version : 25-Jan-2024 * * analyzes and publishes get values * @@ -36,7 +36,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_ANALYZER_VERSION 0x000705 +#define B2B_ANALYZER_VERSION 0x000800 // standard includes #include // getopt @@ -763,7 +763,7 @@ void recGetvalue(long *tag, diagval_t *address, int *size) } // if mode B2B_MODE_B2C - if (mode == B2B_MODE_B2B) { + if (mode == B2B_MODE_B2BFBEAT) { // match diagnostics; theoretical value is '0' if (!isnan(dicGetval[sid].inj_diagMatch) && !isnan(dicSetval[sid].cPhase) && !isnan(dicSetval[sid].inj_cTrig) && (dicSetval[sid].inj_T != -1)) { diff --git a/modules/b2b/x86/b2b-mon.c b/modules/b2b/x86/b2b-mon.c index 9bfcf7e06..864b0f4a1 100644 --- a/modules/b2b/x86/b2b-mon.c +++ b/modules/b2b/x86/b2b-mon.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_MON_VERSION 0x000705 +#define B2B_MON_VERSION 0x000800 // standard includes #include // getopt @@ -272,11 +272,11 @@ void buildPrintLine(uint32_t idx) // destination switch (set_mode[idx]) { - case B2B_MODE_OFF : sprintf(dest, "---"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; break; - case B2B_MODE_BSE : sprintf(dest, "kicker"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; break; - case B2B_MODE_B2E : sprintf(dest, "target"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; break; - case B2B_MODE_B2C : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 1; break; - case B2B_MODE_B2B : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 1; flagExtTrig = 1; flagInjTrig = 1; break; + case B2B_MODE_OFF : sprintf(dest, "---"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; break; + case B2B_MODE_BSE : sprintf(dest, "kicker"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; break; + case B2B_MODE_B2E : sprintf(dest, "target"); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 0; break; + case B2B_MODE_B2C : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 0; flagExtTrig = 1; flagInjTrig = 1; break; + case B2B_MODE_B2BFBEAT : sprintf(dest, "%s", tmp1); flagTCBS = 1; flagOther = 1; flagB2b = 1; flagExtTrig = 1; flagInjTrig = 1; break; default: sprintf(dest, TXTUNKWN); flagTCBS = 0; flagOther = 0; flagB2b = 0; flagExtTrig = 0; flagInjTrig = 0; break; } // switch set_mode diff --git a/modules/b2b/x86/b2b-serv-raw.cpp b/modules/b2b/x86/b2b-serv-raw.cpp index 1178ff388..e8d51c003 100644 --- a/modules/b2b/x86/b2b-serv-raw.cpp +++ b/modules/b2b/x86/b2b-serv-raw.cpp @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERV_RAW_VERSION 0x000705 +#define B2B_SERV_RAW_VERSION 0x000800 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-ui.c b/modules/b2b/x86/b2b-ui.c index a11376dfe..f72df962b 100644 --- a/modules/b2b/x86/b2b-ui.c +++ b/modules/b2b/x86/b2b-ui.c @@ -3,7 +3,7 @@ * * created : 2020 * author : Dietrich Beck, GSI-Darmstadt - * version : 19-Aug-2029 + * version : 19-Aug-2024 * * user interface for B2B * @@ -234,7 +234,7 @@ void submitSid(uint64_t ebDevice, ring_t ring, uint32_t sid) errorFlag = 0; status = COMMON_STATUS_OK; if (!errorFlag) if ((status = b2b_context_ext_upload(ebDevice, sid, gid, mode, fH1Ext, 1, nHExt, cTrigExt, 1, cPhase, 1, 1)) != COMMON_STATUS_OK) errorFlag = 1; - if (mode > B2B_MODE_B2E) + if (mode == B2B_MODE_B2C || mode == B2B_MODE_B2BFBEAT || mode == B2B_MODE_B2BPSHIFTE || mode == B2B_MODE_B2BPSHIFTI) if (!errorFlag) if ((status = b2b_context_inj_upload(ebDevice, sid, ringInj, 3, 4, 0x42, fH1Inj, 1, nHInj, cTrigInj, 1)) != COMMON_STATUS_OK) errorFlag = 1; if (errorFlag) { diff --git a/modules/b2b/x86/b2b-viewer.c b/modules/b2b/x86/b2b-viewer.c index e629deffd..57527d3c9 100644 --- a/modules/b2b/x86/b2b-viewer.c +++ b/modules/b2b/x86/b2b-viewer.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 17-Oct-2023 + * version : 30-Jan-2024 * * subscribes to and displays status of a b2b transfer * @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_VIEWER_VERSION 0x000705 +#define B2B_VIEWER_VERSION 0x000800 // standard includes #include // getopt @@ -107,11 +107,15 @@ double b2b_diffD; // difference of rf double b2b_beatNue; // beat frequency double b2b_beatT; // beat period -#define MSKRECMODE0 0x105 // mask defining events that should be received for the different modes, mode off -#define MSKRECMODE1 0x155 // ... mode BSE -#define MSKRECMODE2 0x155 // ... mode B2E -#define MSKRECMODE3 0x3ff // ... mode B2C -#define MSKRECMODE4 0x3ff // ... mode B2B +#define MSKRECMODE0 0x405 // mask defining events that should be received for the different modes, mode off +#define MSKRECMODE1 0x545 // ... mode BSE +#define MSKRECMODE2 0x545 // ... mode B2E +#define MSKRECMODE3 0xfcf // ... mode B2C +#define MSKRECMODE4 0xfcf // ... mode B2BFBEAT +#define MSKRECMODE5 0x555 // ... mode B2EPSHIFT +#define MSKRECMODE6 0xfdf // ... mode B2BPSHIFTE +#define MSKRECMODE7 0xfef // ... mode B2BPSHIFTI + // other int flagPrintSet; // flag: print set values @@ -333,6 +337,10 @@ int printSet(uint32_t sid) sprintf(modeStr, "'bunch 2 bucket'"); modeMask = MSKRECMODE4; break; + case 5 : + sprintf(modeStr, "'bunch 2 fast ext. w. phase shift"); + modeMask = MSKRECMODE5; + break; default : sprintf(modeStr, "'unknonwn'"); } // switch mode @@ -350,7 +358,7 @@ int printSet(uint32_t sid) printf("inj: %s\n", TXTNA); printf("b2b: %s\n", TXTNA); break;*/ - case 1 ... 2 : + case 1 ... 2 : printf("ext: kick corr %8.3f ns; gDDS %15.6f Hz, %15.6f ns, h =%2d\n", set_extCTrig, set_extNue, set_extT, set_extH); printf("inj: %s\n", TXTNA); printf("b2b: %s\n", TXTNA); @@ -365,6 +373,11 @@ int printSet(uint32_t sid) printf("inj: kick corr %8.3f ns; gDDS %15.6f Hz, %15.6f ns, h =%2d\n", set_injCTrig, set_injNue, set_injT, set_injH); printf("b2b: phase corr %8.3f ns %12.3f °\n", set_cPhase, set_cPhaseD); break; + case 5: + printf("ext: kick corr %8.3f ns; gDDS %15.6f Hz, %15.6f ns, h =%2d\n", set_extCTrig, set_extNue, set_extT, set_extH); + printf("inj: %s\n", TXTNA); + printf("b2b: phase corr %8.3f ns %12.3f °\n", set_cPhase, set_cPhaseD); + break; default : ; } // switch set_mode @@ -401,6 +414,13 @@ int printDiag(uint32_t sid) else printf("b2b: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", dicDiagval.phaseOffAct, dicDiagval.phaseOffAve, dicDiagval.phaseOffSdev, dicGetval.ext_phaseSysmaxErr + dicGetval.inj_phaseSysmaxErr, dicDiagval.phaseOffMin, dicDiagval.phaseOffMax); break; + case 5 : + if (dicDiagval.ext_ddsOffN == 0) printf("ext: %s\n", TXTNA); + else printf("ext: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", + dicDiagval.ext_ddsOffAct, dicDiagval.ext_ddsOffAve, dicDiagval.ext_ddsOffSdev, dicGetval.ext_phaseSysmaxErr, dicDiagval.ext_ddsOffMin, dicDiagval.ext_ddsOffMax); + printf("inj: %s\n", TXTNA); + printf("b2b: %s\n", TXTNA); + break; default : ; } // switch set mode @@ -414,7 +434,7 @@ int printKick(uint32_t sid) printf("--- kicker --- #ext %5u, #inj %5u\n", dicDiagstat.ext_monRemN, dicDiagstat.inj_monRemN); // extraction kicker - if (set_mode == 0) printf("ext: %s\n\n", TXTNA); + if (set_mode == B2B_MODE_OFF) printf("ext: %s\n\n", TXTNA); else { printf("ext: monitor delay [ns] %5.0f", dicGetval.ext_dKickMon); printf(", probe delay [ns] %5.0f\n" , dicGetval.ext_dKickProb); @@ -424,13 +444,13 @@ int printKick(uint32_t sid) } // else mode == 0 // injection kicker - if (set_mode < 3) printf("inj: %s\n\n", TXTNA); + if ((set_mode < B2B_MODE_B2C) || (set_mode == B2B_MODE_B2EPSHIFT)) printf("inj: %s\n\n", TXTNA); else { printf("inj: monitor delay [ns] %5.0f", dicGetval.inj_dKickMon); printf(", probe delay [ns] %5.0f" , dicGetval.inj_dKickProb); printf(", diff mon. [ns] %f\n", dicGetval.inj_dKickMon - dicGetval.ext_dKickMon); - if (set_mode > 3) printf(" mon h=1 ph [ns] act %4.0f, ave(sdev) %8.3f(%6.3f), minmax %4.0f, %4.0f\n", dicDiagstat.inj_monRemAct, dicDiagstat.inj_monRemAve, dicDiagstat.inj_monRemSdev, - dicDiagstat.inj_monRemMin, dicDiagstat.inj_monRemMax); + if (set_mode > B2B_MODE_B2C) printf(" mon h=1 ph [ns] act %4.0f, ave(sdev) %8.3f(%6.3f), minmax %4.0f, %4.0f\n", dicDiagstat.inj_monRemAct, dicDiagstat.inj_monRemAve, dicDiagstat.inj_monRemSdev, + dicDiagstat.inj_monRemMin, dicDiagstat.inj_monRemMax); else printf("\n"); } // else mode < 3 @@ -448,7 +468,7 @@ int printStatus(uint32_t sid) printf("--- status (expert) --- #b2b %5u, #ext %5u, #inj %5u\n", dicDiagstat.cbs_priOffN, dicDiagstat.cbs_kteOffN, dicDiagstat.cbs_ktiOffN); - printf("events : PME PMI PRE PRI KTE KTI KDE KDI PDE PDI\n"); + printf("events : PME PMI PRE PRI PSE PSI KTE KTI KDE KDI PDE PDI\n"); printf("required:"); for (i=0; i<10; i++) if ((modeMask >> i) & 0x1) printf(" X"); else printf(" "); @@ -487,7 +507,7 @@ int printStatus(uint32_t sid) (double)dicDiagstat.cbs_kteOffAct/1000.0, dicDiagstat.cbs_kteOffAve/1000.0, dicDiagstat.cbs_kteOffSdev/1000.0, (double)dicDiagstat.cbs_kteOffMin/1000.0, (double)dicDiagstat.cbs_kteOffMax/1000.0); } - if (set_mode < B2B_MODE_B2C) + if ((set_mode < B2B_MODE_B2C) || (set_mode == B2B_MODE_B2EPSHIFT)) printf("KTI-CBS [us]: %s\n", TXTNA); else printf("KTI-CBS [us]: act %8.2f ave(sdev) %7.2f(%8.2f) minmax %7.2f, %8.2f\n", @@ -512,6 +532,7 @@ int printRf(uint32_t sid) printf("--- rf DDS [ns] --- #ext %5u, #inj %5u\n", dicDiagval.ext_rfOffN, dicDiagval.inj_rfOffN); switch(set_mode) { case 0 ... 2 : + case 5 : // this is an OR if ((dicGetval.flagEvtErr >> 2) & 0x1) printf("ext: %s\n", TXTERROR); else printf("ext: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", dicDiagval.ext_rfOffAct, dicDiagval.ext_rfOffAve, dicDiagval.ext_rfOffSdev, dicGetval.ext_phaseSysmaxErr, dicDiagval.ext_rfOffMin, dicDiagval.ext_rfOffMax); @@ -528,6 +549,7 @@ int printRf(uint32_t sid) printf("inj: %s\n\n\n", TXTNA); break; case 3 ... 4 : + case 6 ... 7 : // this is an OR if ((dicGetval.flagEvtErr >> 2) & 0x1) printf( "ext: act %s\n", TXTERROR); else printf("ext: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", @@ -585,7 +607,16 @@ void printData(int flagOnce, uint32_t sid, char *name) sprintf(modeStr, "'bunch 2 coasting'"); break; case 4 : - sprintf(modeStr, "'bunch 2 bucket'"); + sprintf(modeStr, "'bunch 2 bucket f-beat'"); + break; + case 5 : + sprintf(modeStr, "'b2extr. phase shift'"); + break; + case 6 : + sprintf(modeStr, "'b2b phase shift extr.'"); + break; + case 7 : + sprintf(modeStr, "'b2 phase shift inj.'"); break; default : sprintf(modeStr, "'unknonwn'"); From 4efc924c5a3732a37473ff8cb1b9c68e2ef51e49 Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Wed, 28 Aug 2024 13:43:21 +0200 Subject: [PATCH 12/13] b2b: set version number to 00.08.00 --- modules/b2b/x86/b2b-archiver.c | 2 +- modules/b2b/x86/b2b-client-sys.c | 2 +- modules/b2b/x86/b2b-jitter-check.cpp | 2 +- modules/b2b/x86/b2b-serv-kickdiag.cpp | 4 ++-- modules/b2b/x86/b2b-serv-sys.c | 2 +- modules/b2b/x86/b2b-sim.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/b2b/x86/b2b-archiver.c b/modules/b2b/x86/b2b-archiver.c index 046564b0d..d14508190 100644 --- a/modules/b2b/x86/b2b-archiver.c +++ b/modules/b2b/x86/b2b-archiver.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_ARCHIVER_VERSION 0x000705 +#define B2B_ARCHIVER_VERSION 0x000800 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-client-sys.c b/modules/b2b/x86/b2b-client-sys.c index 7c7cd89c8..702f385b6 100644 --- a/modules/b2b/x86/b2b-client-sys.c +++ b/modules/b2b/x86/b2b-client-sys.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_CLIENT_SYS_VERSION 0x000705 +#define B2B_CLIENT_SYS_VERSION 0x000800 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-jitter-check.cpp b/modules/b2b/x86/b2b-jitter-check.cpp index af1188be6..da6c390bb 100644 --- a/modules/b2b/x86/b2b-jitter-check.cpp +++ b/modules/b2b/x86/b2b-jitter-check.cpp @@ -37,7 +37,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_JITTER_CHECK_VERSION 0x000705 +#define B2B_JITTER_CHECK_VERSION 0x000800 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-serv-kickdiag.cpp b/modules/b2b/x86/b2b-serv-kickdiag.cpp index 9e56650b9..01cd12a9b 100644 --- a/modules/b2b/x86/b2b-serv-kickdiag.cpp +++ b/modules/b2b/x86/b2b-serv-kickdiag.cpp @@ -6,7 +6,7 @@ * version : 23-Aug-2024 * * publishes additional diagnostic data of the kicker - + * * this is experimental, as this information is not retrieved via a timing message (sent by * the b2b system) but it is obtained from local ECA actions at the kicker frontend * @@ -37,7 +37,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERV_KICKD_VERSION 0x000705 +#define B2B_SERV_KICKD_VERSION 0x000800 #define __STDC_FORMAT_MACROS #define __STDC_CONSTANT_MACROS diff --git a/modules/b2b/x86/b2b-serv-sys.c b/modules/b2b/x86/b2b-serv-sys.c index fbd8f978f..e1fe4393c 100644 --- a/modules/b2b/x86/b2b-serv-sys.c +++ b/modules/b2b/x86/b2b-serv-sys.c @@ -34,7 +34,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2B_SERVSYS_VERSION 0x000705 +#define B2B_SERVSYS_VERSION 0x000800 // standard includes #include // getopt diff --git a/modules/b2b/x86/b2b-sim.c b/modules/b2b/x86/b2b-sim.c index eeeff6aff..ada253c4f 100644 --- a/modules/b2b/x86/b2b-sim.c +++ b/modules/b2b/x86/b2b-sim.c @@ -35,7 +35,7 @@ * For all questions and ideas contact: d.beck@gsi.de * Last update: 15-April-2019 *********************************************************************************************/ -#define B2BSIM_VERSION 0x000705 +#define B2BSIM_VERSION 0x000800 #define MAXSAMPLES 1000 #define MAXDATA 10000000 From fa09c9a8c7216f77e11a2f46dd81059ad3adf6af Mon Sep 17 00:00:00 2001 From: Dietrich Beck Date: Wed, 28 Aug 2024 14:19:41 +0200 Subject: [PATCH 13/13] b2b: merge cleanup --- modules/b2b/include/b2blib.h | 2 +- modules/b2b/x86/b2b-archiver.c | 8 ++++---- modules/b2b/x86/b2b-mon.c | 14 +++++++------- modules/b2b/x86/b2b-viewer.c | 22 +++++++++++----------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/b2b/include/b2blib.h b/modules/b2b/include/b2blib.h index 45973eddc..ce7ca19a7 100644 --- a/modules/b2b/include/b2blib.h +++ b/modules/b2b/include/b2blib.h @@ -114,7 +114,7 @@ extern "C" { float inj_dKickProbLevel; float inj_diagPhase; float inj_diagMatch; - uint32_t flagEvtRec; // flag for events received; pme, pmi, pre, pri, kte, kti, kde, kdi, pde, pdi, start, stop + uint32_t flagEvtRec; // flag for events received; pme, pmi, pre, pri, pse, psi, kte, kti, kde, kdi, pde, pdi, start, stop uint32_t flagEvtErr; // error flag; pme, pmi, ... uint32_t flagEvtLate; // flag for events late; pme, pmi, ... uint64_t tCBS; // deadline of CMD_B2B_START [ns] diff --git a/modules/b2b/x86/b2b-archiver.c b/modules/b2b/x86/b2b-archiver.c index d14508190..8ed7cb7ae 100644 --- a/modules/b2b/x86/b2b-archiver.c +++ b/modules/b2b/x86/b2b-archiver.c @@ -105,7 +105,7 @@ static void help(void) { // header String for file char * headerString() { - return "patternName; time_CBS_UTC; ext_gid; ext_sid; mode; ext_T [as]; ext_h; ext_cTrig; inj_T; inj_h; inj_cTrig; cPhase; ext_phase; ext_phaseFract; ext_phaseErr; ext_maxsysErr; ext_dKickMon; ext_dkickProb; ext_kickLen; ext_kickLevel; ext_diagPhase; ext_diag_Match; inj_gid; inj_sid; inj_phase; inj_phaseFract; inj_phaseErr; inj_maxsysErr; inj_dKickMon; inj_dKickProb; inj_kickLen; inj_kickLevel; inj_diagPhase; inj_diagMatch; received PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; error PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; late PME; PMI; PRE; PRI; KTE; KTI; KDE; KDI; PDE; PDI; fin-CBS; prr-CBS; t0E-CBS; t0I-CBS; kte-CBS; kti-CBS; ext_nueGet; ext_dNueGet; inj_nueGet; inj_dNueGet"; + return "patternName; time_CBS_UTC; ext_gid; ext_sid; mode; ext_T [as]; ext_h; ext_cTrig; inj_T; inj_h; inj_cTrig; cPhase; ext_phase; ext_phaseFract; ext_phaseErr; ext_maxsysErr; ext_dKickMon; ext_dkickProb; ext_kickLen; ext_kickLevel; ext_diagPhase; ext_diag_Match; inj_gid; inj_sid; inj_phase; inj_phaseFract; inj_phaseErr; inj_maxsysErr; inj_dKickMon; inj_dKickProb; inj_kickLen; inj_kickLevel; inj_diagPhase; inj_diagMatch; received PME; PMI; PRE; PRI; PSE; PSI; KTE; KTI; KDE; KDI; PDE; PDI; error PME; PMI; PRE; PRI; PSE; PSI; KTE; KTI; KDE; KDI; PDE; PDI; late PME; PMI; PRE; PRI; PSE; PSI; KTE; KTI; KDE; KDI; PDE; PDI; fin-CBS; prr-CBS; t0E-CBS; t0I-CBS; kte-CBS; kti-CBS; ext_nueGet; ext_dNueGet; inj_nueGet; inj_dNueGet"; } // headerString // receive get values @@ -202,9 +202,9 @@ void recGetvalue(long *tag, diagval_t *address, int *size) new += sprintf(new, "; %8.3f", act); } // else isnan - for (i=0; i<10; i++) new += sprintf(new, "; %d", ((dicGetval[sid].flagEvtRec >> i) & 0x1)); - for (i=0; i<10; i++) new += sprintf(new, "; %d", ((dicGetval[sid].flagEvtErr >> i) & 0x1)); - for (i=0; i<10; i++) new += sprintf(new, "; %d", ((dicGetval[sid].flagEvtLate >> i) & 0x1)); + for (i=0; i> i) & 0x1)); + for (i=0; i> i) & 0x1)); + for (i=0; i> i) & 0x1)); new += sprintf(new, "; %f; %f; %f; %f; %f; %f", dicGetval[sid].finOff, dicGetval[sid].prrOff, dicGetval[sid].preOff, dicGetval[sid].priOff, dicGetval[sid].kteOff, dicGetval[sid].ktiOff); // frequency values; chk: in principle we should check the timestammp of the service too? diff --git a/modules/b2b/x86/b2b-mon.c b/modules/b2b/x86/b2b-mon.c index 864b0f4a1..2b7bd7a20 100644 --- a/modules/b2b/x86/b2b-mon.c +++ b/modules/b2b/x86/b2b-mon.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 22-Aug-2024 + * version : 28-Aug-2024 * * subscribes to and displays status of many b2b transfers * @@ -297,7 +297,7 @@ void buildPrintLine(uint32_t idx) if (*(uint32_t *)&(dicDiagval[idx]) == no_link_32) sprintf(nueMeasExt, "NOLINK"); else { nueDiff = dicDiagval[idx].ext_rfNueAct - set_extNue[idx]; - if ((dicGetval[idx].flagEvtErr >> 2) & 0x1) sprintf(nueMeasExt, "ERROR: no RF signal detected"); + if ((dicGetval[idx].flagEvtErr >> tagPre) & 0x1) sprintf(nueMeasExt, "ERROR: no RF signal detected"); else { if ((fabs(dicDiagval[idx].ext_ddsOffAct) > set_extT[idx] / 10) || (fabs(dicDiagval[idx].ext_rfOffAct) > set_extT[idx] / 4)){ // this is hack to possibly detect wrong set-values sprintf(tmp1, "check DDS"); @@ -320,7 +320,7 @@ void buildPrintLine(uint32_t idx) if (*(uint32_t *)&(dicDiagval[idx]) == no_link_32) sprintf(nueMeasInj, "NOLINK"); else { nueDiff = dicDiagval[idx].inj_rfNueAct - set_injNue[idx]; - if ((dicGetval[idx].flagEvtErr >> 3) & 0x1) sprintf(nueMeasInj, "ERROR: no RF signal detected"); + if ((dicGetval[idx].flagEvtErr >> tagPri) & 0x1) sprintf(nueMeasInj, "ERROR: no RF signal detected"); else { if ((fabs(dicDiagval[idx].inj_ddsOffAct) > set_injT[idx] / 10) || (fabs(dicDiagval[idx].inj_rfOffAct) > set_injT[idx] / 4)){ // this is hack to possibly detect wrong set-values sprintf(tmp1, "check DDS"); @@ -353,8 +353,8 @@ void buildPrintLine(uint32_t idx) } // else flagOther if (flagB2b) { - if ((dicGetval[idx].flagEvtErr >> 4) & 0x1) sprintf(b2b, "%s", TXTERROR); - else sprintf(b2b, "%7.1f %7.1f", convertUnit(dicSetval[idx].cPhase, dicSetval[idx].ext_T), convertUnit(dicDiagval[idx].phaseOffAct, dicSetval[idx].ext_T)); + if ((dicGetval[idx].flagEvtErr >> tagKte) & 0x1) sprintf(b2b, "%s", TXTERROR); + else sprintf(b2b, "%7.1f %7.1f", convertUnit(dicSetval[idx].cPhase, dicSetval[idx].ext_T), convertUnit(dicDiagval[idx].phaseOffAct, dicSetval[idx].ext_T)); } // if flagB2B else { if (flagInjTrig) sprintf(b2b, "coastg"); @@ -363,7 +363,7 @@ void buildPrintLine(uint32_t idx) if (flagExtTrig) { // trigger event received - if ((dicGetval[idx].flagEvtRec >> 4) & 0x1) sprintf(tmp1, "%7.1f", convertUnit(set_extCTrig[idx] - dicDiagval[idx].ext_ddsOffAct, dicSetval[idx].ext_T)); + if ((dicGetval[idx].flagEvtRec >> tagKte) & 0x1) sprintf(tmp1, "%7.1f", convertUnit(set_extCTrig[idx] - dicDiagval[idx].ext_ddsOffAct, dicSetval[idx].ext_T)); else sprintf(tmp1, "%s", TXTERROR); // signal from output of kicker electronics if (isnan(dicGetval[idx].ext_dKickMon)) sprintf(tmp2, "%s", TXTERROR); @@ -380,7 +380,7 @@ void buildPrintLine(uint32_t idx) if (flagInjTrig) { // trigger event received - if ((dicGetval[idx].flagEvtRec >> 5) & 0x1) { + if ((dicGetval[idx].flagEvtRec >> tagKti) & 0x1) { if (flagB2b) { if (isnan(dicDiagval[idx].inj_ddsOffAct)) sprintf(tmp1, "%s", TXTUNKWN); else sprintf(tmp1, "%7.1f", convertUnit(set_injCTrig[idx] - dicDiagval[idx].inj_ddsOffAct, dicSetval[idx].inj_T)); //b2b : diff to DDS of injection ring diff --git a/modules/b2b/x86/b2b-viewer.c b/modules/b2b/x86/b2b-viewer.c index 57527d3c9..3282d529c 100644 --- a/modules/b2b/x86/b2b-viewer.c +++ b/modules/b2b/x86/b2b-viewer.c @@ -3,7 +3,7 @@ * * created : 2021 * author : Dietrich Beck, GSI-Darmstadt - * version : 30-Jan-2024 + * version : 28-Aug-2024 * * subscribes to and displays status of a b2b transfer * @@ -471,19 +471,19 @@ int printStatus(uint32_t sid) printf("events : PME PMI PRE PRI PSE PSI KTE KTI KDE KDI PDE PDI\n"); printf("required:"); - for (i=0; i<10; i++) if ((modeMask >> i) & 0x1) printf(" X"); else printf(" "); + for (i=0; i> i) & 0x1) printf(" X"); else printf(" "); printf("\n"); printf("received:"); - for (i=0; i<10; i++) if ((dicGetval.flagEvtRec >> i) & 0x1) printf(" X"); else printf(" "); + for (i=0; i> i) & 0x1) printf(" X"); else printf(" "); printf("\n"); printf("late :"); - for (i=0; i<10; i++) if ((dicGetval.flagEvtLate >> i) & 0x1) printf(" X"); else printf(" "); + for (i=0; i> i) & 0x1) printf(" X"); else printf(" "); printf("\n"); printf("error :"); - for (i=0; i<10; i++) if ((flagEvtErr >> i) & 0x1) printf(" X"); else printf(" "); + for (i=0; i> i) & 0x1) printf(" X"); else printf(" "); printf("\n"); if (set_mode == B2B_MODE_OFF) { @@ -533,13 +533,13 @@ int printRf(uint32_t sid) switch(set_mode) { case 0 ... 2 : case 5 : // this is an OR - if ((dicGetval.flagEvtErr >> 2) & 0x1) printf("ext: %s\n", TXTERROR); + if ((dicGetval.flagEvtErr >> tagPre) & 0x1) printf("ext: %s\n", TXTERROR); else printf("ext: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", dicDiagval.ext_rfOffAct, dicDiagval.ext_rfOffAve, dicDiagval.ext_rfOffSdev, dicGetval.ext_phaseSysmaxErr, dicDiagval.ext_rfOffMin, dicDiagval.ext_rfOffMax); printf("inj: %s\n", TXTNA); if (dicDiagval.ext_rfNueN == 0) printf("ext: %s\n\n\n", TXTNA); else { - if ((dicGetval.flagEvtErr >> 2) & 0x1) + if ((dicGetval.flagEvtErr >> tagPre) & 0x1) printf("ext: calc [Hz] act(unctnty) %s\n", TXTERROR); else printf("ext: calc [Hz] act(unctnty) %14.6f(%8.6f) diff %9.6f\n", dicDiagval.ext_rfNueAct, dicDiagval.ext_rfNueActErr, dicDiagval.ext_rfNueAct - 1000000000.0 / set_extT); @@ -550,16 +550,16 @@ int printRf(uint32_t sid) break; case 3 ... 4 : case 6 ... 7 : // this is an OR - if ((dicGetval.flagEvtErr >> 2) & 0x1) + if ((dicGetval.flagEvtErr >> tagPre) & 0x1) printf( "ext: act %s\n", TXTERROR); else printf("ext: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", dicDiagval.ext_rfOffAct, dicDiagval.ext_rfOffAve, dicDiagval.ext_rfOffSdev, dicGetval.ext_phaseSysmaxErr, dicDiagval.ext_rfOffMin, dicDiagval.ext_rfOffMax); - if ((dicGetval.flagEvtErr >> 3) & 0x1) printf("inj: %s\n", TXTERROR); + if ((dicGetval.flagEvtErr >> tagPri) & 0x1) printf("inj: %s\n", TXTERROR); else printf("inj: act %8.3f ave(sdev,smx) %8.3f(%6.3f,%5.3f) minmax %8.3f %8.3f\n", dicDiagval.inj_rfOffAct, dicDiagval.inj_rfOffAve, dicDiagval.inj_rfOffSdev, dicGetval.inj_phaseSysmaxErr, dicDiagval.inj_rfOffMin, dicDiagval.inj_rfOffMax); if (dicDiagval.ext_rfNueN == 0) printf("ext: %s\n\n\n", TXTNA); else { - if ((dicGetval.flagEvtErr >> 2) & 0x1) + if ((dicGetval.flagEvtErr >> tagPre) & 0x1) printf("ext: calc [Hz] act(unctnty) %s\n", TXTERROR); else printf("ext: calc [Hz] act(unctnty) %14.6f(%8.6f) diff %9.6f\n", dicDiagval.ext_rfNueAct, dicDiagval.ext_rfNueActErr, dicDiagval.ext_rfNueAct - 1000000000.0 / set_extT); @@ -568,7 +568,7 @@ int printRf(uint32_t sid) } // else if (dicDiagval.inj_rfNueN == 0) printf("inj: %s\n\n\n", TXTNA); else { - if ((dicGetval.flagEvtErr >> 3) & 0x1) + if ((dicGetval.flagEvtErr >> tagPri) & 0x1) printf("inj: calc [Hz] act(unctnty) %s\n", TXTERROR); else printf("inj: calc [Hz] act(unctnty) %14.6f(%8.6f) diff %9.6f\n", dicDiagval.inj_rfNueAct, dicDiagval.inj_rfNueActErr, dicDiagval.inj_rfNueAct - 1000000000.0 / set_injT);