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
This uses ibek-support 'recipes' to pull the two support modules from GitHub and builds them in our devcontainer. Now any IOC instances we run in the devcontainer will be able to use these support modules.
160
160
161
+
Having run the above commands you could look in **/epics/support** to see the additional built support modules.
162
+
161
163
Next, make sure that the next build of our `ioc-lakeshore340` container image will have the same support built in by updating the Dockerfile as follows:
162
164
163
165
```dockerfile
@@ -186,13 +188,9 @@ order to do so we must first add a recipe for it to `ibek-support`.
186
188
The `ibek-support` submodule is used to share information about how to build
187
189
and use support modules. It contains three kinds of files:
188
190
189
-
1. install.sh - These are used to fetch and build support modules. They are
190
-
run from the Dockerfile as described above.
191
-
2. IBEK support module `definitions`: These are used to help IOCs build their
192
-
iocShell boot scripts and EPICS Database from YAML descriptions.
193
-
3. PVI definitions: These are used to add structure to the set of PV's a
194
-
device exposes. This structure allows us to auto-generate engineering
195
-
screens for the device. See <https://github.com/epics-containers/pvi>.
191
+
1. install.sh - These are used to fetch and build support modules. They are run from the Dockerfile as described above.
192
+
2. IBEK support YAML: These are used to help IOCs build their iocShell boot scripts and EPICS Database from YAML descriptions. These are the files that contribute to the schema used when making an ioc.yaml instance file for this Generic IOC.
193
+
3. PVI definitions: These are used to add structure to the set of PV's a device exposes. This structure allows us to auto-generate engineering screens for the device. See <https://github.com/epics-containers/pvi>.
196
194
197
195
`ibek-support` is curated for security reasons, therefore we need to work with
198
196
a fork of it so we can add our own recipe for lakeshore340. If you make changes
@@ -219,13 +217,14 @@ cd ..
219
217
220
218
We are using the `tutorial-KEEP` branch which is a snapshot of the `ibek-support` state
221
219
appropriate for this tutorial. Normally you would use the `main` branch and
222
-
then create your own branch off of that to work in.
220
+
then create your own branch off of that to work in, therefore you could skip the `git checkout tutorial-KEEP` line and instead do `git checkout -b my-new-feature-branch; git push -u origin my-new-feature-branch`.
223
221
224
222
:::{note}
225
223
IMPORTANT: we used an *HTTPS* URL for the `ibek-support` submodule, not
226
224
a *SSH* URL. This is because other clones of `ioc-lakeshore340` will not
227
-
be guaranteed to have the required SSH keys. HTTPS is fine for reading, but
228
-
to write you need SSH. Therefore add the following to your `~/.gitconfig`:
225
+
be guaranteed to have the required SSH keys (i.e. when CI is running).
226
+
227
+
HTTPS is fine for reading, but to write you need SSH. Therefore add the following to your `~/.gitconfig`:
@@ -244,31 +243,31 @@ a particular commit (until updated with `git pull`) see
244
243
245
244
The first file we will create is the `install.sh` script for lakeshore340. This is a simple script that fetches the support module from GitHub and builds it.
246
245
247
-
These scripts draw heavily on the `ibek` tool to do tasks that most support modules require. They are also are as close to identical as possible for simple support modules.
246
+
These scripts draw heavily on the `ibek` tool to docommon tasks that most support modules require. They are also are as close to identical as possible for simple support modules. `ibek` commands allow us to have a simple, consistent structure for all support module's `install.sh` scripts.
248
247
249
248
IMPORTANT points to note are:
250
249
251
250
- Although we are using `ibek` we are really just automating what an EPICS engineer would do manually. This is very much using the vanilla EPICS build system that comes with EPICS base, along with the vanilla Make and Config files that come with each support module. These steps are:-
252
251
253
252
- make sure we have the necessary system dependencies installed
254
-
- fetch a version of the support module from GitHub
253
+
- fetch a version of the support module from GitHub or other source
255
254
- add a RELEASE.local to enable dependency resolution
256
255
- optionally add CONFIG_SITE.local to apply settings for the build environment
257
256
- run make to build the support module
258
-
- take a note of the dbds and libs that we build so that we can use them
259
-
to make our IOC instance later
257
+
- take a note of the dbds and libs that we build so that we can link them in to our Generic IOC build later
260
258
261
259
- This is a bash script so although we encourage a very standard structure,
262
260
you can do anything you like. For example this support module has to
263
261
compile a 3rd party library before it can build the support module itself.
# use the relatively simple calc install.sh as a template
270
+
cp calc/install.sh lakeshore340/install.sh
272
271
code lakeshore340/install.sh
273
272
```
274
273
@@ -278,21 +277,21 @@ The changes required for any support module you care to build would be:
278
277
279
278
- change the NAME variable to match the name of the support module
280
279
281
-
- add in`ibek support apt-install` lines for any system dependencies.
282
-
These can be for the developer stage or the runtime stage or both.
280
+
- add in `ibek support apt-install` lines for any build time system dependencies. Also add `ibek support add-runtime-packages` for any runtime dependencies (runs apt-get install in the runtime stage).
283
281
284
-
- change the `ibek support add-*` lines to declare the libs and DBDs
285
-
that this module will publish.
282
+
- change the `ibek support add-*` lines to declare the libs and DBDs that this module will publish. For this StreamDevice module we don't need to add any libs or DBDs.
286
283
287
-
- add extra release macros for RELEASE.local (the RELEASE macro for
288
-
the current support module is added automatically). Or add
289
-
CONFIG entries for CONFIG_SITE.local as required.
290
-
None of these were required for lakeshore340. To see how to use these
291
-
functions see
284
+
- add extra release macros for RELEASE.local (the RELEASE macro for the current support module is added automatically). Or add CONFIG entries for CONFIG_SITE.local as required. None of these were required for lakeshore340. To see how to use these functions see
292
285
293
286
- ibek support add-release-macro --help
294
287
- ibek support add-to-config-site --help
295
288
289
+
- occasionally we will use `sed` to modify files in the support module. In particular it is sometimes beneficial to comment out some of the lines in the root Makefile in order to skip over test and documentation building. This is donein the script below for the lakeshore340 documentation. Note that the sed command is idempotent, so it is safe to run the script more than once.
290
+
291
+
- To see all commands forassistingin building support modules see **ibek support --help**
292
+
293
+
- NOTE: all of the ibek support commands are idempotent. Therefore it is safe to run install.sh more than once. This is an advantage of using ibek instead of hand coding the build process.
# prepare *.bob, *.pvi, *.ibek.support.yaml for access outside the container.
327
326
ibek support generate-links ${FOLDER}
327
+
328
+
328
329
```
329
330
330
331
Having made these changes you can now test the script by running it:
@@ -354,43 +355,43 @@ an iocShell startup script and an EPICS Database. You can supply hand
354
355
crafted `st.cmd` and `ioc.subst` files for this purpose. The Generic IOC
355
356
we have made above is already capable of using such files.
356
357
357
-
For this exercise we will use the full capabilities of `ibek` to generate
358
-
these files from a YAML description of the IOC instance. To do this we need
359
-
to create a YAML file that describes what the instance YAML is allowed to
360
-
make.
358
+
For this exercise we will use the full capabilities of `ibek` to generate these files from a YAML description of the IOC instance. To do this we need to create a Support YAML file that describes what the instance YAML is allowed to make.
361
359
362
-
TODO: a detailed description of the YAML files' structure and purpose should
360
+
The advantage of using YAML to describe your instances is that there is a considerable amount of validation that can be done on the YAML file to ensure that it is correct. Checking is done at the time of writing the YAML file, using a schema aware editor. More extensive checks are donein the CI of your services project when you push your IOC instance definition changes. Also, much of the complexity of using a given support module can be managed in a single place by the author of the YAML file.
361
+
362
+
**TODO**: a detailed description of the YAML files' structure and purpose should
363
363
be included in the `ibek` documentation and linked here.
To create an `ibek` support YAML file we need to provide a list of `definitions` .
369
-
Each `definition` gives:
368
+
To create an `ibek` support YAML file we need to provide a list of `entity_models` .
369
+
Each `entity_model` gives:
370
370
371
-
- a name and description for the `definition`
371
+
- a name and description for the `entity_model`
372
372
373
-
- a list of arguments that an
374
-
instance of this `definition` may supply, with each having:
373
+
- a list of parameters that an instance of this type of `entity` may supply, with each having:
375
374
376
375
- a type (string, integer, float, boolean, enum)
377
376
- a name
378
377
- a description
379
378
- optionally a default value
380
379
381
-
- A list of database templates to instantiate for each instance of this `definition`
380
+
- A list of database templates to instantiate for each instance of this `entity`
382
381
\- including values for the Macros in the template
383
382
384
383
- A list of iocShell command line entries to add before or after `iocInit`
385
384
386
385
In all of the fields Jinja templating can be used to combine the values of
387
386
arguments into the final output. At its simplest this is just the name of
388
-
an argument in double curly braces e.g. `{{argument_name}}`. But, it can
387
+
an argument in double curly braces e.g. `{{parameter_name}}`. But, it can
389
388
also be used to do more complex things as a Python interpreter is evaluating
390
389
the text inside the curly braces and that interpreter has the values of
391
-
all the `definition` arguments available in its context.
390
+
all the `entity` arguments available in its context.
392
391
See <https://jinja.palletsprojects.com/en/3.0.x/templates/>
393
392
393
+
**TODO**: `ibek` also needs detailed documentation of the interfaces available to the Jinja interpreter. This is to include order of evaluation, what is available in the context, etc.
394
+
394
395
:::{note}
395
396
IMPORTANT: the file created below MUST have the suffix `.ibek.support.yaml`.
396
397
This means it is a support yaml file for `ibek`. This is important because
@@ -412,68 +413,64 @@ contents:
412
413
413
414
module: lakeshore340
414
415
415
-
defs:
416
+
entity_models:
416
417
- name: lakeshore340
417
418
description: |-
418
419
Lakeshore 340 Temperature Controller
419
420
Notes: The temperatures in Kelvin are archived once every 10 secs.
# use a regex to say that we want all the parameters in the template
468
+
# this is equivalent to {P: '{{P}}', PORT: '{{PORT}}', ADDR: '{{ADDR}}', SCAN: '{{SCAN}}', TEMPSCAN: '{{TEMPSCAN}}', name: '{{name}}', LOOP: '{{LOOP}}'}
469
+
args:
470
+
.*:
474
471
```
475
472
476
-
This file declares a list of arguments, one for each of the database template
473
+
This file declares a list of parameters, one for each of the database template
477
474
macros that it needs to substitute. It then declares that we need to instantiate
478
475
the `lakeshore340.template` database template and passes all of the arguments
479
476
verbatim to the template.
@@ -515,7 +512,7 @@ When a Generic IOC is built, each support module will register its support YAML
515
512
516
513
This registration process happens as part of the `install.sh` script for the support module. It is done by the `ibek support generate-links` command.
517
514
518
-
Here we just need to go ahead and re-run our `install.sh` script to register the lakeshore340 support YAML that we just created:
515
+
Here we just need to go ahead and re-run our `install.sh` script to register the lakeshore340 support YAML that we just created. Because the ibek support commands are idempotent it is safe to run the `install.sh` script more than once.
519
516
520
517
```bash
521
518
cd /workspaces/ioc-lakeshore340/ibek-support
@@ -573,11 +570,15 @@ Add the following contents to the new yaml file:
description: auto-generated by https://github.com/epics-containers/builder2ibek
575
+
description: example IOC for testing lakeshore340
579
576
580
577
entities:
578
+
- type: epics.EpicsEnvSet
579
+
name: EPICS_TZ
580
+
value: GMT0BST
581
+
581
582
- type: devIocStats.iocAdminSoft
582
583
IOC: "{{ ioc_name | upper }}"
583
584
@@ -595,9 +596,9 @@ entities:
595
596
name: lakeshore
596
597
```
597
598
598
-
The above YAML file declares an IOC instance that has the following 3
599
-
`entities` (which is what we call instances of `definitions`in`ibek`):
599
+
The above YAML file declares an IOC instance that has the following 4 `entities` (which is what we call instances of `entity_models`in`ibek`):
600
600
601
+
- A EpicsEnvSet entity that sets the timezone for the IOC (because the compiled IOC is Generic - all instances need to set the timezone).
601
602
- A devIocStats object that will supply monitoring PVs
602
603
- An asyn IP port that will be used to talk to the simulator
603
604
- A lakeshore340 object that will talk to the simulator via the asyn port
@@ -671,14 +672,7 @@ you can:
671
672
672
673
For the final step we will get the Generic IOC container image published to GHCR. This means committing all our changes and pushing them up to GitHub so that the Continuous Integration system can build the container image and publish it.
673
674
674
-
Before we do that we need to make sure our changes we have manually made inside the developer container will be applied at container build time. There is one thing we have done that is not yet added to the Dockerfile. That is the building of the lakeshore support module itself. Therefore we need to add the following lines to the Dockerfile just after the install of the `asyn` and `StreamDevice` support modules:
675
-
676
-
```dockerfile
677
-
COPY ibek-support/lakeshore340/ lakeshore340/
678
-
RUN lakeshore340/install.sh 2-6-2
679
-
```
680
-
681
-
These commands will do the same install we did manually above. They rely on our new additions to the `ibek-support` submodule which shows that it is important to commit the submodule changes first before we push ioc-lakeshore340 repository to GitHub.
675
+
Before we do that we need to make sure our changes we have manually made inside the developer container will be applied at container build time.
682
676
683
677
Perform the following commands to commit and push the changes:
0 commit comments