Home | Trees | Indices | Help |
|
---|
|
Concurrence Container
This state allows for simple split-join concurrency. The user adds a set of states which are all executed simultaneously. The concurrent split state can only transition once all conatained states are ready to transition.
This container can be configured to return a given outcome as a
function of the outcomes of the contained states. This is specified in
the constructor of the class, or after construction with Concurrence.add_outcome_map
.
While a concurrence will not terminate until all if its children terminate, it is possible for it to preempt a subset of states
Given these causes of termination, the outcome can be determined in four ways:
The specification of the outcome maps and the outcome callback are described in the constructor documentation below. More than one policy can be supplied, and each policy has the potential to not be satisfied. In the situation in which multiple policies are provided, and a given policy is not satisfied, the outcome choice precedence is as follows:
In practive it is best to try to accomplish your task with just ONE outcome policy.
Instance Methods | |||
|
|||
|
|||
|
|||
dict of string: State |
|
||
smach.State |
|
||
list of string |
|
||
|
|||
list of string |
|
||
list of 3-tuple |
|
||
|
|||
Inherited from |
|||
Inherited from container.Container | |||
---|---|---|---|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
bool |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from state.State | |||
|
|||
|
|||
tuple of string |
|
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Static Methods | |||
|
Instance Variables | |
Inherited from container.Container | |
---|---|
userdata Userdata to be passed to child states. |
Properties | |
Inherited from |
Method Details |
Constructor for smach Concurrent Split. @type outcomes: list of strings @param outcomes: The potential outcomes of this state machine. @type default_outcome: string @param default_outcome: The outcome of this state if no elements in the outcome map are satisfied by the outcomes of the contained states. @type outcome_map: list @param outcome_map: This is an outcome map for determining the outcome of this container. Each outcome of the container is mapped to a dictionary mapping child labels onto outcomes. If none of the child-outcome maps is satisfied, the concurrence will terminate with thhe default outcome. For example, if the and_outcome_map is: {'succeeded' : {'FOO':'succeeded', 'BAR':'done'}, 'aborted' : {'FOO':'aborted'}} Then the concurrence will terimate with outcome 'succeeded' only if BOTH states 'FOO' and 'BAR' have terminated with outcomes 'succeeded' and 'done', respectively. The outcome 'aborted' will be returned by the concurrence if the state 'FOO' returns the outcome 'aborted'. If the outcome of a state is not specified, it will be treated as irrelevant to the outcome of the concurrence If the criteria for one outcome is the subset of another outcome, the container will choose the outcome which has more child outcome criteria satisfied. If both container outcomes have the same number of satisfied criteria, the behavior is undefined. If a more complex outcome policy is required, see the user can provide an outcome callback. See outcome_cb, below. @type child_termination_cb: callale @param child_termination_cb: This callback gives the user the ability to force the concurrence to preempt running states given the termination of some other set of states. This is useful when using a concurrence as a monitor container. This callback is called each time a child state terminates. It is passed a single argument, a dictionary mapping child state labels onto their outcomes. If a state has not yet terminated, it's dict value will be None. This function can return three things: - False: continue blocking on the termination of all other states - True: Preempt all other states - list of state labels: Preempt only the specified states I{If you just want the first termination to cause the other children to terminate, the callback (lamda so: True) will always return True.} @type outcome_cb: callable @param outcome_cb: If the outcome policy needs to be more complicated than just a conjunction of state outcomes, the user can supply a callback for specifying the outcome of the container. This callback is called only once all child states have terminated, and it is passed the dictionary mapping state labels onto their respective outcomes. If the callback returns a string, it will treated as the outcome of the container. If the callback returns None, the concurrence will first check the outcome_map, and if no outcome in the outcome_map is satisfied, it will return the default outcome. B{NOTE: This callback should be a function ONLY of the outcomes of the child states. It should not access any other resources.}
|
Add state to the opened concurrence. This state will need to terminate before the concurrence terminates. |
Overloaded execute method. This starts all the threads. |
Preempt all contained states.
|
Get the children of this container. This is empty for leaf states.
|
Access child state by key.
|
Get the initial state description.
|
Set initial active state of a container.
|
Get a description of the current state. Note that this is specific to container implementation.
|
Get the internal outcome edges of this container. Get a list of 3-tuples (OUTCOME, LABEL_FROM, LABEL_TO) which coresspond to transitions inside this container.
|
Check constistency of this container.
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jan 11 10:11:57 2013 | http://epydoc.sourceforge.net |