imporove performance

This commit is contained in:
chrys 2017-06-24 00:36:56 +02:00
parent 3037ad36e0
commit 72057cda0e
3 changed files with 16 additions and 19 deletions

View File

@ -26,8 +26,7 @@ class eventManager():
self.cleanEventQueue() self.cleanEventQueue()
def heartBeatTimer(self): def heartBeatTimer(self):
try: try:
time.sleep(0.3) time.sleep(8)
print('bin auch da')
except: except:
pass pass
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay') #self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
@ -43,8 +42,9 @@ class eventManager():
event = self._eventQueue.get() event = self._eventQueue.get()
st = time.time() st = time.time()
self.eventDispatcher(event) self.eventDispatcher(event)
print('NET loop ' + str(time.time() - st)) #print('NET loop ' + str(time.time() - st))
def eventDispatcher(self, event): def eventDispatcher(self, event):
print(event['Type'])
if not event: if not event:
return return
if event['Type'] == fenrirEventType.Ignore: if event['Type'] == fenrirEventType.Ignore:
@ -83,7 +83,7 @@ class eventManager():
while( self.isMainEventLoopRunning()): while( self.isMainEventLoopRunning()):
st = time.time() st = time.time()
self.proceedEventLoop() self.proceedEventLoop()
print('ALL loop ' + str(time.time() - st)) #print('ALL loop ' + str(time.time() - st))
def stopMainEventLoop(self, Force = False): def stopMainEventLoop(self, Force = False):
if Force: if Force:
self._mainLoopRunning.value = 0 self._mainLoopRunning.value = 0
@ -148,6 +148,5 @@ class eventManager():
pass pass
print(e) print(e)
self.putToEventQueue(event, Data) self.putToEventQueue(event, Data)
print('jo')
if runOnce: if runOnce:
break break

View File

@ -42,15 +42,15 @@ class driver():
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
return return
self.updateInputDevices() self.updateInputDevices()
self.env['runtime']['eventManager'].addSimpleEventThread(fenrirEventType.KeyboardInput, self.inputWatchdog, {'dev':self.iDevicesFD, 'syn':self.watchDog}) self.env['runtime']['eventManager'].addSimpleEventThread(fenrirEventType.KeyboardInput, self.inputWatchdog, {'dev':self.iDevicesFD})
def shutdown(self): def shutdown(self):
if not self._initialized: if not self._initialized:
return return
def inputWatchdog(self, iDevicesFD): def inputWatchdog(self, iDevicesFD):
deviceFd = [] deviceFd = []
for fd in iDevicesFD: for fd in iDevicesFD['dev']:
deviceFd.append(fd) deviceFd.append(fd)
while self.watchDog.value == 1: while self.watchDog.value == 0:
time.sleep(0.01) time.sleep(0.01)
r, w, x = select(deviceFd, [], [], 3) r, w, x = select(deviceFd, [], [], 3)
self.watchDog.value = 0 self.watchDog.value = 0
@ -171,7 +171,6 @@ class driver():
for fd in self.iDevices: for fd in self.iDevices:
self.iDevicesFD[i] = fd self.iDevicesFD[i] = fd
i +=1 i +=1
print(self.iDevicesFD[:])
self.iDeviceNo = len(evdev.list_devices()) self.iDeviceNo = len(evdev.list_devices())
def mapEvent(self, event): def mapEvent(self, event):

View File

@ -110,15 +110,13 @@ class driver():
watchdog = select.epoll() watchdog = select.epoll()
watchdog.register(vcsa[currScreen], select.EPOLLPRI) watchdog.register(vcsa[currScreen], select.EPOLLPRI)
watchdog.register(tty, select.EPOLLPRI) watchdog.register(tty, select.EPOLLPRI)
lastChange = 0
while True: while True:
changes = watchdog.poll()
print('-----------------------------') changes = watchdog.poll(3)
print(changes)
for change in changes: for change in changes:
fileno = change[0] fileno = change[0]
event = change[1] event = change[1]
print(change,fileno, tty.fileno())
if fileno == tty.fileno(): if fileno == tty.fileno():
tty.seek(0) tty.seek(0)
currScreen = str(tty.read()[3:-1]) currScreen = str(tty.read()[3:-1])
@ -127,12 +125,13 @@ class driver():
watchdog.register(vcsa[ currScreen ], select.EPOLLPRI) watchdog.register(vcsa[ currScreen ], select.EPOLLPRI)
oldScreen = currScreen oldScreen = currScreen
eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":''}) eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":''})
print('new screen '+ currScreen)
else: else:
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
content = vcsa[currScreen].read() content = vcsa[currScreen].read()
print(time.time(), lastChange)
if time.time() - lastChange > 0.1:
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":''}) eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":''})
print('update '+ str(time.time())) lastChange = time.time()
def update(self, trigger='onUpdate'): def update(self, trigger='onUpdate'):
newContentBytes = b'' newContentBytes = b''