no empty input event; make hartbeat work; plugInputDevice trigger
This commit is contained in:
parent
9bee489bc7
commit
e8c0109267
0
src/fenrir/commands/onHeartBeat/76000-time.py
Normal file → Executable file
0
src/fenrir/commands/onHeartBeat/76000-time.py
Normal file → Executable file
@ -28,35 +28,3 @@ commandInfo = {
|
|||||||
'lastCommandExecutionTime': time.time(),
|
'lastCommandExecutionTime': time.time(),
|
||||||
'lastCommandRequestTime': time.time(),
|
'lastCommandRequestTime': time.time(),
|
||||||
}
|
}
|
||||||
|
|
||||||
# used by the commandManager
|
|
||||||
commands = {
|
|
||||||
'onInput':{
|
|
||||||
},
|
|
||||||
'onScreenChanged':{
|
|
||||||
},
|
|
||||||
'onScreenUpdate':{
|
|
||||||
},
|
|
||||||
'onApplicationChange':{
|
|
||||||
},
|
|
||||||
'commands':{
|
|
||||||
},
|
|
||||||
'onSwitchApplicationProfile':{
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
# used by the commandManager
|
|
||||||
commandsIgnore = {
|
|
||||||
'onInput':{
|
|
||||||
},
|
|
||||||
'onScreenChanged':{
|
|
||||||
},
|
|
||||||
'onScreenUpdate':{
|
|
||||||
},
|
|
||||||
'onApplicationChange':{
|
|
||||||
},
|
|
||||||
'commands':{
|
|
||||||
},
|
|
||||||
'onSwitchApplicationProfile':{
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
@ -15,6 +15,8 @@ class commandManager():
|
|||||||
def initialize(self, environment):
|
def initialize(self, environment):
|
||||||
self.env = environment
|
self.env = environment
|
||||||
# commands
|
# commands
|
||||||
|
self.env['commands'] = {}
|
||||||
|
self.env['commandsIgnore'] = {}
|
||||||
for commandFolder in self.env['general']['commandFolderList']:
|
for commandFolder in self.env['general']['commandFolderList']:
|
||||||
self.env['runtime']['commandManager'].loadCommands(commandFolder,
|
self.env['runtime']['commandManager'].loadCommands(commandFolder,
|
||||||
self.env['runtime']['settingsManager'].getSetting('general', 'commandPath'))
|
self.env['runtime']['settingsManager'].getSetting('general', 'commandPath'))
|
||||||
@ -42,7 +44,8 @@ class commandManager():
|
|||||||
if not os.access(commandFolder, os.R_OK):
|
if not os.access(commandFolder, os.R_OK):
|
||||||
self.env['runtime']['debug'].writeDebugOut("commandFolder not readable:" + commandFolder ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("commandFolder not readable:" + commandFolder ,debug.debugLevel.ERROR)
|
||||||
return
|
return
|
||||||
|
self.env['commands'][section] = {}
|
||||||
|
self.env['commandsIgnore'][section] = {}
|
||||||
commandList = glob.glob(commandFolder+'*')
|
commandList = glob.glob(commandFolder+'*')
|
||||||
for command in commandList:
|
for command in commandList:
|
||||||
try:
|
try:
|
||||||
@ -62,7 +65,6 @@ class commandManager():
|
|||||||
self.env['commands'][section][fileName.upper()].initialize(self.env)
|
self.env['commands'][section][fileName.upper()].initialize(self.env)
|
||||||
self.env['runtime']['debug'].writeDebugOut("Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True)
|
self.env['runtime']['debug'].writeDebugOut("Load command:" + section + "." + fileName.upper() ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(command+str(e))
|
|
||||||
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||||
continue
|
continue
|
||||||
@ -172,8 +174,7 @@ class commandManager():
|
|||||||
self.env['runtime']['debug'].writeDebugOut("Executing trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO)
|
self.env['runtime']['debug'].writeDebugOut("Executing trigger.command:" + trigger + "." + command ,debug.debugLevel.INFO)
|
||||||
self.env['commands'][trigger][command].run()
|
self.env['commands'][trigger][command].run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command ,debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + command + str(e) ,debug.debugLevel.ERROR)
|
||||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
|
||||||
|
|
||||||
def executeCommand(self, command, section = 'commands'):
|
def executeCommand(self, command, section = 'commands'):
|
||||||
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
if self.env['runtime']['screenManager'].isSuspendingScreen():
|
||||||
|
@ -19,8 +19,6 @@ environment = {
|
|||||||
'runtime': runtimeData,
|
'runtime': runtimeData,
|
||||||
'general': generalData,
|
'general': generalData,
|
||||||
'settings': settingsData,
|
'settings': settingsData,
|
||||||
'commands': commandData.commands,
|
|
||||||
'commandsIgnore': commandData.commandsIgnore,
|
|
||||||
'commandInfo': commandData.commandInfo,
|
'commandInfo': commandData.commandInfo,
|
||||||
'commandBuffer': commandData.commandBuffer,
|
'commandBuffer': commandData.commandBuffer,
|
||||||
'input': inputData,
|
'input': inputData,
|
||||||
|
@ -44,23 +44,18 @@ class eventManager():
|
|||||||
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'])
|
print(event['Type'], self._eventQueue.qsize())
|
||||||
if not event:
|
if not event:
|
||||||
return
|
return
|
||||||
if event['Type'] == fenrirEventType.Ignore:
|
if event['Type'] == fenrirEventType.Ignore:
|
||||||
return
|
return
|
||||||
elif event['Type'] == fenrirEventType.StopMainLoop:
|
elif event['Type'] == fenrirEventType.StopMainLoop:
|
||||||
self.handleStopMainLoop()
|
self.handleStopMainLoop()
|
||||||
print('stop')
|
|
||||||
return
|
return
|
||||||
elif event['Type'] == fenrirEventType.ScreenUpdate:
|
elif event['Type'] == fenrirEventType.ScreenUpdate:
|
||||||
self.env['runtime']['fenrirManager'].handleScreenUpdate()
|
self.env['runtime']['fenrirManager'].handleScreenUpdate()
|
||||||
print(self._eventQueue.qsize())
|
|
||||||
print('ScreenUpdate')
|
|
||||||
elif event['Type'] == fenrirEventType.KeyboardInput:
|
elif event['Type'] == fenrirEventType.KeyboardInput:
|
||||||
self.env['runtime']['fenrirManager'].handleInput()
|
self.env['runtime']['fenrirManager'].handleInput()
|
||||||
print(self._eventQueue.qsize())
|
|
||||||
print('KeyboardInput')
|
|
||||||
elif event['Type'] == fenrirEventType.BrailleInput:
|
elif event['Type'] == fenrirEventType.BrailleInput:
|
||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
elif event['Type'] == fenrirEventType.PlugInputDevice:
|
||||||
@ -69,14 +64,9 @@ class eventManager():
|
|||||||
pass
|
pass
|
||||||
elif event['Type'] == fenrirEventType.ScreenChanged:
|
elif event['Type'] == fenrirEventType.ScreenChanged:
|
||||||
self.env['runtime']['fenrirManager'].handleScreenChange()
|
self.env['runtime']['fenrirManager'].handleScreenChange()
|
||||||
print(self._eventQueue.qsize())
|
|
||||||
print('ScreenChanged')
|
|
||||||
elif event['Type'] == fenrirEventType.HeartBeat:
|
elif event['Type'] == fenrirEventType.HeartBeat:
|
||||||
# run timer actions
|
self.env['runtime']['fenrirManager'].handleHeartBeat()
|
||||||
#self.env['runtime']['fenrirManager'].handleProcess()
|
#print('HeartBeat at {0} {1}'.format(event['Type'], event['Data'] ))
|
||||||
print(self._eventQueue.qsize())
|
|
||||||
print('HeartBeat at {0} {1}'.format(event['Type'], event['Data'] ))
|
|
||||||
|
|
||||||
def isMainEventLoopRunning(self):
|
def isMainEventLoopRunning(self):
|
||||||
return self._mainLoopRunning.value == 1
|
return self._mainLoopRunning.value == 1
|
||||||
def startMainEventLoop(self):
|
def startMainEventLoop(self):
|
||||||
|
@ -67,7 +67,7 @@ class fenrirManager():
|
|||||||
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('onUpdate')
|
self.environment['runtime']['screenManager'].update('onScreenChange')
|
||||||
|
|
||||||
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
||||||
@ -90,11 +90,9 @@ class fenrirManager():
|
|||||||
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')
|
||||||
def handlePlugInputDevice(self):
|
def handlePlugInputDevice(self):
|
||||||
if not self.environment['runtime']['screenManager'].isSuspendingScreen(): # remove if all works
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('PlugInputDevice')
|
||||||
self.environment['runtime']['inputManager'].updateInputDevices()
|
|
||||||
def handleHeartBeat(self):
|
def handleHeartBeat(self):
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat')
|
||||||
self.handlePlugInputDevice()
|
|
||||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||||
|
|
||||||
def prepareCommand(self):
|
def prepareCommand(self):
|
||||||
|
@ -13,6 +13,6 @@ generalData = {
|
|||||||
'prevUser':'',
|
'prevUser':'',
|
||||||
'managerList':['eventManager','punctuationManager','cursorManager','applicationManager','commandManager'
|
'managerList':['eventManager','punctuationManager','cursorManager','applicationManager','commandManager'
|
||||||
,'screenManager','inputManager','outputManager','debug'],
|
,'screenManager','inputManager','outputManager','debug'],
|
||||||
'commandFolderList':['commands','onInput','onScreenUpdate','onScreenChanged'
|
'commandFolderList':['commands','onInput','onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice'
|
||||||
,'onApplicationChange','onSwitchApplicationProfile',],
|
,'onApplicationChange','onSwitchApplicationProfile',],
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,12 @@ 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.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):
|
||||||
|
time.sleep(2)
|
||||||
|
#self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay')
|
||||||
|
return time.time()
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
@ -54,7 +59,9 @@ class driver():
|
|||||||
if active.value == 0:
|
if active.value == 0:
|
||||||
return
|
return
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
r, w, x = select(deviceFd, [], [], 2)
|
r = []
|
||||||
|
while r == []:
|
||||||
|
r, w, x = select(deviceFd, [], [], 2)
|
||||||
self.watchDog.value = 0
|
self.watchDog.value = 0
|
||||||
def getInputEvent(self):
|
def getInputEvent(self):
|
||||||
if not self.hasIDevices():
|
if not self.hasIDevices():
|
||||||
|
Loading…
Reference in New Issue
Block a user