Package mosp :: Module controller :: Class Controller
[hide private]
[frames] | no frames]

Class Controller

source code


Controller to connect and coordinate simulations.

Instance Methods [hide private]
 
__init__(self, sims)
Initialize connections and identifiy simulations.
source code
 
connect_to(self, sim)
Connect to sim and exchange simulation information.
source code
 
sims_byName(self)
Get simulations by name.
source code
 
sims_bySocket(self)
Get simulations by socket.
source code
 
send(self, socket, msg)
Send a message to a socket.
source code
 
receive(self, sock)
Receive the next message(-blob) from a socket.
source code
 
cut_msgs(self, msgsblob)
Cut a message blob into seperate messages and messages into fields.
source code
 
dispatch(self, msgs, sender)
Sort messages to the correct server.
source code
 
put_to_sims(self, byName, bySocket)
Put all collected data to simulations.
source code
 
do_steps(self, byName, bySocket, steps=1)
Tell all simulations to do a number of steps.
source code
 
get_from_sims(self, byName, bySocket)
Get the next messages from all simulations that have data ready.
source code
 
run(self, until)
Run the simulations for a given number of ticks.
source code
 
shutdown(self)
End all simulations.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, sims)
(Constructor)

source code 

Initialize connections and identifiy simulations.

Parameters:
  • sims - a list of all simulations that should be connected, represented by lists containing type, port.
Overrides: object.__init__

cut_msgs(self, msgsblob)

source code 

Cut a message blob into seperate messages and messages into fields.

To Do: make this more flexible, accept more message-types.

dispatch(self, msgs, sender)

source code 

Sort messages to the correct server.

Parameters:
  • sender - sender of the messages, to return messages with invalid receiver to.

put_to_sims(self, byName, bySocket)

source code 

Put all collected data to simulations.

This sends all messages, that were received since the last call to the receiver.

Parameters:
  • byName (dict with the names of simulations as keys and the according lists as items.) - all simulations that should be considered as receivers.
  • bySocket (dict with the sockets of simulations as keys and the according lists as items.) - all simulations that should be considered as receivers.

do_steps(self, byName, bySocket, steps=1)

source code 

Tell all simulations to do a number of steps.

Parameters:
  • byName (dict with the names of simulations as keys and the according lists as items.) - all simulations that should be considered as receivers.
  • bySocket (dict with the sockets of simulations as keys and the according lists as items.) - all simulations that should be considered as receivers.
  • steps - the number of steps that all simulations should do (default = 1).

get_from_sims(self, byName, bySocket)

source code 

Get the next messages from all simulations that have data ready.

Parameters:
  • byName (dict with the names of simulations as keys and the according lists as items.) - all simulations that should be considered as receivers.
  • bySocket (dict with the sockets of simulations as keys and the according lists as items.) - all simulations that should be considered as receivers.

run(self, until)

source code 

Run the simulations for a given number of ticks.

Parameters:
  • until - number of ticks to run all simulations for.