示例#1
0
 public TriggeredEventArgs(SpikeOrigin spikeOrigin, TriggerInfo triggerInfo, int charge, IEnumerable <FireInfo> path)
 {
     this.SpikeOrigin = spikeOrigin;
     this.TriggerInfo = triggerInfo;
     this.Charge      = charge;
     this.Path        = path;
 }
示例#2
0
        public FireInfo Spike(SpikeOrigin spikeOrigin, TriggerInfo triggerInfo, IEnumerable <FireInfo> path)
        {
            FireInfo result = FireInfo.Empty;

            this.triggerInfos.Add(triggerInfo);
            // Note: this.triggerInfos.ToList() required to fix "collection modified" issue
            var effectiveTriggers = Neuron.GetEffectiveTriggers(this.triggerInfos.ToList());
            var positiveCharge    = Neuron.GetChargeByEffect(effectiveTriggers, NeurotransmitterEffect.Excite);
            var negativeCharge    = Neuron.GetChargeByEffect(effectiveTriggers, NeurotransmitterEffect.Inhibit);
            var sumCharge         = (int)(Constants.RestingPotential + positiveCharge + negativeCharge);

            this.Triggered?.Invoke(this, new TriggeredEventArgs(spikeOrigin, triggerInfo, sumCharge, path));

            // if spiked enough and spiked after repolarization
            if (sumCharge >= this.Threshold && DateTime.Now > this.fireInfos.LastOrDefault().Timestamp.Add(Constants.RefractoryPeriod))
            {
                result = new FireInfo(DateTime.Now, effectiveTriggers.ToArray());
                this.fireInfos.Add(result);
                this.triggerInfos.Clear();
                this.Fired?.Invoke(this, new FiredEventArgs(result, sumCharge));
            }

            return(result);
        }