From df8e470f3b139c17c669bdaabe9b91ca089a768a Mon Sep 17 00:00:00 2001 From: Tom Cobb Date: Fri, 2 Jul 2021 14:59:26 +0100 Subject: [PATCH] Add test case for mbb severity and fix error --- docs/reference/api.rst | 4 ++-- softioc/builder.py | 2 +- tests/expected_records.db | 1 + tests/sim_records.py | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/reference/api.rst b/docs/reference/api.rst index 4acc2830..af1cd22b 100644 --- a/docs/reference/api.rst +++ b/docs/reference/api.rst @@ -273,8 +273,8 @@ All functions return a wrapped `ProcessDeviceSupportIn` or status = mbbIn('STATUS', 'OK', - ('FAILING', alarm.MINOR_ALARM), - ('FAILED', alarm.MAJOR_ALARM)) + ('FAILING', "MINOR"), + ('FAILED', "MAJOR")) Numerical values are assigned to options sequentially from 0 to 15 and cannot be overridden. diff --git a/softioc/builder.py b/softioc/builder.py index 2101a4f4..0fa1447d 100644 --- a/softioc/builder.py +++ b/softioc/builder.py @@ -72,7 +72,7 @@ def process_value(prefix, value, option, severity=None): if severity: fields[prefix + 'SV'] = severity for prefix, (value, option) in zip(_mbbPrefixes, enumerate(options)): - if isinstance(value, tuple): + if isinstance(option, tuple): # The option is tuple consisting of the option name and an optional # alarm severity. process_value(prefix, value, *option) diff --git a/tests/expected_records.db b/tests/expected_records.db index 53c7c1ea..977e2407 100644 --- a/tests/expected_records.db +++ b/tests/expected_records.db @@ -631,6 +631,7 @@ record(mbbi, "TS-DI-TEST-01:MBBI") field(PINI, "YES") field(SCAN, "I/O Intr") field(TWST, "Three") + field(TWSV, "MINOR") field(TWVL, "2") field(ZRST, "One") field(ZRVL, "0") diff --git a/tests/sim_records.py b/tests/sim_records.py index a6d8c396..18d86464 100644 --- a/tests/sim_records.py +++ b/tests/sim_records.py @@ -26,7 +26,7 @@ def on_update_name(value, name): t_boolin = boolIn('BOOLIN', 'True', 'False', initial_value=False) t_longin = longIn('LONGIN', initial_value=33) t_stringin = stringIn('STRINGIN', initial_value="Testing string") -t_mbbi = mbbIn('MBBI', 'One', 'Two', 'Three', initial_value=2) +t_mbbi = mbbIn('MBBI', 'One', 'Two', ('Three', "MINOR"), initial_value=2) t_ao = aOut('AO', initial_value=12.45, on_update_name=on_update_name) t_boolout = boolOut(