Table of Contents

Class Condition

Namespace
Geotab.Checkmate.ObjectModel.Exceptions
Assembly
Geotab.Checkmate.ObjectModel.dll

Conditions model the logic that govern a Rule and can apply to many different types of data and entities. Conditions are structured in hierarchical tree. A condition's type (see ConditionType) defines the meaning of each condition in the tree and can be an operator, special operator, data or an asset.

Depending on the type of condition, it can have a minimum of 0 and maximum of 1 entity properties (Device, Driver, Diagnostic, WorkTime, Zone or ZoneType) defined per condition. Operator conditions (OR, AND, >, <, ==, NOT) will not have any entity properties populated. Special Operator conditions evaluate against special types of data such as Aux data, Zones, WorkHours, etc. and may have the entity property populated and/or a child condition populated with a Data condition. Asset conditions will only have the asset entity property populated.

The unit of measure for data is described either by the related Diagnostic's UnitOfMeasure or as follows:

A tree of conditions can define simple or complex rules and can be very powerful. Please take into consideration all possible consequences of a series of rules. Overly complex, poorly written or an excessive number of rules can have undesirable performance effects.

This class is in development. Its public interface is a subject to change.
public class Condition : Entity, IEntity, IComparable, IIdentifiable, IDriverProvider, IDeviceProvider, IZoneProvider, IZoneTypeProvider, IWorkTimeProvider, IDiagnosticProvider, IConditionContainer
Inheritance
Condition
Implements
Inherited Members

Constructors

Condition()

Initializes a new instance of the Condition class.

public Condition()

Condition(Id?)

Initializes a new instance of the Condition class.

public Condition(Id? id)

Parameters

id Id

Id

Condition(Id?, Rule?, ConditionType?, Condition?, IList<Condition>?, double?, Device?, Driver?, Zone?, ZoneType?, Diagnostic?, WorkTime?, Condition?, Group?)

Initializes a new instance of the Condition class.

public Condition(Id? id, Rule? rule, ConditionType? conditionType, Condition? parent, IList<Condition>? children, double? value, Device? device, Driver? driver, Zone? zone, ZoneType? zoneType, Diagnostic? diagnostic, WorkTime? workTime, Condition? linkTarget, Group? group = null)

Parameters

id Id

The id.

rule Rule

The rule.

conditionType ConditionType?

The type of the condition.

parent Condition

The parent.

children IList<Condition>

The children.

value double?

The value.

device Device

The device.

driver Driver

The driver.

zone Zone

The zone.

zoneType ZoneType

Type of the zone.

diagnostic Diagnostic

The diagnostic.

workTime WorkTime

The work time.

linkTarget Condition

The link target.

group Group

The Group

Condition(Id?, ConditionType?, IList<Condition>?, double?, Device?, Driver?, Zone?, ZoneType?, Diagnostic?, WorkTime?, Group?)

Initializes a new instance of the Condition class.

public Condition(Id? id, ConditionType? conditionType, IList<Condition>? children, double? value, Device? device, Driver? driver, Zone? zone, ZoneType? zoneType, Diagnostic? diagnostic, WorkTime? workTime, Group? group = null)

Parameters

id Id

The id.

conditionType ConditionType?

The type of the condition.

children IList<Condition>

The children.

value double?

The value.

device Device

The device.

driver Driver

The driver.

zone Zone

The zone.

zoneType ZoneType

Type of the zone.

diagnostic Diagnostic

The diagnostic.

workTime WorkTime

The work time.

group Group

The group.

Fields

ModifiedStockRuleConditions

Declares a state when a stock rule conditions is changed.

public const string ModifiedStockRuleConditions = "Modified stock rule conditions"

Field Value

string

ZoneConditionTypes

Gets Zone Condition Types.

public static readonly ImmutableHashSet<ConditionType> ZoneConditionTypes

Field Value

ImmutableHashSet<ConditionType>

Properties

Children

Gets or sets child condition(s) of this condition.

public IList<Condition>? Children { get; set; }

Property Value

IList<Condition>

Condition.

ConditionType

Gets or sets the ConditionType defines the meaning of this condition.

public ConditionType? ConditionType { get; set; }

Property Value

ConditionType?

ConditionType

Device

Gets or sets specified Device associated with the condition.

public Device? Device { get; set; }

Property Value

Device

Device

Diagnostic

Gets or sets the Diagnostic to compare the value of.

public Diagnostic? Diagnostic { get; set; }

Property Value

Diagnostic

Diagnostic

Driver

Gets or sets specified Driver associated with the condition.

public Driver? Driver { get; set; }

Property Value

Driver

Driver

Group

Gets or sets specified Group associated with the condition.

public Group? Group { get; set; }

Property Value

Group

Group

LinkTarget

Gets or sets the Condition that this Condition is a link of.

public Condition? LinkTarget { get; set; }

Property Value

Condition

Condition

Parent

Gets or sets the parent Condition for this Condition. Null for root condition.

public Condition? Parent { get; set; }

Property Value

Condition

Condition

Rule

