do some ajustments, and fix typos

This commit is contained in:
Chrys 2017-06-21 15:05:38 +02:00
parent c8dd57e4b4
commit 756d1d9b99
3 changed files with 16 additions and 12 deletions

View File

@ -17,7 +17,7 @@ class command():
return _('exits Fenrir') return _('exits Fenrir')
def run(self): def run(self):
self.env['eventManager'].stopMainEventLoop() self.env['runtime']['eventManager'].stopMainEventLoop()
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -41,7 +41,7 @@ class eventManager():
self.terminateAllProcesses() self.terminateAllProcesses()
self.cleanEventQueue() self.cleanEventQueue()
def timerProcess(self): def timerProcess(self):
time.sleep(0.005) time.sleep(0.04)
#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):
@ -60,6 +60,7 @@ class eventManager():
return return
elif event['Type'] == fenrirEventType.StopMainLoop: elif event['Type'] == fenrirEventType.StopMainLoop:
self._mainLoopRunning.value = 0 self._mainLoopRunning.value = 0
print('stop')
return return
elif event['Type'] == fenrirEventType.ScreenUpdate: elif event['Type'] == fenrirEventType.ScreenUpdate:
print('do an update') print('do an update')
@ -76,22 +77,25 @@ class eventManager():
pass pass
elif event['Type'] == fenrirEventType.HeartBeat: elif event['Type'] == fenrirEventType.HeartBeat:
self.env['runtime']['fenrirManager'].handleProcess() self.env['runtime']['fenrirManager'].handleProcess()
print(self._eventQueue.qsize())
print('HeartBeat at ' + str(event['Type']) + ' ' +str(event['Data'] )) print('HeartBeat at ' + str(event['Type']) + ' ' +str(event['Data'] ))
def startMainEventLoop(self): def startMainEventLoop(self):
self._mainLoopRunning.value = True self._mainLoopRunning.value = 1
while(self._mainLoopRunning.value): while(self._mainLoopRunning.value == 1):
st = time.time()
self.proceedEventLoop() self.proceedEventLoop()
print('loop ' + str(time.time() - st))
def stopMainEventLoop(self, Force = False): def stopMainEventLoop(self, Force = False):
if Force: if Force:
self._mainLoopRunning.value = False self._mainLoopRunning.value = 0
self._eventQueue.put({"Type":fenrirEventType.StopMainLoop,"Data":None}) self._eventQueue.put({"Type":fenrirEventType.StopMainLoop,"Data":None})
def addCustomEventThread(self, function): def addCustomEventThread(self, function):
self._mainLoopRunning.value = True self._mainLoopRunning.value = 1
t = Process(target=self.eventWorkerThread, args=(q, function)) t = Process(target=self.eventWorkerThread, args=(q, function))
self._eventProcesses.append(t) self._eventProcesses.append(t)
t.start() t.start()
def addSimpleEventThread(self, event, function): def addSimpleEventThread(self, event, function):
self._mainLoopRunning.value = True self._mainLoopRunning.value = 1
t = Process(target=self.simpleEventWorkerThread, args=(event, function)) t = Process(target=self.simpleEventWorkerThread, args=(event, function))
self._eventProcesses.append(t) self._eventProcesses.append(t)
t.start() t.start()
@ -124,7 +128,7 @@ class eventManager():
return return
if not callable(function): if not callable(function):
return return
while self._mainLoopRunning.value: while self._mainLoopRunning.value == 1:
Data = None Data = None
try: try:
Data = function() Data = function()

View File

@ -109,16 +109,16 @@ class fenrirManager():
self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands') self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands')
def shutdownRequest(self): def shutdownRequest(self):
self.environment['eventManager'].stopMainEventLoop() self.environment['runtime']['eventManager'].stopMainEventLoop()
def captureSignal(self, siginit, frame): def captureSignal(self, siginit, frame):
self.shutdownRequest() self.shutdownRequest()
def shutdown(self): def shutdown(self):
self.environment['eventManager'].stopMainEventLoop() self.environment['runtime']['eventManager'].stopMainEventLoop()
self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True) self.environment['runtime']['outputManager'].presentText(_("Quit Fenrir"), soundIcon='ScreenReaderOff', interrupt=True)
self.environment['eventManager'].cleanEventQueue() self.environment['runtime']['eventManager'].cleanEventQueue()
self.environment['eventManager'].stopMainEventLoop(True) self.environment['runtime']['eventManager'].stopMainEventLoop(True)
for currManager in self.environment['general']['managerList']: for currManager in self.environment['general']['managerList']:
if self.environment['runtime'][currManager]: if self.environment['runtime'][currManager]:
self.environment['runtime'][currManager].shutdown() self.environment['runtime'][currManager].shutdown()