Class LimitClassificationActor
Actor 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 fireFunction(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:
{
"channel1": [10, 20, 30],
"channel2": [5, 7, 9, 12],
...
}
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.
-
Field Summary
Fields inherited from class com.framed.cdss.Actor
id, inputChannels, outputChannels -
Constructor Summary
ConstructorsConstructorDescriptionLimitClassificationActor(EventBus eventBus, String id, org.json.JSONArray firingRules, org.json.JSONArray inputChannels, org.json.JSONArray outputChannels, org.json.JSONObject limits) Constructs aLimitClassifier. -
Method Summary
Modifier and TypeMethodDescriptioncheckLimits(Map<String, Object> snapshot) Classifies each channel's input value using its configured list of ascending upper bounds.voidfireFunction(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.cdss.Actor
getInputChannels, getOutputChannels, valueMatchesExpected
-
Constructor Details
-
LimitClassificationActor
public LimitClassificationActor(EventBus eventBus, String id, org.json.JSONArray firingRules, org.json.JSONArray inputChannels, org.json.JSONArray outputChannels, org.json.JSONObject limits) Constructs aLimitClassifier.- Parameters:
eventBus- the event bus used for input and output messagingid- the identifier for this classifierfiringRules- firing rules forwarded toActorinputChannels- 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 channel's 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
-
fireFunction
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:
fireFunctionin classActor- Parameters:
latestSnapshot- a map channel → numeric value
-