Skip to content

Commit f09b8a9

Browse files
committed
add devcontainers2
1 parent 8fd8809 commit f09b8a9

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

docs/tutorials.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ tutorials/create_beamline
1313
tutorials/deploy_example
1414
tutorials/create_ioc
1515
tutorials/dev_container
16+
tutorials/dev_container2
1617
tutorials/ioc_changes1
1718
tutorials/ioc_changes2
1819
tutorials/generic_ioc

docs/tutorials/dev_container2.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Developer Containers Part 2
2+
3+
In this tutorial we will take a look at some of the extra features that came with the ioc-adsimdetector developer container we built in the previous tutorial. The compose folder in the ioc-adsimdetector repository contains a docker-compose file that can be used to launch a gateway and a phoebus container to view the PVs from the IOC. This works in the same way as the test compose profile that we used in the `t01-services` repository from earlier tutorials.
4+
5+
## Channel Access
6+
7+
If you want to inspect or change PV values for your developer container you can do so using the command line tools inside of the container.
8+
9+
If you still have your previous session open then you can use that. If you need to relaunch your developer container, then you can do so with the following commands:
10+
11+
```bash
12+
cd ioc-adsimdetector
13+
code .
14+
# ctrl-shift-p and choose 'reopen in container'
15+
# open a terminal in vscode
16+
17+
ibek dev instance /workspaces/t01-services/services/bl01t-ea-cam-01
18+
cd /epics/ioc
19+
make
20+
./start.sh
21+
```
22+
23+
Now you can open a new terminal in vscode and interact with the IOC using the EPICS CLI tools:
24+
25+
```bash
26+
caget BL01T-EA-CAM-01:DET:Acquire
27+
caput BL01T-EA-CAM-01:DET:Acquire 1
28+
caput BL01T-EA-CAM-01:ARR:EnableCallbacks 1
29+
# now see the (changing) value of the image array
30+
caget -#100 BL01T-EA-CAM-01:ARR:ArrayData
31+
caget -#100 BL01T-EA-CAM-01:ARR:ArrayData
32+
...
33+
```
34+
35+
This just shows that you have all the EPICS tools available to you inside the container.
36+
37+
Note that you have the ability to install any other tools you might need inside the container using `sudo apt update; sudo apt install package-name`, the container is based on **ubuntu 24.04** so all packages available for that distro are available to you. podman users should drop the `sudo` from the start of the commands.
38+
39+
If you want to use a GUI tool or any other tools you have installed on your host machine we will need a couple of extra steps.
40+
41+
## Phoebus and Gateway
42+
43+
Generic IOCs can use PVI to auto generate engineering screens for your IOC instance in the form of phoebus bob files. ioc-adsimdetector uses this to make screens for the simdetector driver and for all of the AreaDetector plugins installed in the IOC instance.
44+
45+
To make use of these screens we can use an install phoebus on the host machine or run it in a separate dedicated container. In either case we need our PVs to be accessible from outside of the container. For this purpose we use a separate gateway container which runs in the same network as the IOC container and binds to the channel access ports on the host machine's loopback adapter.
46+
47+
To launch both phoebus in a container and the ca-gateway container we use compose just like we did in the `t01-services` tutorial. The compose file is in the `compose` folder of the `ioc-adsimdetector` repository.
48+
49+
IMPORTANT: the commands we are about to run must be executed on the host, not in the developer container. We are launching further containers here and we do not want 'containers in containers' because there lies madness! To launch the gateway and phoebus containers, open a new terminal on the host use the following commands:
50+
51+
```bash
52+
cd /workspaces/ioc-adsimdetector/compose
53+
. ./environment.sh
54+
ec up -d
55+
```
56+
57+
Phoebus will be launched and attempt to load the bob file called **opi/ioc/index.bob**. The **opi** folder is a place where the author of this generic IOC could place some screens. The subfolder **ioc** is not committed to git and is where the IOC instance will place its autogenerated engineering screens. The autogenerated screens always include and index.bob which is the entry point to all other autogenerated screens.
58+
59+
## Using Host Machine Tools
60+
61+
If you have EPICS tools installed on the host machine then those can now also be used.
62+
63+
You will need to tell channel access that it should search against the loopback adapter to find PVs from your developer container. Do this with:
64+
65+
```bash
66+
export EPICS_CA_ADDR_LIST=127.0.0.1
67+
```
68+
69+
If you are running **phoebus** on the host machine it is configured via a settings file. Launching phoebus on your host with the following command will apply the correct settings and launch the index screen for the IOC instance:
70+
71+
```bash
72+
phoebus.sh -settings compose/phoebus/config/settings.ini -resource /opi/ioc/index.bob
73+
```

0 commit comments

Comments
 (0)