Situation Detector
From RuleCore Support
The situation detector consists of a number of co-operating detector nodes which are used to track and detect a situation.
The nodes are organized in a tree structure. Each node has one parent and usually one or more child nodes depending on the type of the node. Some nodes can only be used as leaf nodes.
Each rule instance contains its own situation detector. The event stream view in each rule decides which events are seen by each rule instance and thus it is possible that the situation detector will not see all inbound events.
The state of each node can be active or inactive. A node changes its state between these two states depending on its internal logic. Over time, the state of the node can change back and forth between these two states multiple times.
For example, an All node is activated when all its child nodes are active at the same point in time. If one of the child nodes are inactivated, the All node changes its state to inactive again.
A node may also use other information than the activation values of its child nodes in order to calculate its own activation value.
A detector node may choose to emit a constant activation signal, which can not change at a later point in time, based on the internal logic of the node. The node may somehow have decided that its value can not change anymore and thus emits a constant signal to its parent node. If a constant signal indicating an inactive state reaches the root detector node the situation can never be detected at a later point in time and thus the rule instance can be removed and the negative action of the rule will be executed.
Some nodes does not have any child nodes at all in the detector tree. For example, the EventPickup node is a leaf node without any children. Its internal logic picks up events of a particular type from the event view in the rule by executing a ruleCore XPath expression.
The root node of the detector tree is always a Detector node. The Detector node will inform the rule its used in when a situation is detected. This happens when an activation signal reaches it.
Situation Detector Nodes
The detector tree is used to describe an interesting situation and can be used to monitor the progress as the situation develops.
The detector tree is evaluated from bottom up. EventPickup nodes are used as leaf nodes of the tree and are activated if they select any events from the rule's event view. The evaluation of nodes is propagated up from the leaf nodes through the tree until the root node is reached.
The detector nodes have all some common properties:
- Evaluation of detector nodes is completely automatic. Evaluation of a node is performed in order to determine its activation value; active or inactive. The engine decides, based in incoming events, when and what detector nodes needs to be evaluated. Evaluation starts at leaf nodes and propagate upward. The passing of time can also result in evaluation of a detector node. The engine decides automatically which nodes need to be evaluated and when.
- Each detector node has one parent and zero or more children depending on detector node type. The one single exception if the root Detector node which has no parent and can only have one single child.
- The output and input of all nodes are compatible. Thus nodes can generally be connected to any other nodes. Each node can place some restrictions on allowed types or number of child nodes if some type or number of nodes does not make any sense.
Some nodes can have one or more named control child nodes. These nodes are not considered to be part of the situation detector tree. They control only the behavior of their parent node and are located in the control name space. Control child nodes are used to configure a detector node and can contain any detector node. What behavior is controlled is dependent on the name of the control child node and is documented specifically for each detector node.
- Each node can have a name. The name can be used to identify nodes in the situation detection tree when creating the XSLT transform which creates the outgoing event.
- A node can be active or inactive. A node will compute its own activation value.
- A node's activation value can depend on:
- the activation values of it's children
- the node's previous internal state, if any
- the activation values of the node's control child nodes, if any.
- the algorithm used by the node to calculate its activation value based on above.
- Each node has a degree of completion indicated by a decimal number between 0.0 and 1.0. The degree of completion indicates how near the node is from being activated. A degree of completeness of 0.0 means that the sub situation described by a node and its descendant nodes has not yet started to develop. A node is activated when its degree of completeness reaches 1.0. Values between 0.0 and 1.0 indicate a partially developed situation.
Each node can be in two different modes:
- Continuous – Evaluate continuously
- Once – Evaluate only if not yet active.
Node Summary
- Detector – Root node, situation is detected when child node is active.
- All – Active when all child nodes are active
- Any – Active when any child node is active
- Not – Inverts activation value of child node.
- Sequencing nodes:
- Sequence search – Active when child nodes are activated in sequence.
- Sequence match – Active when child nodes are activated in sequence.
- EventCount – Active when event count is over or below threshold
- EventPickup – Active when one or more events are picked up from view.
- Within – Active if child nodes are activated within a time limit.
- Time – Active at a specific point in time
- Gate – Lets a child activation through depending on control child nodes.