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.
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
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
IdThe id.
rule
RuleThe rule.
conditionType
ConditionType?The type of the condition.
parent
ConditionThe parent.
children
IList<Condition>The children.
value
double?The value.
device
DeviceThe device.
driver
DriverThe driver.
zone
ZoneThe zone.
zoneType
ZoneTypeType of the zone.
diagnostic
DiagnosticThe diagnostic.
workTime
WorkTimeThe work time.
linkTarget
ConditionThe link target.
group
GroupThe 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
IdThe id.
conditionType
ConditionType?The type of the condition.
children
IList<Condition>The children.
value
double?The value.
device
DeviceThe device.
driver
DriverThe driver.
zone
ZoneThe zone.
zoneType
ZoneTypeType of the zone.
diagnostic
DiagnosticThe diagnostic.
workTime
WorkTimeThe work time.
group
GroupThe group.
Fields
ModifiedStockRuleConditions
Declares a state when a stock rule conditions is changed.
public const string ModifiedStockRuleConditions = "Modified stock rule conditions"
Field Value
ZoneConditionTypes
Gets Zone Condition Types.
public static readonly ImmutableHashSet<ConditionType> ZoneConditionTypes
Field Value
Properties
Children
Gets or sets child condition(s) of this condition.
public IList<Condition>? Children { get; set; }
Property Value
ConditionType
Gets or sets the ConditionType defines the meaning of this condition.
public ConditionType? ConditionType { get; set; }
Property Value
Device
Gets or sets specified Device associated with the condition.
public Device? Device { get; set; }
Property Value
Diagnostic
Gets or sets the Diagnostic to compare the value of.
public Diagnostic? Diagnostic { get; set; }
Property Value
Driver
Gets or sets specified Driver associated with the condition.
public Driver? Driver { get; set; }
Property Value
Group
Gets or sets specified Group associated with the condition.
public Group? Group { get; set; }
Property Value
LinkTarget
Gets or sets the Condition that this Condition is a link of.
public Condition? LinkTarget { get; set; }
Property Value
Parent
Gets or sets the parent Condition for this Condition. Null for root condition.
public Condition? Parent { get; set; }
Property Value
Rule
Gets or sets the Rule that this condition applies to.
public Rule? Rule { get; set; }
Property Value
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
Value
Gets or sets the specified value to evaluate against.
public double? Value { get; set; }
Property Value
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
Zone
Gets or sets specified Zone associated with the condition.
public Zone? Zone { get; set; }
Property Value
ZoneType
Gets or sets specified ZoneType associated with the condition.
public ZoneType? ZoneType { get; set; }
Property Value
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
boolif set to true [clone].
AreChildrenEmptyOrNull()
Gets whether there are children.
public bool AreChildrenEmptyOrNull()
Returns
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
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
ConditionThe rule condition.
conditionType
ConditionTypeThe condition type being searched.
Returns
GetConditions()
Gets or Sets children Condition(s).
public IList<Condition>? GetConditions()
Returns
GetDataSourceKind()
Gets the kind of the data source.
public DataSourceKind GetDataSourceKind()
Returns
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
boolTreat 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
boolTreat 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
Returns
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
TraverseChildren(Condition?, IList<Condition>?, bool)
Traverses the children.
public static IEnumerable<Condition> TraverseChildren(Condition? parent, IList<Condition>? children, bool optimize)
Parameters
parent
ConditionThe parent.
children
IList<Condition>The children.
optimize
boolif set to true [optimize].
Returns
Exceptions
- ArgumentException
Choose either parameter to provide the children collection but not both.