Ejemplo n.º 1
0
    def __init__(self):
        osc.init()
        oscid = osc.listen(port=3002)
        # Send start/stop simulation
        osc.bind(oscid, self.start_simulation, '/send_start')
        # Receive cycle status
        osc.bind(oscid, self.output_cycle, '/receive_hello')
        # Retrieve simulation status
        osc.bind(oscid, self.simulation_status_receive, '/simu-status')
        # Retrieve server stopped
        osc.bind(oscid, self.server_stopped, '/server-stop')
        # Receive grid status
        osc.bind(oscid, self.grid_update, '/states')

        # Params
        self.cycle = 0
        self.server_running = False
        self.start_simu = True
        self.max_cycle = -1
        self.agents_num = 10
        self.grid = [1, 1]
        self.repeat = -1
        self.max_repeat = 1
        self.first_time = True

        # Read params from txt file
        self.params_txt()

        # Send message asking for simulation status
        osc.sendMsg('/simu-status_ask', [], port=3000)

        while True:
            osc.readQueue(oscid)
Ejemplo n.º 2
0
 def simuspeed(self, wait):
     print("Wait change to: {}s".format(wait))
     osc.sendMsg('/simu-speed', [wait, ], port=3000)
Ejemplo n.º 3
0
 def stop_simulation(self):
     print("ABORT THE SIMULATION!")
     osc.sendMsg('/start', [False, ], port=3000)
     self.cycle = 0
     self.start_simu = True
Ejemplo n.º 4
0
 def start_simulation(self):
     print("PERMISSION GRANTED: Simulation start!")
     osc.sendMsg('/start', [True, self.max_cycle, self.agents_num,
                            self.grid[0], self.grid[1]], port=3000)