add VCSA watchdog prototype

This commit is contained in:
chrys 2017-06-22 00:04:07 +02:00
parent 900d7c9178
commit 42ade1fbf8
2 changed files with 49 additions and 2 deletions

41
play zone/epollScreen.py Normal file
View File

@ -0,0 +1,41 @@
#!/bin/python
import select
import time
vcsa = {}
for i in range(1,7):
vcsa[str(i)] = open('/dev/vcs'+str(i),'rb')
vcsa[str(i)].read()
tty = open('/sys/devices/virtual/tty/tty0/active','r')
oldTty = str(tty.read()[3:-1])
watchdog = select.poll()
watchdog.register(tty, select.EPOLLPRI)
watchdog.register(vcsa[ oldTty ], select.EPOLLPRI)
while True:
changed = watchdog.poll()
print('-----------------------------')
print(changed,tty.fileno())
for fileno, event in changed:
if tty.fileno() == fileno:
currTty = tty.seek(0)
#b = open('/sys/devices/virtual/tty/tty0/active','r')
currTty = str(tty.read()[3:-1])
print('|'+currTty+'|'+oldTty+'|')
if currTty != oldTty:
watchdog.register(vcsa[ currTty ].fileno(), select.EPOLLPRI)
watchdog.unregister(vcsa[ oldTty ].fileno())
oldTty = currTty
print('new screen ' + currTty)
else:
print('update '+ currTty + ' ' + str(fileno))
vcsa[currTty].seek(0)
b = vcsa[currTty].read()
#print(b)
time.sleep(0.5)

View File

@ -41,10 +41,14 @@ class eventManager():
self.terminateAllProcesses()
self.cleanEventQueue()
def timerProcess(self):
try:
time.sleep(0.03)
except:
pass
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
return time.time()
def terminateAllProcesses(self):
time.sleep(1)
for proc in self._eventProcesses:
try:
proc.terminate()
@ -52,7 +56,9 @@ class eventManager():
print(e)
def proceedEventLoop(self):
event = self._eventQueue.get()
st = time.time()
self.eventDispatcher(event)
print('NET loop ' + str(time.time() - st))
def eventDispatcher(self, event):
if not event:
return
@ -84,7 +90,7 @@ class eventManager():
while(self._mainLoopRunning.value == 1):
st = time.time()
self.proceedEventLoop()
print('loop ' + str(time.time() - st))
print('ALL loop ' + str(time.time() - st))
def stopMainEventLoop(self, Force = False):
if Force:
self._mainLoopRunning.value = 0