Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve yaml processing #41

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ibek-support
48 changes: 25 additions & 23 deletions ioc/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,32 @@ 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
readarray entities < <(yq -o=j -I=0 '.entities[]' ${ibek_src})
for ((count = 0 ; count < ${#entities[@]} ; count++ )) # Interate over each entity
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
instance_class=${instance_id}-${instance_class}
# 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/${instance_class}.template
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/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 2 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
done

# get the ibek support yaml files this ioc's support modules
defs=/epics/ibek-defs/*.ibek.support.yaml
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ibek==3.0.0
ibek==3.0.1
# to install direct from github during development in a branch
# git+https://github.com/epics-containers/ibek.git@fix-extract-assets
# ibek@git+https://github.com/epics-containers/ibek.git@branch