Skip to content

Commit 745f6c7

Browse files
Default DISP to TRUE for all In records
1 parent 8d76fb5 commit 745f6c7

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Unreleased_
1212
Changed:
1313

1414
- `Remove python2 support <../../pull/64>`
15+
- `Default DISP to TRUE for all In records <../../pull/74>`
1516

1617
3.2.1_ - 2021-11-25
1718
-------------------

softioc/builder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919

2020
def _in_record(record, name, **fields):
21-
'''For input records we provide some automatic extra features: scanning
22-
and initialisation as appropriate.'''
21+
'''For input records we provide some automatic extra features: scanning,
22+
initialisation as appropriate, and blocking puts from outside the IOC.'''
2323

2424
fields.setdefault('SCAN', 'I/O Intr')
2525
if 'initial_value' in fields:
2626
fields.setdefault('PINI', 'YES')
27+
fields.setdefault('DISP', 1)
2728
return getattr(PythonDevice, record)(name, **fields)
2829

2930

tests/test_records.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,36 @@ def test_enum_length_restriction():
1818
"ManyLabels", "one", "two", "three", "four", "five", "six",
1919
"seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen",
2020
"fourteen", "fifteen", "sixteen", "seventeen")
21+
22+
def test_DISP_defaults_on():
23+
"""Test that all IN record types have DISP=1 set by default"""
24+
in_records = [
25+
builder.aIn,
26+
builder.boolIn,
27+
builder.longIn,
28+
builder.mbbIn,
29+
builder.stringIn,
30+
builder.WaveformIn,
31+
]
32+
33+
record_counter = 0
34+
35+
for creation_func in in_records:
36+
kwargs = {}
37+
record_counter += 1
38+
record_name = "DISP" + str(record_counter)
39+
40+
if creation_func == builder.WaveformIn:
41+
kwargs = {"length": 1}
42+
43+
record = creation_func(record_name, **kwargs)
44+
45+
# Note: DISP attribute won't exist if field not specified
46+
assert record.DISP.Value() == 1
47+
48+
def test_DISP_can_be_overridden():
49+
"""Test that DISP can be forced off for In records"""
50+
51+
record = builder.longIn("DISP-OFF", DISP=0)
52+
# Note: DISP attribute won't exist if field not specified
53+
assert record.DISP.Value() == 0

0 commit comments

Comments
 (0)