@@ -20,8 +20,8 @@ Some of the reasons for doing this are:
20
20
want to add support for a second device, this is allowed but you should
21
21
consider the alternative of creating a new Generic IOC.
22
22
If you keep your Generic IOCs simple and focused on a single device, they
23
- will be smaller and there will be less of them. IOCs can still be
24
- linked via CA and this is preferable to recompiling a Generic IOC
23
+ will be smaller and there will be less of them. IOCs' records can still be
24
+ linked via CA links and this is preferable to recompiling a Generic IOC
25
25
for every possible combination of devices. Using Kubernetes to
26
26
manage multiple small services is cleaner than having a handful of
27
27
monolithic services.
@@ -31,8 +31,8 @@ This tutorial will make some changes to the generic IOC ``ioc-adsimdetector``
31
31
that you already used in earlier tutorials.
32
32
33
33
For this exercise we will work locally inside the ``ioc-adsimdetector ``
34
- developer container. To discover how to fork repositories and push changes
35
- back to GitHub
34
+ developer container. Following tutorials will show how to fork repositories
35
+ and push changes back to GitHub
36
36
37
37
For this exercise we will be using an example IOC Instance to test our changes.
38
38
Instead of working with a beamline repository, we will use the example ioc instance
@@ -62,14 +62,17 @@ The ``build`` script does two things.
62
62
- it fetches the git submodule called ``ibek-support ``. This submodule is shared
63
63
between all the EPICS IOC container images and contains the support YAML files
64
64
that tell ``ibek `` how to build support modules inside the container
65
- environment.
65
+ environment and how to use them at runtime .
66
66
- it builds the Generic IOC container image locally.
67
67
68
68
.. note ::
69
69
70
70
The ``build `` script is a convenience script that is provided in the
71
71
Generic IOC Template project. It is exactly equivalent to cloning
72
- with ``--recursive `` flag and then running ``ec dev build ``.
72
+ with ``--recursive `` flag and then running ``ec dev build ``. Equally,
73
+ opening a vscode dev container will also build the container for you, but it
74
+ does require the ``ibek-support `` submodule to be present - using
75
+ ``--recursive `` flag to git clone ensures this.
73
76
74
77
Verify the Example IOC Instance is working
75
78
------------------------------------------
@@ -81,9 +84,9 @@ that need to be done before you can run an IOC instance inside of it.
81
84
- Select an IOC instance definition to run
82
85
83
86
The folder ``ioc `` inside of the ``ioc-adsimdetector `` is where the IOC source code
84
- resided. However the devcontainer always makes a symlink to this folder at
87
+ resided. However our containers always make a symlink to this folder at
85
88
``/epics/ioc ``. This is so that it is always in the same place and can easily be
86
- found by ibek and the developer. Therefore you can build the binary with the
89
+ found by ibek ( and the developer!) . Therefore you can build the binary with the
87
90
following command:
88
91
89
92
.. code-block :: console
@@ -98,8 +101,7 @@ following command:
98
101
source code built by its Dockerfile (``ioc-adsimdetector/Dockerfile ``
99
102
contains the same command).
100
103
101
- For a detailed explanation of why this is the case see
102
- `ioc-source `
104
+ For a detailed explanation of why this is the case see `ioc-source `
103
105
104
106
The IOC instance definition is a YAML file that tells ``ibek `` what the runtime
105
107
assets (ie. EPICS DB and startup script) should look like. Previous tutorials
@@ -109,11 +111,9 @@ following command will select the example IOC instance:
109
111
110
112
.. code-block :: console
111
113
112
- ibek dev instance /epics /ioc-adsimdetector/ioc_examples/bl01t-ea-ioc-02
114
+ ibek dev instance /workspaces /ioc-adsimdetector/ioc_examples/bl01t-ea-ioc-02
113
115
114
- In an earlier tutorial when learning about the dev container, we manually
115
- performed this step, see `choose-ioc-instance `. The above command does
116
- exactly the same thing: removes the existing config folder in ``/epics/ioc ``
116
+ The above command removes the existing config folder ``/epics/ioc/config `` and
117
117
and symlinks in the chosen IOC instance definition's ``config `` folder.
118
118
119
119
Now run the IOC:
@@ -124,3 +124,124 @@ Now run the IOC:
124
124
./start.sh
125
125
126
126
You should see an iocShell prompt and no error messages above.
127
+
128
+ Let us also make sure we can see the simulation images that the IOC is
129
+ producing. For this we need the ``cd2v `` tool that we used earlier. You
130
+ can use the same virtual environment that you created earlier, or create
131
+ a new one and install again. Note that these commands are to be run
132
+ in a terminal outside of the developer container.
133
+
134
+ .. code-block :: console
135
+
136
+ python3 -m venv cd2v
137
+ source ~/cd2v/bin/activate
138
+ pip install c2dataviewer
139
+
140
+ Run the ``cd2v `` tool and connect it to our IOCs PVA output:
141
+
142
+ .. code-block :: console
143
+
144
+ cd2v --pv BL01T-EA-TST-02:PVA:OUTPUT &
145
+
146
+
147
+ Back inside the developer container, you can now start the detector and
148
+ the PVA plugin, by opening a new terminal and running the following:
149
+
150
+ .. code-block :: console
151
+
152
+ caput BL01T-EA-TST-02:PVA:EnableCallbacks 1
153
+ caput BL01T-EA-TST-02:CAM:Acquire 1
154
+
155
+ You should see the moving image in the ``cd2v `` window. We now have a working
156
+ IOC instance that we can use to test our changes.
157
+
158
+ Making a change to the Generic IOC
159
+ ----------------------------------
160
+
161
+ One interesting way of changing a Generic IOC is to modify the support YAML
162
+ for one of the support modules. The support YAML describes the ``entities `` that
163
+ an IOC instance can make use of in its instance YAML file. This will be
164
+ covered in much more detail in `generic_ioc `.
165
+
166
+ For this exercise we will make a change to the ``ioc-adsimdetector `` support
167
+ YAML file. We will change the startup script that it generates so that the
168
+ simulation detector is automatically started when the IOC starts.
169
+
170
+ To make this change we just need to have the startup script set the values
171
+ of the records ``BL01T-EA-TST-02:CAM:Acquire `` and
172
+ ``BL01T-EA-TST-02:PVA:EnableCallbacks `` to 1.
173
+
174
+ To make this change, open the file
175
+ ``ibek-support/ADSimDetector/ADSimDetector.ibek.support.yaml ``
176
+ and add a ``post_init `` section just after the ``pre_init `` section:
177
+
178
+ .. code-block :: yaml
179
+
180
+ post_init :
181
+ - type : text
182
+ value : |
183
+ dbpf {{P}}{{R}}Acquire 1
184
+
185
+ Next make a change to the file ``ibek-support/ADCore/ADCore.ibek.support.yaml ``.
186
+ Find the NDPvaPlugin section and also add a ``post_init `` section:
187
+
188
+ .. code-block :: yaml
189
+
190
+ post_init :
191
+ - type : text
192
+ value : |
193
+ dbpf {{P}}{{R}}EnableCallbacks 1
194
+
195
+
196
+ If you now go to the terminal where you ran your IOC, you can stop it with
197
+ ``Ctrl+C `` and then start it again with ``./start.sh ``. You should see the
198
+ following output at the end of the startup log:
199
+
200
+ .. code-block :: console
201
+
202
+ dbpf BL01T-EA-TST-02:CAM:Acquire 1
203
+ DBF_STRING: "Acquire"
204
+ dbpf BL01T-EA-TST-02:PVA:EnableCallbacks 1
205
+ DBF_STRING: "Enable"
206
+ epics>
207
+
208
+ You should also see the ``cd2v `` window update with the moving image again.
209
+
210
+ If you wanted to publish these changes you would have to commit both the
211
+ ``ibek-support `` submodule and the ``ioc-adsimdetector `` repository and push
212
+ them in that order because of the sub-module dependency. But we won't be
213
+ pushing these changes as they are just for demonstration purposes. In later
214
+ tutorials we will cover making forks and doing pull requests for when you have
215
+ changes to share back with the community.
216
+
217
+ Note: this is a slightly artificial example, as it would change the behaviour
218
+ for all instances of a PVA plugin and a simDetector. In a real IOC you would
219
+ do this on a per instance basis.
220
+
221
+ Let us quickly do the instance YAML change to demonstrate the correct approach
222
+ to this auto-starting detector.
223
+
224
+ Undo the support yaml changes:
225
+
226
+ .. code-block :: console
227
+
228
+ cd /workspaces/ioc-adsimdetector/ibek-support
229
+ git reset --hard
230
+
231
+ Add the following to
232
+ ``/workspaces/ioc-adsimdetector/ioc_examples/bl01t-ea-ioc-02/config/ioc.yaml ``:
233
+
234
+ .. code-block :: yaml
235
+
236
+ - type : epics.dbpf
237
+ pv : BL01T-EA-TST-02:CAM:Acquire
238
+ value : " 1"
239
+
240
+ - type : epics.dbpf
241
+ pv : BL01T-EA-TST-02:PVA:EnableCallbacks
242
+ value : " 1"
243
+
244
+ Now restart the IOC and you should see the same behaviour as before. Here
245
+ we have made the change on a per instance basis, and used the ``dbpf `` entity
246
+ declared globally in ``ibek-support/_global/epics.ibek.support.yaml ``.
247
+
0 commit comments