Class RuleEvaluator
The decisions a rule file makes, reading by reading, with no link and no outputs of its own.
public sealed class RuleEvaluator : IDisposable
- Inheritance
-
RuleEvaluator
- Implements
- Inherited Members
Remarks
The program moves the messages and drives the outputs: it hands each reading over with the topic it arrived on, and learns which rules set or cleared and what each calls for. This is the deciding half of a RuleEngine, which owns a link and outputs; the two decide alike.
Properties
Actuators
Gets the actuators the rules drive, each once, in name order: the outputs the program has to have.
public IReadOnlyList<string> Actuators { get; }
Property Value
Topics
Gets the topics the rules watch, each once, in name order: the topics to subscribe to.
public IReadOnlyList<string> Topics { get; }
Property Value
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Evaluate(string, float)
Judges one reading from one topic against every rule that watches it.
public IReadOnlyList<RuleFired> Evaluate(string topic, float reading)
Parameters
topicstringThe topic the reading arrived on.
readingfloatThe reading, already decoded from the message.
Returns
- IReadOnlyList<RuleFired>
What fired, in the order the rules are listed; empty when no rule watches the topic or the reading changed nothing.
Exceptions
- PamojaException
A rule watches the topic and the reading is not a finite number.
FromJson(string)
Loads a rule file and arms its rules, every condition starting cleared.
public static RuleEvaluator FromJson(string text)
Parameters
textstringThe rule file.
Returns
- RuleEvaluator
The evaluator, which the caller disposes.
Exceptions
- PamojaException
The text is not a rule file, or holds a rule no engine could run, such as one that watches a filter or has nothing to do.
IsSet(string)
Reports whether a rule's condition currently holds.
public bool? IsSet(string rule)
Parameters
rulestringThe rule's name.
Returns
- bool?
The condition's state, or
nullfor a name no rule has.
ToJson()
Writes the rules back out as the file a fleet shares.
public string ToJson()
Returns
- string
The rule file.
Watches(string)
Reports whether any rule watches a topic, so the program knows whether to decode a message.
public bool Watches(string topic)
Parameters
topicstringThe topic a message arrived on.
Returns
- bool
truewhen some rule watches it.