|
|
@@ -1,12 +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 sockets.socket_client import socket_manager
|
|
|
|
|
|
# from .BlueToothMode import BlueToothMode
|
|
|
class RemoteControlV2(BaseClass):
|
|
|
@@ -25,6 +26,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:
|
|
|
@@ -204,6 +206,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 +217,34 @@ 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()
|
|
|
+ async def sendControlData():
|
|
|
+ await socket_manager.websocket.send(json.dumps(input_data))
|
|
|
+ loop.create_task(sendControlData(), name="sendControlData")
|
|
|
+ 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)
|