Flexible handler for NTScalar standard optional fields #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The file
nthandlers.py
implements the logic required for NTScalar control, valueAlarm, and timeStamp fields. A put or post will be evaluated against those structures if present, e.g. ifcontrol.limitHigh
is set then the value of the PV will not be allowed to exceed that value, or if a value belowvalueAlarm.lowAlarmLimit
is set thenalarm.severity
will be set tovalueAlarm.lowAlarmSeverity
.The included example code shows this in practice:
and using pvput we see the expected results:
The code uses two orderedDicts to construct a list of rules. One set of rules are applied to
onFirstConnect
and are used to ensure the PVs are immediately in the correct state, e.g. control limits applied before first connection is evaluated. The second set of rules are applied to eachpost
(these have the prior and ServerOperation state to consider). In practice the two sets of rules share a considerable amount of code. A developer may interact with the orderedDicts to override default behaviour or add additional user-specified behaviour.Does this seem useful? If so, in generalt terms, is this implementation a sensible way of supplying this functionality?
I thought it made sense to check if was desired before extending to other Normative Types or implementing tests.