def swi_nengo_viz(self, filename, code): if self.user is None: return code = code.replace('\r\n', '\n') fn = os.path.join(self.script_path, filename) locals = {} exec(code, locals) model = locals['model'] viz = nengo_viz.Viz(filename=fn, model=model, locals=locals) nengo_viz.server.Server.viz = viz port = 8080 if not self.nengo_viz_started: t = threading.Thread(target=nengo_viz.server.Server.start, kwargs=dict(port=port, browser=False)) t.daemon = True t.start() self.nengo_viz_started = True return '%d' % port
avoid_inhibit = nengo.Ensemble(n_neurons=50, dimensions=1, intercepts=Uniform(0.2, 0.9)) nengo.Connection(joystick[5], avoid_inhibit, synapse=None) nengo.Connection(avoid_inhibit, sensors_ir.neurons, transform=[[-1]] * 200, synapse=0.1) nengo.Connection(avoid_inhibit, sensors_us.neurons, transform=[[-1]] * 200, synapse=0.1) if False: import nengo_viz viz = nengo_viz.Viz(model) viz.value(sensor_node) viz.value(control.output) viz.value(motor.output) viz.start() if False: with model: nengo.Probe(sensors_us) nengo.Probe(sensors_us, 'spikes') import nengo_gui.javaviz jv = nengo_gui.javaviz.View(model) sim = nengo.Simulator(model) jv.update_model(sim) jv.view()