예제 #1
0
 def check(self, sock):
     while init_An24.checking(sock) != [0, 0, 0, 0, 0]:
         checkList = init_An24.checking(sock)
         paint_button(checkList)
         time.sleep(5)
         #init_An24.checking(sock)
     checkList = [0, 0, 0, 0, 0]
     paint_button(checkList)
예제 #2
0
파일: main.py 프로젝트: dizhipeng/Project-1
 def check(self,sock):
     while init_An24.checking(sock) != [0, 0, 0, 0, 0]:
         checkList = init_An24.checking(sock)
         paint_button(checkList)
         time.sleep(5)
         #init_An24.checking(sock)
     checkList = [0, 0, 0, 0, 0]
     paint_button(checkList)
예제 #3
0
 def on_ButtonCheck_clicked(self, checked):
     """
     Slot documentation goes here.
     """
     # TODO: not implemented yet
     """
     此处checkList为返回的电极检查结果
     """
     #checkList=[2, 1, 1, 1, 1]
     checkList = init_An24.checking(init_An24.sock)  #!!!!!!!!!!!!!!
     print checkList
     labelList = [
         self.Check, self.Check_2, self.Check_3, self.Check_4, self.Check_5
     ]
     for i in range(5):
         if checkList[i] == 0:
             labelList[i].setStyleSheet(
                 "background-image: url(:/picture/imgs/OK.png);background-repeat:no-repeat;"
             )
         elif checkList[i] == 2:
             labelList[i].setStyleSheet(
                 "background-image: url(:/picture/imgs/questionMark.png);background-repeat:no-repeat;"
             )
         else:
             labelList[i].setStyleSheet(
                 "background-image: url(:/picture/imgs/No.png);background-repeat:no-repeat;"
             )
예제 #4
0
파일: main.py 프로젝트: dizhipeng/Project-1
 def on_ButtonCheck_clicked(self, checked):
     """
     Slot documentation goes here.
     """
     # TODO: not implemented yet
     """
     此处checkList为返回的电极检查结果
     """
     #checkList=[2, 1, 1, 1, 1]
     global check_value  
     check_value = init_An24.checking(init_An24.sock)                                                                  #!!!!!!!!!!!!
     self.update()
     if check_value == [0, 0, 0, 0, 0]:
         self.ButtonStart.setEnabled(True)
예제 #5
0
 def on_ButtonCheck_clicked(self, checked):
     """
     Slot documentation goes here.
     """
     # TODO: not implemented yet
     """
     此处checkList为返回的电极检查结果
     """
     #checkList=[2, 1, 1, 1, 1]
     global check_value
     check_value = init_An24.checking(init_An24.sock)  #!!!!!!!!!!!!
     self.update()
     if check_value == [0, 0, 0, 0, 0]:
         self.ButtonStart.setEnabled(True)
예제 #6
0
파일: main.py 프로젝트: dizhipeng/Project-1
 def on_ButtonCheck_clicked(self, checked):
     """
     Slot documentation goes here.
     """
     # TODO: not implemented yet
     """
     此处checkList为返回的电极检查结果
     """
     #checkList=[2, 1, 1, 1, 1]
     checkList = init_An24.checking(init_An24.sock)                                            #!!!!!!!!!!!!!!
     print checkList
     labelList=[self.Check, self.Check_2, self.Check_3,self.Check_4, self.Check_5]
     for i in range(5):            
         if checkList[i]==0:
             labelList[i].setStyleSheet("background-image: url(:/picture/imgs/OK.png);background-repeat:no-repeat;") 
         elif checkList[i]==2:
             labelList[i].setStyleSheet("background-image: url(:/picture/imgs/questionMark.png);background-repeat:no-repeat;")
         else:
             labelList[i].setStyleSheet("background-image: url(:/picture/imgs/No.png);background-repeat:no-repeat;")
예제 #7
0
파일: AN24.py 프로젝트: dizhipeng/Project-1
 def init_chk(self):
     return init_An24.checking(self.sock, 
             self.run_chk) 
예제 #8
0
 def init_chk(self):
     return init_An24.checking(self.sock, self.run_chk)
예제 #9
0
파일: data.py 프로젝트: dizhipeng/Project-1
    str1 = data.decode("ascii")
    print 'hexbuf:', hexbuf, str1
    print '-------------------------------'
    print 'endpos:', endpos
    print '-------------------------------'
    print 'lbuf:',lbuf
    print 'regbuf:', regbuf 
    print type(data)
   
if __name__ == '__main__':
    #print 'i can print'
    #sock = 
    init_An24.conn()
    init_An24.battry(init_An24.sock)

    init_An24.checking(init_An24.sock)
    #print rvalue
    start_data_thread(init_An24.sock)
    #print 'there can go'

    #data_recv_An24(addr)
    #stream_in_cache()

   
#client_sock.close()
#server_sock.close()
    



