|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.roboticsAPI.controllerModel.sunrise.Primitive
public abstract class Primitive
A Primitive represents a Sunrise-specific controller command. The command has a specific life cycle and tracks its execution on the controller. The Primitive state always reflects the execution state of the command on the controller.
A Primitive is not meant to be passed on to the user of the API. Each Primitive belongs to a
SunriseExecutionContainer that the user can use to track the execution of commands.
!!! CAUTION implementers !!!
If the Primitive hierarchy is extended so that there is can be a primitive that contain of more than one consecutive SPRs or SPR stacks you have to make sure that all the SPRs will be cancelled if one of them goes into error state.
For now this function is implemented in
SunriseExecutionContainer.primitiveStateChanged(Primitive, ExecutionState, String)!
| Constructor Summary | |
|---|---|
protected |
Primitive(SunriseExecutionContainer container)
Creates a new Primitive instance. |
| Method Summary | |
|---|---|
void |
addStateListener(IPrimitiveStateListener listener)
Adds a listener for this primitive. |
abstract void |
cancel()
Cancels the primitive. |
protected FiredConditionInfo |
createFiredConditionInfo(SPR spr,
SunriseStopCondition stopCondition)
Creates the fired condition information. |
abstract Collection<SPR> |
getAllSprs()
Returns all SPRs that this Primitive consists of. |
SunriseExecutionContainer |
getContainer()
Returns the container to which this Primitive belongs. |
static IRedundancyCollection |
getRedundancy(int status,
int turn,
Double alpha)
Returns the correct redundancy collection depending on the specifying an alpha value or not. |
ExecutionState |
getState()
Returns the current state of the Primitive. |
protected void |
handleSprCompoundEvent(SPR spr,
Message msg)
Called when one of the SPR compounds has thrown an event. |
protected void |
handleSprStateChanged(SPR eventSpr,
SPRState newState)
Called when the state of the given SPR changed. |
protected static ExecutionState |
mapSunriseStateToCommandState(SPRState sprState)
Utility method: Maps a Sunrise SPR state to an ExecutionState. |
protected void |
registerAsSprListener(SPR spr)
Registers this primitive for SPR state events. |
void |
removeStateListener(IPrimitiveStateListener listener)
Removes the listener from this primitive. |
protected void |
setState(ExecutionState newState,
String errorMessage)
Sets the state of this Primitive and notifies its ExecutionContainer of the state change. |
protected com.kuka.common.Pair<ExecutionState,String> |
stateFromSpr(SPR spr,
SPRState newState)
Utility method: Examines the given SPR and the given state for error conditions and maps them to an ExecutionState. |
protected abstract void |
unregisterAllSprListener()
Unregisters this primitive from ALL SPR state events. |
protected void |
unregisterAsSprListener(SPR spr)
Unregisters this primitive from SPR state events. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected Primitive(SunriseExecutionContainer container)
container - the container to which this Primitive belongs.| Method Detail |
|---|
protected void registerAsSprListener(SPR spr)
handleSprStateChanged(SPR, SPRState) and handleSprCompoundEvent(SPR, Message).
spr - the SPRprotected void unregisterAsSprListener(SPR spr)
handleSprStateChanged(SPR, SPRState) and handleSprCompoundEvent(SPR, Message).
spr - the SPRprotected abstract void unregisterAllSprListener()
handleSprStateChanged(SPR, SPRState) and handleSprCompoundEvent(SPR, Message).
public abstract Collection<SPR> getAllSprs()
public abstract void cancel()
Cancels all SPRs belonging to the primitive.
public SunriseExecutionContainer getContainer()
protected static ExecutionState mapSunriseStateToCommandState(SPRState sprState)
ExecutionState.
sprState - The Sunrise SPR state.
public ExecutionState getState()
protected void setState(ExecutionState newState,
String errorMessage)
newState - the new stateerrorMessage - an error message, may be null
protected com.kuka.common.Pair<ExecutionState,String> stateFromSpr(SPR spr,
SPRState newState)
ExecutionState.
spr - the SPR to examine.newState - The state of the SPR to consider. This is a separate parameter for this method because the state of
the SPR can change asynchronously.
Pair consisting of a corresponding ExecutionState and an error string. The string can
be null.
protected FiredConditionInfo createFiredConditionInfo(SPR spr,
SunriseStopCondition stopCondition)
spr - The SPR which contains the stop condition which has fired.stopCondition - The stop condition which has fired.
FiredConditionInfo.
public static IRedundancyCollection getRedundancy(int status,
int turn,
Double alpha)
status - status valueturn - turn valuealpha - alpha value or null if not existing.
protected void handleSprStateChanged(SPR eventSpr,
SPRState newState)
eventSpr - The SPR which changed it's state.newState - The new state of the SPR.
protected void handleSprCompoundEvent(SPR spr,
Message msg)
spr - The SPR whose compound has thrown an event.msg - compound event message.public final void addStateListener(IPrimitiveStateListener listener)
listener - The state listener for this primitive's state. null is not allowed.
IllegalArgumentException - if listener is null or the same listener is already registeredpublic final void removeStateListener(IPrimitiveStateListener listener)
listener - The state listener for this primitive's state. null is not allowed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||