Exemple #1
0
def idle(endRxFunc):
    tdisp = dm.dequeue()
    if tdisp != None:
        mess, pos = tdisp
        lcd_mess(mess, pos)
    t = time.perf_counter()
    for ind in sensors:
        node, handler = sensors[ind]
        if node.messageTimeout != 0 and t - node.messageTimeout > 0:
            log(0, "TimedOut %s" % ind)
            node.messageTimeout = 0
            endRxFunc()
            handler.send(("TimedOut", ))
            return True
    s = int(t)
    if s == ls.lastSec:
        time.sleep(0.05)
        return False

    if (s % 5 == 0):
        if ls.not0:
            endRxFunc()
            log(1, "Sending network present message")
            log(1, "time=%s" % time.perf_counter())
            tx(serialNo, 0, (s % period) // 5, 0, 0,
               1)  #Send 'network present' message
            time.sleep(0.05)
            ls.not0 = False
            return True
        if actionQueue != []:
            endRxFunc()
            cont, ser, i, c, d1, d2, p = actionQueue.pop()
            log(1, "Sending control message to %s" % i)
            log(1, "time=%s" % time.perf_counter())
            cont.messageTimeout = time.perf_counter() + 0.05
            tx(ser, i, c, d1, d2, p)
            return True
    dm.enqueue((num_str(s % period, 10, 3), 13))
    ls.lastSec = s
    ls.not0 = True
    return bsmHandler(endRxFunc)
Exemple #2
0
 def __init__(self):
     lcd_init()
     lcd_mess("bubblNet ph= ", 0)
     lcd_mess("                ", 64)
     self.messageQueue = []