##// END OF EJS Templates
Version: 2.1.3.2...
Version: 2.1.3.2 -controller_api.py: Safe access to ControllerThread -GUI: user interaction enhanced.

File last commit:

r672:a1a5642b5594
r672:a1a5642b5594
Show More
controller_api.py
140 lines | 3.1 KiB | text/x-python | PythonLexer
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 import threading
from PyQt4 import QtCore
from PyQt4.QtCore import SIGNAL
from schainpy.controller import Project
class ControllerThread(threading.Thread, Project):
def __init__(self, filename):
threading.Thread.__init__(self)
Project.__init__(self)
self.setDaemon(True)
self.filename = filename
Miguel Valdez
Version: 2.1.3.2...
r672
self.lock = threading.Lock()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control = {'stop':False, 'pause':False}
def __del__(self):
self.control['stop'] = True
def stop(self):
Miguel Valdez
Version: 2.1.3.2...
r672
self.lock.acquire()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control['stop'] = True
Miguel Valdez
Version: 2.1.3.2...
r672 self.lock.release()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 def pause(self):
Miguel Valdez
Version: 2.1.3.2...
r672
self.lock.acquire()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control['pause'] = not(self.control['pause'])
Miguel Valdez
Version: 2.1.3.2...
r672 paused = self.control['pause']
self.lock.release()
Miguel Valdez
GUI: Every icon were resized
r668
Miguel Valdez
Version: 2.1.3.2...
r672 return paused
Miguel Valdez
GUI: Every icon were resized
r668
Miguel Valdez
Version: 2.1.3.2...
r672 def isPaused(self):
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636
Miguel Valdez
Version: 2.1.3.2...
r672 self.lock.acquire()
paused = self.control['pause']
self.lock.release()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636
Miguel Valdez
Version: 2.1.3.2...
r672 return paused
def isStopped(self):
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636
Miguel Valdez
Version: 2.1.3.2...
r672 self.lock.acquire()
stopped = self.control['stop']
self.lock.release()
return stopped
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 def run(self):
self.control['stop'] = False
self.control['pause'] = False
self.readXml(self.filename)
self.createObjects()
self.connectObjects()
Project.run(self)
def isRunning(self):
return self.is_alive()
def isFinished(self):
return not self.is_alive()
class ControllerQThread(QtCore.QThread, Project):
def __init__(self, filename):
QtCore.QThread.__init__(self)
Project.__init__(self)
self.filename = filename
Miguel Valdez
Version: 2.1.3.2...
r672
self.lock = threading.Lock()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control = {'stop':False, 'pause':False}
def __del__(self):
self.control['stop'] = True
self.wait()
def stop(self):
Miguel Valdez
Version: 2.1.3.2...
r672
self.lock.acquire()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control['stop'] = True
Miguel Valdez
Version: 2.1.3.2...
r672 self.lock.release()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 def pause(self):
Miguel Valdez
Version: 2.1.3.2...
r672
self.lock.acquire()
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control['pause'] = not(self.control['pause'])
Miguel Valdez
Version: 2.1.3.2...
r672 paused = self.control['pause']
self.lock.release()
return paused
def isPaused(self):
self.lock.acquire()
paused = self.control['pause']
self.lock.release()
return paused
def isStopped(self):
self.lock.acquire()
stopped = self.control['stop']
self.lock.release()
return stopped
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 def run(self):
Miguel Valdez
Version: 2.1.3.2...
r672
Miguel Valdez
ControllerThread was eliminated from controller.py and it was added to controller_api.py
r636 self.control['stop'] = False
self.control['pause'] = False
self.readXml(self.filename)
self.createObjects()
self.connectObjects()
self.emit( SIGNAL( "jobStarted( PyQt_PyObject )" ), 1)
Project.run(self)
Miguel Valdez
Version: 2.1.3.2...
r672 self.emit( SIGNAL( "jobFinished( PyQt_PyObject )" ), 1)