Skip to content

Commit

Permalink
add value typing to the list test example
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Jun 2, 2024
1 parent f61b2ce commit 3925360
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 206 deletions.
2 changes: 1 addition & 1 deletion src/ibek/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Value(BaseSettings):
description: str = Field(
description="Description of what the value will be used for"
)
value: str = Field(description="The contents of the value")
value: Any = Field(description="The contents of the value")
type: ValueTypes = Field(
description="The type of the value", default=ValueTypes.string
)
Expand Down
2 changes: 1 addition & 1 deletion tests/generate_samples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ mv `pwd`/epics/{runtime,opi}/* `pwd`/outputs/listarg
############################################################################

echo making an ioc schema using fastVacuum support yaml
ibek ioc generate-schema --no-ibek-defs support/fastVacuum.ibek.support.yaml --output schemas/fastVacuum.ibek.schema.json
ibek ioc generate-schema --no-ibek-defs support/fastVacuum.ibek.support.yaml --output schemas/fastVacuum.ibek.ioc.schema.json

echo making fastVacuum ioc
EPICS_ROOT=`pwd`/epics ibek runtime generate iocs/fastVacuum.ibek.ioc.yaml support/fastVacuum.ibek.support.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,46 +119,37 @@
"type": "string"
},
"addr_offset": {
"anyOf": [
{
"description": "jinja that renders to <class 'int'>",
"pattern": ".*\\{\\{.*\\}\\}.*",
"type": "string"
},
{
"description": "waveform address offset for the first waveform for this channel",
"type": "integer"
}
],
"default": "{{ (gaugeNum | int - 1) * (master.combined_nelm | int) }}",
"description": "waveform address offset for the first waveform for this channel",
"title": "Addr Offset",
"type": "string"
},
"wave0_addr": {
"default": "{{ (addr_offset | int) + (master.waveform_nelm | int) * 0 }}",
"description": "waveform address",
"title": "Wave0 Addr",
"type": "string"
},
"wave1_addr": {
"default": "{{ (addr_offset | int) + (master.waveform_nelm | int) * 1 }}",
"description": "waveform address",
"title": "Wave1 Addr",
"type": "string"
},
"wave2_addr": {
"default": "{{ (addr_offset | int) + (master.waveform_nelm | int) * 2 }}",
"description": "waveform address",
"title": "Wave2 Addr",
"type": "string"
},
"wave3_addr": {
"default": "{{ (addr_offset | int) + (master.waveform_nelm | int) * 3 }}",
"description": "waveform address",
"title": "Wave3 Addr",
"type": "string"
},
"wave4_addr": {
"default": "{{ (addr_offset | int) + (master.waveform_nelm | int) * 4 }}",
"description": "waveform address",
"title": "Wave4 Addr",
"type": "string"
"description": "union of <class 'int'> and jinja representation of {typ}",
"title": "Addr Offset"
},
"wave5_addr": {
"default": "{{ (addr_offset | int) + (master.waveform_nelm | int) * 5 }}",
"description": "waveform address",
"title": "Wave5 Addr",
"type": "string"
"wave_addr": {
"anyOf": [
{
"description": "jinja that renders to <class 'list'>",
"pattern": ".*\\{\\{.*\\}\\}.*",
"type": "string"
},
{
"description": "waveform address",
"items": {},
"type": "array"
}
],
"default": "{% for i in range(6) %}\n{{ addr_offset + master.waveform_nelm * i }}\n{% endfor %}",
"description": "union of <class 'list'> and jinja representation of {typ}",
"title": "Wave Addr"
}
},
"required": [
Expand Down Expand Up @@ -211,16 +202,36 @@
"type": "string"
},
"waveform_nelm": {
"default": "500",
"description": "waveform element count",
"title": "Waveform Nelm",
"type": "string"
"anyOf": [
{
"description": "jinja that renders to <class 'int'>",
"pattern": ".*\\{\\{.*\\}\\}.*",
"type": "string"
},
{
"description": "waveform element count",
"type": "integer"
}
],
"default": "{{500}}",
"description": "union of <class 'int'> and jinja representation of {typ}",
"title": "Waveform Nelm"
},
"combined_nelm": {
"default": "{{ (6 * waveform_nelm|int) }}",
"description": "total waveform element count",
"title": "Combined Nelm",
"type": "string"
"anyOf": [
{
"description": "jinja that renders to <class 'int'>",
"pattern": ".*\\{\\{.*\\}\\}.*",
"type": "string"
},
{
"description": "total waveform element count",
"type": "integer"
}
],
"default": "{{ 6 * waveform_nelm }}",
"description": "union of <class 'int'> and jinja representation of {typ}",
"title": "Combined Nelm"
}
},
"required": [
Expand Down
118 changes: 0 additions & 118 deletions tests/samples/support/fastVaccum.builder.py

This file was deleted.

65 changes: 25 additions & 40 deletions tests/samples/support/fastVacuum.ibek.support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ defs:
- description: waveform element count
name: waveform_nelm
value: "500"
type: int
value: 500

- description: total waveform element count
name: combined_nelm
type: int
value: |-
{{ (6 * waveform_nelm|int) }}
{{ 6 * waveform_nelm }}
databases:
- file: $(DLSPLC)/db/dlsPLC_fastVacuumMaster.template
Expand Down Expand Up @@ -111,24 +113,25 @@ defs:
pre_values:
- description: auto gauge count
name: gaugeNum
type: int
value: |-
{{ _ctx_.counter("fvGaugeNum", start=1) }}
- description: fan number
name: fan
value: |-
{{ "%02d" % (gaugeNum | int / 7 + 1) }}
{{ "%02d" % (gaugeNum / 7 + 1) }}
- description: mask for the channel
name: mask
value: |-
{{ _ctx_.set('fvMask', _ctx_.get('fvMask', 0) + 2**(gaugeNum | int)) }}
{{ _ctx_.set('fvMask', _ctx_.get('fvMask', 0) + 2**gaugeNum) }}
values:
- description: link number
name: lnk_no
value: |-
{{ ((gaugeNum | int - 1) % 6) + 1 }}
{{ ((gaugeNum - 1) % 6) + 1 }}
- description: Gauge PV
name: gaugePV
Expand All @@ -137,38 +140,20 @@ defs:
- description: waveform address offset for the first waveform for this channel
name: addr_offset
type: int
value: |-
{{ (gaugeNum | int - 1) * (master.combined_nelm | int) }}
{{ (gaugeNum - 1) * master.combined_nelm }}
- description: waveform address
name: wave0_addr
- description: waveform addresses
name: wave_addr
type: list
# this is still not pretty enough :-(
value: |-
{{ (addr_offset | int) + (master.waveform_nelm | int) * 0 }}
- description: waveform address
name: wave1_addr
value: |-
{{ (addr_offset | int) + (master.waveform_nelm | int) * 1 }}
- description: waveform address
name: wave2_addr
value: |-
{{ (addr_offset | int) + (master.waveform_nelm | int) * 2 }}
- description: waveform address
name: wave3_addr
value: |-
{{ (addr_offset | int) + (master.waveform_nelm | int) * 3 }}
- description: waveform address
name: wave4_addr
value: |-
{{ (addr_offset | int) + (master.waveform_nelm | int) * 4 }}
- description: waveform address
name: wave5_addr
value: |-
{{ (addr_offset | int) + (master.waveform_nelm | int) * 5 }}
{%- set addr = [] -%}
{%- for i in range(6) -%}
{%- set addr = addr.append(addr_offset + master.waveform_nelm * i) -%}
{%- endfor -%}
{{ addr }}
databases:
- file: $(DLSPLC)/db/dlsPLC_fastVacuumLink.template
Expand All @@ -184,11 +169,11 @@ defs:
id: "{{id}}"
em:
waveform_nelm: "{{master.waveform_nelm}}"
wave0_addr:
wave1_addr:
wave2_addr:
wave3_addr:
wave4_addr:
wave5_addr:
wave0_addr: "{{wave_addr[0]}}"
wave1_addr: "{{wave_addr[1]}}"
wave2_addr: "{{wave_addr[2]}}"
wave3_addr: "{{wave_addr[3]}}"
wave4_addr: "{{wave_addr[4]}}"
wave5_addr: "{{wave_addr[5]}}"
combined_nelm: "{{master.combined_nelm}}"
timeout:

0 comments on commit 3925360

Please sign in to comment.