protected override IList <IRuleOutputChanged> InputValueChanged(RuleInterfaceInstance instance, IDispatchable source, object value) { if (_outputValue == null) { Context.Logger.LogError($"{Context.RuleInstance.Name} OutputValue is {null}, we ignore any incoming value.."); return(new List <IRuleOutputChanged>()); } if (value != null && instance.This2RuleInterfaceTemplate == TriggerRuleFactory.RuleInput && Boolean.TryParse(value.ToString(), out bool bValue) && bValue) { var change = new RuleOutputChanged(_output1, _outputValue); Context.Logger.LogDebug($"{Context.RuleInstance.Name} Change output value to {_outputValue}"); if (Delay > 0) { Task.Run(async() => { await Task.Delay(Delay); await _context.Dispatcher.DispatchValue(change.Instance, change.Value); }); } else { return(new List <IRuleOutputChanged> { change }); } } else if (instance.This2RuleInterfaceTemplate == TriggerRuleFactory.RuleValueInput) { Context.Logger.LogDebug($"{Context.RuleInstance.Name} Change value param to {_outputValue}"); _outputValue = value; } return(new List <IRuleOutputChanged>()); }
protected override IList <IRuleOutputChanged> InputValueChanged(RuleInterfaceInstance instance, IDispatchable source, object value) { if (value != null && instance.This2RuleInterfaceTemplate == StateToImpulsRuleFactory.RuleInput) { _i1 = Convert.ToInt32(value); } if (_i1.HasValue && _i1.Value > 0) { Task.Run(() => { var change = new RuleOutputChanged(_output1, 0); Thread.Sleep(Delay); _context.Dispatcher.DispatchValue(change.Instance, change.Value); }); } return(new List <IRuleOutputChanged>()); }