Gets or sets the Rule that this condition applies to.

public Rule? Rule { get; set; }

Property Value

Rule

Rule

Sequence

Gets or sets the sequence that defines the Condition's relative order in a list of Children Conditions of the parent Condition.

public long? Sequence { get; set; }

Property Value

long?

returns Nullable<T> where T is. long

Remarks

The property is reserved for internal use only. Do not manipulate the property value directly as it may lead to unexpected results.

Unit

Gets the name of the metric used.

public string? Unit { get; }

Property Value

string

string

Value

Gets or sets the specified value to evaluate against.

public double? Value { get; set; }

Property Value

double?

double

WorkTime

Gets or sets the WorkTime that the event must occur inside/outside of for the violation to occur.

public WorkTime? WorkTime { get; set; }

Property Value

WorkTime

WorkTime

Zone

Gets or sets specified Zone associated with the condition.

public Zone? Zone { get; set; }

Property Value

Zone

Zone

ZoneType

Gets or sets specified ZoneType associated with the condition.

public ZoneType? ZoneType { get; set; }

Property Value

ZoneType

ZoneType

Methods

AddChildren(IEnumerable<Condition?>?, bool)

Adds the children to a condition.

public void AddChildren(IEnumerable<Condition?>? newChildren, bool clone)

Parameters

newChildren IEnumerable<Condition>

The children.

clone bool

if set to true [clone].

AreChildrenEmptyOrNull()

Gets whether there are children.

public bool AreChildrenEmptyOrNull()

Returns

bool

bool

Clone()

Creates a new object that is a copy of the current instance.

public override IEntity Clone()

Returns

IEntity

A new object that is a copy of this instance.

Equal(Condition?, Condition?)

Compares two condtions for special kind of equality. It looks for similar condition tree structure and relevant properties value.

public static bool Equal(Condition? rootCondition1, Condition? rootCondition2)

Parameters

rootCondition1 Condition

The first condition.

rootCondition2 Condition

The second condition.

Returns

bool

Equality result as a boolean.

FindCondition(Condition?, ConditionType)

Breadth First Search for the first occurance of a rule's condition

public static Condition? FindCondition(Condition? rootCondition, ConditionType conditionType)

Parameters

rootCondition Condition

The rule condition.

conditionType ConditionType

The condition type being searched.

Returns

Condition

Condition

GetConditions()

Gets or Sets children Condition(s).

public IList<Condition>? GetConditions()

Returns

IList<Condition>

IList<T>

GetDataSourceKind()

Gets the kind of the data source.

public DataSourceKind GetDataSourceKind()

Returns

DataSourceKind

DataSourceKind

IsMeasurementCondition(bool)

Gets a boolean value indicating whether the provided Condition's output is a sequence of measurements or a sequence of ExceptionEvents.

public bool IsMeasurementCondition(bool includeSpeedLimitTypes = true)

Parameters

includeSpeedLimitTypes bool

Treat SpeedLimit and related condition types as measurements producing.

Returns

bool

The boolean value or true or false.

IsMeasurementCondition(ConditionType?, bool)

Gets a boolean value indicating whether the provided ConditionType's output is a sequence of measurements or a sequence of ExceptionEvents.

public static bool IsMeasurementCondition(ConditionType? conditionType, bool includeSpeedLimitTypes = true)

Parameters

conditionType ConditionType?

The ConditionType to check.

includeSpeedLimitTypes bool

Treat SpeedLimit and related condition types as measurements producing.

Returns

bool

The boolean value or true or false.

IsNoDVIRCheckConditionValid(Condition)

Checks NoDVIRCheck Condition structure.

public static bool IsNoDVIRCheckConditionValid(Condition value)

Parameters

value Condition

The Condition to check against.

Returns

bool

bool

IsSpeedLimitCondition()

Gets a boolean value indicating whether the ConditionType is one of SpeedLimit related types.

public bool IsSpeedLimitCondition()

Returns

bool

A boolean value or true or false.

IsSpeedLimitCondition(ConditionType?)

Gets a boolean value indicating whether the ConditionType is one of SpeedLimit related types.

public static bool IsSpeedLimitCondition(ConditionType? conditionType)

Parameters

conditionType ConditionType?

The ConditionType to check.

Returns

bool

A boolean value or true or false.

IsZoneCondition(ConditionType?)

Gets a boolean value indicating whether the ConditionType is one of Zone related types.

public static bool IsZoneCondition(ConditionType? conditionType)

Parameters

conditionType ConditionType?

The ConditionType to check.

Returns

bool

A boolean value or true or false.

Remarks

These condition types are mathcing the ones in GetZoneConditions()

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

TraverseChildren(Condition?, IList<Condition>?, bool)

Traverses the children.

public static IEnumerable<Condition> TraverseChildren(Condition? parent, IList<Condition>? children, bool optimize)

Parameters

parent Condition

The parent.

children IList<Condition>

The children.

optimize bool

if set to true [optimize].

Returns

IEnumerable<Condition>

List<T>

Exceptions

ArgumentException

Choose either parameter to provide the children collection but not both.