|
|
@@ -30,6 +30,8 @@ class RemoteControlV2(BaseClass):
|
|
|
self.connect_state = False
|
|
|
self.is_running = False
|
|
|
self.goods_art_no = None
|
|
|
+ # 0 闲置;1进行中;2已完成;
|
|
|
+ self.photo_take_state = 0
|
|
|
|
|
|
def to_connect_com(self, port_name, is_test=False):
|
|
|
if self.connect_state:
|
|
|
@@ -213,6 +215,7 @@ class RemoteControlV2(BaseClass):
|
|
|
)
|
|
|
self.msg_type = "blue_tooth"
|
|
|
return
|
|
|
+ self.photo_take_state = 1
|
|
|
input_data = {
|
|
|
"data": {
|
|
|
"action": control_program,
|
|
|
@@ -229,12 +232,16 @@ class RemoteControlV2(BaseClass):
|
|
|
)
|
|
|
self.goods_art_no = None
|
|
|
self.msg_type = "blue_tooth"
|
|
|
+ self.photo_take_state = 2
|
|
|
|
|
|
- def handlerTakePhoto(self):
|
|
|
+ async def handlerTakePhoto(self):
|
|
|
"""处理单独拍照"""
|
|
|
+ await asyncio.sleep(0.1)
|
|
|
+ print("开始单拍0")
|
|
|
session = SqlQuery()
|
|
|
crud = CRUD(PhotoRecord)
|
|
|
record = crud.read(session=session, order_by="id", ascending=False)
|
|
|
+ print("开始单拍0-读取数据库")
|
|
|
if record == None:
|
|
|
# 发送失败消息
|
|
|
self.sendSocketMessage(
|
|
|
@@ -244,10 +251,13 @@ class RemoteControlV2(BaseClass):
|
|
|
device_status=2,
|
|
|
)
|
|
|
else:
|
|
|
+ print("开始单拍1")
|
|
|
+ self.photo_take_state = 1
|
|
|
image_index = record.image_index + 1
|
|
|
insert_photo_records(
|
|
|
record.image_deal_mode, record.goods_art_no, image_index
|
|
|
)
|
|
|
+ print("开始单拍1-插入数据")
|
|
|
capture_one = DigiCam()
|
|
|
try:
|
|
|
captrure_folder_path = capture_one.getCaptureFolderPath()
|
|
|
@@ -255,12 +265,13 @@ class RemoteControlV2(BaseClass):
|
|
|
watch_dog.goods_art_no = record.goods_art_no
|
|
|
watch_dog.image_index = image_index
|
|
|
watch_dog.start_observer(captrure_folder_path)
|
|
|
+ print("开始单拍1-检查相机")
|
|
|
camera_is_connect = capture_one.checkCameraConnect()
|
|
|
if camera_is_connect is not True:
|
|
|
self.sendSocketMessage(1, "相机未连接,请检查", device_status=-1)
|
|
|
return
|
|
|
- capture_one.getCaptureFolderPath()
|
|
|
capture_one.run_capture_action("Capture")
|
|
|
+ print("开始单拍1-完成拍照")
|
|
|
time.sleep(1)
|
|
|
self.msg_type = "photo_take"
|
|
|
self.sendSocketMessage(
|
|
|
@@ -270,24 +281,26 @@ class RemoteControlV2(BaseClass):
|
|
|
if record.image_deal_mode == 1
|
|
|
else "执行左脚程序"
|
|
|
),
|
|
|
+ data={"goods_art_no": record.goods_art_no},
|
|
|
device_status=2,
|
|
|
)
|
|
|
self.msg_type = "blue_tooth"
|
|
|
except Exception as e:
|
|
|
- print("错误信息:",e)
|
|
|
self.sendSocketMessage(1, "digicam未初始化,请检查", device_status=-1)
|
|
|
+ self.photo_take_state = 0
|
|
|
|
|
|
- def analysis_received_data(self):
|
|
|
+ async def analysis_received_data(self):
|
|
|
if not self.connect_state:
|
|
|
return
|
|
|
-
|
|
|
+ await asyncio.sleep(0.01)
|
|
|
if self.bluetooth_address:
|
|
|
receive_data = self.bluetooth_ins.read_cmd_one(
|
|
|
address=self.bluetooth_address
|
|
|
)
|
|
|
- # print("received data", receive_data)
|
|
|
+ # print("received data", 1)
|
|
|
else:
|
|
|
receive_data = self.serial_ins.read_cmd(out_time=1, check=None)
|
|
|
+ # print("received data", 2)
|
|
|
# print("self.bluetooth_ins", receive_data)
|
|
|
if receive_data is False:
|
|
|
self.connect_state = False
|
|
|
@@ -295,6 +308,9 @@ class RemoteControlV2(BaseClass):
|
|
|
|
|
|
if not receive_data:
|
|
|
return
|
|
|
+ if self.photo_take_state != 0:
|
|
|
+ print("正在拍照", self.photo_take_state)
|
|
|
+ return
|
|
|
receive_data_parser = receive_data[0]
|
|
|
# 数据 结构 command,按命令解析
|
|
|
if receive_data_parser == 1:
|
|
|
@@ -316,11 +332,19 @@ class RemoteControlV2(BaseClass):
|
|
|
print(message)
|
|
|
if button_value in [1, 2]:
|
|
|
# 扫描货号
|
|
|
+ if self.photo_take_state != 0:
|
|
|
+ self.sendSocketMessage(1, "前置拍照未完成,请稍后", device_status=-1)
|
|
|
+ return
|
|
|
print("收到货号信息", self.goods_art_no)
|
|
|
self.handlerAction(button_value)
|
|
|
+ self.photo_take_state = 0
|
|
|
if button_value in [3]:
|
|
|
# 处理遥控器单拍
|
|
|
- self.handlerTakePhoto()
|
|
|
+ self.msg_type = "handler_take_picture"
|
|
|
+ # 0 闲置;1进行中;2已完成;
|
|
|
+ _data = {"type": self.msg_type,"data":None}
|
|
|
+ self.sendSocketMessage(0, "处理单拍消息", data=_data, device_status=-1)
|
|
|
+ self.msg_type = "blue_tooth"
|
|
|
self.sendSocketMessage(code=0, msg="", data=message, device_status=2)
|
|
|
if settings.IS_DEBUG:
|
|
|
print("收到按键", button_value)
|
|
|
@@ -452,7 +476,7 @@ class RemoteControlV2(BaseClass):
|
|
|
code=1, msg="遥控设备V2 未连接", data=message, device_status=-1
|
|
|
)
|
|
|
break
|
|
|
- self.analysis_received_data()
|
|
|
+ await self.analysis_received_data()
|
|
|
|
|
|
self.is_running = False
|
|
|
if not self.connect_state:
|