performance improvements
This commit is contained in:
parent
449f149f97
commit
16f4e3e981
74
src/fenrir/commands/onHeartBeat/2000-GetSessionInfo.py
Executable file
74
src/fenrir/commands/onHeartBeat/2000-GetSessionInfo.py
Executable file
@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/python
|
||||||
|
import time
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
# Fenrir TTY screen reader
|
||||||
|
# By Chrys, Storm Dragon, and contributers.
|
||||||
|
|
||||||
|
from core import debug
|
||||||
|
import time
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
class command():
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
def initialize(self, environment):
|
||||||
|
self.env = environment
|
||||||
|
self.lastTime = datetime.datetime.now()
|
||||||
|
self.lastDateString = ''
|
||||||
|
self.lastTimeString = ''
|
||||||
|
def shutdown(self):
|
||||||
|
pass
|
||||||
|
def getDescription(self):
|
||||||
|
return 'No Description found'
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
if not self.env['runtime']['settingsManager'].getSettingAsBool('time', 'enabled'):
|
||||||
|
return
|
||||||
|
onMinutes = self.env['runtime']['settingsManager'].getSetting('time', 'onMinutes')
|
||||||
|
delaySec = self.env['runtime']['settingsManager'].getSettingAsInt('time', 'delaySec')
|
||||||
|
# no need
|
||||||
|
if onMinutes == '' and delaySec <= 0:
|
||||||
|
return
|
||||||
|
onMinutes = onMinutes.split(',')
|
||||||
|
now = datetime.datetime.now()
|
||||||
|
# ignore onMinutes if there is a delaySec
|
||||||
|
if delaySec > 0:
|
||||||
|
if int((now-self.lastTime).total_seconds()) < delaySec:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# shoul announce?
|
||||||
|
if not str(now.minute) in onMinutes:
|
||||||
|
return
|
||||||
|
# already announced?
|
||||||
|
if now.hour == self.lastTime.hour:
|
||||||
|
if now.minute == self.lastTime.minute:
|
||||||
|
return
|
||||||
|
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
|
||||||
|
dateString = datetime.datetime.strftime(now, dateFormat)
|
||||||
|
|
||||||
|
presentDate = self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentDate') and \
|
||||||
|
self.lastDateString != dateString
|
||||||
|
presentTime = self.env['runtime']['settingsManager'].getSettingAsBool('time', 'presentTime')
|
||||||
|
# no changed value to announce
|
||||||
|
if not (presentDate or presentTime):
|
||||||
|
return
|
||||||
|
timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat')
|
||||||
|
timeString = datetime.datetime.strftime(now, timeFormat)
|
||||||
|
|
||||||
|
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'interrupt'):
|
||||||
|
self.env['runtime']['outputManager'].interruptOutput()
|
||||||
|
if self.env['runtime']['settingsManager'].getSettingAsBool('time', 'announce'):
|
||||||
|
self.env['runtime']['outputManager'].playSoundIcon('announce')
|
||||||
|
|
||||||
|
if presentTime:
|
||||||
|
# present the time
|
||||||
|
self.env['runtime']['outputManager'].presentText(_('Autotime: {0}').format(timeString), soundIcon='', interrupt=False)
|
||||||
|
# and date if changes
|
||||||
|
if presentDate:
|
||||||
|
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=False)
|
||||||
|
self.lastDateString = dateString
|
||||||
|
self.lastTime = datetime.datetime.now()
|
||||||
|
self.lastTimeString = timeString
|
||||||
|
def setCallback(self, callback):
|
||||||
|
pass
|
@ -53,9 +53,11 @@ class eventManager():
|
|||||||
self.handleStopMainLoop()
|
self.handleStopMainLoop()
|
||||||
return
|
return
|
||||||
elif event['Type'] == fenrirEventType.ScreenUpdate:
|
elif event['Type'] == fenrirEventType.ScreenUpdate:
|
||||||
|
pass
|
||||||
self.env['runtime']['fenrirManager'].handleScreenUpdate()
|
self.env['runtime']['fenrirManager'].handleScreenUpdate()
|
||||||
elif event['Type'] == fenrirEventType.KeyboardInput:
|
elif event['Type'] == fenrirEventType.KeyboardInput:
|
||||||
self.env['runtime']['fenrirManager'].handleInput()
|
self.env['runtime']['fenrirManager'].handleInput()
|
||||||
|
#self.env['runtime']['fenrirManager'].handleScreenUpdate()
|
||||||
elif event['Type'] == fenrirEventType.BrailleInput:
|
elif event['Type'] == fenrirEventType.BrailleInput:
|
||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
||||||
|
@ -63,8 +63,8 @@ class fenrirManager():
|
|||||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||||
if self.environment['input']['keyForeward'] > 0:
|
if self.environment['input']['keyForeward'] > 0:
|
||||||
self.environment['input']['keyForeward'] -=1
|
self.environment['input']['keyForeward'] -=1
|
||||||
#self.environment['runtime']['screenManager'].update('onInput')
|
self.environment['runtime']['screenManager'].update('onInput')
|
||||||
#self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||||
self.handleCommands()
|
self.handleCommands()
|
||||||
def handleScreenChange(self):
|
def handleScreenChange(self):
|
||||||
self.environment['runtime']['screenManager'].update('onScreenChange')
|
self.environment['runtime']['screenManager'].update('onScreenChange')
|
||||||
@ -80,14 +80,15 @@ class fenrirManager():
|
|||||||
|
|
||||||
def handleScreenUpdate(self):
|
def handleScreenUpdate(self):
|
||||||
s = time.time()
|
s = time.time()
|
||||||
|
|
||||||
self.environment['runtime']['screenManager'].update('onUpdate')
|
self.environment['runtime']['screenManager'].update('onUpdate')
|
||||||
'''
|
|
||||||
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
||||||
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
||||||
self.environment['runtime']['applicationManager'].getPrevApplication(), \
|
self.environment['runtime']['applicationManager'].getPrevApplication(), \
|
||||||
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
||||||
'''
|
|
||||||
#if not self.environment['runtime']['screenManager'].isScreenChange():
|
#if not self.environment['runtime']['screenManager'].isScreenChange():
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
|
||||||
#print(time.time() -s)
|
#print(time.time() -s)
|
||||||
|
@ -21,16 +21,18 @@ class screenManager():
|
|||||||
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
|
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
|
||||||
|
|
||||||
def update(self, trigger='onUpdate'):
|
def update(self, trigger='onUpdate'):
|
||||||
self.env['runtime']['screenDriver'].getCurrScreen()
|
|
||||||
self.env['runtime']['screenDriver'].getSessionInformation()
|
if trigger == 'onScreenChange':
|
||||||
|
self.env['runtime']['screenDriver'].getCurrScreen()
|
||||||
|
self.env['runtime']['screenDriver'].getSessionInformation()
|
||||||
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
|
||||||
if self.isScreenChange():
|
if self.isScreenChange():
|
||||||
self.changeBrailleScreen()
|
self.changeBrailleScreen()
|
||||||
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
|
||||||
self.env['runtime']['screenDriver'].update(trigger)
|
self.env['runtime']['screenDriver'].update(trigger)
|
||||||
if trigger == 'onUpdate' or self.isScreenChange() \
|
#if trigger == 'onUpdate' or self.isScreenChange() \
|
||||||
or len(self.env['screen']['newDelta']) > 6:
|
# or len(self.env['screen']['newDelta']) > 6:
|
||||||
self.env['runtime']['screenDriver'].getCurrApplication()
|
# self.env['runtime']['screenDriver'].getCurrApplication()
|
||||||
self.env['screen']['lastScreenUpdate'] = time.time()
|
self.env['screen']['lastScreenUpdate'] = time.time()
|
||||||
|
|
||||||
def isSuspendingScreen(self, screen = None):
|
def isSuspendingScreen(self, screen = None):
|
||||||
|
@ -45,7 +45,7 @@ class driver():
|
|||||||
self.env['runtime']['eventManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdog)
|
self.env['runtime']['eventManager'].addSimpleEventThread(fenrirEventType.PlugInputDevice, self.plugInputDeviceWatchdog)
|
||||||
self.env['runtime']['eventManager'].addSimpleEventThread(fenrirEventType.KeyboardInput, self.inputWatchdog, {'dev':self.iDevicesFD})
|
self.env['runtime']['eventManager'].addSimpleEventThread(fenrirEventType.KeyboardInput, self.inputWatchdog, {'dev':self.iDevicesFD})
|
||||||
def plugInputDeviceWatchdog(self):
|
def plugInputDeviceWatchdog(self):
|
||||||
time.sleep(2)
|
time.sleep(2.5)
|
||||||
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
|
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
|
||||||
return time.time()
|
return time.time()
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
@ -58,7 +58,7 @@ class driver():
|
|||||||
while self.watchDog.value == 0:
|
while self.watchDog.value == 0:
|
||||||
if active.value == 0:
|
if active.value == 0:
|
||||||
return
|
return
|
||||||
time.sleep(0.01)
|
time.sleep(0.001)
|
||||||
r = []
|
r = []
|
||||||
while r == []:
|
while r == []:
|
||||||
r, w, x = select(deviceFd, [], [], 2)
|
r, w, x = select(deviceFd, [], [], 2)
|
||||||
|
@ -98,7 +98,6 @@ class driver():
|
|||||||
self.env['screen']['autoIgnoreScreens'] = []
|
self.env['screen']['autoIgnoreScreens'] = []
|
||||||
|
|
||||||
def updateWatchdog(self,active , eventQueue):
|
def updateWatchdog(self,active , eventQueue):
|
||||||
print('init VCSA updateWatchdog')
|
|
||||||
currScreen = '2'
|
currScreen = '2'
|
||||||
vcsa = {}
|
vcsa = {}
|
||||||
for i in range(1,7):
|
for i in range(1,7):
|
||||||
|
Loading…
Reference in New Issue
Block a user