@@ -181,7 +181,7 @@ done to make the build cache more efficient and speed up development.
181
181
For example we could copy everything out of the ibek-support directory
182
182
in a single command but then if I changed a StreamDevice ibek-support file the
183
183
build would have to re-fetch and re-make all the support modules. By
184
- only copying the files we are about to use in the next step we can,
184
+ only copying the files we are about to use in the next step we can
185
185
massively increase the build cache hit rate.
186
186
187
187
.. note ::
@@ -302,7 +302,7 @@ To make your lakeshore340 install.sh script:
302
302
cp devIocStats/install.sh lakeshore340/install.sh
303
303
code install.sh
304
304
305
- Now edit the install.sh script to look like the following code block.
305
+ Now edit the install.sh script to look like the code block below .
306
306
307
307
The changes required for any support module you care to build would be:
308
308
@@ -314,8 +314,9 @@ The changes required for any support module you care to build would be:
314
314
- add extra release macros for RELEASE.local (the RELEASE macro for
315
315
the current support module is added automatically). Or add
316
316
CONFIG entries for CONFIG_SITE.local as required.
317
- None were required for lakeshore340. To see how to use these
318
- functions see:
317
+ None of these were required for lakeshore340. To see how to use these
318
+ functions see
319
+
319
320
- ibek support add-release-macro --help
320
321
- ibek support add-to-config-site --help
321
322
@@ -356,15 +357,15 @@ Having made these changes you can now test the script by running it:
356
357
357
358
cd /workspaces/ioc-lakeshore340/ibek-support
358
359
chmod +x lakeshore340/install.sh
359
- lakeshore340/install.sh 2-6-1
360
+ lakeshore340/install.sh 2-6-2
360
361
361
362
You now have lakeshore340 support in your developer container. Let's go ahead
362
363
and add that into the Dockerfile:
363
364
364
365
.. code-block :: dockerfile
365
366
366
367
COPY ibek-support/lakeshore340/ lakeshore340/
367
- RUN lakeshore340/install.sh 2-6-1
368
+ RUN lakeshore340/install.sh 2-6-2
368
369
369
370
This means you can compile an IOC with lakeshore340 support in this container
370
371
but we don't yet have a way to generate startup scripts and EPICS Databases
@@ -389,18 +390,19 @@ The current version of this is here
389
390
https://epics-containers.github.io/ibek/main/developer/explanations/entities.html
390
391
but it is rather out of date.
391
392
392
- To create a ibek support YAML file we need to provide a list of ``definitions `` .
393
+ To create an `` ibek `` support YAML file we need to provide a list of ``definitions `` .
393
394
Each ``definition `` gives:
394
395
395
- - a name and description for the ``definitions ``- a list of arguments that an
396
- instance of this ``definitions `` may supply with each having:
396
+ - a name and description for the ``definition ``
397
+ - a list of arguments that an
398
+ instance of this ``definition `` may supply, with each having:
397
399
398
400
- a type (string, integer, float, boolean, enum)
399
401
- a name
400
402
- a description
401
403
- optionally a default value
402
404
403
- - A list of database templates to instantiate for each instance of this ``definitions ``
405
+ - A list of database templates to instantiate for each instance of this ``definition ``
404
406
- including values for the Macros in the template
405
407
406
408
- A list of iocShell command line entries to add before or after ``iocInit ``
@@ -410,7 +412,7 @@ arguments into the final output. At its simplest this is just the name of
410
412
an argument in double curly braces e.g. ``{{argument_name}} ``. But, it can
411
413
also be used to do more complex things as a Python interpreter is evaluating
412
414
the text inside the curly braces and that interpreter has the values of
413
- all the ``definitions `` arguments available in its context.
415
+ all the ``definition `` arguments available in its context.
414
416
See https://jinja.palletsprojects.com/en/3.0.x/templates/
415
417
416
418
To make a lakeshore340 YAML file, put the following contents in a file called
@@ -488,7 +490,7 @@ the ``lakeshore340.template`` database template and passes all of the arguments
488
490
verbatim to the template.
489
491
490
492
Finally it declares that we need to add a line to the iocShell startup script
491
- that allows the IOC to find the modules StreamDevice protocol files.
493
+ that allows the IOC to find the module's StreamDevice protocol files.
492
494
493
495
Note that in the list of DB args or in the startup lines we can use combinations
494
496
of arguments to make the final output.
@@ -502,12 +504,174 @@ e.g. to make a more descriptive PV prefix we could use:
502
504
args :
503
505
P : " {{P + ':' + name + ':'}}"
504
506
507
+ Finally, also note that the top line refers to a schema file. This is the global
508
+ ``ibek `` schema for support module definition YAML. A single schema is used
509
+ for all support modules and is published along side the latest release of ``ibek ``.
510
+ This means that a schema aware editor can provide auto-completion and validation
511
+ for your support module YAML files. The VSCode extension here
512
+ https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml
513
+ adds this capability.
514
+
505
515
.. note ::
506
516
507
517
Because this is a DLS module originally, it has an ``etc/builder.py `` file
508
- that is used by the ``XML Builder `` tool. ``ibek `` has a converter tool
518
+ that is used by the ``XML Builder `` tool. ``ibek `` has a converter
509
519
that will translate this file into an ``ibek `` YAML file. Only DLS users
510
520
can take advantage of this because it needs access to all the dependent
511
521
DLS support module forks to work. See `../how-to/builder2ibek.support `
512
522
523
+ Example IOC instance
524
+ --------------------
525
+
526
+ In order to test our Generic IOC we now require an IOC instance to launch it.
527
+ For this exercise we will build an example instance right into the Generic IOC.
528
+ This is a great way to allow developers to experiment with the container,
529
+ but it is most likely to require a simulation of some kind to take the place
530
+ of a real piece of hardware for the instance to talk to.
531
+
532
+ Before creating the instance it is useful to have a schema for the YAML we
533
+ are about to write. To generate a schema for this specific Generic IOC
534
+ perform the following command:
535
+
536
+ .. code-block :: bash
537
+
538
+ ibek ioc generate-schema > /tmp/ibek.ioc.schema.json
539
+
540
+ This will make a schema that allows declaration of instances of the
541
+ definitions defined in the support YAML file we made above. But ALSO combines
542
+ in the definitions from the ``devIocStats `` support module and all other
543
+ modules that have been built inside this container.
544
+
545
+ Once this repository is published to GitHub, the schema will be available
546
+ as part of the release at the following URL:
547
+
548
+ .. code-block ::
549
+
550
+ https://github.com/<YOUR GITHUB ACCOUNT>/ioc-lakeshore340/releases/download/<VERSION TAG>/ibek.ioc.schema.json
551
+
552
+ This would then be the URL you would put at the top of any IOC instances using
553
+ your released Generic IOC.
554
+
555
+ To create the instance we create a folder:
556
+
557
+ /workspaces/ioc-lakeshore340/ioc-examples/bl16i-ea-ioc-07/config/
558
+
559
+ and create a file in there called:
560
+
561
+ bl16i-ea-ioc-07.yaml
562
+
563
+ with the following contents:
564
+
565
+ .. code-block :: yaml
566
+
567
+ # yaml-language-server: $schema=/tmp/ibek.ioc.schema.json
568
+
569
+ ioc_name : " {{ ioc_yaml_file_name }}"
570
+
571
+ description : auto-generated by https://github.com/epics-containers/builder2ibek
572
+
573
+ entities :
574
+ - type : devIocStats.iocAdminSoft
575
+ IOC : " {{ ioc_name | upper }}"
576
+
577
+ - type : asyn.AsynIP
578
+ name : p1
579
+ port : 127.0.0.1:5401
580
+
581
+ - type : lakeshore340.lakeshore340
582
+ ADDR : 12
583
+ LOOP : 2
584
+ P : BL16I-EA-LS340-01
585
+ PORT : p1
586
+ SCAN : 5
587
+ TEMPSCAN : 2
588
+ name : lakeshore
589
+
590
+
591
+ The above YAML file declares an IOC instance that has the following 3
592
+ ``entities `` (which is what we call instances of ``definitions `` in ``ibek ``):
593
+
594
+ - A devIocStats object that will supply monitoring PVs
595
+ - An asyn IP port that will be used to talk to the simulator
596
+ - A lakeshore340 object that will talk to the simulator via the asyn port
597
+
598
+ This instance is now ready to run inside the developer container. To do so
599
+ perform the following steps:
600
+
601
+ .. code-block :: bash
602
+
603
+ cd /epics/support/lakeshore340/etc/simulations/
604
+ ./lakeshore340_sim.py
605
+
606
+ Now create a new terminal in VSCode (Terminal -> New Terminal) and run:
607
+
608
+ .. code-block :: bash
609
+
610
+ ibek dev instance /workspaces/ioc-lakeshore340/ioc-examples/bl16i-ea-ioc-07
611
+ cd /epics/ioc
612
+ make
613
+ ./start.sh
614
+
615
+ If all is well then you should see the IOC start up and connect to the
616
+ simulator. You will see the simulator logging the queries it receives.
617
+
618
+ TODO: it is possible to launch the bob file in:
619
+
620
+ /epics/support/lakeshore340/lakeshore340App/opi/bob/lakeshore340.bob
621
+
622
+ to see a GUI for this IOC instance. However, I'm reserving writing about
623
+ GUI until I have the PVI integration done on this module and we can see
624
+ the auto-generated GUI.
625
+
626
+ To investigate what ``ibek `` did to make the Generic IOC binary and the
627
+ IOC instance files, take a look at the following files.
628
+
629
+ - ``/epics/runtime `` - the runtime assets created from a combination of the
630
+ instance YAML and all the referenced support YAML
631
+
632
+ - ``/epics/ioc/iocApp/Makefile `` - this picks up the libs and DBDs from the
633
+ support module builds which record their dbds and libs in:
634
+
635
+ - ``/epics/support/configure/dbd_list ``
636
+ - ``/epics/support/configure/lib_list ``
637
+
638
+ - ``/epics/ioc/support/configure/RELEASE `` - a global release file that contains
639
+ macros for all the support built in the container. This is soft linked
640
+ to ``configure/RELEASE.local `` in each support module.
641
+
642
+ - ``/epics/support/configure/RELEASE.shell `` - created along with the global
643
+ release file. Sets all the release macros as shell environment variables
644
+ for passing into the ioc startup script.
645
+
646
+ .. note ::
647
+
648
+ Because this IOC instance is a copy of a real IOC at DLS it comes
649
+ from a builder XML file originally. DLS users with builder beamlines
650
+ can use ``builder2ibek `` to convert their builder XML files into
651
+ ``ibek `` YAML IOC instance files. See `../how-to/builder2ibek `.
652
+ Note this is distinct from making support YAML files with
653
+ ``builder2ibek.support ``.
654
+
655
+ Experimenting With Changes to the IOC Instance and Generic IOC
656
+ --------------------------------------------------------------
657
+
658
+ Inside the developer container you can add and remove support, change the
659
+ IOC instance YAML file and re-build the IOC instance until everything is
660
+ working as you want it to. At that point you can push the changes to GitHub
661
+ and the CI should build a container image. Once that has succeeded you can
662
+ tag the release and the CI will publish the container image to GHCR.
663
+
664
+ Note that building the IOC binary is required after any change to the set
665
+ of support modules inside this container. However it is not required after
666
+ changes to the IOC instance YAML file. If you want to change the instance
667
+ you can:
668
+
669
+ - edit the YAML file
670
+ - stop the IOC
671
+ - start the IOC with ``./start.sh ``
672
+ - that's it
673
+
674
+
675
+
676
+
513
677
0 commit comments