class TestWifi(threading.Thread): def __init__(self, port, id): threading.Thread.__init__(self) self.id = id self.w = WifiReal(port, id) self.r = Routing(self.w) self.t = Topology(self.r) def prt(self, msg): print("APP {}: {}".format(self.id, msg)) def run(self): # print(self.module.get_visible_macs()) while (True): self.prt("Starting cycle") self.w.run() # self.t.run() self.prt(self.r.get_graph()) s_time = time.time() while (time.time() - s_time < 5 + (randint(0, 20) / 5)): self.w.listen_for_lines()
class GetIpt(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.ipt = None def run(self): while(True): self.ipt = input() print("Got input: {}".format(self.ipt)) if not get_ipt: g = Graph() g.start() else: i = GetIpt() i.start() while (True): print("APP: Starting cycle") w.run() t.run() print("APP: graph: {}".format(r.get_graph())) if not get_ipt: g.set_graph(r.get_graph()) else: if i.ipt: p = i.ipt.split(",") i.ipt = None if len(p) == 2: t.send_msg(p[0], p[1])