You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorials/ioc_changes2.md
+62-70Lines changed: 62 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,111 +14,99 @@ Some of the reasons for doing this are:
14
14
in the support YAML file.
15
15
16
16
:::{note}
17
-
If you are considering making a change to a Generic IOC because you
18
-
want to add support for a second device, this is allowed but you should
19
-
consider the alternative of creating a new Generic IOC.
20
-
If you keep your Generic IOCs simple and focused on a single device, they
21
-
will be smaller and there will be less of them. IOCs' records can still be
22
-
linked via CA links and this is preferable to recompiling a Generic IOC
23
-
for every possible combination of devices. Using Kubernetes to
24
-
manage multiple small services is cleaner than having a handful of
25
-
monolithic services.
17
+
If you are considering making a change to a Generic IOC because you want to add support for a second device, this is allowed but you should consider the alternative of creating a new Generic IOC for the second device. If you keep your Generic IOCs simple and focused on a single device, they will be smaller and there will be less of them. IOCs' records can still be linked via CA links and this is preferable to recompiling a Generic IOC for every possible combination of devices. Using Kubernetes to manage multiple small services is cleaner than having a handful of monolithic services.
18
+
19
+
Having said this. If there is a common collection of devices that are frequently deployed together and usually restarted together then there is merit in making a Generic IOC for that collection. For example, at DLS we have a Single generic IOC for the set of vacuum equipment that we deploy on every beamline.
26
20
:::
27
21
28
-
This tutorial will make some changes to the generic IOC `ioc-adsimdetector`
29
-
that you already used in earlier tutorials.
22
+
This tutorial will make some changes to the generic IOC `ioc-adsimdetector` that you already used in earlier tutorials.
30
23
31
-
For this exercise we will work locally inside the `ioc-adsimdetector`
32
-
developer container. Following tutorials will show how to fork repositories
33
-
and push changes back to GitHub
24
+
For this exercise we will work locally inside the `ioc-adsimdetector` developer container and will not commit our changes back. Following tutorials will show how to fork repositories and push changes back to GitHub
34
25
35
-
For this exercise we will be using an example IOC Instance to test our changes. Instead of working with a beamline repository, we will use the example ioc instance inside `ioc-adsimdetector`. It is a good idea for Generic IOC authors to include an example IOC Instance in their repository for testing changes in isolation. Obviously, this is easy for a simulation IOC, for IOCs that normally connect to real hardware this would require an additional simulator of some kind.
26
+
For this exercise we will be using an example IOC Instance to test our changes. Instead of working with a beamline repository, we will use the example ioc instance that is already inside `ioc-adsimdetector`. It is a good idea for Generic IOC authors to include an example IOC Instance in their repository for testing changes in isolation. Obviously, this is easy for a simulation IOC, for IOCs that normally connect to real hardware this would require a simulator of some kind.
36
27
37
28
## Preparation
38
29
39
-
First, clone the `ioc-adsimdetector` repository and make sure the container
40
-
build is working:
30
+
First, clone the `ioc-adsimdetector` repository and make sure the container build is working. You may also use the existing clone you have from previous tutorials.
# Or ctrl+shift+p and choose "Remote-Containers: Reopen in Container"
36
+
# ctrl+shift+p and choose "Remote-Containers: Reopen in Container"
49
37
```
50
38
51
-
Note that if you do not see the prompt to reopen in the container, you can open
52
-
the `Remote` menu with `Ctrl+Alt+O` and select `Reopen in Container`.
53
-
54
-
The `build` script does two things.
55
-
56
-
- it fetches the git submodule called `ibek-support`. This submodule is shared between all the Generic IOC container images and contains the support YAML files that tell `ibek` how to build support modules inside the container environment and how to use them at runtime.
57
-
- it builds the Generic IOC container image developer target locally using docker or podman.
58
-
59
39
## Verify the Example IOC Instance is working
60
40
61
-
When a new Generic IOC developer container is opened, there are two things
62
-
that need to be done before you can run an IOC instance inside of it.
41
+
When a new Generic IOC developer container is opened, there are two things that need to be done before you can run an IOC instance inside of it.
63
42
64
43
- Build the IOC binary
65
44
- Select an IOC instance definition to run
66
45
67
-
The folder `ioc` inside of the `ioc-adsimdetector` is where the IOC source code resided. However our containers always make a symlink to this folder at `/epics/ioc`. This is so that it is always in the same place and can easily be found by ibek (and the developer!). Therefore you can build the IOC binary with the
68
-
following command:
46
+
The folder `ioc` inside of the `ioc-adsimdetector` is where the IOC source code resides. However our containers always make a symlink to this folder at `/epics/ioc`. This is so that it is always in the same place and can easily be found by ibek (and the developer!). Therefore you can build the IOC binary with the following command:
69
47
70
-
```console
48
+
```bash
71
49
cd /epics/ioc
72
50
make
73
51
```
74
52
75
-
The IOC instance definition is a YAML file that tells `ibek` what the runtime assets (ie. EPICS DB and startup script) should look like. Previous tutorials selected the IOC instance definition from a beamline repository. In this case we will use the example IOC instance that comes with `ioc-adsimdetector`. The following command will select the example IOC instance:
53
+
The IOC instance definition is a YAML file that tells `ibek` what the runtime assets (ie. EPICS DB and startup script) should look like. Previous tutorials selected the IOC instance definition from a beamline repository. In this case we will use the example IOC instance that comes with `ioc-adsimdetector`. It can be found in `services/bl01t-ea-ioc-02`. The following command will select the example IOC instance:
76
54
77
-
```console
78
-
ibek dev instance /workspaces/ioc-adsimdetector/services/bl01t-ea-test-02
55
+
```bash
56
+
ibek dev instance /workspaces/ioc-adsimdetector/services/bl01t-ea-ioc-02
79
57
```
80
58
81
-
The above command removes the existing config folder `/epics/ioc/config` and
82
-
symlinks in the chosen IOC instance definition's `config` folder.
59
+
The above command removes the existing config folder `/epics/ioc/config` and symlinks in the chosen IOC instance definition's `config` folder to `/epics/ioc/config`.
83
60
84
61
Now run the IOC:
85
62
86
-
```console
87
-
cd /epics/ioc
63
+
```bash
88
64
./start.sh
89
65
```
90
66
91
67
You should see an iocShell prompt and no error messages above.
92
68
93
-
Let us also make sure we can see the simulation images that the IOC is
94
-
producing. For this we need the `c2dv` tool that we used earlier. You
95
-
can use the same virtual environment that you created earlier, or create
96
-
a new one and install again. Note that these commands are to be run
97
-
in a terminal outside of the developer container.
69
+
Let us also make sure we can see the simulation images that the IOC is producing. For this we will use phoebus and we will create a screen to display the image. Previously we had a pre-defined screen from the template project for this - but this example IOC uses a different PV prefix so we need to create a new screen.
98
70
99
-
```console
100
-
python3 -m venv c2dv
101
-
source ~/c2dv/bin/activate
102
-
pip install c2dataviewer
71
+
From *outside of the developer container* start up phoebus and the ca-gateway as we did in earlier tutorials:
72
+
73
+
```bash
74
+
cd ioc-adsimdetector/compose
75
+
. ./environment.sh
76
+
ec up -d
103
77
```
104
78
105
-
Run the `c2dv` tool and connect it to our IOCs PVA output:
79
+
Phoebus should now be up and running and showing the auto generated **index.bob**, In phoebus do the following steps:
106
80
107
-
```console
108
-
c2dv --pv BL01T-EA-TST-02:PVA:OUTPUT &
109
-
```
81
+
- right click in the index.bob screen and choose "Open in editor"
82
+
- from the plots section of the widget pallet select "Image" and drag a rectangle for you image widget in the index.bob screen.
83
+
- in the properties pane
84
+
- deselect X and Y axis Visible checkboxes
85
+
- set PV Name to 'BL01T-EA-TST-02:ARR:ArrayData'
86
+
- set Title to 'SimDetector Image'
87
+
- set Data width and height to 1024
88
+
- choose File -> Save As and save as `/opi/demo.bob`
89
+
- click the 'Execute Display' green arrow button on the right of the top toolbar
110
90
111
-
Back inside the developer container, you can now start the detector and
112
-
the PVA plugin, by opening a new terminal and running the following:
91
+
IMPORTANT: you must save in `/opi` not `/opi/ioc` because the second folder has its contents cleared and filled with auto generated screens every time the IOC is started.
113
92
114
-
```console
115
-
caput BL01T-EA-TST-02:PVA:EnableCallbacks 1
93
+
Back inside the developer container, you can now start the detector and the Std Arrays plugin, by opening a new terminal and running the following:
94
+
95
+
```bash
96
+
caput BL01T-EA-TST-02:ARR:EnableCallbacks 1
116
97
caput BL01T-EA-TST-02:DET:Acquire 1
117
98
```
118
99
119
-
You should see the moving image in the `c2dv` window. We now have a working
100
+
You should see the moving image in the Phoebus window. We now have a working
120
101
IOC instance that we can use to test our changes.
121
102
103
+
104
+
:::{figure} ../images/phoebus2.png
105
+
Phoebus with image widget
106
+
:::
107
+
108
+
Note: the buttons to launch the engineering screens won't work right away because your new screen is in a different folder. To fix this, go back into the screen editor and add `ioc/` to the beginning of the `Display Path` in the `Open Display` action for each button.
109
+
122
110
## Making a change to the Generic IOC
123
111
124
112
One interesting way of changing a Generic IOC is to modify the support YAML
@@ -132,10 +120,10 @@ simulation detector is automatically started when the IOC starts.
132
120
133
121
To make this change we just need to have the startup script set the values
and add a `post_init` section just after the `pre_init` section:
140
128
141
129
```yaml
@@ -145,8 +133,8 @@ post_init:
145
133
dbpf {{P}}{{R}}Acquire 1
146
134
```
147
135
148
-
Next make a change to the file `ibek-support/ADCore/ADCore.ibek.support.yaml`.
149
-
Find the NDPvaPlugin section and also add a `post_init` section:
136
+
Next make a change to the file `/workspaces/ioc-adsimdetector/ibek-support/ADCore/ADCore.ibek.support.yaml`.
137
+
Find the NDStdArrays section and also add a `post_init` section:
150
138
151
139
```yaml
152
140
post_init:
@@ -155,19 +143,21 @@ post_init:
155
143
dbpf {{P}}{{R}}EnableCallbacks 1
156
144
```
157
145
146
+
The values that you add into entities like the above are rendered at runtime to make the startup script. The `{{P}}` and `{{R}}` are placeholders that are replaced with the PV prefix and record name of the IOC instance. They are rendered using Jinja 2 with a context that includes all of the values of the parameters in the entity. You can go and look at your rendered startup script in `/epics/runtime/st.cmd`.
147
+
158
148
If you now go to the terminal where you ran your IOC, you can stop it with
159
149
`Ctrl+C`and then start it again with `./start.sh`. You should see the
160
150
following output at the end of the startup log:
161
151
162
152
```console
163
153
dbpf BL01T-EA-TST-02:DET:Acquire 1
164
154
DBF_STRING: "Acquire"
165
-
dbpf BL01T-EA-TST-02:PVA:EnableCallbacks 1
155
+
dbpf BL01T-EA-TST-02:ARR:EnableCallbacks 1
166
156
DBF_STRING: "Enable"
167
157
epics>
168
158
```
169
159
170
-
You should also see the `c2dv` window update with the moving image again.
160
+
You should also see the demo window update with the moving image again.
171
161
172
162
If you wanted to publish these changes you would have to commit both the
173
163
`ibek-support`submodule and the `ioc-adsimdetector` repository and push
@@ -177,29 +167,31 @@ tutorials we will cover making forks and doing pull requests for when you have
177
167
changes to share back with the community.
178
168
179
169
Note: this is a slightly artificial example, as it would change the behaviour
180
-
for all instances of a PVA plugin and a simDetector. In a real IOC you would
170
+
for all instances of a StdArray plugin and a simDetector. In a real IOC you would
181
171
do this on a per instance basis.
182
172
183
173
Let us quickly do the instance YAML change to demonstrate the correct approach
184
174
to this auto-starting detector.
185
175
186
176
Undo the support yaml changes:
187
177
188
-
```console
178
+
```bash
189
179
cd /workspaces/ioc-adsimdetector/ibek-support
190
180
git reset --hard
191
181
```
192
182
183
+
If you restart the IOC now you will see that the detector does not start.
0 commit comments