Change a Support Module#
In Create a Generic IOC you wrapped an existing support module, ADSimDetector,
without changing its source. This tutorial changes the source of the module
itself, the most common type 3 change from Types of change: add a
record, fix a driver bug, expose a new parameter. You build the change in the
developer container of the Generic IOC with ibek dev support, test it, publish
it, and point the module’s ibek-support recipe at the release that holds it.
The worked example adds a record to ADSimDetector in the ioc-adsim-demo
project from Create a Generic IOC. The same steps work for any module that a
Generic IOC builds. The last section starts a brand-new module the same way.
How a Generic IOC Developer Container Works explains what the commands do in more detail (see Working on a support module).
Before you start#
Open the ioc-adsim-demo project in its developer container, as in
Create a Generic IOC. ibek dev support needs ibek 4.12.0 or later in the
container:
# in the container
ibek --version
If it is earlier, follow The ibek version first.
Build the module from a clone#
In a terminal in the container:
# in the container
ibek dev support ADSimDetector
The command:
clones the repository named in
ibek-support/ADSimDetector/ADSimDetector.install.ymlto/workspaces/ADSimDetector, at itsversion,R2-11. On the host that folder is next to yourioc-adsim-demofolder;removes the
ADSimDetectorthat the image built and links/epics/support/ADSimDetectorto the clone;builds
ADSimDetector, the modules after it in theDockerfile, and the IOC.
It ends with the comparison of the container with the project, which says
that ADSimDetector is linked to its clone. Add /workspaces/ADSimDetector to the
VSCode workspace (File -> Add Folder to Workspace) to edit it.
The build leaves its mark on the clone. The files it makes are hidden from
git status, by the module’s .gitignore or, where that does not cover them,
by the clone’s .git/info/exclude. It also edits configure/RELEASE so that the module builds against the
other modules in the container. That edit shows in git status: do not commit
it.
Change the source#
Add a record to the end of
/workspaces/ADSimDetector/simDetectorApp/Db/simDetector.template:
record(stringin, "$(P)$(R)Greeting")
{
field(VAL, "Hello from my ADSimDetector")
}
Build the module again, with the modules after it and the IOC:
# in the container
ibek dev support ADSimDetector
Run the same command after each change to the source.
Test it#
Run the instance from Create a Generic IOC:
ibek dev instance /workspaces/t01-services/services/bl01t-ea-cam-01
cd /epics/ioc
./start.sh
At the epics> prompt, find the record and read it:
epics> dbgrep "*Greeting"
epics> dbgf <the record name that dbgrep printed>
dbgf prints Hello from my ADSimDetector. Stop the IOC with Ctrl-D.
Publish the change#
An ibek-support recipe builds a module from a git repository at a given
version, so the change needs a release in a repository before a Generic IOC
image can build it. You cannot push to areaDetector/ADSimDetector, so fork it
on GitHub and push the change to your fork. Commit only your own change, not
the edit to configure/RELEASE:
# in the container
cd /workspaces/ADSimDetector
git checkout -b greeting
git add simDetectorApp/Db/simDetector.template
git commit -m "Add a Greeting record"
git remote add fork <YOUR FORK HTTPS URL>
git push fork greeting
git tag R2-11-greeting
git push fork R2-11-greeting
For a change that others need too, open a pull request at the module’s own repository, and point the recipe at the release that includes it once the maintainers make one. For the tutorial, the tag in your fork will do.
Point the recipe at the tag. Edit
ibek-support/ADSimDetector/ADSimDetector.install.yml in the project:
version: R2-11-greeting
organization: https://github.com/<YOUR GITHUB USER>/
Build the release#
Stop building from the clone, and build the version of the recipe instead:
# in the container
ibek dev support --release ADSimDetector
ibek dev sync --build
--release removes the link to the clone and builds nothing; the clone stays
on the host. ibek dev sync --build then clones ADSimDetector at
R2-11-greeting from your fork and builds it, the modules after it and the
IOC, as the image build will. Run the instance again to check that the record
is there.
Commit the recipe in your ibek-support fork, commit the new submodule commit
in ioc-adsim-demo, push both and release the Generic IOC, as in
Publish the Generic IOC.
Start a brand-new module#
A new support module is worked on in the same way, once it has a repository and a minimal recipe:
Create the module’s repository, for example
mymoduleon GitHub, with at least one commit on its default branch, such as a README.In the project’s
ibek-support, writeibek-support/mymodule/mymodule.install.yml:# yaml-language-server: $schema=../_scripts/support_install_variables.json module: mymodule version: main organization: https://github.com/<YOUR GITHUB USER>/
and add the module to the project’s
Dockerfile, after the modules it depends on (see Add the module to the Dockerfile):COPY ibek-support/mymodule/ mymodule RUN ansible.sh mymodule
Clone the repository to
/workspaces/mymoduleand lay out the EPICS source there.makeBaseApp.pl, from EPICS base, makes a support module layout:# in the container cd /workspaces git clone https://github.com/<YOUR GITHUB USER>/mymodule.git cd mymodule makeBaseApp.pl -t support mymodule git add . git commit -m "EPICS support module layout"
Commit the layout before the first build, so that
git statusshows the build’s edits toconfigure/RELEASEand you leave them out of your commits.Build it from the clone, which
ibek dev supportuses because its remote is the repository of the recipe:ibek dev support mymodule
Add the
dbdsandlibsthat the module installs to itsinstall.yml(see Create a Generic IOC) as the source comes to install them: the layout installs no library until it has source files. Write itsmymodule.ibek.support.yaml, then work on the source as above.
Warning
The order of the <module>_DBD lines in *App/src/Makefile matters. List each
DBD file after the DBD files it depends on, or the Generic IOC build fails. See
DBD files must be combined in the correct order.
Commit the source, without the build’s edits to configure/RELEASE, tag a
release, and set the recipe’s version to that tag
before you release the Generic IOC.
A new module has no published Generic IOC release yet, so there is no online schema for its example instance to validate against. Generate one in the container from the definitions that the container has linked:
ibek ioc generate-schema > /tmp/ibek.ioc.schema.json
and point the example instance’s schema line at that file until the Generic IOC is released:
# yaml-language-server: $schema=/tmp/ibek.ioc.schema.json