Skip to content

Commit

Permalink
move all runtime assets to /epics/runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 9, 2023
1 parent 90c6c93 commit bc4b5f8
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/ibek/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

# UIs and templates generated at runtime
OPI_OUTPUT_PATH = EPICS_ROOT / "opi"
PVI_OUTPUT_PATH = EPICS_ROOT / "pvi"
RUNTIME_OUTPUT_PATH = EPICS_ROOT / "runtime"

IOC_DBDS = SUPPORT / "configure/dbd_list"
IOC_LIBS = SUPPORT / "configure/lib_list"
Expand Down
17 changes: 11 additions & 6 deletions src/ibek/runtime_cmds/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from pvi.device import Device

from ibek.gen_scripts import create_boot_script, create_db_script, ioc_deserialize
from ibek.globals import OPI_OUTPUT_PATH, PVI_DEFS, PVI_OUTPUT_PATH, NaturalOrderGroup
from ibek.globals import (
OPI_OUTPUT_PATH,
PVI_DEFS,
RUNTIME_OUTPUT_PATH,
NaturalOrderGroup,
)
from ibek.ioc import IOC, Entity
from ibek.support import Database

Expand All @@ -27,11 +32,11 @@ def generate(
..., help="The filepath to a support module definition file"
),
out: Path = typer.Option(
default="config/st.cmd",
default=RUNTIME_OUTPUT_PATH / "st.cmd",
help="Path to output startup script",
),
db_out: Path = typer.Option(
default="config/ioc.subst",
default=RUNTIME_OUTPUT_PATH / "ioc.subst",
help="Path to output database expansion shell script",
),
):
Expand All @@ -41,8 +46,8 @@ def generate(
ioc_instance = ioc_deserialize(instance, definitions)

# Clear out generated files so developers know if something stop being generated
shutil.rmtree(PVI_OUTPUT_PATH, ignore_errors=True)
PVI_OUTPUT_PATH.mkdir(exist_ok=True)
shutil.rmtree(RUNTIME_OUTPUT_PATH, ignore_errors=True)
RUNTIME_OUTPUT_PATH.mkdir(exist_ok=True)
shutil.rmtree(OPI_OUTPUT_PATH, ignore_errors=True)
OPI_OUTPUT_PATH.mkdir(exist_ok=True)

Expand Down Expand Up @@ -97,7 +102,7 @@ def generate_pvi(ioc: IOC) -> Tuple[List[IndexEntry], List[Tuple[Database, Entit

if entity_pvi.pva:
# Create a template with the V4 structure defining a PVI interface
output_template = PVI_OUTPUT_PATH / f"{device_name}.pvi.template"
output_template = RUNTIME_OUTPUT_PATH / f"{device_name}.pvi.template"
format_template(device, PVI_PV_PREFIX, output_template)

# Add to extra databases to be added into substitution file
Expand Down
15 changes: 9 additions & 6 deletions src/ibek/templates/ioc/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# If the config folder contains a st.cmd script and a ioc.subst file then
# optionally generate ioc.db from the ioc.subst file and use the st.cmd script
# as the IOC startup script. Note that the expanded database file will
# be generated in /tmp/ioc.db
# be generated in ${RUNTIME_DIR}ioc.db
#
# 3. start.sh ******************************************************************
# If the config folder contains a start.sh script it will be executed.
Expand Down Expand Up @@ -61,19 +61,22 @@ override=${CONFIG_DIR}/start.sh
ibek_src=${CONFIG_DIR}/ioc.yaml
# Startup script for EPICS IOC generated by ibek
ioc_startup=${CONFIG_DIR}/st.cmd
# expanded database file
epics_db=/tmp/ioc.db

# folder for runtime assets
export RUNTIME_DIR=${EPICS_ROOT}/runtime
mkdir -p ${RUNTIME_DIR}

# expanded database file
epics_db=${RUNTIME_DIR}/ioc.db

# 1. ioc.yaml ******************************************************************
if [ -f ${ibek_src} ]; then

# Database generation script generated by ibek
db_src=/tmp/ioc.subst
final_ioc_startup=/tmp/st.cmd
db_src=${RUNTIME_DIR}/ioc.subst
final_ioc_startup=${RUNTIME_DIR}/st.cmd

# get ibek the support yaml files this ioc's support modules
# get the ibek support yaml files this ioc's support modules
defs=/epics/ibek-defs/*.ibek.support.yaml
ibek runtime generate ${ibek_src} ${defs} --out ${final_ioc_startup} --db-out ${db_src}

Expand Down
2 changes: 1 addition & 1 deletion src/ibek/templates/st.cmd.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dbLoadDatabase dbd/ioc.dbd
ioc_registerRecordDeviceDriver pdbbase

{{ script_elements }}
dbLoadRecords /tmp/ioc.db
dbLoadRecords $(RUNTIME_DIR)/ioc.db
iocInit

{% if post_ioc_init_elements %}
Expand Down
1 change: 1 addition & 0 deletions tests/generate_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

export SAMPLES_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}"))/samples

export EPICS_ROOT=${SAMPLES_DIR}/epics

# this is so relative schema mode lines work
cd $SAMPLES_DIR
Expand Down
136 changes: 136 additions & 0 deletions tests/samples/epics/opi/index.bob
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<display version="2.0.0">
<name>Display</name>
<x>0</x>
<y>0</y>
<width>273</width>
<height>130</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
<widget type="label" version="2.0.0">
<name>Title</name>
<class>TITLE</class>
<text>test-multiple-ioc - Index</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>273</width>
<height>25</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
</font>
</font>
<foreground_color use_class="true">
<color name="Text" red="0" green="0" blue="0">
</color>
</foreground_color>
<transparent use_class="true">true</transparent>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>imple</text>
<x>23</x>
<y>30</y>
<width>115</width>
<height>20</height>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
<actions>
<action type="open_display">
<file>simple.pvi.bob</file>
<target>tab</target>
<description>Open Display</description>
<macros>
<prefix>{{ name }}</prefix>
</macros>
</action>
</actions>
<text>imple</text>
<x>143</x>
<y>30</y>
<width>125</width>
<height>20</height>
<tooltip>$(actions)</tooltip>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>imple</text>
<x>23</x>
<y>55</y>
<width>115</width>
<height>20</height>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
<actions>
<action type="open_display">
<file>simple.pvi.bob</file>
<target>tab</target>
<description>Open Display</description>
<macros>
<prefix>{{ name }}</prefix>
</macros>
</action>
</actions>
<text>imple</text>
<x>143</x>
<y>55</y>
<width>125</width>
<height>20</height>
<tooltip>$(actions)</tooltip>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>imple</text>
<x>23</x>
<y>80</y>
<width>115</width>
<height>20</height>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
<actions>
<action type="open_display">
<file>simple.pvi.bob</file>
<target>tab</target>
<description>Open Display</description>
<macros>
<prefix>{{ name }}</prefix>
</macros>
</action>
</actions>
<text>imple</text>
<x>143</x>
<y>80</y>
<width>125</width>
<height>20</height>
<tooltip>$(actions)</tooltip>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>imple</text>
<x>23</x>
<y>105</y>
<width>115</width>
<height>20</height>
</widget>
<widget type="action_button" version="3.0.0">
<name>OpenDisplay</name>
<actions>
<action type="open_display">
<file>simple.pvi.bob</file>
<target>tab</target>
<description>Open Display</description>
<macros>
<prefix>{{ name }}</prefix>
</macros>
</action>
</actions>
<text>imple</text>
<x>143</x>
<y>105</y>
<width>125</width>
<height>20</height>
<tooltip>$(actions)</tooltip>
</widget>
</display>
49 changes: 49 additions & 0 deletions tests/samples/epics/opi/simple.pvi.bob
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<display version="2.0.0">
<name>Display</name>
<x>0</x>
<y>0</y>
<width>273</width>
<height>55</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
<widget type="label" version="2.0.0">
<name>Title</name>
<class>TITLE</class>
<text>Simple Device - ${prefix}</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>273</width>
<height>25</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
</font>
</font>
<foreground_color use_class="true">
<color name="Text" red="0" green="0" blue="0">
</color>
</foreground_color>
<transparent use_class="true">true</transparent>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>Simple PV</text>
<x>23</x>
<y>30</y>
<width>115</width>
<height>20</height>
</widget>
<widget type="textupdate" version="2.0.0">
<name>TextUpdate</name>
<pv_name>${prefix}Simple</pv_name>
<x>143</x>
<y>30</y>
<width>125</width>
<height>20</height>
<font>
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
</font>
</font>
<horizontal_alignment>1</horizontal_alignment>
</widget>
</display>
1 change: 1 addition & 0 deletions tests/samples/epics/pvi-defs/simple.pvi.device.yaml
2 changes: 1 addition & 1 deletion tests/samples/outputs/all.st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ my_mixed_enum_no_default =
ExampleTestFunction 127.0.0.1 Consumer Two With DB Ref1 Ref1.127.0.0.1
# PORT defaults to the id of PORT, i.e. PORT.name

dbLoadRecords /tmp/ioc.db
dbLoadRecords $(RUNTIME_DIR)/ioc.db
iocInit


Expand Down
2 changes: 1 addition & 1 deletion tests/samples/outputs/objects.st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ ExampleTestFunction 10.0.0.2 Consumer of another port AsynPort2 AsynPort2.10.0.0
ExampleTestFunction 10.0.0.2 Another Consumer of the 2nd port AsynPort2 AsynPort2.10.0.0.2
# PORT defaults to the id of PORT, i.e. PORT.name

dbLoadRecords /tmp/ioc.db
dbLoadRecords $(RUNTIME_DIR)/ioc.db
iocInit

2 changes: 1 addition & 1 deletion tests/samples/outputs/utils.st.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ ioc_registerRecordDeviceDriver pdbbase
# counter "InterruptVector" is now 193
# counter "InterruptVector" is now 194

dbLoadRecords /tmp/ioc.db
dbLoadRecords $(RUNTIME_DIR)/ioc.db
iocInit

0 comments on commit bc4b5f8

Please sign in to comment.