Esempio n. 1
0
    def _onTimer(self, timerEvent):
        """
        Updates all subsystems when the timer event is recieved
        
        This will ensure that if subsystem updates take longer than the 
        _updateInterval, that is just waits another _updateInterval
        """
        currentTime = self._getTime()
        timeSinceLastIteration = (currentTime - self._lastTime)

        # Update each subsystem with the time since the last update
        subsystemIter = (self._app.getSubsystem(name)
                         for name in self._app.getSubsystemNames())
        for subsystem in subsystemIter:
            subsystem.update(timeSinceLastIteration)

        self._lastTime = currentTime

        # If we have run over into the next intervale, just wait an entire
        # interval
        updateTime = self._updateInterval - (self._getTime() - currentTime)
        if updateTime < 0:
            updateTime = self.updateInterval
        self.timer.Start(updateTime, True)

        # Update heart beat
        self._heartBeat += 1
Esempio n. 2
0
    def _onTimer(self, timerEvent):
        """
        Updates all subsystems when the timer event is recieved
        
        This will ensure that if subsystem updates take longer than the 
        _updateInterval, that is just waits another _updateInterval
        """
        currentTime = self._getTime()
        timeSinceLastIteration = (currentTime - self._lastTime)
        
        # Update each subsystem with the time since the last update
        names = self._app.getSubsystemNames()
        subsystemIter = (self._app.getSubsystem(names[i]) for i in 
                         xrange(0, len(names)) )

        updated = 0
        for subsystem in subsystemIter:
            if not subsystem.backgrounded():
                updated += 1
                subsystem.update(timeSinceLastIteration)
        self._lastTime = currentTime

        # Check if the number of updated subsystems matches the expected
        if self._numSubsystems > -1 and (updated != self._numSubsystems):
            # Shit hit the fan, close the application
            self._frame.Close(True)
            errorMsg = "ERROR: Wrong number of subsystems updating." \
                       " Expected %d, found %d." % \
                       (self._numSubsystems, updated)
            #print errorMsg 
            raise Exception(errorMsg)
        
        # If we have run over into the next interval, just wait an entire 
        # interval
        updateTime = self._updateInterval - (self._getTime() - currentTime)
        if updateTime < 0:
            updateTime = self.updateInterval
        self.timer.Start(updateTime, True)
        
        # Update heart beat
        self._heartBeat += 1
Esempio n. 3
0
    def _onTimer(self, timerEvent):
        """
        Updates all subsystems when the timer event is recieved
        
        This will ensure that if subsystem updates take longer than the 
        _updateInterval, that is just waits another _updateInterval
        """
        currentTime = self._getTime()
        timeSinceLastIteration = (currentTime - self._lastTime)

        # Update each subsystem with the time since the last update
        names = self._app.getSubsystemNames()
        subsystemIter = (self._app.getSubsystem(names[i])
                         for i in xrange(0, len(names)))

        updated = 0
        for subsystem in subsystemIter:
            if not subsystem.backgrounded():
                updated += 1
                subsystem.update(timeSinceLastIteration)
        self._lastTime = currentTime

        # Check if the number of updated subsystems matches the expected
        if self._numSubsystems > -1 and (updated != self._numSubsystems):
            # Shit hit the fan, close the application
            self._frame.Close(True)
            errorMsg = "ERROR: Wrong number of subsystems updating." \
                       " Expected %d, found %d." % \
                       (self._numSubsystems, updated)
            #print errorMsg
            raise Exception(errorMsg)

        # If we have run over into the next interval, just wait an entire
        # interval
        updateTime = self._updateInterval - (self._getTime() - currentTime)
        if updateTime < 0:
            updateTime = self.updateInterval
        self.timer.Start(updateTime, True)

        # Update heart beat
        self._heartBeat += 1