Table of Contents

Class RuleEvaluator

Namespace
Pamoja.Profile
Assembly
Pamoja.Profile.dll

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

IReadOnlyList<string>

Topics

Gets the topics the rules watch, each once, in name order: the topics to subscribe to.

public IReadOnlyList<string> Topics { get; }

Property Value

IReadOnlyList<string>

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

topic string

The topic the reading arrived on.

reading float

The 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

text string

The 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

rule string

The rule's name.

Returns

bool?

The condition's state, or null for 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

topic string

The topic a message arrived on.

Returns

bool

true when some rule watches it.