|
|
@@ -21,15 +21,17 @@ async def handlerSend(
|
|
|
code = receiveData.get("code")
|
|
|
msg = receiveData.get("msg")
|
|
|
data = receiveData.get("data")
|
|
|
- print("receiveData", receiveData)
|
|
|
- print("jsonType", jsonType)
|
|
|
async def MsgCallback(msg):
|
|
|
msg_id = msg.get("msg_id")
|
|
|
match msg_id:
|
|
|
case "PhotoUpdated":
|
|
|
PhotoFilename = msg.get("PhotoFilename")
|
|
|
- if PhotoFilename != "" and PhotoFilename != None:
|
|
|
- print("PhotoFilename", PhotoFilename)
|
|
|
+ PhotoLocation = msg.get("PhotoLocation")
|
|
|
+ if (PhotoFilename != "" and PhotoFilename != None) and (
|
|
|
+ PhotoLocation == "Local Disk"
|
|
|
+ ):
|
|
|
+ # print("PhotoFilename", temp_photo_name, PhotoFilename)
|
|
|
+ # temp_photo_name = PhotoFilename
|
|
|
data = manager.jsonMessage(
|
|
|
code=1,
|
|
|
msg=f"照片获取成功",
|
|
|
@@ -48,6 +50,7 @@ async def handlerSend(
|
|
|
msg_type="smart_shooter_enable_preview",
|
|
|
)
|
|
|
await manager.send_personal_message(data, websocket)
|
|
|
+
|
|
|
# 构建监听条件
|
|
|
smart_shooter.callback_listen = MsgCallback
|
|
|
loop.create_task(
|
|
|
@@ -67,7 +70,9 @@ async def handlerSend(
|
|
|
dictMsg = {"code":code,"msg":msg,"data":data}
|
|
|
await manager.broadcast(dictMsg)
|
|
|
case "connect_mcu":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
device_ctrl.mcu_exit = False
|
|
|
# if device_ctrl.serial_ins.check_connect():
|
|
|
# print("未连接")
|
|
|
@@ -80,7 +85,9 @@ async def handlerSend(
|
|
|
loop.create_task(blue_tooth.main_func(), name="blue_tooth")
|
|
|
# loop.close()
|
|
|
case "init_mcu":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
# 是否强制初始化
|
|
|
is_force_init = data.get("value",False)
|
|
|
loop.create_task(device_ctrl.initDevice(is_force_init), name="init_mcu")
|
|
|
@@ -95,10 +102,14 @@ async def handlerSend(
|
|
|
)
|
|
|
await manager.send_personal_message(data, websocket)
|
|
|
return
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
device_ctrl.controlDevice(device_name, value)
|
|
|
case "stop_action":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
if device_ctrl.is_runn_action == True:
|
|
|
print("动作执行中,停止")
|
|
|
device_ctrl.is_stop_action = True
|
|
|
@@ -146,22 +157,32 @@ async def handlerSend(
|
|
|
await manager.send_personal_message(data, websocket, msg_type=msg_type)
|
|
|
return
|
|
|
action_list = [device.model_dump() for device in all_devices]
|
|
|
- print("action_list", action_list)
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ print("handl send smart_shooter", smart_shooter)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
- device_ctrl.run_mcu_config(action_list, goods_art_no, action_info),
|
|
|
+ device_ctrl.run_mcu_config(
|
|
|
+ action_list, goods_art_no, action_info, smart_shooter
|
|
|
+ ),
|
|
|
name="run_mcu_config",
|
|
|
)
|
|
|
case "run_mcu_single":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
- device_ctrl.run_mcu_config_single(data, None, "run_mcu_single"),
|
|
|
+ device_ctrl.run_mcu_config_single(
|
|
|
+ data, None, "run_mcu_single", -1, smart_shooter
|
|
|
+ ),
|
|
|
name="run_mcu_single",
|
|
|
)
|
|
|
case "handler_take_picture":
|
|
|
- blue_tooth = BlueToothMode(websocket_manager=manager)
|
|
|
+ blue_tooth = BlueToothMode(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
- blue_tooth.remote_control_v2.handlerTakePhoto(),
|
|
|
+ blue_tooth.remote_control_v2.handlerTakePhoto(smart_shooter),
|
|
|
name="run_mcu_config",
|
|
|
)
|
|
|
case "re_take_picture":#重拍
|
|
|
@@ -194,21 +215,32 @@ async def handlerSend(
|
|
|
# 清除图片记录,执行重拍
|
|
|
reset_data = {"image_path": None}
|
|
|
photoRecord.update(session, record_id, **reset_data)
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
device_ctrl.run_mcu_config_single(
|
|
|
- device_action.model_dump(), goods_art_no, msg_type=msg_type,image_index=image_index
|
|
|
+ device_action.model_dump(),
|
|
|
+ goods_art_no,
|
|
|
+ msg_type=msg_type,
|
|
|
+ image_index=image_index,
|
|
|
+ smart_shooter=smart_shooter,
|
|
|
+ action_id=action_id,
|
|
|
),
|
|
|
name="run_mcu_config_single",
|
|
|
)
|
|
|
case "get_deviation":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
device_ctrl.getDeviationInfo(),
|
|
|
name="get_deviation",
|
|
|
)
|
|
|
case "set_deviation":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
value = data.get("value", None)
|
|
|
action_name = data.get("action_name", None)
|
|
|
loop.create_task(
|
|
|
@@ -216,7 +248,9 @@ async def handlerSend(
|
|
|
name="set_deviation",
|
|
|
)
|
|
|
case "move_deviation":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
value = data.get("value", None)
|
|
|
action_name = data.get("action_name", None)
|
|
|
loop.create_task(
|
|
|
@@ -224,19 +258,25 @@ async def handlerSend(
|
|
|
name="move_deviation",
|
|
|
)
|
|
|
case "get_mcu_other_info":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
device_ctrl.getMcuOtherInfo(),
|
|
|
name="mcu_other_set_get",
|
|
|
)
|
|
|
case "set_mcu_other_info":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
device_ctrl.setMcuOtherInfo(data),
|
|
|
name="setMcuOtherInfo",
|
|
|
)
|
|
|
case "send_command":
|
|
|
- device_ctrl = DeviceControl(websocket_manager=manager)
|
|
|
+ device_ctrl = DeviceControl(
|
|
|
+ websocket_manager=manager, smart_shooter=smart_shooter
|
|
|
+ )
|
|
|
loop.create_task(
|
|
|
device_ctrl.sendCommand(data.get("command", None)),
|
|
|
name="sendCommand",
|