diff --git a/.gitea/scripts/deploy-and-restart-service.sh b/.gitea/scripts/deploy-and-restart-service.sh new file mode 100755 index 0000000..9feeed3 --- /dev/null +++ b/.gitea/scripts/deploy-and-restart-service.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +SERVICE_NAME=$1 +AGEBD_ENV=$2 + +echo "==========================================" +echo "Deploying service: $SERVICE_NAME (${AGEBD_ENV})" +echo "==========================================" + +SERVICE_NAME_LOWER=$(echo "$SERVICE_NAME" | tr '[:upper:]' '[:lower:]') +SERVICE_NAME_UPPER=$(echo "$SERVICE_NAME" | tr '[:lower:]' '[:upper:]') +SERVICE_DIR=/sls/bd/hla/${AGEBD_ENV}/services/${SERVICE_NAME_LOWER}/current +SYSTEMD_UNIT_NAME=AGEBD-SERVICE-${SERVICE_NAME_UPPER}.service +SYSTEMD_UNIT_FILE_PATH=${SERVICE_DIR}/systemd/${SYSTEMD_UNIT_NAME} + +# TODO: see https://gitea.psi.ch/sls/hla_framework_bd/issues/50 +# rm -rf "${SERVICE_DIR}" +# mkdir -p ${SERVICE_DIR} +# cp -r ./services/${SERVICE_NAME_LOWER}/current/* ${SERVICE_DIR}/ + +rsync -avz --delete \ + --exclude='.nfs*' \ + --exclude='.git/' \ + --exclude='.venv/' \ + --exclude='__pycache__/' \ + --exclude='*.pyc' \ + --exclude='.pytest_cache/' \ + ./services/${SERVICE_NAME_LOWER}/current/* ${SERVICE_DIR}/ + + +if [ -f "${SYSTEMD_UNIT_FILE_PATH}" ]; then + sed -i "s/{{ *agebd_env* }}/${AGEBD_ENV}/g" "${SYSTEMD_UNIT_FILE_PATH}" +fi + +mkdir -p ${HOME}/.config/systemd/user +ln -sf "${SYSTEMD_UNIT_FILE_PATH}" "${HOME}/.config/systemd/user/${SYSTEMD_UNIT_NAME}" + +export XDG_RUNTIME_DIR="/run/user/$(id -u)" +systemctl --user daemon-reload +systemctl --user enable "${SYSTEMD_UNIT_NAME}" +systemctl --user restart "${SYSTEMD_UNIT_NAME}" diff --git a/.gitea/workflows/add-new-service.yml b/.gitea/workflows/add-new-service.yml index 1471f16..0d465d6 100644 --- a/.gitea/workflows/add-new-service.yml +++ b/.gitea/workflows/add-new-service.yml @@ -5,30 +5,23 @@ on: branches: - 'feature/add-service-*' +env: + UV_CACHE_DIR: /var/cache/uv + UV_LINK_MODE: hardlink + # TODO: when to deploy to prod? Manual (i.e. cli command)? jobs: deploy: runs-on: hla-dev - env: - ANSIBLE_CONFIG: "${{ github.workspace }}/ansible/ansible.cfg" - steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Install and setup uv - uses: actions/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 - with: - version: "latest" - enable-cache: true # Speeds up runs by caching python dependencies # TODO: does this work? - - - name: Install Python 3.10 - run: uv python install 3.10 - - - name: Run tests + - name: Run cli tests run: | - cd cli && uv run pytest + echo $UV_CACHE_DIR + uv run --directory cli pytest - name: Parse Service Directory Name id: parse_branch @@ -38,36 +31,19 @@ jobs: SERVICE_NAME="${BRANCH#feature/add-service-}" echo "service_name_lower=$SERVICE_NAME" >> $GITHUB_OUTPUT - # TODO: look into venv caching (will do later in case we move from uv to pixi) - # - name: Cache Python Virtual Environment - # uses: actions/cache@v4 - # with: - # path: .venv - # # Changes uv.lock will automatically invalidate the cache and rebuild - # key: ${{ runner.os }}-uv-cli-venv-${{ hashFiles('cli/uv.lock') }} - # restore-keys: | - # ${{ runner.os }}-uv-cli-venv- + # - name: Install Master IOC - # # Only create the venv if the cache didn't restore an existing one - # if [ ! -d ".venv" ]; then - # echo "Building new .venv" - # uv venv .venv - # fi - - name: Initialize Virtual Environment from cli/uv.lock - run: | - uv venv .venv - uv sync --directory cli + # - name: Restart Master IOC - - name: Install Ansible Galaxy Collections + - name: Deploy and Restart Master Service run: | - uv run ansible-galaxy collection install -r ansible/collections/requirements.yml -p ./ansible/installed-collections + ./.gitea/scripts/deploy-and-restart-service.sh "master" "dev" - # TODO: dev/prod - - name: Run New Service Playbook - working-directory: ansible + # - name: Install New IOC + + # - name: Start New IOC + + - name: Deploy and Restart New Service run: | - uv run ansible-playbook playbooks/add-new-service.yml \ - -i "inventories/dev/hosts.yml" \ - --extra-vars="repo_root=${{ github.workspace }}" \ - --extra-vars="service_name_lower=${{ steps.parse_branch.outputs.service_name_lower }}" \ - -v + SERVICE_NAME=${{ steps.parse_branch.outputs.service_name_lower }} + ./.gitea/scripts/deploy-and-restart-service.sh "${SERVICE_NAME}" "dev" diff --git a/.gitea/workflows/deploy-py-agebd-pypi.yml b/.gitea/workflows/deploy-py-agebd-pypi.yml deleted file mode 100644 index 87b5b24..0000000 --- a/.gitea/workflows/deploy-py-agebd-pypi.yml +++ /dev/null @@ -1,13 +0,0 @@ -# name: Deploy agebd python package to gitea/pypi -# -# # TODO: services depend on this workflow -# on: -# push: -# branches: -# - main -# paths: -# - 'packages/agebd/**' -# -# jobs: -# deploy: -# runs-on: hla-dev diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 09353e2..ef7e9ff 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -13,23 +13,29 @@ on: - 'qt/**' - 'services/**' +# Cancel previous runs if a new commit is pushed to the same branch +concurrency: + group: deploy-${{ github.ref }} + cancel-in-progress: true + +env: + # commit tagged ? yes->prod : no->dev + AGEBD_ENV: ${{ github.ref_type == 'tag' && 'prod' || 'dev' }} + UV_CACHE_DIR: /var/cache/uv + UV_LINK_MODE: hardlink jobs: deploy: runs-on: hla-dev - env: - # commit tagged ? yes->prod : no->dev - AGEBD_ENV: ${{ github.ref_type == 'tag' && 'prod' || 'dev' }} - steps: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 2 # needed for git diff tracking + fetch-depth: 0 # Needed for git diff in service detection - - name: Defined filter paths - uses: actions/paths-filter@v3 # see: https://gitea.psi.ch/actions/paths-filter + - name: Define filter paths + uses: actions/paths-filter@v3 id: filter with: filters: | @@ -42,86 +48,126 @@ jobs: services: - 'services/**' - - name: Install uv - uses: actions/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 - - - name: Install Python 3.10 - run: uv python install 3.10 - - - name: Run tests + - name: Run core tests run: | - cd scripts && uv run pytest + echo $UV_CACHE_DIR + uv run --directory cli pytest + uv run --directory packages/agebd pytest + uv run --directory scripts pytest - # TODO: maybe this is better: `rsync -av --delete ./ "${DEST_DIR}/"` # Sync everything perfectly, including hidden files, and delete old stale files + # ----------------------------------------------------------------- + # Directory Deployments + # ----------------------------------------------------------------- - name: Bin - deploy if: steps.filter.outputs.bin == 'true' env: - # commit tagged ? yes->prod : no->dev - DEST_DIR: /sls/bd/hla/${{ github.ref_type == 'tag' && 'prod' || 'dev' }}/bin - working-directory: bin + DEST_DIR: /sls/bd/hla/${{ env.AGEBD_ENV }}/bin run: | - mkdir -p ${DEST_DIR} - cp -r ./* ${DEST_DIR} + # TODO: see https://gitea.psi.ch/sls/hla_framework_bd/issues/50 + # rm -rf "${DEST_DIR}" + # mkdir -p "${DEST_DIR}" + # cp -r ./bin/* "${DEST_DIR}/" + + rsync -avz --delete \ + --exclude='.nfs*' \ + --exclude='.git/' \ + --exclude='.venv/' \ + --exclude='__pycache__/' \ + --exclude='*.pyc' \ + --exclude='.pytest_cache/' \ + ./bin/* "${DEST_DIR}/" + - # TODO: maybe this is better: `rsync -av --delete ./ "${DEST_DIR}/"` # Sync everything perfectly, including hidden files, and delete old stale files - name: Agebd - deploy if: steps.filter.outputs.agebd == 'true' env: - # commit tagged ? yes->prod : no->dev - DEST_DIR: /sls/bd/hla/${{ github.ref_type == 'tag' && 'prod' || 'dev' }}/packages/agebd - working-directory: packages/agebd + DEST_DIR: /sls/bd/hla/${{ env.AGEBD_ENV }}/packages/agebd run: | - mkdir -p ${DEST_DIR} - cp -r ./* ${DEST_DIR} + # TODO: see https://gitea.psi.ch/sls/hla_framework_bd/issues/50 + # rm -rf "${DEST_DIR}" + # mkdir -p "${DEST_DIR}" + # cp -r ./packages/agebd/* "${DEST_DIR}/" + + rsync -avz --delete \ + --exclude='.nfs*' \ + --exclude='.git/' \ + --exclude='.venv/' \ + --exclude='__pycache__/' \ + --exclude='*.pyc' \ + --exclude='.pytest_cache/' \ + ./packages/agebd/* "${DEST_DIR}/" - # TODO: maybe this is better: `rsync -av --delete ./ "${DEST_DIR}/"` # Sync everything perfectly, including hidden files, and delete old stale files - name: Qt - deploy if: steps.filter.outputs.qt == 'true' env: - # commit tagged ? yes->prod : no->dev - DEST_DIR: /sls/bd/hla/${{ github.ref_type == 'tag' && 'prod' || 'dev' }}/qt - working-directory: qt + DEST_DIR: /sls/bd/hla/${{ env.AGEBD_ENV }}/qt run: | - mkdir -p ${DEST_DIR} - cp -r ./* ${DEST_DIR} + # TODO: see https://gitea.psi.ch/sls/hla_framework_bd/issues/50 + # rm -rf "${DEST_DIR}" + # mkdir -p "${DEST_DIR}" + # cp -r ./qt/* "${DEST_DIR}/" + + rsync -avz --delete \ + --exclude='.nfs*' \ + --exclude='.git/' \ + --exclude='.venv/' \ + --exclude='__pycache__/' \ + --exclude='*.pyc' \ + --exclude='.pytest_cache/' \ + ./qt/* "${DEST_DIR}/" - # TODO: (when) do we need to restart the master service or reinstall/restart the master ioc? + # ----------------------------------------------------------------- + # Services Detection, Testing, and Deployment + # ----------------------------------------------------------------- + - name: Detect Services to Test + # Run tests for a service if the service changed OR if core package agebd changed + if: steps.filter.outputs.services == 'true' || steps.filter.outputs.agebd == 'true' + id: detect-services + run: | + # If agebd changed, test ALL services to prevent breaking downstream dependencies + if [ "${{ steps.filter.outputs.agebd }}" = "true" ]; then + echo ":packages/agebd changed. Triggering tests for ALL services." + SERVICES_TO_TEST=$(ls -d services/*/ | xargs -n1 basename | tr '\n' ' ') + else + BEFORE="${{ github.event.before }}" + if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then + BEFORE="HEAD~1" + fi - - name: Services - Initialize Virtual Environment from cli/uv.lock + # Get space-separated list of modified service folder names + SERVICES_TO_TEST=$(git diff --name-only "$BEFORE" "${{ github.sha }}" | awk -F/ '$1=="services" && $2!="" {print $2}' | sort -u | tr '\n' ' ') + fi + + echo "services=$SERVICES_TO_TEST" >> $GITHUB_OUTPUT + echo "Services queued for testing: $SERVICES_TO_TEST" + + - name: Test Services + if: steps.detect-services.outputs.services != '' + run: | + SERVICES="${{ steps.detect-services.outputs.services }}" + + for SERVICE in $SERVICES; do + SERVICE_APP_DIR="services/$SERVICE/current/app" + if [ -d "$SERVICE_APP_DIR" ]; then + echo "==========================================" + echo "Running tests for: $SERVICE_APP_DIR" + echo "==========================================" + + uv run --directory "$SERVICE_APP_DIR" pytest + fi + done + + - name: Deploy Changed Services + # ONLY deploy services that explicitly had file changes (prevents redeploying all services if only agebd changed) if: steps.filter.outputs.services == 'true' run: | - uv venv .venv - uv sync --directory cli - - - name: Services - Install Ansible Galaxy Collections - if: steps.filter.outputs.services == 'true' - run: | - uv run ansible-galaxy collection install -r ansible/collections/requirements.yml -p ./ansible/installed-collections - - - name: Services - Run Ansible Orchestrator - if: steps.filter.outputs.services == 'true' - working-directory: ansible - run: | - set -x - - # Disable pipefail temporarily or add an '|| true' fallback so grep doesn't kill the script - set +e - CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) - set -e - - # 1. Parse changed directory names into space-separated string (e.g. "master other-service") - CHANGED_SVC=$(echo "$CHANGED_FILES" | awk -F/ '$1=="services" {print $2}' | sort -u | xargs) - - echo "Detected changed services: '$CHANGED_SVC'" - - # Safely halt the execution if there is nothing to pass to Ansible - if [ -z "$CHANGED_SVC" ]; then - echo "No services changed in this commit range. Skipping deployment smoothly." - exit 0 + BEFORE="${{ github.event.before }}" + if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then + BEFORE="HEAD~1" fi - # 3. Fire the playbook passing variables down - ansible-playbook playbooks/deploy-and-restart-modified-services.yml \ - -i "inventories/$AGEBD_ENV/hosts.yml" \ - --extra-vars="changed_services_raw='$CHANGED_SVC'" \ - -v + CHANGED_SERVICES=$(git diff --name-only "$BEFORE" "${{ github.sha }}" | awk -F/ '$1=="services" && $2!="" {print $2}' | sort -u) + + for SERVICE in $CHANGED_SERVICES; do + ./.gitea/scripts/deploy-and-restart-service.sh "${SERVICE}" "${AGEBD_ENV}" + done diff --git a/README.md b/README.md index b684968..d0e6f3c 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@ ### Users -- [Add a new service](docs/user/add-new-service.md) +- [Add a new service](https://sls.psi.ch/hla_framework_bd/user/add-new-service/) ### Developers -- [Overview](docs/developer/overview.md) - +- [Overview](https://sls.psi.ch/hla_framework_bd/developer/overview/) diff --git a/bin/start_service.sh b/bin/start_service.sh index 24dda0c..a298071 100755 --- a/bin/start_service.sh +++ b/bin/start_service.sh @@ -16,8 +16,9 @@ SVC_DIR=${SERVICES_DIR}/${SVC_NAME_LOWER} #. /sls/bd/exchange/BeamData/user/felix/workarounds/epicsRHEL8.rc # temporary fix . /etc/profile.d/cas_12_epics.sh -# TODO: only for dev -export EPICS_CA_ADDR_LIST='sls-cagw.psi.ch:5062 129.129.146.88' +if [ "${AGEBD_ENV}" = "dev" ]; then + export EPICS_CA_ADDR_LIST="$EPICS_CA_ADDR_LIST 129.129.146.255" +fi # activate conda environment . /opt/gfa/python-3.10/latest/bin/activate @@ -42,4 +43,4 @@ source ${APP_DIR}/.venv/bin/activate # TODO: use `exec python3 ...` here? python -u -B -m agebd_${SVC_NAME_LOWER_UNDERSCORES}.main -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 diff --git a/docs/developer/cicd_runner.md b/docs/developer/cicd_runner.md index a43584d..1efa972 100644 --- a/docs/developer/cicd_runner.md +++ b/docs/developer/cicd_runner.md @@ -22,6 +22,9 @@ cd ~/gitea-runner /usr/local/bin/act_runner register --instance https://gitea.psi.ch/ --labels hla-dev --token --no-interactive ``` +Note, if you use a systemd service with a config file as in the example below, +the labels will be read from that file. + This generates a `.runner` file. @@ -42,6 +45,7 @@ tar -xf node-v20.11.1-linux-x64.tar.xz --strip-components=2 -C ~/.local/bin/ nod rm node-v20.11.1-linux-x64.tar.xz ``` + ## Manually run the runner ```shell @@ -105,6 +109,38 @@ SocketMode=0660 SocketGroup=podman ``` +Created uv cache dir, for `UV_CACHE_DIR`: + +``` +sudo mkdir -m 777 /var/cache/uv +``` + +Change the location of the act cache and working directory (uv .venvs are built here, take up lots of space) + +``` +sudo mkdir -m 777 /var/lib/act_runner/cache +sudo mkdir -m 777 /var/lib/act_runner/work +``` + +and edit `/etc/act_runner/config.yaml` + +``` +cache: + dir: "/var/lib/act_runner/cache" +host: + # The parent directory of a job's working directory. + # If it's empty, $HOME/.cache/act/ will be used. + workdir_parent: "/var/lib/act_runner/work" +``` + +Configure the runner labels: (edit `/etc/act_runner/config.yaml`) + +``` +runner: + labels: + - "hla-dev" +``` + Enable and restart: ``` diff --git a/packages/agebd/src/agebd/service/pvs.py b/packages/agebd/src/agebd/service/pvs.py index 887b92d..dd098e2 100644 --- a/packages/agebd/src/agebd/service/pvs.py +++ b/packages/agebd/src/agebd/service/pvs.py @@ -1,6 +1,6 @@ from agebd.pv import PVLink -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 class BasePVs: diff --git a/services/dbpm3curr/current/app/src/agebd_dbpm3curr/main.py b/services/dbpm3curr/current/app/src/agebd_dbpm3curr/main.py index c37cc54..011d64c 100644 --- a/services/dbpm3curr/current/app/src/agebd_dbpm3curr/main.py +++ b/services/dbpm3curr/current/app/src/agebd_dbpm3curr/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_dbpm3curr import PVs, Service from agebd_dbpm3curr.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/injectionguard/current/app/src/agebd_injectionguard/main.py b/services/injectionguard/current/app/src/agebd_injectionguard/main.py index e0f95c5..ad8395f 100644 --- a/services/injectionguard/current/app/src/agebd_injectionguard/main.py +++ b/services/injectionguard/current/app/src/agebd_injectionguard/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_injectionguard import PVs, Service from agebd_injectionguard.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/master/current/app/src/agebd_master/main.py b/services/master/current/app/src/agebd_master/main.py index 141d067..44f31e9 100644 --- a/services/master/current/app/src/agebd_master/main.py +++ b/services/master/current/app/src/agebd_master/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_master import PVs, Service from agebd_master.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/orbitbump/current/ioc/README.md b/services/orbitbump/current/ioc/README.md deleted file mode 100644 index 9a0741c..0000000 --- a/services/orbitbump/current/ioc/README.md +++ /dev/null @@ -1 +0,0 @@ -# TODO: dev/prod templating diff --git a/services/orbitbump/current/systemd/AGEBD-SERVICE-ORBITBUMP.service b/services/orbitbump/current/systemd/AGEBD-SERVICE-ORBITBUMP.service deleted file mode 100644 index 36063b6..0000000 --- a/services/orbitbump/current/systemd/AGEBD-SERVICE-ORBITBUMP.service +++ /dev/null @@ -1,17 +0,0 @@ -[Unit] -Description=AGEBD-SERVICE-ORBITBUMP -After=network.target - -[Service] -Environment=AGEBD_ENV={{ agebd_env }} -Environment=PYTHONUNBUFFERED=1 -ExecStart=/sls/bd/hla/{{ agebd_env }}/bin/start_service.sh ORBITBUMP -Restart=no - -[Install] -WantedBy=default.target - -# https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html -# systemctl --user daemon-reload -# systemctl --user enable /sls/bd/bin/systemd/AGEBD-SERVICE-ORBITBUMP.service -# systemctl --user start AGEBD-SERVICE-ORBITBUMP diff --git a/services/params/current/ioc/AGEBD-CPCL-PARAMS_main.subs b/services/params/current/ioc/AGEBD-CPCL-PARAMS_main.subs new file mode 100644 index 0000000..644bfbc --- /dev/null +++ b/services/params/current/ioc/AGEBD-CPCL-PARAMS_main.subs @@ -0,0 +1,4 @@ +file PARAMS.template { + pattern { DEVICE } + { AGEBD-PARAMS{{ agebd_env_suffix }} } +} diff --git a/services/params/current/ioc/AGEBD-CPCL-PARAMS_parameters.yaml b/services/params/current/ioc/AGEBD-CPCL-PARAMS_parameters.yaml new file mode 100644 index 0000000..6c115a3 --- /dev/null +++ b/services/params/current/ioc/AGEBD-CPCL-PARAMS_parameters.yaml @@ -0,0 +1,6 @@ +cpu_architecture: x86_64 +epics_version: 7.0.8 +ioc_host: sls-vserv-bd-01{{ agebd_env_suffix }} +ioc_port: {{ ioc_port }} +os: RHEL8 +os_id: rhel diff --git a/services/params/current/ioc/PARAMS.template b/services/params/current/ioc/PARAMS.template new file mode 100644 index 0000000..2cc20b4 --- /dev/null +++ b/services/params/current/ioc/PARAMS.template @@ -0,0 +1,83 @@ +record(calcout, "$(DEVICE):CURRENTLIMIT"){ + field(DESC, "Current Limit") + field(ASG, "READONLY") + field(PREC, "3") + field(EGU, "mA") + field(VAL, "25") + field(CALC, "A ? 25 : 410 ") + field(SCAN, "Passive") + field(INPA, "AGEBD-INJECTIONGUARD:CONTROL-BRIDGE-CHECK-01 CPP") +} + +record(calcout, "$(DEVICE):CURRENT"){ + field(DESC, "Current reading") + field(PREC, "3") + field(EGU, "mA") + field(VAL, "0") + field(CALC, "A > 300 ? A : B ") + field(SCAN, "Passive") + field(INPA, "ARS07-DPCT-0000:CURR CPP") + field(INPB, "AGEBD-DBPM3CURR:CURRENT-AVG") +} + +record(calcout, "$(DEVICE):INJECTION-RATE"){ + field(DESC, "Rate der Akkumulation im Speicherring") + field(FLNK, "$(DEVICE):TRANSMISSION") + field(PREC, "4") + field(EGU, "mA/min") + field(VAL, "0") + field(CALC, "A > 300 ? C : B ") + field(SCAN, "Passive") + field(INPA, "ARS07-DPCT-0000:CURR CPP") + field(INPB, "AGEBD-TAUBPM:INJRATE CPP") + field(INPC, "AGEBD-TAUPCT:INJRATE CPP") +} + +record(calcout, "$(DEVICE):TRANSMISSION"){ + field(DESC, "Transmission Booster PCT to Ring") + field(PREC, "3") + field(EGU, "%") + field(VAL, "0") + # mA/min / 60 = mA/s + # mA/s / 3.125 = mA/shot + # A = C/s --> mA/shot = (mC/s)/shot = (nC/us)/shot + # 288 m / c = 0.96 us + # mA/shot * 0.96 us = nC / shot + # ABODI-DPCT:EXT-CURR.EGU "nC" + field(CALC, "A ? (B/60/3.125*0.96 / C * 100) : D") + field(SCAN, "Passive") + field(INPA, "$(DEVICE):INJECTION-ACTIVE") + field(INPB, "$(DEVICE):INJECTION-RATE") + field(INPC, "ABODI-DPCT:EXT-CURR") + field(INPD, "$(DEVICE):TRANSMISSION.LD") +} + +record(calcout, "$(DEVICE):LIFETIME"){ + field(DESC, "Lifetime calculation") + field(PREC, "3") + field(EGU, "hours") + field(VAL, "0") + field(CALC, "A > 300 ? C : B") + field(SCAN, "Passive") + field(INPA, "ARS07-DPCT-0000:CURR CPP") + field(INPB, "AGEBD-TAUBPM:TAU CPP") + field(INPC, "AGEBD-TAUPCT:TAU CPP") +} + +record(calcout, "$(DEVICE):INJECTION-ACTIVE"){ + field(DESC, "Injection active") + field(VAL, "0") + field(CALC, "A & B & !!C & D & E & F & G & H & I & !J & K & L") + field(INPA, "AGETI-CVME-MASTER-TMA:SR-Inj-Guard-Status-I CP") + field(INPB, "AGETI-CVME-MASTER-TMA:SR-Inj-Status-Sel CP") + field(INPC, "ALIRF-VME-A-GUN:CH1-MODE CP") + field(INPD, "AGETI-CVME-MASTER-TMA:Evt-LI-Gun-Ena-Sel CP") + field(INPE, "AGETI-CVME-MASTER-TMA:Evt-BO-Inj-Ena-Sel CP") + field(INPF, "AGETI-CVME-MASTER-TMA:Evt-BO-MA-B-Ena-Sel CP") + field(INPG, "AGETI-CVME-MASTER-TMA:Evt-BO-Ramp-Ena-Sel CP") + field(INPH, "AGETI-CVME-MASTER-TMA:Evt-BO-Ext-Ena-Sel CP") + field(INPI, "AGETI-CVME-MASTER-TMA:Evt-SR-Inj-Ena-Sel CP") + field(INPJ, "AGESA-SBDC-0000:SUM_INPUT_NOT_OK_LATCHED CP") + field(INPK, "AGETI-CVME-MASTER-TMA:SR-Inj-Trigger-I CP") + field(INPL, "AGEBD-TIMING:GO CP") +} diff --git a/services/params/current/ioc/startup.script b/services/params/current/ioc/startup.script new file mode 100644 index 0000000..941c745 --- /dev/null +++ b/services/params/current/ioc/startup.script @@ -0,0 +1,4 @@ +epicsEnvSet("ENGINEER", "armborst") +require array +require SynApps +addScan 300 diff --git a/services/plots/current/app/src/agebd_plots/main.py b/services/plots/current/app/src/agebd_plots/main.py index 32b23bf..0d1ed2f 100644 --- a/services/plots/current/app/src/agebd_plots/main.py +++ b/services/plots/current/app/src/agebd_plots/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_plots import PVs, Service from agebd_plots.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/postmortemlog/current/app/src/agebd_postmortemlog/main.py b/services/postmortemlog/current/app/src/agebd_postmortemlog/main.py index 24b5c00..22b0c6e 100644 --- a/services/postmortemlog/current/app/src/agebd_postmortemlog/main.py +++ b/services/postmortemlog/current/app/src/agebd_postmortemlog/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_postmortemlog import PVs, Service from agebd_postmortemlog.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/scrubbing/current/app/src/agebd_scrubbing/main.py b/services/scrubbing/current/app/src/agebd_scrubbing/main.py index f9e95ab..2fcbe1a 100644 --- a/services/scrubbing/current/app/src/agebd_scrubbing/main.py +++ b/services/scrubbing/current/app/src/agebd_scrubbing/main.py @@ -6,7 +6,7 @@ from agebd_scrubbing import PVs, Service from agebd_scrubbing.runner import Runner from agebd_scrubbing.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/shifttool/current/app/src/agebd_shifttool/main.py b/services/shifttool/current/app/src/agebd_shifttool/main.py index 82a4d08..193909c 100644 --- a/services/shifttool/current/app/src/agebd_shifttool/main.py +++ b/services/shifttool/current/app/src/agebd_shifttool/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_shifttool import PVs, Service from agebd_shifttool.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/taubpm/current/app/src/agebd_taubpm/main.py b/services/taubpm/current/app/src/agebd_taubpm/main.py index 2b19800..f7cd48f 100644 --- a/services/taubpm/current/app/src/agebd_taubpm/main.py +++ b/services/taubpm/current/app/src/agebd_taubpm/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_taubpm import PVs, Service from agebd_taubpm.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/taupct/current/app/src/agebd_taupct/main.py b/services/taupct/current/app/src/agebd_taupct/main.py index b4001a1..a05c57a 100644 --- a/services/taupct/current/app/src/agebd_taupct/main.py +++ b/services/taupct/current/app/src/agebd_taupct/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_taupct import PVs, Service from agebd_taupct.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/timing/current/app/src/agebd_timing/main.py b/services/timing/current/app/src/agebd_timing/main.py index c3fe8dc..cda08a0 100644 --- a/services/timing/current/app/src/agebd_timing/main.py +++ b/services/timing/current/app/src/agebd_timing/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_timing import PVs, Service from agebd_timing.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/topuptool/current/app/src/agebd_topuptool/main.py b/services/topuptool/current/app/src/agebd_topuptool/main.py index 4be29be..bac7316 100644 --- a/services/topuptool/current/app/src/agebd_topuptool/main.py +++ b/services/topuptool/current/app/src/agebd_topuptool/main.py @@ -6,7 +6,7 @@ from agebd_topuptool import PVs, Service from agebd_topuptool.runner import Runner from agebd_topuptool.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/tune/current/app/src/agebd_tune/main.py b/services/tune/current/app/src/agebd_tune/main.py index f4b8e8a..11d68f8 100644 --- a/services/tune/current/app/src/agebd_tune/main.py +++ b/services/tune/current/app/src/agebd_tune/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_tune import PVs, Service from agebd_tune.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/tunebump/current/app/src/agebd_tunebump/main.py b/services/tunebump/current/app/src/agebd_tunebump/main.py index 0750964..c2c4dae 100644 --- a/services/tunebump/current/app/src/agebd_tunebump/main.py +++ b/services/tunebump/current/app/src/agebd_tunebump/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_tunebump import PVs, Service from agebd_tunebump.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/tunefbx/current/app/src/agebd_tunefbx/main.py b/services/tunefbx/current/app/src/agebd_tunefbx/main.py index fb3a0c9..5b947e6 100644 --- a/services/tunefbx/current/app/src/agebd_tunefbx/main.py +++ b/services/tunefbx/current/app/src/agebd_tunefbx/main.py @@ -6,7 +6,7 @@ from agebd.utils import init_logging from agebd_tunefbx import PVs, Service from agebd_tunefbx.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( diff --git a/services/tunefby/current/app/src/agebd_tunefby/main.py b/services/tunefby/current/app/src/agebd_tunefby/main.py index 5545f7f..08665aa 100644 --- a/services/tunefby/current/app/src/agebd_tunefby/main.py +++ b/services/tunefby/current/app/src/agebd_tunefby/main.py @@ -7,7 +7,7 @@ from agebd_tunefby import PVs, Service from agebd_tunefby.service import SERVICE_NAME -# TODO: remove: cicd test 10 +# TODO: remove: cicd test 51 def main( log_level: LogLevel = typer.Option(