public void Invoke(object sender, TriggeredEventArgs e) { if (!Enable)//если выключено - выходим { return; } e.triggerData.Stopper.RegisterStopper(stopSender); e.triggerData.InterpretationFuncs.Add(new Function(new Func <object[], object>((ps) => { Interpreter.ExecuteScript(Script, e.triggerData); return(ps); }), FuncType.Parameters, "StartBind")); e.triggerData.InterpretationFuncs.Add(new Function(new Func <object[], object>((ps) => { e.triggerData.Stopper.IsStopped = true; return(ps); }), FuncType.Parameters, "Stop")); e.triggerData.InterpretationFuncs.Add(new Function(new Func <object[], object>((ps) => { stopSender.Stop(); return(ps); }), FuncType.Parameters, "StopThisBind")); e.triggerData.InterpretationFuncs.Add(new Function(new Func <object[], object>((ps) => { e.triggerData.Stopper.UnRegisterStopper(stopSender); stopSender.Stop(); e.triggerData.Stopper.RegisterStopper(stopSender); return(ps); }), FuncType.Parameters, "StopAnotherRunsOfThisBind")); Interpreter.ExecuteScript(e.TriggerScript, e.triggerData); e.triggerData.Stopper.UnRegisterStopper(stopSender); }
protected Task Invoke(TriggeredEventArgs e) { return(Task.Run(() => { if (EnableTrigger && EnableAllTriggers) { Triggered?.Invoke(this, e); } })); }
public void AddTriggered(Neuron value, TriggeredEventArgs triggeredEventArgs) { if (this.enabled) { this.TriggeredAdded?.Invoke(this, new SpikeResultEventArgs(new NeuronResult(triggeredEventArgs.TriggerInfo.Timestamp, value.Id, value.Data, triggeredEventArgs.TriggerInfo.Effect, triggeredEventArgs.Charge))); var path = string.Join(" >> ", triggeredEventArgs.Path.Select(fi => SpikeResultsService.GetTriggersWithChargeString(fi.Triggers, this.neurons))); SpikeResultsService.logger.Info($"{value.ToString()} triggered." + $"{Environment.NewLine}\t{triggeredEventArgs.SpikeOrigin.ToString()}" + $"{Environment.NewLine}\tCharge: {triggeredEventArgs.Charge} mV" + $"{Environment.NewLine}\tPath: {path} >> {(neurons.Contains(triggeredEventArgs.TriggerInfo.PresynapticId) ? neurons[triggeredEventArgs.TriggerInfo.PresynapticId].Data : string.Empty)} "); } }
private void neuron_Triggered(object sender, TriggeredEventArgs e) { this.container.Resolve <ISpikeResultsService>().AddTriggered((Neuron)sender, e); }