Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/reference/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,12 @@ All functions return a wrapped `ProcessDeviceSupportIn` or

status = mbbIn('STATUS',
'OK',
('FAILING', "MINOR"),
('FAILED', "MAJOR"))
('FAILING', 'MINOR'),
('FAILED', 'MAJOR'),
('NOT CONNECTED', 'INVALID'))

Severities can also be assigned using the `softioc.alarm` numerical
severities if preferred.

Numerical values are assigned to options sequentially from 0 to 15 and
cannot be overridden.
Expand Down
6 changes: 6 additions & 0 deletions softioc/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ def longOut(name, DRVL=None, DRVH=None, EGU=None, **fields):
'ZR', 'ON', 'TW', 'TH', 'FR', 'FV', 'SX', 'SV', # 0-7
'EI', 'NI', 'TE', 'EL', 'TV', 'TT', 'FT', 'FF'] # 8-15

# All the severity strings supported by <prefix>SV
_severityStrings = ["NO_ALARM", "MINOR", "MAJOR", "INVALID"]

# Converts a list of (option [,severity]) values or tuples into field settings
# suitable for mbbi and mbbo records.
def _process_mbb_values(options, fields):
def process_value(prefix, value, option, severity=None):
fields[prefix + 'ST'] = option
fields[prefix + 'VL'] = value
if severity:
if isinstance(severity, int):
# Map alarm.MINOR_ALARM -> "MINOR"
severity = _severityStrings[severity]
fields[prefix + 'SV'] = severity
for prefix, (value, option) in zip(_mbbPrefixes, enumerate(options)):
if isinstance(option, tuple):
Expand Down
5 changes: 3 additions & 2 deletions tests/expected_records.db
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file was automatically generated on Fri 13 Aug 2021 16:49:03 BST.
#
#
# *** Please do not edit this file: edit the source file instead. ***
#
#
Comment thread
thomascobb marked this conversation as resolved.
Outdated

record(ai, "TS-DI-TEST-01:AI")
{
Expand Down Expand Up @@ -73,6 +73,7 @@ record(mbbi, "TS-DI-TEST-01:MBBI")
field(TWSV, "MINOR")
field(TWVL, "2")
field(ZRST, "One")
field(ZRSV, "MAJOR")
field(ZRVL, "0")
}

Expand Down
6 changes: 4 additions & 2 deletions tests/sim_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from epicsdbbuilder import GetRecordNames, WriteRecords

from softioc import softioc
from softioc import softioc, alarm
from softioc.builder import *

import numpy
Expand All @@ -26,7 +26,9 @@ 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', "MINOR"), initial_value=2)
t_mbbi = mbbIn(
'MBBI', ('One', alarm.MAJOR_ALARM), 'Two', ('Three', "MINOR"),
initial_value=2)

t_ao = aOut('AO', initial_value=12.45, on_update_name=on_update_name)
t_boolout = boolOut(
Expand Down