Skip to content

Commit 3866562

Browse files
authored
Merge pull request #74 from dls-controls/add_disp_to_in_records
Default DISP to TRUE for all In records
2 parents 5034531 + 0cda4cd commit 3866562

File tree

5 files changed

+57
-4
lines changed

5 files changed

+57
-4
lines changed

.vscode/launch.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
{
8+
"name": "Python: Current File",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal"
13+
},
714
{
815
"name": "Debug Unit Test",
916
"type": "python",
1017
"request": "launch",
1118
"justMyCode": false,
1219
"program": "${file}",
13-
"purpose": ["debug-test"],
20+
"purpose": [
21+
"debug-test"
22+
],
1423
"console": "integratedTerminal",
1524
"env": {
1625
// The default config in setup.cfg's "[tool:pytest]" adds coverage.
@@ -20,4 +29,4 @@
2029
},
2130
}
2231
]
23-
}
32+
}

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/expected_records.db

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
record(ai, "TS-DI-TEST-01:AI")
22
{
3+
field(DISP, "1")
34
field(DTYP, "Python")
45
field(INP, "@TS-DI-TEST-01:AI")
56
field(PINI, "YES")
@@ -14,6 +15,7 @@ record(ao, "TS-DI-TEST-01:AO")
1415

1516
record(bi, "TS-DI-TEST-01:BOOLIN")
1617
{
18+
field(DISP, "1")
1719
field(DTYP, "Python")
1820
field(INP, "@TS-DI-TEST-01:BOOLIN")
1921
field(ONAM, "False")
@@ -33,6 +35,7 @@ record(bo, "TS-DI-TEST-01:BOOLOUT")
3335

3436
record(longin, "TS-DI-TEST-01:LONGIN")
3537
{
38+
field(DISP, "1")
3639
field(DTYP, "Python")
3740
field(INP, "@TS-DI-TEST-01:LONGIN")
3841
field(MDEL, "-1")
@@ -49,6 +52,7 @@ record(longout, "TS-DI-TEST-01:LONGOUT")
4952

5053
record(waveform, "TS-DI-TEST-01:LONGSTRING")
5154
{
55+
field(DISP, "1")
5256
field(DTYP, "Python")
5357
field(FTVL, "UCHAR")
5458
field(INP, "@TS-DI-TEST-01:LONGSTRING")
@@ -58,6 +62,7 @@ record(waveform, "TS-DI-TEST-01:LONGSTRING")
5862

5963
record(mbbi, "TS-DI-TEST-01:MBBI")
6064
{
65+
field(DISP, "1")
6166
field(DTYP, "Python")
6267
field(INP, "@TS-DI-TEST-01:MBBI")
6368
field(ONST, "Two")
@@ -87,6 +92,7 @@ record(mbbo, "TS-DI-TEST-01:MBBO")
8792

8893
record(waveform, "TS-DI-TEST-01:SIN")
8994
{
95+
field(DISP, "1")
9096
field(DTYP, "Python")
9197
field(FTVL, "DOUBLE")
9298
field(INP, "@TS-DI-TEST-01:SIN")
@@ -111,6 +117,7 @@ record(ao, "TS-DI-TEST-01:SINP")
111117

112118
record(stringin, "TS-DI-TEST-01:STRINGIN")
113119
{
120+
field(DISP, "1")
114121
field(DTYP, "Python")
115122
field(INP, "@TS-DI-TEST-01:STRINGIN")
116123
field(PINI, "YES")
@@ -125,6 +132,7 @@ record(stringout, "TS-DI-TEST-01:STRINGOUT")
125132

126133
record(waveform, "TS-DI-TEST-01:WAVEFORM")
127134
{
135+
field(DISP, "1")
128136
field(DTYP, "Python")
129137
field(FTVL, "DOUBLE")
130138
field(INP, "@TS-DI-TEST-01:WAVEFORM")
@@ -135,6 +143,7 @@ record(waveform, "TS-DI-TEST-01:WAVEFORM")
135143

136144
record(waveform, "TS-DI-TEST-01:WAVEFORM2")
137145
{
146+
field(DISP, "1")
138147
field(DTYP, "Python")
139148
field(FTVL, "FLOAT")
140149
field(INP, "@TS-DI-TEST-01:WAVEFORM2")

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)