示例#1
0
        Starts the state machine with the first task from the task list
        """
        self._stateMachine.start(self._taskOrder[0])

    def stop(self):
        """
        Stops the currently running state machine.
        """
        self._stateMachine.stop()

    def addConnection(self, conn):
        self._connections.append(conn)

    def getNextTask(self, task):
        """
        Returns the task which will be transitioned to when the given task 
        transitions to the next task.
        """
        return self._nextTaskMap[task]

    def getFailureState(self, task):
        """
        Returns the state which will be transitioned to when the given task
        fails in an unrecoverable way.  Recoverable failure are handled 
        internally by that task. 
        """
        return self._failureTaskMap.get(task, None)


core.registerSubsystem('AI', AI)
示例#2
0
            self._firstRun = False

        newEvent = RemoteAi.StateEvent()

        # Explicit cast necessary for Ice
        newEvent.timeStamp = long(event.timeStamp - self._startTime)
        newEvent.eventType = event.type
        # Find the state name
        fullClassName = str(event.string)

        # Recreate the class
        stateClass = resolve(fullClassName)
        if issubclass(stateClass, task.Task):
            # It's a task, make that the type
            newEvent.type = "Task"
        else:
            newEvent.type = "State"
        # Parse out the last name from the fullClassName
        newEvent.name = fullClassName.split('.')[-1]

        # Record this event in the adapter
        self._obj.RecordEvent(newEvent)

    def _onEntered(self, event):
        self._recordEvent(event)

    def _onExited(self, event):
        self._recordEvent(event)

core.registerSubsystem('RemoteAi', AiInformationServer)
示例#3
0
        Starts the state machine with the first task from the task list
        """
        self._stateMachine.start(self._taskOrder[0])
    
    def stop(self):
        """
        Stops the currently running state machine.
        """
        self._stateMachine.stop()
    
    def addConnection(self, conn):
        self._connections.append(conn)

    def getNextTask(self, task):
        """
        Returns the task which will be transitioned to when the given task 
        transitions to the next task.
        """
        return self._nextTaskMap[task]
    
    def getFailureState(self, task):
        """
        Returns the state which will be transitioned to when the given task
        fails in an unrecoverable way.  Recoverable failure are handled 
        internally by that task. 
        """
        return self._failureTaskMap.get(task, None)
    
    
core.registerSubsystem('AI', AI)
示例#4
0
        else:
            for aiEvent,aiState in currentState.transitions().iteritems():
                eventName = str(aiEvent).split(' ')[-1]
                
                # Style is determine whether or not we are branching
                style = "solid"
                if type(aiState) is Branch:
                    style = "dotted"
                    aiState = aiState.state
                
                # Determine state names
                startName = Machine._dottedName(currentState)
                endName = Machine._dottedName(aiState)

                if (not noLoops) or (startName != endName):
                    strStruct = "%s -> %s [label=%s,style=%s]" % \
                        (startName, endName, eventName, style)
                    stateList.append(strStruct)
                    if not currentState in traversedList:
                        traversedList.append(currentState)

                    # Don't recuse on a state we have already seen
                    if not aiState in traversedList:
                        Machine._traverse(aiState, stateList,
                                          traversedList, noLoops)
    @staticmethod
    def _dottedName(cls):
        return cls.__module__.replace('.','_') + '_' + cls.__name__
    
core.registerSubsystem('StateMachine', Machine)
示例#5
0
文件: state.py 项目: gsulliva/tortuga
        else:
            for aiEvent,aiState in currentState.transitions().iteritems():
                eventName = str(aiEvent).split(' ')[-1]
                
                # Style is determine whether or not we are branching
                style = "solid"
                if type(aiState) is Branch:
                    style = "dotted"
                    aiState = aiState.state
                
                # Determine state names
                startName = Machine._dottedName(currentState)
                endName = Machine._dottedName(aiState)

                if (not noLoops) or (startName != endName):
                    strStruct = "%s -> %s [label=%s,style=%s]" % \
                        (startName, endName, eventName, style)
                    stateList.append(strStruct)
                    if not currentState in traversedList:
                        traversedList.append(currentState)

                    # Don't recuse on a state we have already seen
                    if not aiState in traversedList:
                        Machine._traverse(aiState, stateList,
                                          traversedList, noLoops)
    @staticmethod
    def _dottedName(cls):
        return cls.__module__.replace('.','_') + '_' + cls.__name__
    
core.registerSubsystem('StateMachine', Machine)
示例#6
0
    def _handler(self, event):
        value = getattr(event, self._property)

        newEvent = core.StringEvent()
        newEvent.string = "%s:%s:%s:%s" % (self._eventType, self._property, self._name, value)

        if self._critical > self._warning:
            self._checkMaximum(value, newEvent)
        else:
            self._checkMinimum(value, newEvent)

        self._lastValue = value


core.registerSubsystem("Monitor", Monitor)


class CpuData(object):
    def __init__(self, f, size):
        self._size = size
        self._file = f
        self._data = []

        if self._file is not None:
            self.appendData = self._appendData
            self.flushData = self._flushData
        else:
            self.appendData = self._pass
            self.flushData = self._pass
示例#7
0
        self.depthRate = self.depthFilter.getValue(1, time)

        # Package all events
        devent = math.NumericEvent()
        devent.number = self.getEstimatedDepth()
        
        drevent = math.NumericEvent()
        drevent.number = self.getEstimatedDepthRate()

        pevent = math.Vector2Event()
        pevent.vector2 = self.getEstimatedPosition()

        vevent = math.Vector2Event()
        vevent.vector2 = self.getEstimatedVelocity()

        oevent = math.OrientationEvent()
        oevent.orientation = self.getEstimatedOrientation()

        # Send all events at the same time
        self.publish(estimation.IStateEstimator.ESTIMATED_DEPTH_UPDATE, devent)
        self.publish(estimation.IStateEstimator.ESTIMATED_DEPTHRATE_UPDATE,
                     drevent)
        self.publish(estimation.IStateEstimator.ESTIMATED_POSITION_UPDATE,
                     pevent)
        self.publish(estimation.IStateEstimator.ESTIMATED_VELOCITY_UPDATE,
                     vevent)
        self.publish(estimation.IStateEstimator.ESTIMATED_ORIENTATION_UPDATE,
                     oevent)

core.registerSubsystem('IdealStateEstimator', IdealStateEstimator)
示例#8
0
    def _handler(self, event):
        value = getattr(event, self._property)

        newEvent = core.StringEvent()
        newEvent.string = '%s:%s:%s:%s' % (self._eventType, self._property,
                                           self._name, value)

        if self._critical > self._warning:
            self._checkMaximum(value, newEvent)
        else:
            self._checkMinimum(value, newEvent)

        self._lastValue = value


core.registerSubsystem('Monitor', Monitor)


class CpuData(object):
    def __init__(self, f, size):
        self._size = size
        self._file = f
        self._data = []

        if self._file is not None:
            self.appendData = self._appendData
            self.flushData = self._flushData
        else:
            self.appendData = self._pass
            self.flushData = self._pass