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

View File

@ -42,15 +42,15 @@ class driver():
self.env['runtime']['debug'].writeDebugOut('InputDriver: ' + _evdevAvailableError,debug.debugLevel.ERROR)
return
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):
if not self._initialized:
return
def inputWatchdog(self, iDevicesFD):
deviceFd = []
for fd in iDevicesFD:
for fd in iDevicesFD['dev']:
deviceFd.append(fd)
while self.watchDog.value == 1:
while self.watchDog.value == 0:
time.sleep(0.01)
r, w, x = select(deviceFd, [], [], 3)
self.watchDog.value = 0
@ -170,8 +170,7 @@ class driver():
i = 0
for fd in self.iDevices:
self.iDevicesFD[i] = fd
i +=1
print(self.iDevicesFD[:])
i +=1
self.iDeviceNo = len(evdev.list_devices())
def mapEvent(self, event):

View File

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