comparison zbmux.py @ 15:a472d6eab97e

Play back the last 5 lines to newly connected clients rather than 1.
author darius@Inchoate
date Sat, 17 Jan 2009 21:43:59 +1030
parents ac60a9244bdf
children ce3712110055
comparison
equal deleted inserted replaced
14:ac60a9244bdf 15:a472d6eab97e
51 log.msg("Me - %s, terminal - %s" % (str(type(self)), str(type(self.terminal)))) 51 log.msg("Me - %s, terminal - %s" % (str(type(self)), str(type(self.terminal))))
52 self.terminal.eraseDisplay() 52 self.terminal.eraseDisplay()
53 self.terminal.resetPrivateModes([]) 53 self.terminal.resetPrivateModes([])
54 54
55 # Send the last whole line we've seen out 55 # Send the last whole line we've seen out
56 if self.factory.lastline != None: 56 for l in self.factory.lastlines:
57 self.message(self.factory.lastline) 57 self.message(l + '\n')
58 58
59 self.pending = "" 59 self.pending = ""
60 self.pendtimer = None 60 self.pendtimer = None
61 self.factory.clients.append(self) 61 self.factory.clients.append(self)
62 62
97 97
98 def __init__(self, zbid, lognamebase): 98 def __init__(self, zbid, lognamebase):
99 self.zbid = zbid 99 self.zbid = zbid
100 self.clients = [] 100 self.clients = []
101 self.tmpline = "" 101 self.tmpline = ""
102 self.lastline = None 102 self.lastlines = []
103 103
104 # Open logger 104 # Open logger
105 self.logger = logging.getLogger('Zigbee-%d' % (zbid)) 105 self.logger = logging.getLogger('Zigbee-%d' % (zbid))
106 self.logger.setLevel(logging.DEBUG) 106 self.logger.setLevel(logging.DEBUG)
107 107
121 121
122 # Logger is line oriented, convert from packet oriented here 122 # Logger is line oriented, convert from packet oriented here
123 self.tmpline = self.tmpline + message 123 self.tmpline = self.tmpline + message
124 tmp = self.tmpline.split('\n') 124 tmp = self.tmpline.split('\n')
125 for l in tmp[0:-1]: 125 for l in tmp[0:-1]:
126 self.lastline = l # Stores last seen line for new clients 126 self.lastlines.append(l)
127 self.lastlines = self.lastlines[-5:]
127 self.logger.debug(l.replace('\n', '')) 128 self.logger.debug(l.replace('\n', ''))
128 self.tmpline = tmp[-1] 129 self.tmpline = tmp[-1]
129 130
130 class ZBProto(Protocol): 131 class ZBProto(Protocol):
131 """Protocol to handle packets from the ZB module on the serial port""" 132 """Protocol to handle packets from the ZB module on the serial port"""