Download latest PDF - Read the Docs

Transcript
Brian Documentation, Release 1.5dev
In an IPython shell you can do something like this:
client = RemoteControlClient()
spikes = client.evaluate('M.spikes')
i, t = zip(*spikes)
plot(t, i, '.')
client.execute('stop()')
class brian.RemoteControlClient(server=None, authkey=’brian’)
Used to remotely control (via IP) a running Brian script
Initialisation arguments:
server The IP server details, a pair (host, port). If you want to allow control only on the one machine (for
example, by an IPython shell), leave this as None (which defaults to host=’localhost’, port=2719). To
allow remote control, use (‘’, portnumber).
authkey The authentication key to allow access, change it from ‘brian’ if you are allowing access from outside
(otherwise you allow others to run arbitrary code on your machine).
Use a RemoteControlServer on the simulation you want to control.
Has the following methods:
execute(code)
Executes the specified code in the server process. If it raises an exception, the server process will catch it
and reraise it in the client process.
evaluate(code)
Evaluate the code in the server process and return the result. If it raises an exception, the server process
will catch it and reraise it in the client process.
set(name, value)
Sets the variable name (a string) to the given value (can be an array, etc.). Note that the variable is set in
the local namespace, not the global one, and so this cannot be used to modify global namespace variables.
To do that, set a local namespace variable and then call execute() with an instruction to change the
global namespace variable.
pause()
Temporarily stop the simulation in the server process, continue simulation with the :meth:’go’ method.
go()
Continue a simulation that was paused.
stop()
Stop a simulation, equivalent to execute(’stop()’).
Example usage
Main simulation code includes a line like this:
server = RemoteControlServer()
In an IPython shell you can do something like this:
client = RemoteControlClient()
spikes = client.evaluate('M.spikes')
i, t = zip(*spikes)
plot(t, i, '.')
client.execute('stop()')
304
Chapter 8. Reference