Loading comm/client/main.py +8 −8 Changes for comm/client/main.py: 8 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import adc2018solver as pynqrouter app = Flask(__name__) args = {} # pynq_thread = None client_baseurl = "" @app.route('/start', methods=["POST"]) Loading @@ -43,9 +42,15 @@ def start(): qstr = request.form["question"] qname = request.form["qname"] qseed = request.form["qseed"] req_id = request.form["req_id"] boardstr = BoardStr.conv_boardstr(qstr.split('\n'), 'random', int(qseed)) option = {"name": qname, "host": args['host'], "client": client_baseurl} option = { "name": qname, "host": args['host'], "client": client_baseurl, "req_id": req_id } pynqrouter.start_solver(boardstr, qseed, option) # pynq_thread = pynqrouter.start_solver(boardstr, qseed, option) Loading @@ -64,8 +69,6 @@ def start(): @app.route('/stop') def stop(): # global pynq_thread if pynqrouter.solver_thread is None: ans = {"status": "No threads"} else: Loading @@ -73,15 +76,11 @@ def stop(): pynqrouter.stop_solver() ans = {"status": "Stopped"} # pynq_thread = None return json.dumps(ans) @app.route("/status") def status(): # global pynq_thread res_mes = "" if pynqrouter.solver_thread is None: Loading Loading @@ -121,3 +120,4 @@ if __name__ == "__main__": if args["debug"]: app.debug = True app.run(host='0.0.0.0', port=args["port"], threaded=True) solver/adc2018solver.py +21 −4 Changes for solver/adc2018solver.py: 21 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -154,11 +154,19 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()): # 解けなかったらLEDを消す mmio_led.write(0, 0) sys.stderr.write('Cannot solve it!\n') res = {'client': option['client'], 'qname': option['name'], 'answer': '', 'cputime': -1} res = { 'client': option['client'], 'qname': option['name'], 'solution': '', 'cputime': -1.0, 'req_id': option['req_id'], 'solved': False } if "host" in option: requests.post("http://{}/post".format(option['host']), data=res) solver_thread = None return { 'solved': False, 'solution': '', 'elapsed': -1.0 } return res print('Solved!') # 解けたらLEDを全部つける Loading Loading @@ -187,11 +195,20 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()): if solver_thread is not None: solver_thread.stopped() res = {'client': option['client'], 'qname': option['name'], 'answer': solution, 'cputime': elapsed} res = { 'client': option['client'], 'qname': option['name'], 'solution': solution, 'cputime': elapsed, 'req_id': option['req_id'], 'solved': True } if "host" in option: r = requests.post("http://{}/post".format(option['host']), data=res) solver_thread = None return { 'solved': True, 'solution': solution, 'elapsed': elapsed } return res def main(): parser = argparse.ArgumentParser(description="Solver with pynqrouter") Loading Loading
comm/client/main.py +8 −8 Changes for comm/client/main.py: 8 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import adc2018solver as pynqrouter app = Flask(__name__) args = {} # pynq_thread = None client_baseurl = "" @app.route('/start', methods=["POST"]) Loading @@ -43,9 +42,15 @@ def start(): qstr = request.form["question"] qname = request.form["qname"] qseed = request.form["qseed"] req_id = request.form["req_id"] boardstr = BoardStr.conv_boardstr(qstr.split('\n'), 'random', int(qseed)) option = {"name": qname, "host": args['host'], "client": client_baseurl} option = { "name": qname, "host": args['host'], "client": client_baseurl, "req_id": req_id } pynqrouter.start_solver(boardstr, qseed, option) # pynq_thread = pynqrouter.start_solver(boardstr, qseed, option) Loading @@ -64,8 +69,6 @@ def start(): @app.route('/stop') def stop(): # global pynq_thread if pynqrouter.solver_thread is None: ans = {"status": "No threads"} else: Loading @@ -73,15 +76,11 @@ def stop(): pynqrouter.stop_solver() ans = {"status": "Stopped"} # pynq_thread = None return json.dumps(ans) @app.route("/status") def status(): # global pynq_thread res_mes = "" if pynqrouter.solver_thread is None: Loading Loading @@ -121,3 +120,4 @@ if __name__ == "__main__": if args["debug"]: app.debug = True app.run(host='0.0.0.0', port=args["port"], threaded=True)
solver/adc2018solver.py +21 −4 Changes for solver/adc2018solver.py: 21 added lines, 4 removed lines. Original line number Diff line number Diff line Loading @@ -154,11 +154,19 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()): # 解けなかったらLEDを消す mmio_led.write(0, 0) sys.stderr.write('Cannot solve it!\n') res = {'client': option['client'], 'qname': option['name'], 'answer': '', 'cputime': -1} res = { 'client': option['client'], 'qname': option['name'], 'solution': '', 'cputime': -1.0, 'req_id': option['req_id'], 'solved': False } if "host" in option: requests.post("http://{}/post".format(option['host']), data=res) solver_thread = None return { 'solved': False, 'solution': '', 'elapsed': -1.0 } return res print('Solved!') # 解けたらLEDを全部つける Loading Loading @@ -187,11 +195,20 @@ def solve(boardstr, seed=12345, zero_padding=False, option=dict()): if solver_thread is not None: solver_thread.stopped() res = {'client': option['client'], 'qname': option['name'], 'answer': solution, 'cputime': elapsed} res = { 'client': option['client'], 'qname': option['name'], 'solution': solution, 'cputime': elapsed, 'req_id': option['req_id'], 'solved': True } if "host" in option: r = requests.post("http://{}/post".format(option['host']), data=res) solver_thread = None return { 'solved': True, 'solution': solution, 'elapsed': elapsed } return res def main(): parser = argparse.ArgumentParser(description="Solver with pynqrouter") Loading