import serial
import serial.tools.list_ports
import threading
import time
import json
import socket
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import sys






class protu(QObject):
    # 进度信号，ip，1~100
    rate_signal =pyqtSignal([int])
    # 结束信号，ip，成败，描述
    end_signal = pyqtSignal([bool,str])
    # 接收到数据信号
    recv_signal =pyqtSignal([int,bytearray,str])

    def __init__(self) -> None:
        QObject.__init__(self)
        self.app = QApplication(sys.argv)

    def wait_in_thread(self):
        print("wait int thread")
        while(True):
            self.recv_signal.emit(0,bytearray(),"ok")
            print("in wait")
            time.sleep(1)
    def start_thread(self):
        self.recv_signal.connect(self.recv_slot)
        self.thread_ = threading.Thread(target=self.wait_in_thread, args=())
        self.thread_.start()
        self.recv_signal.emit(0,bytearray(),"ok")
        sys.exit(self.app.exec())
    def recv_slot(self,ack:int,data:bytearray,err:str):
        print("recv slot")


pro=protu()
pro.start_thread()


