def new_thread(points, delay, n, lines, columns, fps = 0, test_class = DiagramTest): # test multi-thread execution: VoronoiDiagram.start(title = test_class.__name__ + " - New-thread test", lines = lines, columns = columns, fps_limit = fps) # configure threads = [] # create tests in different threads for i in xrange(0,n): test = test_class(points, delay) threads.append(test) VoronoiDiagram.new_diagram(test.diagram, label="test") test.start() # waiting until previewer terminates while VoronoiDiagram.in_state(Preview.RUNNING): pass # stop tests threads for t in threads: t.stop()
import logging.config from pymote.networkgenerator import NetworkGenerator from pymote.simulation import Simulation from pymote.npickle import write_npickle from pymote.conf import global_settings from distributed_voronoi import DistributedVoronoi from point2D import Point2D from voronoi import VoronoiDiagram # Do not show log logging.config.dictConfig({'version': 1,'loggers':{}}) VoronoiDiagram.start() global_settings.ENVIRONMENT2D_SHAPE = VoronoiDiagram.panel_dim() # generates the network with 10 hosts net_gen = NetworkGenerator(n_count=99, n_min=1, n_max=100) net = net_gen.generate_random_network() # Defines the network algorithm net.algorithms = ((DistributedVoronoi, {'informationKey':'axis'}),) # Assign to node memory its position for node in net.nodes(): node.memory['axis'] = (int(net.pos[node][0]), int(net.pos[node][1]))