def acquire(self, spike: Spike, act: IActivation): if not self.spike and self.id() == spike.id() and ( self.max_age_value < 0 or spike.age() <= act.secs_to_ticks(self.max_age_value)): assert not spike.is_wiped() with spike.causal_group() as cg: # Causal group might refuse acquisition, if one of act's state's write-props is unavailable. if not cg.acquired(spike, act, self.detached_value): return False self.spike = spike self._min_age_ticks = act.secs_to_ticks(self.min_age_value) return True return False
def emit(self, signal, parents=None, wipe: bool = False, payload=None) -> None: # Copy instead of calling super to obtain reference to created spike. if wipe: self.wipe(signal) with self._lock: new_spike = Spike(sig=signal.id(), parents=parents, consumable_resources=set( self._properties.keys()), payload=payload) logger.debug(f"Emitting {new_spike}") service.spike(new_spike.id()) self._spikes_per_signal[signal].add(new_spike)