Merge branch 'main' of https://git.tgoim.com/leon/CPY_DevController
This commit is contained in:
+11
-8
@@ -4,7 +4,9 @@ import time
|
||||
import base64
|
||||
import socket
|
||||
import httpx
|
||||
|
||||
from config import *
|
||||
|
||||
from PySide6.QtCore import Signal, Slot,QObject,QMetaObject,Qt,QTimer
|
||||
from Manager.product_manager import productManager
|
||||
from Manager.history_manager import historyManager
|
||||
@@ -41,7 +43,7 @@ class MQTTClient(QObject):
|
||||
self.local_client = mqtt.Client(client_id = 'controller_' + self.random_string(6)) # 创建本地客户端
|
||||
self.device_client = mqtt.Client(client_id = 'controller_dev_' + self.random_string(6)) # 创建设备客户端
|
||||
self.m_clienttimestamp = 0
|
||||
self.cur_product_id = "C8111D73-F387-981D-18D5-849816E1793C"
|
||||
|
||||
# 设置回调函数
|
||||
self.local_client.on_connect = self.on_connect
|
||||
self.local_client.on_message = self.on_message
|
||||
@@ -212,7 +214,7 @@ class MQTTClient(QObject):
|
||||
if json_obj.get("value") == "true":
|
||||
cid = json_obj.get("cid")
|
||||
print("Follow,",cid)
|
||||
self.send_current_product(self.cur_product_id)
|
||||
self.send_current_product(productManager.cur_product_id)
|
||||
elif method == "input":
|
||||
key = json_obj.get("key")
|
||||
value = json_obj.get("value")
|
||||
@@ -269,10 +271,11 @@ class MQTTClient(QObject):
|
||||
self.send_products()
|
||||
|
||||
elif method == "currentProduct":
|
||||
self.cur_product_id = json_obj.get("id")
|
||||
print(f"Current product id: {self.cur_product_id}")
|
||||
self.send_current_product(self.cur_product_id)
|
||||
self.send_current_product_id(self.cur_product_id)
|
||||
cur_product_id = json_obj.get("id")
|
||||
print(f"Current product id: {cur_product_id}")
|
||||
self.send_current_product(cur_product_id)
|
||||
self.send_current_product_id(cur_product_id)
|
||||
productManager.setCurProductId(cur_product_id)
|
||||
|
||||
elif method == "loadHistoryList":
|
||||
cid = json_obj.get("cid")
|
||||
@@ -525,10 +528,10 @@ class MQTTClient(QObject):
|
||||
def send_products(self):
|
||||
"""发送产品信息"""
|
||||
data = dict()
|
||||
data["current_id"] = self.cur_product_id
|
||||
data["current_id"] = productManager.cur_product_id
|
||||
data["method"] = "productList"
|
||||
data["infos"] = productManager.getInfo()
|
||||
print(f"Current product id: {self.cur_product_id}")
|
||||
print(f"Current product id: {productManager.cur_product_id}")
|
||||
self.publish_cpy(TOPICPRODUCT, data, 1) # 发布设备信息
|
||||
|
||||
def start_ys(self, flag):
|
||||
|
||||
Reference in New Issue
Block a user