add VCSA watchdog prototype
This commit is contained in:
parent
900d7c9178
commit
42ade1fbf8
41
play zone/epollScreen.py
Normal file
41
play zone/epollScreen.py
Normal 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -41,10 +41,14 @@ class eventManager():
|
|||||||
self.terminateAllProcesses()
|
self.terminateAllProcesses()
|
||||||
self.cleanEventQueue()
|
self.cleanEventQueue()
|
||||||
def timerProcess(self):
|
def timerProcess(self):
|
||||||
|
try:
|
||||||
time.sleep(0.03)
|
time.sleep(0.03)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
|
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
|
||||||
return time.time()
|
return time.time()
|
||||||
def terminateAllProcesses(self):
|
def terminateAllProcesses(self):
|
||||||
|
time.sleep(1)
|
||||||
for proc in self._eventProcesses:
|
for proc in self._eventProcesses:
|
||||||
try:
|
try:
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
@ -52,7 +56,9 @@ class eventManager():
|
|||||||
print(e)
|
print(e)
|
||||||
def proceedEventLoop(self):
|
def proceedEventLoop(self):
|
||||||
event = self._eventQueue.get()
|
event = self._eventQueue.get()
|
||||||
|
st = time.time()
|
||||||
self.eventDispatcher(event)
|
self.eventDispatcher(event)
|
||||||
|
print('NET loop ' + str(time.time() - st))
|
||||||
def eventDispatcher(self, event):
|
def eventDispatcher(self, event):
|
||||||
if not event:
|
if not event:
|
||||||
return
|
return
|
||||||
@ -84,7 +90,7 @@ class eventManager():
|
|||||||
while(self._mainLoopRunning.value == 1):
|
while(self._mainLoopRunning.value == 1):
|
||||||
st = time.time()
|
st = time.time()
|
||||||
self.proceedEventLoop()
|
self.proceedEventLoop()
|
||||||
print('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
|
||||||
|
Loading…
Reference in New Issue
Block a user