Beispiel #1
0
    def touchConnect(self):  # 在文本框内容最后接着插入输入内容

        self.comPort = self.e.get()
        if self.isOpen and self.isOpeningCOM:
            pyutil.func_closePort()
            self.showLog("关闭串口成功")
        else:
            print(self.comPort)
            if self.comPort and self.comPort != '' and int(
                    self.comPort) >= 0 and int(self.comPort) < 20:
                self.showLog("正在打开串口:com%s,请等串口初始化完成" % (self.comPort))
                time.sleep(0.5)
                if not self.isOpeningCOM:
                    print('xdd')
                    if self.isOpen:
                        pyutil.func_closePort()
                        self.isOpen = False
                        self.showLog("串口已关闭")
                    else:
                        tmport = 'com' + self.comPort
                        self.initSeial(tmport)
                        time.sleep(0.5)
                        if pyutil.func_openSerial():
                            print('open ok')
                            self.isCheckOK = False
                        else:
                            print('open erro')
                        time.sleep(0.5)
                        if not self.isCheckOK and pyutil.func_isSerialOpen():
                            self.isOpeningCOM = True
                            self.isTestCom = True
Beispiel #2
0
def serialThread(pUtool):
    time.sleep(1)
    if pyutil.func_isSerialOpen():
        pUtool.showLog('尝试打开之前设置的串口')
    else:
        pUtool.showLog('未设置串口号,或串口被占用,\n串口号可在设备管理器中查看')
    time.sleep(2.0)
    pyutil.func_sendCMD('t')
    taskobj = TimeObj()
    times = taskobj.times
    while True:
        time.sleep(0.005)
        nowtime = int(time.time()*1000)
        if len(times) > 0 and times[0] <= nowtime:
            if nowtime - times[0] > 60: #一分钟前已点击,这里直接认为时间为无效
                ptime = times.pop(0)
                taskobj.timedict.pop(ptime)
                print('time is passed:%s'%(timetool.getNowDate(ptime/1000)))
            else:
                touchdat = taskobj.timedict.pop(times.pop(0))
                key = touchdat['key']
                tmpcount = touchdat['times']
                delay = touchdat['delay']
                while tmpcount > 0:
                    pyutil.func_sendCMD(key)
                    if delay > 0:
                        time.sleep(delay/1000.0)
                    else:
                        time.sleep(0.005)
                    tmpcount -= 1
        elif len(times) < 1:
            taskobj.initTimer()
            times = taskobj.times
            time.sleep(1.0)
            print('init times again')
Beispiel #3
0
def serialThread(pUtool):
    time.sleep(1)
    if pyutil.func_isSerialOpen():
        pUtool.showLog('尝试打开之前设置的串口')
    else:
        pUtool.showLog('未设置串口号,或串口被占用,\n串口号可在设备管理器中查看')
    while True:
        time.sleep(1.0)
        if pUtool.isTestCom:
            pyutil.func_sendCMD('t')
Beispiel #4
0
    def __init__(self):
        #
        self.isOpen = False
        self.isCheckOK = False
        self.isOpeningCOM = False
        self.portName = ''
        self.lastReadData = None
        self.callbackTh = None

        self.isTestCom = False

        self.initCallBack()

        self.comPort = None

        if pyutil.func_isSerialOpen():
            self.showLog('正在打开之前设置的串口')
            self.isOpeningCOM = True
            self.isTestCom = True
            self.comPort = pyutil.stool.dev[3:]
            self.showLog('serial port:' + str(self.comPort))
Beispiel #5
0
    def __init__(self):
        #
        self.isOpen = False
        self.isCheckOK = False
        self.isOpeningCOM = False
        self.portName = ''
        self.lastReadData = None
        self.callbackTh = None

        self.isTestCom = False

        self.initCallBack()
        # self.queue = Queue.Queue()
        #
        self.window = tk.Tk()
        self.window.title('青苹果屏幕点击器')
        self.window.geometry('500x360')  # 这里的乘是小x
        self.log = StringVar()
        self.log.set('正在初始化。。。')
        self.status = IntVar()
        self.comPort = None
        self.conBtnTxt = StringVar()
        self.conBtnTxt.set('打开串口')

        self.eTxt = StringVar()

        self.lbcom = tk.Label(self.window, text='com')
        self.lbcom.place(x=25, y=255, anchor='nw')

        self.e = tk.Entry(self.window,
                          textvariable=self.eTxt,
                          width=5,
                          show=None)  #显示成明文形式
        # e.pack()
        self.e.place(x=65, y=255, anchor='nw')

        self.lbinputlog = tk.Label(self.window, text='在下边输入串口编号,串口号在设备管理器查看')
        self.lbinputlog.place(x=5, y=220, anchor='nw')

        # 第6步,创建并放置两个按钮分别触发两种情况
        self.b1 = tk.Button(self.window,
                            text='1',
                            width=5,
                            height=2,
                            command=self.touch1)
        # b1.pack()
        self.b1.place(x=305, y=5, anchor='nw')

        self.b2 = tk.Button(self.window,
                            text='2',
                            width=5,
                            height=2,
                            command=self.touch2)
        # b2.pack()
        self.b2.place(x=355, y=5, anchor='nw')

        self.b3 = tk.Button(self.window,
                            text='3',
                            width=5,
                            height=2,
                            command=self.touch3)
        self.b3.place(x=405, y=5, anchor='nw')

        self.b4 = tk.Button(self.window,
                            text='4',
                            width=5,
                            height=2,
                            command=self.touch4)
        self.b4.place(x=305, y=55, anchor='nw')
        self.b5 = tk.Button(self.window,
                            text='5',
                            width=5,
                            height=2,
                            command=self.touch5)
        self.b5.place(x=355, y=55, anchor='nw')
        self.b6 = tk.Button(self.window,
                            text='6',
                            width=5,
                            height=2,
                            command=self.touch6)
        self.b6.place(x=405, y=55, anchor='nw')

        self.b7 = tk.Button(self.window,
                            text='7',
                            width=5,
                            height=2,
                            command=self.touch7)
        self.b7.place(x=305, y=105, anchor='nw')
        self.b8 = tk.Button(self.window,
                            text='8',
                            width=5,
                            height=2,
                            command=self.touch8)
        self.b8.place(x=355, y=105, anchor='nw')
        self.b9 = tk.Button(self.window,
                            text='9',
                            width=5,
                            height=2,
                            command=self.touch9)
        self.b9.place(x=405, y=105, anchor='nw')

        self.b10 = tk.Button(self.window,
                             text='10',
                             width=5,
                             height=2,
                             command=self.touch10)
        self.b10.place(x=305, y=155, anchor='nw')
        self.bok = tk.Button(self.window,
                             text='ok',
                             width=5,
                             height=2,
                             command=self.touchOK)
        self.bok.place(x=405, y=155, anchor='nw')

        self.bcon = tk.Button(self.window,
                              textvariable=self.conBtnTxt,
                              width=10,
                              height=2,
                              command=self.touchConnect)
        self.bcon.place(x=335, y=255, anchor='nw')

        self.lb = tk.Label(self.window,
                           width=40,
                           height=10,
                           textvariable=self.log)
        self.lb.place(x=5, y=5, anchor='nw')

        if pyutil.func_isSerialOpen():
            self.showLog('正在打开之前设置的串口')
            self.isOpeningCOM = True
            self.isTestCom = True
            self.comPort = pyutil.stool.dev[3:]
            self.eTxt.set(self.comPort)