Skip to content

Commit

Permalink
Improve archiver info tags implementation
Browse files Browse the repository at this point in the history
- Fix minor bugs (missing quotes, unnecessary commands, etc)
- Create ECMC_ARCHIVER_POLICY macro
- Create configureArchiver.cmd
  • Loading branch information
Carlos Doro Neto committed Sep 2, 2024
1 parent 1720b23 commit 83ded70
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
5 changes: 3 additions & 2 deletions db/core/ecmcMotorRecord.template
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ record(motor, "$(PREFIX)$(MOTOR_NAME)") {
field(SREV, "$(SREV=1)")
field(UREV, "$(UREV=1.0)")
field(VMAX, "$(VMAX=0)")
$(ECMC_BLOCK_ARCHIVER=#)info(aa_policy, "default")
$(ECMC_BLOCK_ARCHIVER=#)info(archiver, "$(ECMC_ARCHIVER=)")

$(ECMC_BLOCK_ARCHIVER)info(aa_policy, "$(ECMC_ARCHIVER_POLICY)")
$(ECMC_BLOCK_ARCHIVER)info(archiver, "$(ECMC_ARCHIVER_CLUSTER)")
}

# The message text
Expand Down
10 changes: 8 additions & 2 deletions db/core/ecmcMotorRecordPva.template
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@ record(motor, "$(PREFIX)$(MOTOR_NAME)") {
field(RRES, "$(RRES=0)")
field(SREV, "$(SREV=1)")
field(UREV, "$(UREV=1.0)")

$(ECMC_BLOCK_ARCHIVER)info(aa_policy, "$(ECMC_ARCHIVER_POLICY)")
$(ECMC_BLOCK_ARCHIVER)info(archiver, "$(ECMC_ARCHIVER_CLUSTER)")
info(Q:group, {
"${PREFIX}axis${AXIS_NO}": {
"setpoint": {+channel:"VAL"},
"readback": {+channel:"RBV"}
}
})
$(ECMC_BLOCK_ARCHIVER=#)info(aa_policy, "default")
$(ECMC_BLOCK_ARCHIVER=#)info(archiver, "$(ECMC_ARCHIVER=)")
}

# The message text
record(stringin, "$(PREFIX)$(MOTOR_NAME)-MsgTxt") {
field(DTYP, "asynOctetRead")
field(INP, "@asyn($(MOTOR_PORT),$(AXIS_NO))MOTOR_MESSAGE_TEXT")
field(SCAN, "I/O Intr")

info(Q:group, {
"${PREFIX}axis${AXIS_NO}": {
"MsgTxt": {+channel:"VAL"}
Expand All @@ -59,6 +61,7 @@ record(stringout, "$(PREFIX)$(MOTOR_NAME)-DbgStrToLOG") {
field(VAL, "")
field(DTYP, "asynOctetWrite")
field(OUT, "@asyn($(MOTOR_PORT),$(AXIS_NO))StrToLOG")

info(Q:group, {
"${PREFIX}axis${AXIS_NO}": {
"DbgStrToLOG": {+channel:"VAL"}
Expand All @@ -82,6 +85,7 @@ record(longin, "$(PREFIX)$(MOTOR_NAME)-Err") {
field(DTYP, "asynInt32")
field(INP, "@asyn($(MOTOR_PORT),$(AXIS_NO))MCUErr")
field(SCAN, "I/O Intr")

info(Q:group, {
"${PREFIX}axis${AXIS_NO}": {
"Error": {+channel:"VAL"}
Expand All @@ -94,6 +98,7 @@ record(ai, "$(PREFIX)$(MOTOR_NAME)-VelAct") {
field(PREC, "$(PREC)")
field(INP, "@asyn($(MOTOR_PORT),$(AXIS_NO))VelAct")
field(SCAN, "I/O Intr")

info(Q:group, {
"${PREFIX}axis${AXIS_NO}": {
"velocityActual": {+channel:"VAL"}
Expand All @@ -120,6 +125,7 @@ record(ai, "$(PREFIX)$(MOTOR_NAME)-EncAct") {
field(PREC, "0")
field(INP, "@asyn($(MOTOR_PORT),$(AXIS_NO))EncAct")
field(SCAN, "I/O Intr")

info(Q:group, {
"${PREFIX}axis${AXIS_NO}": {
"encoderActual": {+channel:"VAL"}
Expand Down
12 changes: 2 additions & 10 deletions motion/ecmc_axis_mr.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@ ${ECMC_MR_MODULE="ecmcMotorRecord"}CreateAxis(${ECMC_MOTOR_PORT}, "${ECMC_AXIS_N
ecmcEpicsEnvSetCalc("ECMC_TEMP_SREV","if(abs(${ECMC_ENC_SCALE_DENOM=1})>0){RESULT:=abs(${ECMC_ENC_SCALE_DENOM=0});} else {RESULT:=1.0};","%d")
ecmcEpicsEnvSetCalc("ECMC_TEMP_UREV","if(abs(${ECMC_ENC_SCALE_NUM=0})>0){RESULT:=abs(${ECMC_ENC_SCALE_NUM=0});} else {RESULT:=1.0};","%lf")

#- Check if we should include info tags for automatic PV archival
#- ECMC_ARCHIVER must be defined by integrator in st.cmd
#- Currently only works at ESS
ecmcEpicsEnvSetCalcTernary("ECMC_BLOCK_ARCHIVER", "${NAMING} == 'ESSnaming' and ${ECMC_ARCHIVER} != '')", "", "#")

ecmcEpicsEnvSetCalc
ecmcEpicsEnvSetCalcTernary
#- Use correct field depending on use of ACCL or ACCS
ecmcFileExist(${ECMC_MR_MODULE="ecmcMotorRecord${ECMC_PVA}"}.template,1,1)
${ECMC_BLOCK_ACCL} dbLoadRecords(${ECMC_MR_MODULE="ecmcMotorRecord${ECMC_PVA}"}.template, "PREFIX=${ECMC_PREFIX}, MOTOR_NAME=${ECMC_MOTOR_NAME}, MOTOR_PORT=${ECMC_MOTOR_PORT}, AXIS_NO=${ECMC_AXIS_NO}, DESC=${ECMC_DESC}, EGU=${ECMC_EGU}, PREC=${ECMC_PREC}, VELO=${ECMC_VELO}, JVEL=${ECMC_JOG_VEL}, JAR=${ECMC_JAR}, ACCL=${ECMC_ACCL=0}, RDBD=${ECMC_MON_AT_TARGET_TOL}, DLLM=${ECMC_SOFT_LOW_LIM}, DHLM=${ECMC_SOFT_HIGH_LIM}, HOMEPROC=${ECMC_HOME_PROC},SREV=${ECMC_TEMP_SREV},UREV=${ECMC_TEMP_UREV}, ${ECMC_AXISFIELDINIT=""}, ECMC_BLOCK_ARCHIVER=${ECMC_BLOCK_ARCHIVER}, ECMC_ARCHIVER=${ECMC_ARCHIVER}")
${ECMC_BLOCK_ACCS} dbLoadRecords(${ECMC_MR_MODULE="ecmcMotorRecord${ECMC_PVA}"}.template, "PREFIX=${ECMC_PREFIX}, MOTOR_NAME=${ECMC_MOTOR_NAME}, MOTOR_PORT=${ECMC_MOTOR_PORT}, AXIS_NO=${ECMC_AXIS_NO}, DESC=${ECMC_DESC}, EGU=${ECMC_EGU}, PREC=${ECMC_PREC}, VELO=${ECMC_VELO}, JVEL=${ECMC_JOG_VEL}, JAR=${ECMC_JAR}, ACCS=${ECMC_ACCS_EGU_PER_S2=0}, RDBD=${ECMC_MON_AT_TARGET_TOL}, DLLM=${ECMC_SOFT_LOW_LIM}, DHLM=${ECMC_SOFT_HIGH_LIM}, HOMEPROC=${ECMC_HOME_PROC},SREV=${ECMC_TEMP_SREV},UREV=${ECMC_TEMP_UREV}, ${ECMC_AXISFIELDINIT=""}, ECMC_BLOCK_ARCHIVER=${ECMC_BLOCK_ARCHIVER}, ECMC_ARCHIVER=${ECMC_ARCHIVER}")
${ECMC_BLOCK_ACCL} dbLoadRecords(${ECMC_MR_MODULE="ecmcMotorRecord${ECMC_PVA}"}.template, "PREFIX=${ECMC_PREFIX}, MOTOR_NAME=${ECMC_MOTOR_NAME}, MOTOR_PORT=${ECMC_MOTOR_PORT}, AXIS_NO=${ECMC_AXIS_NO}, DESC=${ECMC_DESC}, EGU=${ECMC_EGU}, PREC=${ECMC_PREC}, VELO=${ECMC_VELO}, JVEL=${ECMC_JOG_VEL}, JAR=${ECMC_JAR}, ACCL=${ECMC_ACCL=0}, RDBD=${ECMC_MON_AT_TARGET_TOL}, DLLM=${ECMC_SOFT_LOW_LIM}, DHLM=${ECMC_SOFT_HIGH_LIM}, HOMEPROC=${ECMC_HOME_PROC},SREV=${ECMC_TEMP_SREV},UREV=${ECMC_TEMP_UREV}, ${ECMC_AXISFIELDINIT=""}, ECMC_BLOCK_ARCHIVER=${ECMC_BLOCK_ARCHIVER=#}, ECMC_ARCHIVER_POLICY=${ECMC_ARCHIVER_POLICY=}, ECMC_ARCHIVER_CLUSTER=${ECMC_ARCHIVER_CLUSTER=}")
${ECMC_BLOCK_ACCS} dbLoadRecords(${ECMC_MR_MODULE="ecmcMotorRecord${ECMC_PVA}"}.template, "PREFIX=${ECMC_PREFIX}, MOTOR_NAME=${ECMC_MOTOR_NAME}, MOTOR_PORT=${ECMC_MOTOR_PORT}, AXIS_NO=${ECMC_AXIS_NO}, DESC=${ECMC_DESC}, EGU=${ECMC_EGU}, PREC=${ECMC_PREC}, VELO=${ECMC_VELO}, JVEL=${ECMC_JOG_VEL}, JAR=${ECMC_JAR}, ACCS=${ECMC_ACCS_EGU_PER_S2=0}, RDBD=${ECMC_MON_AT_TARGET_TOL}, DLLM=${ECMC_SOFT_LOW_LIM}, DHLM=${ECMC_SOFT_HIGH_LIM}, HOMEPROC=${ECMC_HOME_PROC},SREV=${ECMC_TEMP_SREV},UREV=${ECMC_TEMP_UREV}, ${ECMC_AXISFIELDINIT=""}, ECMC_BLOCK_ARCHIVER=${ECMC_BLOCK_ARCHIVER=#}, ECMC_ARCHIVER_POLICY=${ECMC_ARCHIVER_POLICY=}, ECMC_ARCHIVER_CLUSTER=${ECMC_ARCHIVER_CLUSTER=}")

epicsEnvSet("ECMC_AXISFIELDINIT", "")

Expand All @@ -36,4 +29,3 @@ dbLoadRecords(${ECMC_MR_MODULE="ecmcMotorRecord"}home.template, "PREFIX=${ECMC_P
#- Cleanup
epicsEnvUnset(ECMC_TEMP_SREV)
epicsEnvUnset(ECMC_TEMP_UREV)
epicsEnvUnset(ECMC_BLOCK_ARCHIVER)
44 changes: 44 additions & 0 deletions scripts/configureArchiver.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#===============================================================================
# configureArchiver.cmd
#- Arguments: [POLICY], [CLUSTER]

#-d /**
#-d \brief Sets variables consumed by info tags related to integration with the EPICS Archiver Appliance.
#-d \details Currently only availble at ESS.
#-d \file
#-d \param POLICY (optional) default value depends on ECMC_P_SCRIPT
#-d \param CLUSTER (optional) default value depends on ECMC_P_SCRIPT
#-d \note Examples:
#-d \code
#-d $(SCRIPTEXEC) ${ecmccfg_DIR}configureArchiver.cmd
#-d $(SCRIPTEXEC) ${ecmccfg_DIR}configureArchiver.cmd, "POLICY=1Hz"
#-d $(SCRIPTEXEC) ${ecmccfg_DIR}configureArchiver.cmd, "CLUSTER=lab"
#-d $(SCRIPTEXEC) ${ecmccfg_DIR}configureArchiver.cmd, "POLICY=1Hz, CLUSTER=lab"
#-d \endcode
#-d \pre Must be called after startup.cmd
#-d \post Must be called before addAxis.cmd
#-d */

#- The default value for ECMC_BLOCK_ARCHIVER is # (check ecmc_axis_mr.cmd).
#- This prevents the info tags from being loaded.
#- The next line removes this restriction.
epicsEnvSet("ECMC_BLOCK_ARCHIVER" , "")

#- Set ESS-specific default values if NAMING==ESSnaming
#- These values are overridden if either POLICY or CLUSTER are non empty.
ecmcEpicsEnvSetCalcTernary("BLOCK_ESS_DEFAULTS", "'${ECMC_P_SCRIPT}' == 'ESSnaming')", "", "#-")
$(BLOCK_ESS_DEFAULTS) epicsEnvSet("ECMC_ARCHIVER_POLICY" , "default")
$(BLOCK_ESS_DEFAULTS) epicsEnvSet("ECMC_ARCHIVER_CLUSTER", "tn")

#- Only set ECMC_ARCHIVER_POLICY and ECMC_ARCHIVER_CLUSTER if
#- POLICY and CLUSTER arguments are, respectively, non-empty.
#- This allows us to honor the default values in ecmc_axis_mr.cmd
ecmcEpicsEnvSetCalcTernary("BLOCK_POLICY" , "'$(POLICY=)' != ''", "", "#-")
ecmcEpicsEnvSetCalcTernary("BLOCK_CLUSTER", "'$(CLUSTER=)' != ''", "", "#-")
$(BLOCK_POLICY) epicsEnvSet("ECMC_ARCHIVER_POLICY" , "$(POLICY)" )
$(BLOCK_CLUSTER) epicsEnvSet("ECMC_ARCHIVER_CLUSTER", "$(CLUSTER)")

#- Cleanup
epicsEnvUnset(BLOCK_ESS_DEFAULTS)
epicsEnvUnset(BLOCK_POLICY)
epicsEnvUnset(BLOCK_CLUSTER)

0 comments on commit 83ded70

Please sign in to comment.