From 72846adce225081d566f77000edc19ab825e1ca9 Mon Sep 17 00:00:00 2001 From: Simon Rose <simon.rose@ess.eu> Date: Tue, 9 Aug 2022 10:06:38 +0200 Subject: [PATCH] E3-662: Improved IOC startup output --- CHANGELOG.md | 1 + require-ess/tools/iocsh | 13 ++-- require-ess/tools/iocsh_functions.bash | 85 +++++++++----------------- 3 files changed, 37 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29d7b03a..0210157c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Patch system now applies all patches in the `patch/` directory. Versioning for patches should be handled by git, not by require. * The loop over `EPICSVERSION` in `driver.makefile` has been removed; various other cleanup has been performed. +* Improved output during IOC startup ## [4.0.0] diff --git a/require-ess/tools/iocsh b/require-ess/tools/iocsh index 9201e0bb..c14f76e9 100644 --- a/require-ess/tools/iocsh +++ b/require-ess/tools/iocsh @@ -105,19 +105,23 @@ IOC_STARTUP=$(mktemp -p "${TMP_PATH}" -q --suffix=_iocsh_${SC_VERSION}) || die 1 # EPICS_DRIVER_PATH defined in iocsh and startup.script_common # Remember, driver is equal to module, so EPICS_DRIVER_PATH is the module directory # In our jargon. It is the same as ${EPICS_MODULES} +print_iocsh_header # shellcheck disable=SC2064 trap "softIoc_end ${IOC_STARTUP}" EXIT HUP INT TERM { printIocEnv - printf "# Set REQUIRE_IOC for its internal PVs\n" + + print_header_line "IOC startup commands" + + printf "# // Set REQUIRE_IOC for its internal PVs\n" printf "epicsEnvSet REQUIRE_IOC \"%s\"\n" "${REQUIRE_IOC}" printf "#\n" - printf "# Enable an exit subroutine for sotfioc\n" + printf "# // Enable an exit subroutine for sotfioc\n" printf "dbLoadRecords \"%s/db/softIocExit.db\" \"IOC=%s\"\n" "${EPICS_BASE}" "${REQUIRE_IOC}" printf "#\n" - printf "# Set E3_IOCSH_TOP for the absolute path where %s is executed.\n" "${SC_SCRIPTNAME}" + printf "# // Set E3_IOCSH_TOP for the absolute path where %s is executed.\n" "${SC_SCRIPTNAME}" printf "epicsEnvSet E3_IOCSH_TOP \"%s\"\n" "${IOCSH_TOP}" printf "#\n" @@ -125,7 +129,7 @@ trap "softIoc_end ${IOC_STARTUP}" EXIT HUP INT TERM loadFiles "$@" - printf "# Set the IOC Prompt String One \n" + printf "# // Set the IOC Prompt String\n" printf "epicsEnvSet IOCSH_PS1 \"%s\"\n" "$IOCSH_PS1" printf "#\n" @@ -134,7 +138,6 @@ trap "softIoc_end ${IOC_STARTUP}" EXIT HUP INT TERM fi if [ "$init" != NO ]; then - printf "# \n" printf "iocInit\n" fi diff --git a/require-ess/tools/iocsh_functions.bash b/require-ess/tools/iocsh_functions.bash index 9c4b12e9..d1443114 100644 --- a/require-ess/tools/iocsh_functions.bash +++ b/require-ess/tools/iocsh_functions.bash @@ -90,71 +90,43 @@ function version() { exit } -# This function doesn't work -function printParamShow() { - declare -a var_list=() - var_list+=(EPICS_CA_REPEATER_PORT) - var_list+=(EPICS_CA_SERVER_PORT) - var_list+=(EPICS_TIMEZONE) - var_list+=(EPICS_TS_NTP_INET) - var_list+=(EPICS_AR_PORT) - - var_list+=(EPICS_VERSION_MAJOR) - var_list+=(EPICS_VERSION_MIDDLE) - var_list+=(EPICS_VERSION_MINOR) - var_list+=(EPICS_VERSION_PATCH) - var_list+=(EPICS_VERSION_FULL) +function print_iocsh_header() { - for var in "${var_list[@]}"; do - printf "# %s=\"%s\"\n" "$var" "${!var}" + printf "███████╗██████╗ ██╗ ██████╗ ██████╗ ███████╗██╗ ██╗███████╗██╗ ██╗ \n" + printf "██╔â•â•â•â•â•â•šâ•â•â•â•â–ˆâ–ˆâ•— ██║██╔â•â•â•â–ˆâ–ˆâ•—██╔â•â•â•â•â• ██╔â•â•â•â•â•â–ˆâ–ˆâ•‘ ██║██╔â•â•â•â•â•â–ˆâ–ˆâ•‘ ██║ \n" + printf "█████╗ █████╔╠██║██║ ██║██║ ███████╗███████║█████╗ ██║ ██║ \n" + printf "██╔â•â•â• â•šâ•â•â•â–ˆâ–ˆâ•— ██║██║ ██║██║ â•šâ•â•â•â•â–ˆâ–ˆâ•‘██╔â•â•â–ˆâ–ˆâ•‘██╔â•â•â• ██║ ██║ \n" + printf "███████╗██████╔╠██║╚██████╔â•â•šâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ•— ███████║██║ ██║███████╗███████╗███████╗\n" + printf "â•šâ•â•â•â•â•â•â•â•šâ•â•â•â•â•â• â•šâ•â• â•šâ•â•â•â•â•â• â•šâ•â•â•â•â•â• â•šâ•â•â•â•â•â•â•â•šâ•â• â•šâ•â•â•šâ•â•â•â•â•â•â•â•šâ•â•â•â•â•â•â•â•šâ•â•â•â•â•â•â•\n" + printf "\n" + +} + +function print_header_line() { + printf "############################################################################\n" + printf "## %s\n" "${1}" + printf "############################################################################\n" +} + +function print_vars() { + print_header_line "$1" + shift + for var in "$@"; do + printf "# %s = \"%s\"\n" "${var}" "${!var}" done printf "#\n" } function printIocEnv() { - declare -a var_list=() - var_list+=(HOSTDISPLAY) - var_list+=(WINDOWID) - var_list+=(PWD) - var_list+=(USER) - var_list+=(LOGNAME) - var_list+=(EPICS_HOST_ARCH) - var_list+=(EPICS_BASE) - # REQUIRE - var_list+=(E3_REQUIRE_NAME) - var_list+=(E3_REQUIRE_VERSION) - var_list+=(E3_REQUIRE_LOCATION) - var_list+=(E3_REQUIRE_BIN) - var_list+=(E3_REQUIRE_DB) - var_list+=(E3_REQUIRE_DBD) - var_list+=(E3_REQUIRE_INC) - var_list+=(E3_REQUIRE_LIB) - - # EPICS and others - var_list+=(EPICS_DRIVER_PATH) - var_list+=(EPICS_CA_AUTO_ADDR_LIST) - var_list+=(EPICS_CA_ADDR_LIST) - var_list+=(EPICS_PVA_AUTO_ADDR_LIST) - var_list+=(EPICS_PVA_ADDR_LIST) - var_list+=(PATH) - - printf "#\n" printf "# Start at \"%s\"\n" "$(date +%Y-W%V-%b%d-%H%M-%S-%Z)" - printf "#\n" - printf "# Version information:\n" printf "# %s : %s%s\n" "European Spallation Source ERIC" "$SC_SCRIPTNAME" ${SC_VERSION:+" ($SC_VERSION)"} printf "#\n" - printf "# --->--> snip -->--> \n" - printf "# Please Use Version and other environment variables\n" - printf "# in order to report or debug this shell\n" - printf "#\n" - for var in "${var_list[@]}"; do - printf "# %s=\"%s\"\n" "$var" "${!var}" - done - printf "# --->--> snip -->--> \n" - printf "#\n" + print_vars "Shell and environment variables" PWD USER LOGNAME PATH + print_vars "EPICS variables" EPICS_BASE EPICS_HOST_ARCH EPICS_DRIVER_PATH EPICS_CA_AUTO_ADDR_LIST EPICS_CA_ADDR_LIST EPICS_PVA_AUTO_ADDR_LIST EPICS_PVA_ADDR_LIST + print_vars "e3-specific variables" E3_REQUIRE_VERSION E3_REQUIRE_LOCATION E3_REQUIRE_BIN E3_REQUIRE_DB E3_REQUIRE_DBD E3_REQUIRE_INC E3_REQUIRE_LIB + } # Ctrl+c : OK @@ -244,9 +216,8 @@ function loadRequire() { local require_lib=${E3_REQUIRE_LIB}/${EPICS_HOST_ARCH}/${libName} local require_dbd=${E3_REQUIRE_DBD}/${E3_REQUIRE_NAME}.dbd - printf "# \n" - printf "# Load %s module, which has the version %s\n" "${E3_REQUIRE_NAME}" "${E3_REQUIRE_VERSION}" - printf "# \n" + printf "# // Load %s module, version %s\n" "${E3_REQUIRE_NAME}" "${E3_REQUIRE_VERSION}" + printf "#\n" printf "dlload %s\n" "${require_lib}" printf "dbLoadDatabase %s\n" "${require_dbd}" printf "%s_registerRecordDeviceDriver\n\n" "${E3_REQUIRE_NAME%-*}" -- GitLab