We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 26b4bfb commit c95035aCopy full SHA for c95035a
docs/reference/api.rst
@@ -273,8 +273,12 @@ All functions return a wrapped `ProcessDeviceSupportIn` or
273
274
status = mbbIn('STATUS',
275
'OK',
276
- ('FAILING', "MINOR"),
277
- ('FAILED', "MAJOR"))
+ ('FAILING', 'MINOR'),
+ ('FAILED', 'MAJOR'),
278
+ ('NOT CONNECTED', 'INVALID'))
279
+
280
+ Severities can also be assigned using the `softioc.alarm` numerical
281
+ severities if preferred.
282
283
Numerical values are assigned to options sequentially from 0 to 15 and
284
cannot be overridden.
softioc/builder.py
@@ -62,13 +62,19 @@ def longOut(name, DRVL=None, DRVH=None, EGU=None, **fields):
62
'ZR', 'ON', 'TW', 'TH', 'FR', 'FV', 'SX', 'SV', # 0-7
63
'EI', 'NI', 'TE', 'EL', 'TV', 'TT', 'FT', 'FF'] # 8-15
64
65
+# All the severity strings supported by <prefix>SV
66
+_severityStrings = ["NO_ALARM", "MINOR", "MAJOR", "INVALID"]
67
68
# Converts a list of (option [,severity]) values or tuples into field settings
69
# suitable for mbbi and mbbo records.
70
def _process_mbb_values(options, fields):
71
def process_value(prefix, value, option, severity=None):
72
fields[prefix + 'ST'] = option
73
fields[prefix + 'VL'] = value
74
if severity:
75
+ if isinstance(severity, int):
76
+ # Map alarm.MINOR_ALARM -> "MINOR"
77
+ severity = _severityStrings[severity]
78
fields[prefix + 'SV'] = severity
79
# zip() silently ignores extra values in options, so explicitly check length
80
assert len(options) <= 16, "May not specify more than 16 enum values"
tests/expected_records.db
@@ -1,8 +1,3 @@
1
-# This file was automatically generated on Fri 13 Aug 2021 16:49:03 BST.
2
-#
3
-# *** Please do not edit this file: edit the source file instead. ***
4
5
-
6
record(ai, "TS-DI-TEST-01:AI")
7
{
8
field(DTYP, "Python")
@@ -73,6 +68,7 @@ record(mbbi, "TS-DI-TEST-01:MBBI")
field(TWSV, "MINOR")
field(TWVL, "2")
field(ZRST, "One")
+ field(ZRSV, "MAJOR")
field(ZRVL, "0")
}
tests/sim_records.py
@@ -4,7 +4,7 @@
from epicsdbbuilder import GetRecordNames, WriteRecords
-from softioc import softioc
+from softioc import softioc, alarm
from softioc.builder import *
9
10
import numpy
@@ -26,7 +26,9 @@ def on_update_name(value, name):
26
t_boolin = boolIn('BOOLIN', 'True', 'False', initial_value=False)
27
t_longin = longIn('LONGIN', initial_value=33)
28
t_stringin = stringIn('STRINGIN', initial_value="Testing string")
29
-t_mbbi = mbbIn('MBBI', 'One', 'Two', ('Three', "MINOR"), initial_value=2)
+t_mbbi = mbbIn(
30
+ 'MBBI', ('One', alarm.MAJOR_ALARM), 'Two', ('Three', "MINOR"),
31
+ initial_value=2)
32
33
t_ao = aOut('AO', initial_value=12.45, on_update_name=on_update_name)
34
t_boolout = boolOut(
tests/test_records.py
@@ -10,7 +10,7 @@ def test_records(tmp_path):
path = str(tmp_path / "records.db")
11
builder.WriteRecords(path)
12
expected = os.path.join(os.path.dirname(__file__), "expected_records.db")
13
- assert open(path).readlines()[4:] == open(expected).readlines()[4:]
+ assert open(path).readlines()[5:] == open(expected).readlines()
14
15
def test_enum_length_restriction():
16
with pytest.raises(AssertionError):
0 commit comments