def __init__(self, live_packet_gather_label, receive_labels=None, send_labels=None, local_host=None, local_port=19999, partitioned_vertices=False): """ :param event_receiver_label: The label of the LivePacketGather\ vertex to which received events are being sent :param receive_labels: Labels of vertices from which live events\ will be received. :type receive_labels: iterable of str :param send_labels: Labels of vertices to which live events will be\ sent :type send_labels: iterable of str :param local_host: Optional specification of the local hostname or\ ip address of the interface to listen on :type local_host: str :param local_port: Optional specification of the local port to listen\ on. Must match the port that the toolchain will send the\ notification on (19999 by default) :type local_port: int """ DatabaseConnection.__init__(self, self._start_callback, local_host=local_host, local_port=local_port) self.add_database_callback(self._read_database_callback) self._live_packet_gather_label = live_packet_gather_label self._receive_labels = receive_labels self._send_labels = send_labels self._partitioned_vertices = partitioned_vertices self._sender_connection = None self._send_address_details = dict() self._atom_id_to_key = dict() self._key_to_atom_id_and_label = dict() self._live_event_callbacks = list() self._start_callbacks = dict() self._init_callbacks = dict() if receive_labels is not None: for label in receive_labels: self._live_event_callbacks.append(list()) self._start_callbacks[label] = list() self._init_callbacks[label] = list() if send_labels is not None: for label in send_labels: self._start_callbacks[label] = list() self._init_callbacks[label] = list() self._receivers = dict() self._listeners = dict()
def __init__(self, live_packet_gather_label, receive_labels=None, send_labels=None, local_host=None, local_port=19999): """ :param event_receiver_label: The label of the LivePacketGather\ vertex to which received events are being sent :param receive_labels: Labels of vertices from which live events\ will be received. :type receive_labels: iterable of str :param send_labels: Labels of vertices to which live events will be\ sent :type send_labels: iterable of str :param local_host: Optional specification of the local hostname or\ ip address of the interface to listen on :type local_host: str :param local_port: Optional specification of the local port to listen\ on. Must match the port that the toolchain will send the\ notification on (19999 by default) :type local_port: int """ DatabaseConnection.__init__( self, self._start_callback, local_host=local_host, local_port=local_port) self.add_database_callback(self._read_database_callback) self._live_packet_gather_label = live_packet_gather_label self._receive_labels = receive_labels self._send_labels = send_labels self._sender_connection = None self._send_address_details = dict() self._atom_id_to_key = dict() self._key_to_atom_id_and_label = dict() self._live_event_callbacks = list() self._start_callbacks = dict() self._init_callbacks = dict() if receive_labels is not None: for label in receive_labels: self._live_event_callbacks.append(list()) self._start_callbacks[label] = list() self._init_callbacks[label] = list() if send_labels is not None: for label in send_labels: self._start_callbacks[label] = list() self._init_callbacks[label] = list() self._receivers = dict() self._listeners = dict()
def run_forever_not_recorded(): sim.setup(1.0) stim = sim.Population(1, sim.SpikeSourcePoisson(rate=10.0)) pop = sim.Population(255, sim.IF_curr_exp(tau_syn_E=1.0), label="pop") sim.Projection( stim, pop, sim.AllToAllConnector(), sim.StaticSynapse(weight=20.0)) conn = DatabaseConnection( start_resume_callback_function=start_callback, stop_pause_callback_function=stop_callback, local_port=None) SpynnakerExternalDevicePluginManager.add_database_socket_address( conn.local_ip_address, conn.local_port, None) sim.external_devices.run_forever() sim.end()
def run_forever_recorded(): sim.setup(1.0) source_spikes = range(0, 5000, 100) stim = sim.Population(1, sim.SpikeSourceArray(source_spikes)) pop = sim.Population(255, sim.IF_curr_exp(tau_syn_E=1.0), label="pop") sim.Projection(stim, pop, sim.AllToAllConnector(), sim.StaticSynapse(weight=20.0)) pop.record(["v", "spikes"]) conn = DatabaseConnection(start_resume_callback_function=start_callback, stop_pause_callback_function=stop_callback, local_port=None) SpynnakerExternalDevicePluginManager.add_database_socket_address( conn.local_ip_address, conn.local_port, None) sim.external_devices.run_forever() spikes = pop.get_data("spikes").segments[0].spiketrains sim.end() for spiketrain in spikes: assert (len(spiketrain) > 0) for spike, source in zip(spiketrain, source_spikes[:len(spiketrain)]): assert (spike > source) assert (spike < source + 10)
def close(self): DatabaseConnection.close(self)
# Setup recording spike_input.record('spikes') receive_pop.record('spikes') receive_reward_pop.record('all') # ----------------------------------------------------------------------------- # Configure Visualiser # ----------------------------------------------------------------------------- print("UDP_PORT1: {}".format(UDP_PORT1)) print("x_fact: {}, y_fact: {}".format(x_factor1, y_factor1)) print("x_bits: {}, y_bits: {}".format( np.uint32(np.ceil(np.log2(X_RESOLUTION / x_factor1))), np.uint32(np.ceil(np.log2(Y_RESOLUTION / y_factor1))))) d_conn = DatabaseConnection(local_port=None) print("\nRegister visualiser process") d_conn.add_database_callback( functools.partial(start_visualiser, pop_label=b1.label, xr=x_factor1, yr=y_factor1, xb=np.uint32(np.ceil(np.log2(X_RESOLUTION / x_factor1))), yb=np.uint32(np.ceil(np.log2(Y_RESOLUTION / y_factor1))), key_conn=key_input_connection)) p.external_devices.add_database_socket_address("localhost", d_conn.local_port, None) # -----------------------------------------------------------------------------