Esempio n. 1
0
    def poll():
        global scan, vs
        
        # Check if the START Scanning button has just pressed
        if f1.justStarted():
            vs = VisioStat( f1.portsopend )
            print("Scanning...")
            scan = True

        # Check if the STOP Scanning button has just pressed
        if f1.justStopped():
            vs.closeall()
            f2.closeall()
            print("Scanning stopped...")
            scan = False

        # Check if we need to scan all ports for VisioStat data
        if scan:
            (idx, pname, raw) = vs.readport()      # this will wait 100 loops
            (serial, seng, feng, value) = toeng( raw )
            if idx>=0: 

                # Uncomment the line below to see the records before logged
                # print( idx, pname+" "+raw, seng )
                f2.eng( idx, seng, pname+" "+raw )
                f3.logstats( idx, pname, serial, raw, feng )
            else:    
                print("--- waiting for data --------")
        
        # In all cases, re-register this routine to be called again by mainloop
        root.after( 10, poll )
Esempio n. 2
0
    def poll():
        global scan, vs

        # Check if the START Scanning button has just pressed
        if f1.justStarted():
            vs = VisioStat(f1.portsopend)
            print("Scanning...")
            scan = True

        # Check if the STOP Scanning button has just pressed
        if f1.justStopped():
            vs.closeall()
            f2.closeall()
            print("Scanning stopped...")
            scan = False

        # Check if we need to scan all ports for VisioStat data
        if scan:
            (idx, pname, raw) = vs.readport()  # this will wait 100 loops
            (serial, seng, feng, value) = toeng(raw)
            if idx >= 0:

                # Uncomment the line below to see the records before logged
                # print( idx, pname+" "+raw, seng )
                f2.eng(idx, seng, pname + " " + raw)
                f3.logstats(idx, pname, serial, raw, feng)
            else:
                print("--- waiting for data --------")

        # In all cases, re-register this routine to be called again by mainloop
        root.after(10, poll)
Esempio n. 3
0
 def decodeline( self ):
     (idx, pname, raw) = self.vs.read1Port()
     # if idx<0, data were not received in-time
     
     if idx<0:
         print( "--- waiting for data ---" ) 
         self.lerr.config( text='Timeout, no data received for 2 sec' )
         return (-1, "     ", 0)   
         
     else:            
         print( raw )
         self.ldata.config( text=raw )
         
         # try to decode the data
         (serial, seng, feng, value) = toeng( raw )
         if serial < 0:
             self.lerr.config( text='decoding error' )                
         else:
             self.lerr.config( text='ok' )                            
         
         return (serial, seng, value)