public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var res1 = (double)await _leftNode.ExecuteNode(ruleExecutionContext); var res2 = (double)await _rightNode.ExecuteNode(ruleExecutionContext); switch (_operatorType) { case OperatorType.More: return(res1 > res2); case OperatorType.Less: return(res1 < res2); case OperatorType.MoreOrEqual: return(res1 >= res2); case OperatorType.LessOrEqual: return(res1 <= res2); case OperatorType.Equal: return(Math.Abs(res1 - res2) < 0.00001); case OperatorType.Unknown: break; default: throw new ArgumentOutOfRangeException(); } return(false); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var resource = ruleExecutionContext.DeviceContext.DeviceSharedResources.SharedResourcesInContainers.FirstOrDefault( container => container.ResourceName == _resoure); var resUshorts = await StaticContainer.Container.Resolve <IPropertyValueService>().GetUshortsOfProperty(resource.Resource, ruleExecutionContext.DeviceContext, true, ruleExecutionContext.IsLocal); var boolArray = resUshorts.Item.GetBoolArrayFromUshortArray(); bool value = Convert.ToBoolean(await _valueOfBit.ExecuteNode(ruleExecutionContext)); boolArray[Convert.ToUInt16(await _numberOfBit.ExecuteNode(ruleExecutionContext))] = value; var subPropertyUshort = boolArray.BoolArrayToUshort(); if (ruleExecutionContext.IsLocal) { ruleExecutionContext.DeviceContext.DeviceMemory.LocalMemoryValues[(resource.Resource as IWithAddress).Address] = subPropertyUshort; ruleExecutionContext.DeviceContext.DeviceEventsDispatcher.TriggerLocalAddressSubscription( (resource.Resource as IWithAddress).Address, 1); } else { ruleExecutionContext.DeviceContext.DeviceMemory.DeviceMemoryValues[(resource.Resource as IWithAddress).Address] = subPropertyUshort; ruleExecutionContext.DeviceContext.DeviceEventsDispatcher.TriggerDeviceAddressSubscription( (resource.Resource as IWithAddress).Address, 1); } return(value); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var numberOfValue = Convert.ToInt32((double)await _numberOfValue.ExecuteNode(ruleExecutionContext)); var deviceValue = new List <ushort>(); if (ruleExecutionContext.Variables.ContainsKey(VariableNames.DEVICE_VALUE)) { deviceValue = ruleExecutionContext.Variables[VariableNames.DEVICE_VALUE] as List <ushort>; } if (deviceValue.Count < numberOfValue + 1) { for (int i = 0; i <= numberOfValue; i++) { if (deviceValue.Count < i + 1) { deviceValue.Add(0); } } } deviceValue[numberOfValue] = Convert.ToUInt16((double)await _valueToSet.ExecuteNode(ruleExecutionContext)); ruleExecutionContext.Variables[VariableNames.DEVICE_VALUE] = deviceValue; return(deviceValue[numberOfValue]); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var res1 = await _leftNode.ExecuteNode(ruleExecutionContext); var res2 = await _rghtNode.ExecuteNode(ruleExecutionContext); return((double)res1 / (double)res2); }
public async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { object res = null; foreach (var ruleNode in _ruleNodes) { res = await ruleNode.ExecuteNode(ruleExecutionContext); } return(res); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var value1 = (double)await _nodeFirst.ExecuteNode(ruleExecutionContext); var value2 = (double)await _nodeSecond.ExecuteNode(ruleExecutionContext); var res = Math.Pow(value1, value2); return(res); }
public Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { ruleExecutionContext.Variables.GetElement(VariableNames.CURRENT_VALUE_OWNER).OnSuccess(o => { if (o is ICanBeHidden canBeHidden) { canBeHidden.IsHidden = true; } }); return(null); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { double res1 = 0; foreach (var node in _nodes) { res1 += Convert.ToDouble(await node.ExecuteNode(ruleExecutionContext)); } return(res1); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var resource = ruleExecutionContext.DeviceContext.DeviceSharedResources.SharedResourcesInContainers .FirstOrDefault( container => container.ResourceName == _resource); var resUshorts = await StaticContainer.Container.Resolve <IPropertyValueService>() .GetUshortsOfProperty(resource.Resource, ruleExecutionContext.DeviceContext, true, ruleExecutionContext.IsLocal); var result = resUshorts.Item[0].GetBoolArrayFromUshort()[ Convert.ToUInt16(await _numberOfBit.ExecuteNode(ruleExecutionContext))]; return(result); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var condition = (bool)await _conditionNode.ExecuteNode(ruleExecutionContext); if (condition) { return(await _ifYesNode.ExecuteNode(ruleExecutionContext)); } if (_ifNoNode == null) { return(null); } return(await _ifNoNode.ExecuteNode(ruleExecutionContext)); }
public async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { var inputFormattedValue = ruleExecutionContext.Variables.GetElement(VariableNames.INPUT_VALUE).Item as IFormattedValue; switch (inputFormattedValue) { case INumericValue numericValue: return(numericValue.NumValue); case IBoolValue boolValue: return(boolValue.BoolValueProperty); case IStringValue stringValue: return(stringValue.StrValue); } return(null); }
public async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { Result <object> res = ruleExecutionContext.Variables.GetElement(VariableNames.RESULT_VALUE); switch (_formatterType) { case FormatterType.Number: var numValue = StaticContainer.Container.Resolve <INumericValue>(); res.OnSuccess(o => { if (_numberOfSymbolsAfterComma.HasValue) { var resNum = (double)o; resNum = Math.Round(resNum, _numberOfSymbolsAfterComma.Value); numValue.NumValue = resNum; } else { numValue.NumValue = (double)o; } }); ruleExecutionContext.SetVariable(VariableNames.RESULT_VALUE, numValue); return(res); case FormatterType.Bool: var boolValue = StaticContainer.Container.Resolve <IBoolValue>(); res.OnSuccess(o => { boolValue.BoolValueProperty = (bool)o; }); ruleExecutionContext.SetVariable(VariableNames.RESULT_VALUE, boolValue); return(res); case FormatterType.String: var stringValue = StaticContainer.Container.Resolve <IStringValue>(); res.OnSuccess(o => { stringValue.StrValue = (string)o; }); ruleExecutionContext.SetVariable(VariableNames.RESULT_VALUE, stringValue); return(res); default: throw new ArgumentOutOfRangeException(); } }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { return(ruleExecutionContext.Variables[VariableNames.RESULT_VALUE]); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { return(_val); }
internal override BrokeredMessage Execute(BrokeredMessage message, RuleExecutionContext context) { return(this.Execute(message)); }
public async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { return((double)(short)(ushort)(double)await _ruleNode.ExecuteNode(ruleExecutionContext)); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { return(Convert.ToDouble((ruleExecutionContext.Variables[VariableNames.DEVICE_VALUE] as List <ushort>)[ Convert.ToInt32((double)await _numberNode.ExecuteNode(ruleExecutionContext))])); }
public RuleExecutionRepository(RuleExecutionContext context) { _context = context ?? throw new ArgumentNullException(nameof(context)); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { return(ruleExecutionContext.Variables[_varName]); }
public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext) { ruleExecutionContext.Variables.Add(_varName, await _node.ExecuteNode(ruleExecutionContext)); return(ruleExecutionContext.Variables[_varName]); }
public RunRegistrationRulesCommandHandler(RuleExecutionContext ruleExecution, IMediator mediator, IOptions <RuleExecutionSettings> settings) { _ruleExecutionContext = ruleExecution; _mediator = mediator; _settings = settings; }
public RecordQAResultsCommandHandler(RuleExecutionContext ruleExecution, IMediator mediator) { _ruleExecutionContext = ruleExecution; _mediator = mediator; }