Esempio n. 1
0
 def initWaitForWindow(self):
     self.TimeoutHasOccurred = False  # for other scritps to know the status
     self.startupTimeout = 10000
     self.elapsed = QtCore.QElapsedTimer()
     self.elapsed.start()
     self.timer = QtCore.QTimer(self)
     self.timer.timeout.connect(self.attemptToFindWindow)
Esempio n. 2
0
    def __init__(self, *argss, **kwargs):
        super(self.__class__, self).__init__(*argss, **kwargs)
        self._timerID = None
        self._elapsed = 0
        self._timer = QtCore.QElapsedTimer()
        self._started = None
        self._ended = None

        self.setupUI()
        self.reset()
class SfmSample(QtCore.QObject):

    SamplingDone = QtCore.Signal(
    )  #conncent to this signal to know when sampling is done
    Timer = QtCore.QElapsedTimer(
    )  #used to time how long each frame Sampling takes

    def __init__(self):

        QtCore.QObject.__init__(self)
        self.StatusBar = self.findtypeinlist(
            sfmApp.GetMainWindow(), QtGui.QStatusBar
        )  #gets the QStatusBar that holds the current sample
        self.StopChecking = False
        self.PrevSample = 0

#returns a object of type from the children of a qwidget

    def findtypeinlist(self, widget, typ, flag=False):

        for i in widget.children():
            if type(i) is typ and i != flag:
                return i

        #this will start an infinite loop that keeps checking if the sampling is every so millisec
    def BeginChecking(self):

        if (self.StopChecking):
            self.StopChecking = False
            return

        currentsample = (int)(
            self.StatusBar.children()[0].children()[-2].text().split(
                " ")[0])  #gets the current sample number, 1 means done

        if (self.PrevSample == 1
                and currentsample > 1):  #this is a new frame, start timer
            self.Timer.start()

        if (currentsample == 1 and self.PrevSample > 1):  #sampling done

            print("Frame #" + (str)(sfmApp.GetHeadTimeInFrames()) + " " + str(
                self.Timer.restart() / 1000.0))  #prints the frame time in sec
            self.SamplingDone.emit()

        self.PrevSample = currentsample

        #recalls the function after 200 millisecs lowering the time  will increase accuracy but will cause bottlenecks for the cpu resulting in longer sample times, 1000 millisecs = 1 sec
        QtCore.QTimer.singleShot(200, lambda: self.BeginChecking())