예제 #10
0
 def init_chk(self):
     chk = init_An24.checking(self.sock, self.run_chk)
     #self.run_chk = chk
     return chk
예제 #11
0
파일: AN24.py 프로젝트: dizhipeng/Project-1
 def init_chk(self):
     chk = init_An24.checking(self.sock,self.run_chk)
     #self.run_chk = chk
     return  chk
예제 #12
0
def data_recv_An24(bd_addr):
    # ************
    #   connect An24(bd_addr) then recieve data from it
    # ************

    #sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
    #sock.connect((bd_addr, port))
    global check_value
    sock = init_An24.conn(bd_addr)
    print '[OK] connecting '
    print 'prepare check...'
    init_An24.checking(sock)
    '''
    while init_An24.checking(sock) != [0, 0, 0, 0, 0]:
        #check_value = init_check(check_signal(sock))
        check_value = init_An24.checking(sock)
        print '[not ok] check', check_value
        time.sleep(5)
    check_value = [0, 0, 0, 0, 0]
    print '[ok] check', check_value
    '''
    print '[start...]'
    sock = init_An24.start(sock)

    print '[waiting reply...]'
    print '[ok] ready to accept data '

    #output = open('output.txt','a')
    pattern = re.compile(r'1002.*?1003', re.DOTALL)
    lbuf = ''
    endstr = '1003'
    endpos = 0
    data_one_sec = []

    while 1:
        buf = sock.recv(65535)

        if not len(buf):
            break

        hexbuf = buf.encode('hex')
        lbuf = lbuf + hexbuf
        #regbuf = pattern.findall(lbuf)

        for m in pattern.finditer(lbuf):
            log('source data:', m.group())
            data_one_sec = data_parse(m.group())
            stream_in_cache(data_one_sec)
            #print data_cache
            #print stream_in_cache()
            #print type(data_all)      #tuple

            #print len(data_all)

            #print type(m.group())     # //str
            #print len(m.group())      # //76
            #print m.group().isdigit()  #//False
            #print dir(m.group())

        if endstr in lbuf:
            endpos = lbuf.index(endstr) + 4

        else:
            pass

        lbuf = lbuf[endpos:]
    close_data_thread()
    output.close()
    sock.close()
예제 #13
0
    for m in pattern.finditer(hexbuf):
        print m.group()
    output.write(regbuf.encode('hex'))
    #print '[ok] query data type', chardet.detect(data)
    str1 = data.decode("ascii")
    print 'hexbuf:', hexbuf, str1
    print '-------------------------------'
    print 'endpos:', endpos
    print '-------------------------------'
    print 'lbuf:', lbuf
    print 'regbuf:', regbuf
    print type(data)


if __name__ == '__main__':
    #print 'i can print'
    #sock =
    init_An24.conn()
    bat = init_An24.battry(init_An24.sock)

    init_An24.checking(init_An24.sock)
    #print rvalue
    start_data_thread(init_An24.sock)
    #print 'there can go'

    #data_recv_An24(addr)
    #stream_in_cache()

#client_sock.close()
#server_sock.close()
예제 #14
0
파일: data.py 프로젝트: dizhipeng/Project-1
def data_recv_An24(bd_addr):
    # ************
    #   connect An24(bd_addr) then recieve data from it
    # ************

    #sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
    #sock.connect((bd_addr, port))
    global check_value
    sock = init_An24.conn(bd_addr)
    print '[OK] connecting '
    print 'prepare check...'
    init_An24.checking(sock)
    '''
    while init_An24.checking(sock) != [0, 0, 0, 0, 0]:
        #check_value = init_check(check_signal(sock))
        check_value = init_An24.checking(sock)
        print '[not ok] check', check_value
        time.sleep(5)
    check_value = [0, 0, 0, 0, 0]
    print '[ok] check', check_value
    '''
    print '[start...]'
    sock = init_An24.start(sock)
    
    print '[waiting reply...]'
    print '[ok] ready to accept data '

    #output = open('output.txt','a')
    pattern = re.compile(r'1002.*?1003', 
            re.DOTALL)
    lbuf = ''
    endstr = '1003'
    endpos = 0
    data_one_sec = []

    while 1:
        buf = sock.recv(65535)

        if not len(buf):
            break
    
        hexbuf = buf.encode('hex')
        lbuf = lbuf + hexbuf
        #regbuf = pattern.findall(lbuf)

        for m in pattern.finditer(lbuf):
            log( 'source data:', m.group())
            data_one_sec = data_parse(m.group())
            stream_in_cache(data_one_sec)
            #print data_cache
            #print stream_in_cache()
            #print type(data_all)      #tuple
            
            #print len(data_all)

            #print type(m.group())     # //str 
            #print len(m.group())      # //76
            #print m.group().isdigit()  #//False
            #print dir(m.group())

        if endstr in lbuf:
            endpos = lbuf.index(endstr) + 4 
         
        else:
            pass
    
        lbuf = lbuf[endpos:]
    close_data_thread()
    output.close()
    sock.close()