create byte command detection infra and try out fire a command

This commit is contained in:
chrys 2018-03-24 22:50:27 +01:00
parent 88c12a3331
commit 11681120ca
3 changed files with 15 additions and 2 deletions

View File

@ -45,7 +45,6 @@ class eventManager():
pass
elif event['Type'] == fenrirEventType.PlugInputDevice:
self.env['runtime']['fenrirManager'].handlePlugInputDevice(event)
pass
elif event['Type'] == fenrirEventType.BrailleFlush:
pass
elif event['Type'] == fenrirEventType.ScreenChanged:
@ -54,6 +53,8 @@ class eventManager():
self.env['runtime']['fenrirManager'].handleHeartBeat(event)
elif event['Type'] == fenrirEventType.ExecuteCommand:
self.env['runtime']['fenrirManager'].handleExecuteCommand(event)
elif event['Type'] == fenrirEventType.ByteInput:
self.env['runtime']['fenrirManager'].handleByteInput(event)
def isMainEventLoopRunning(self):
return self.running.value == 1
def startMainEventLoop(self):

View File

@ -83,6 +83,10 @@ class fenrirManager():
self.environment['input']['keyForeward'] -=1
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
#print('handleInput:',time.time() - startTime)
def handleByteInput(self, event):
if event['Data'] == b'':
return
self.detectByteCommand(event['Data'])
def handleExecuteCommand(self, event):
if event['Data'] == '':
return
@ -131,7 +135,12 @@ class fenrirManager():
def handleHeartBeat(self, event):
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
#self.environment['runtime']['outputManager'].brailleText(flush=False)
def detectByteCommand(self, escapeSequence):
command = ''
if escapeSequence == b'a':
command = 'TIME'
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, command)
def detectCommand(self):
if self.environment['input']['keyForeward'] > 0:
return

View File

@ -150,6 +150,9 @@ class driver(screenDriver):
print('pre stdin')
try:
msgBytes = self.readAll(sys.stdin.fileno())
eventQueue.put({"Type":fenrirEventType.ByteInput,
"Data":msgBytes
})
except (EOFError, OSError):
running = False
break