|
|
@@ -1,13 +1,13 @@
|
|
|
# module_remote_control_v2
|
|
|
|
|
|
|
|
|
+import json
|
|
|
import time, asyncio
|
|
|
import settings
|
|
|
from .SerialIns import SerialIns
|
|
|
from .BaseClass import BaseClass
|
|
|
from sockets.connect_manager import ConnectionManager
|
|
|
|
|
|
-
|
|
|
# from .BlueToothMode import BlueToothMode
|
|
|
class RemoteControlV2(BaseClass):
|
|
|
# sign_data = Signal(dict)
|
|
|
@@ -25,6 +25,7 @@ class RemoteControlV2(BaseClass):
|
|
|
self.bluetooth_address = ""
|
|
|
self.connect_state = False
|
|
|
self.is_running = False
|
|
|
+ self.goods_art_no = None
|
|
|
|
|
|
def to_connect_com(self, port_name, is_test=False):
|
|
|
if self.connect_state:
|
|
|
@@ -142,6 +143,9 @@ class RemoteControlV2(BaseClass):
|
|
|
flag = "接收器已连接 {}".format(
|
|
|
"蓝牙" if self.bluetooth_address else "串口"
|
|
|
)
|
|
|
+ self.sendSocketMessage(code=0, msg="遥控设备V2 打开蓝牙成功", data=None,device_status=2)
|
|
|
+ self.connect_state = True
|
|
|
+ self.is_running = True
|
|
|
else:
|
|
|
flag = "接收器未连接"
|
|
|
device_status = -1
|
|
|
@@ -204,6 +208,7 @@ class RemoteControlV2(BaseClass):
|
|
|
bar_code = receive_data[1:].decode()
|
|
|
bar_code = bar_code.replace("\r", "")
|
|
|
bar_code = bar_code.replace("\n", "")
|
|
|
+ self.goods_art_no = bar_code
|
|
|
message = {"_type": 0, "plugins_mode": "remote_control", "data": bar_code}
|
|
|
print(message)
|
|
|
self.sendSocketMessage(code=0, msg="", data=message, device_status=2)
|
|
|
@@ -214,6 +219,51 @@ class RemoteControlV2(BaseClass):
|
|
|
data = {"button_value": button_value}
|
|
|
message = {"_type": 9, "plugins_mode": "remote_control", "data": data}
|
|
|
print(message)
|
|
|
+ if button_value in [1,2]:
|
|
|
+ # 扫描货号
|
|
|
+ print("收到货号信息", self.goods_art_no)
|
|
|
+ if self.goods_art_no == None or self.goods_art_no =="":
|
|
|
+ self.sendSocketMessage(
|
|
|
+ code=1, msg="货号信息不能为空", data=None, device_status=-1
|
|
|
+ )
|
|
|
+ return
|
|
|
+ control_program = (
|
|
|
+ "执行左脚程序" if button_value == 1 else "执行右脚程序"
|
|
|
+ )
|
|
|
+ input_data = {
|
|
|
+ "data": {
|
|
|
+ "action": control_program,
|
|
|
+ "goods_art_no": self.goods_art_no,
|
|
|
+ },
|
|
|
+ "type": "run_mcu",
|
|
|
+ }
|
|
|
+ # loop = asyncio.get_event_loop()
|
|
|
+ # session = SqlQuery()
|
|
|
+ # crud = CRUD(DeviceConfig)
|
|
|
+ # condtions = {"mode_type": control_program, "action_status": True}
|
|
|
+ # all_devices = crud.read_all(
|
|
|
+ # session, conditions=condtions, order_by="action_index", ascending=True
|
|
|
+ # )
|
|
|
+ # if len(all_devices) == 0:
|
|
|
+ # self.sendSocketMessage(
|
|
|
+ # code=1,
|
|
|
+ # msg=f"当前没有可用配置",
|
|
|
+ # data=input_data,
|
|
|
+ # device_status=2,
|
|
|
+ # )
|
|
|
+ # return
|
|
|
+ # action_list = [device.model_dump() for device in all_devices]
|
|
|
+ # print("action_list", action_list)
|
|
|
+ # loop.create_task(
|
|
|
+ # device_ctrl.run_mcu_config(action_list, self.goods_art_no),
|
|
|
+ # name="run_mcu_config",
|
|
|
+ # )
|
|
|
+ self.sendSocketMessage(
|
|
|
+ code=0,
|
|
|
+ msg=f"准备执行[{control_program}]",
|
|
|
+ data=input_data,
|
|
|
+ device_status=2,
|
|
|
+ )
|
|
|
self.sendSocketMessage(code=0, msg="", data=message, device_status=2)
|
|
|
if settings.IS_DEBUG:
|
|
|
print("收到按键", button_value)
|