diff --git a/Dockerfile b/Dockerfile index 01452e8..879531b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,9 @@ ARG DEVELOPER=${REGISTRY}/epics-base${IMAGE_EXT}-developer:${BASE} ##### build stage ############################################################## FROM ${DEVELOPER} AS developer +# Add missing dependancies +RUN curl -o /usr/bin/yq -L https://github.com/mikefarah/yq/releases/download/v4.44.2/yq_linux_amd64 && chmod +x /usr/bin/yq + # The devcontainer mounts the project root to /epics/generic-source # Using the same location here makes devcontainer/runtime differences transparent. ENV SOURCE_FOLDER=/epics/generic-source @@ -68,6 +71,7 @@ FROM ${RUNTIME} AS runtime # get runtime assets from the preparation stage COPY --from=runtime_prep /assets / +COPY --from=runtime_prep /usr/bin/yq /usr/bin/yq # install runtime system dependencies, collected from install.sh scripts RUN ibek support apt-install-runtime-packages --skip-non-native diff --git a/ioc/start.sh b/ioc/start.sh index 0215318..44a9a0f 100755 --- a/ioc/start.sh +++ b/ioc/start.sh @@ -128,30 +128,34 @@ elif [ -f ${ibek_src} ]; then db_src=${RUNTIME_DIR}/ioc.subst final_ioc_startup=${RUNTIME_DIR}/st.cmd - # Find address (ID) and CLASS of the first camera in the IOC instance yaml. - # NOTE this does not support mixed types of cameras in the same IOC - # ONE camera per IOC instance is recommended - # Multiple cameras of the same type are supported - # Mixed cameras will work but may not expose all their GenICam config parameters - instance_class=$(grep -m1 -oP "(?<=CLASS:\s).*" ${ibek_src}) || true # https://regex101.com/r/358gq3/1 - instance_id=$(grep -m1 -oP "(?<=ID:\s).*" ${ibek_src}) || true # https://regex101.com/r/358gq3/1 - if [[ -n $instance_id ]]; then - if [[ $instance_class == "AutoADGenICam" ]]; then - # Auto generate GenICam database from camera parameters XML - arv-tool-0.8 -a ${instance_id} genicam > /tmp/genicam.xml - python /epics/support/ADGenICam/scripts/makeDb.py /tmp/genicam.xml /epics/support/ADGenICam/db/AutoADGenICam.template + instance_type="INIT" + COUNT=0 + while [ $instance_type != "null" ] # Iterate thoough config entity array + do + instance_type=$(yq .entities[${COUNT}].type ${ibek_src}) + if [ $instance_type = "ADAravis.aravisCamera" ] + then + instance_class=$(yq .entities[${COUNT}].CLASS ${ibek_src}) + instance_id=$(yq .entities[${COUNT}].ID ${ibek_src}) + + if [[ $instance_class == "AutoADGenICam" ]]; then + # Auto generate GenICam database from camera parameters XML + arv-tool-0.8 -a ${instance_id} genicam > /tmp/${instance_id}-genicam.xml + python /epics/support/ADGenICam/scripts/makeDb.py /tmp/${instance_id}-genicam.xml /epics/support/ADGenICam/db/AutoADGenICam.template # "${READ_ID}-AutoADGenICam.template" when ibek fixed + fi + # Generate pvi device from the GenICam DB + pvi convert device --template /epics/support/ADGenICam/db/$instance_class.template /epics/pvi-defs/ /epics/support/ADGenICam/include/ADGenICam.h + mv /epics/pvi-defs/ADGenICam.pvi.device.yaml /epics/pvi-defs/$instance_class.pvi.device.yaml + # change the title of the pvi device to match the camera ID + sed -i "s/arvFeature/Aravis $instance_id/g" /epics/pvi-defs/ADAravis.pvi.device.yaml + sed -i "s/label: ADGenICam/label: GenICam $instance_id/g" /epics/pvi-defs/$instance_class.pvi.device.yaml + # remove ADDriver from GenICam device + sed -i "s/ADDriver//" /epics/pvi-defs/$instance_class.pvi.device.yaml + # TODO: pvi changes should allow us to remove the last 3 sed lines above + # a) you will be able to specify no parent, b) you will be able to specify the label fi - # Generate pvi device from the GenICam DB - pvi convert device --template /epics/support/ADGenICam/db/$instance_class.template /epics/pvi-defs/ /epics/support/ADGenICam/include/ADGenICam.h - mv /epics/pvi-defs/ADGenICam.pvi.device.yaml /epics/pvi-defs/$instance_class.pvi.device.yaml - # change the title of the pvi device to match the camera ID - sed -i "s/arvFeature/Aravis $instance_id/g" /epics/pvi-defs/ADAravis.pvi.device.yaml - sed -i "s/label: ADGenICam/label: GenICam $instance_id/g" /epics/pvi-defs/$instance_class.pvi.device.yaml - # remove ADDriver from GenICam device - sed -i "s/ADDriver//" /epics/pvi-defs/$instance_class.pvi.device.yaml - fi - # TODO: pvi changes should allow us to remove the last 3 sed lines above - # a) you will be able to specify no paretn, b) you will be able to specify the label + COUNT=$((COUNT+1)) + done # get the ibek support yaml files this ioc's support modules defs=/epics/ibek-defs/*.ibek.support.yaml