Add brand and images, fileserver for images, start to add arm queue
This commit is contained in:
27
run.py
27
run.py
@@ -29,6 +29,7 @@ from search import JukeboxSearch
|
||||
#multiprocessing.set_start_method('spawn', True)
|
||||
from pyModbusTCP.client import ModbusClient
|
||||
from uptime import uptime
|
||||
import fileserver
|
||||
|
||||
# set to false to run without real hardware for development
|
||||
real = False
|
||||
@@ -161,7 +162,11 @@ def check_server():
|
||||
tmp = list()
|
||||
for idx in range(len(cable_list)):
|
||||
if cable_list[idx] is not False:
|
||||
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": "Belden", "description": "Blah", "short_description": "Bla"}
|
||||
cabledata = jbs.get_position(str(idx))
|
||||
if "image" in cabledata:
|
||||
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"], "image": cabledata["image"], "description": "Blah", "short_description": "Bla"}
|
||||
else:
|
||||
tmp1 = {"part_number": cable_list[idx], "position": idx, "name": cable_list[idx], "brand": cabledata["brand"], "description": "Blah", "short_description": "Bla"}
|
||||
tmp.append(tmp1)
|
||||
out = {"map": tmp}
|
||||
fprint(out)
|
||||
@@ -354,6 +359,9 @@ def setup_server(pool):
|
||||
fprint("Starting websocket server...", sendqueue=to_server_queue)
|
||||
websocket_process = server.start_websocket_server(to_server_queue, from_server_queue)
|
||||
|
||||
fprint("Starting image file server...", sendqueue=to_server_queue)
|
||||
image_server_process = Process(target=fileserver.run_server, args=(config["cables"]["port"], config["cables"]["directory"]))
|
||||
image_server_process.start()
|
||||
return True
|
||||
|
||||
def handle_error(error):
|
||||
@@ -379,13 +387,18 @@ def get_sensors():
|
||||
out = list()
|
||||
if real:
|
||||
for reg in [352, 288, 304, 368]:
|
||||
val = mbconn.read_holding_registers(reg)[0]
|
||||
if val == 1:
|
||||
out.append(1)
|
||||
else:
|
||||
out.append(0)
|
||||
val = mbconn.read_holding_registers(reg)
|
||||
if val is not None:
|
||||
val = val[0]
|
||||
if val == 1:
|
||||
out.append(1)
|
||||
else:
|
||||
out.append(0)
|
||||
else:
|
||||
out = [0, 0, 0, 0]
|
||||
|
||||
if len(out) != 4:
|
||||
return -1
|
||||
sensors = out
|
||||
#fprint("Values: " + str(sensors))
|
||||
#mbconn.close()
|
||||
@@ -538,7 +551,7 @@ def mainloop_server(pool):
|
||||
for idx in range(len(cable_list)):
|
||||
cable_list_state.append(True)
|
||||
|
||||
pool.apply_async(get_specs.get_multi, (cable_list, 0.3), callback=cable_search_callback, error_callback=handle_error)
|
||||
pool.apply_async(get_specs.get_multi, (cable_list, 0.3, config["cables"]["directory"], config["cables"]["port"]), callback=cable_search_callback, error_callback=handle_error)
|
||||
mode = "Parsing"
|
||||
fprint("All cables scanned. Finding & parsing datasheets...")
|
||||
if mode == "Parsing":
|
||||
|
||||
Reference in New Issue
Block a user