Class LimitClassificationReactor
Reactor that classifies numeric input values per channel
based on a configured, ascending-sorted list of upper bounds.
Classification logic: For each channel, the classifier receives a list of upper bounds:
channelA → [b0, b1, b2, ..., bN] // sorted ascendingGiven an incoming numeric value
v, the classifier returns the
first index i such that:
v <= b[i]If no such upper bound exists (i.e.,
v is greater than all bounds),
the classifier returns:
bounds.size()
Example: Suppose the configuration is:
"SpO2": [90, 93, 96, 100]Then:
v = 89 → index = 0(89 ≤ 90)v = 92 → index = 1(92 ≤ 93)v = 95 → index = 2(95 ≤ 96)v = 100 → index = 3(100 ≤ 100)v = 150 → index = 4(no bound reached → size = 4)
The result is therefore a discrete "classification bin" for each channel.
Input:
The actor listens to a set of input channels and expects incoming snapshots
in reactionFunction(Map) where each channel maps to a numeric value
(any Number subtype is accepted).
Output: For each input event, the actor publishes a result message containing:
timestamp: ISO timestampvalue: the computed classification indexclassName: this classifier's IDchannelID: the output channel used
Limits configuration: Provided as a JSON object of the form:
[10, 20, 30],All lists are required to be numeric and are automatically sorted ascending.
Constraints:
- Limited channels must be a subset of the input channels.
- Each value in the snapshot must be numeric.
- Missing channel values will result in an exception.
This class generalizes a "limits classifier" into multiple dynamically sized classification bins instead of fixed lower/upper bounds.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.framed.arn.Reactor
Reactor.Snapshot -
Field Summary
Fields inherited from class com.framed.arn.Reactor
addressGroup, id, inputChannels, lastLogicalFireTs, outputChannelsFields inherited from class com.framed.core.Service
ADDRESS_REGISTRY_SUFFIX, eventBus, formatter, logger -
Constructor Summary
ConstructorsConstructorDescriptionLimitClassificationReactor(EventBus eventBus, String id, org.json.JSONArray firingRules, String inputChannel, org.json.JSONArray outputChannels, org.json.JSONArray limits, boolean atomic) Constructs aLimitClassifier. -
Method Summary
Modifier and TypeMethodDescriptioncheckLimits(Map<String, Object> snapshot) Classifies each input value using its configured list of ascending upper bounds.voidreactionFunction(Map<String, Object> latestSnapshot) Receives a snapshot from the runtime, classifies all channel values viacheckLimits(Map), and publishes one result message per output channel.Methods inherited from class com.framed.arn.Reactor
getInputChannels, getOutputChannels, valueMatchesExpectedMethods inherited from class com.framed.core.Service
addressRegistry, announceAddress, stop
-
Constructor Details
-
LimitClassificationReactor
public LimitClassificationReactor(EventBus eventBus, String id, org.json.JSONArray firingRules, String inputChannel, org.json.JSONArray outputChannels, org.json.JSONArray limits, boolean atomic) Constructs aLimitClassifier.- Parameters:
eventBus- the event bus used for input and output messagingid- the identifier for this classifierfiringRules- firing rules forwarded toReactorinputChannel- JSON array of input channel namesoutputChannels- JSON array of output channel nameslimits- a JSON object describing upper-bound lists per channelFormat of limitsJson:
{ "channelA": [limit0, limit1, limit2, ...], "channelB": [...], ... }The lists must contain numeric values. They will be sorted ascending.
- Throws:
IllegalArgumentException- if limit channels are not a subset of input channels
-
-
Method Details
-
checkLimits
Classifies each input value using its configured list of ascending upper bounds.For each channel, given:
bounds = [b0, b1, b2, ..., bN] // sorted ascending value = v
the returned index is the firstisuch that:v <= b[i]
Ifvexceeds all bounds, the result is:bounds.size()
- Parameters:
snapshot- a map channel → numeric value (must contain all required channels)- Returns:
- a map channel → classification index
- Throws:
IllegalStateException- if snapshot is null or missing a required channelClassCastException- if a snapshot value is not numeric
-
reactionFunction
Receives a snapshot from the runtime, classifies all channel values viacheckLimits(Map), and publishes one result message per output channel.The output message contains:
timestamp: ISO-8601 timestampvalue: classification index computed bycheckLimits(Map)className: this classifier's IDchannelID: the output channel the message is published to
- Specified by:
reactionFunctionin classReactor- Parameters:
latestSnapshot- a map channel → numeric value
-
