Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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]);
        }
Пример #4
0
        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);
        }
Пример #5
0
        public async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext)
        {
            object res = null;

            foreach (var ruleNode in _ruleNodes)
            {
                res = await ruleNode.ExecuteNode(ruleExecutionContext);
            }
            return(res);
        }
Пример #6
0
        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);
        }
Пример #7
0
 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);
 }
Пример #8
0
        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);
        }
Пример #9
0
        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);
        }
Пример #10
0
        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));
        }
Пример #11
0
        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);
        }
Пример #12
0
        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();
            }
        }
Пример #13
0
 public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext)
 {
     return(ruleExecutionContext.Variables[VariableNames.RESULT_VALUE]);
 }
Пример #14
0
 public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext)
 {
     return(_val);
 }
Пример #15
0
 internal override BrokeredMessage Execute(BrokeredMessage message, RuleExecutionContext context)
 {
     return(this.Execute(message));
 }
Пример #16
0
 public async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext)
 {
     return((double)(short)(ushort)(double)await _ruleNode.ExecuteNode(ruleExecutionContext));
 }
Пример #17
0
 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));
 }
Пример #19
0
 public override async Task <object> ExecuteNode(RuleExecutionContext ruleExecutionContext)
 {
     return(ruleExecutionContext.Variables[_varName]);
 }
Пример #20
0
        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;
 }