예제 #1
0
    def __init__(self):
        QObject.__init__(self, None)
        self._mainthreadid = QThread.currentThreadId()

        self._signalthread = SignalThread()
        QObject.connect(self._signalthread, SIGNAL("triggerSignal()"),
                        self.sensorQueueChanged)

        self._idletimer = QTimer()
        self._delaytimer = QTimer()
        self._timerqueuetimer = QTimer()

        self._idletimer.setSingleShot(True)
        self._delaytimer.setSingleShot(True)
        self._timerqueuetimer.setSingleShot(True)

        self.connect(self._idletimer, SIGNAL("timeout()"), self.idleTimeout)
        self.connect(self._delaytimer, SIGNAL("timeout()"), self.delayTimeout)
        self.connect(self._timerqueuetimer, SIGNAL("timeout()"),
                     self.timerQueueTimeout)

        SoDB.getSensorManager().setChangedCallback(self.sensorQueueChangedCB,
                                                   self)
        SoDB.setRealTimeInterval(1.0 / 25.0)
        SoRenderManager.enableRealTimeUpdate(False)
예제 #2
0
 def sensorQueueChangedCB(self, closure):
     # if we get a callback from another thread, route the callback
     # through SignalThread so that we receive the callback in the
     # QApplication thread (needed since QTimer isn't thread safe)
     if QThread.currentThreadId() != closure._mainthreadid:
         if not closure._signalthread.isRunning():
             closure._signalthread.start()
         self._signalthread.trigger()
     else:
         self.sensorQueueChanged()
예제 #3
0
 def sensorQueueChangedCB(self, closure):
     # if we get a callback from another thread, route the callback
     # through SignalThread so that we receive the callback in the
     # QApplication thread (needed since QTimer isn't thread safe)
     if QThread.currentThreadId() != closure._mainthreadid:
         if not closure._signalthread.isRunning():
             closure._signalthread.start()
         self._signalthread.trigger()
     else:
         self.sensorQueueChanged()
예제 #4
0
 def process(self):
     print(">> process():", os.getpid(), QThread.currentThread(),
           QThread.currentThreadId())
     self.isInterrupted = False
     count = 0
     while not self.isInterrupted:
         if count == 10:
             self.isInterrupted = True
             continue
         try:
             with QMutexLocker(self.mutex):
                 self.addA()
                 self.addOne()
             time.sleep(1)
             count += 1
         except Exception as ex:
             print(ex)
             self.isInterrupted = True
     print("<< process():", os.getpid(), QThread.currentThread(),
           QThread.currentThreadId())
     self.do_something.emit(self.data)
     self.finished.emit()
예제 #5
0
 def process2(self, obj):
     """
     This function stops the thread calling this object.
     """
     print(">> process():", os.getpid(), QThread.currentThread(),
           QThread.currentThreadId())
     self.stopWorking = False
     while not self.stopWorking:
         try:
             with QMutexLocker(self.mutex):
                 self._process()
         except Exception as ex:
             print(ex)
             self.stopWorking = True
     self.do_something.emit(self.data)
     self.finished.emit()
예제 #6
0
    def __init__(self):
        QObject.__init__(self, None)
        self._mainthreadid = QThread.currentThreadId()

        self._signalthread = SignalThread()
        QObject.connect(self._signalthread, SIGNAL("triggerSignal()"),
                        self.sensorQueueChanged)

        self._idletimer = QTimer()
        self._delaytimer = QTimer()
        self._timerqueuetimer = QTimer()

        self._idletimer.setSingleShot(True)
        self._delaytimer.setSingleShot(True)
        self._timerqueuetimer.setSingleShot(True)

        self.connect(self._idletimer, SIGNAL("timeout()"), self.idleTimeout)
        self.connect(self._delaytimer, SIGNAL("timeout()"), self.delayTimeout)
        self.connect(self._timerqueuetimer, SIGNAL("timeout()"), self.timerQueueTimeout)

        SoDB.getSensorManager().setChangedCallback(self.sensorQueueChangedCB, self)
        SoDB.setRealTimeInterval(1.0 / 25.0)
        SoRenderManager.enableRealTimeUpdate(False)
예제 #7
0
파일: Logger.py 프로젝트: 5l1v3r1/map-1
 def log(self, level, msg):
     "Logger implementation."
     print "[" + str(QThread.currentThreadId()) + "]" + level + ": " + msg
예제 #8
0
 def currentThreadID(self):
     from PyQt4.QtCore import QThread
     return QThread.currentThreadId()