gov.nasa.arc.brahms.vm.rt
Class VMPrimitiveActivityCtx

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.ActivityCtx
          extended by gov.nasa.arc.brahms.vm.rt.VMActivityCtx
              extended by gov.nasa.arc.brahms.vm.rt.VMPrimitiveActivityCtx
All Implemented Interfaces:
IActivityCtx, IBrahmsObjectCtx, IPrimitiveActivityCtx, IRuntimeConstants, gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler, java.io.Serializable
Direct Known Subclasses:
VMBroadcastActivityCtx, VMContainmentActivityCtx, VMCreateAgentActivityCtx, VMCreateAreaActivityCtx, VMCreateObjectActivityCtx, VMGestureActivityCtx, VMJavaActivityCtx, VMMoveActivityCtx

public class VMPrimitiveActivityCtx
extends VMActivityCtx
implements IPrimitiveActivityCtx

The VMPrimitiveActivityCtx is a primitive activity context with extensions for use in the virtual machine. It maintains the context of a primitive activity being or to be executed by an active instance. The context maintains the start and end times for an activity, the duration, priority, status, randomness, duration and resources.

Version:
$Revision: 1.1 $ $Date: 2007/10/10 14:04:25 $ $Author: rvhoof $
Author:
Ron van Hoof
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface gov.nasa.arc.brahms.common.rt.IRuntimeConstants
ABORTED, ACTIVE, ACTIVITY, AVAILABLE, COMPLETED, CONSEQUENCE, DETECTABLE, ENDED, ENGINE, EXTERNAL_AGENT, FROM, IMPASSED, INITIAL, INTERRUPTED, JAVA_PROPERTY, sABORTED, sACTIVE, sAVAILABLE, sCOMPLETED, sENDED, sIMPASSED, sINTERRUPTED, sUNAVAILABLE, TO, TRANSFER, UNAVAILABLE
 
Constructor Summary
  VMPrimitiveActivityCtx(PrimitiveActivity act)
          Constructor, creates a new context for the specified VMPrimitiveActivity.
protected VMPrimitiveActivityCtx(PrimitiveActivity act, java.lang.String id)
          Constructor, creates a new context for the specified VMPrimitiveActivity.
 
Method Summary
 void addResource(ParameterCtx resource)
          Adds the specified resource as a resource for this activity.
 long getDuration()
          Returns the calculated duration of the activity used by the VM
 long getElapsedTime()
          Returns the elapsed time when the activity has been active
 ParameterCtx getMaxDuration()
          Returns the maximum duration of the activity.
 ParameterCtx getMinDuration()
          returns the minimum duration of the activity.
 ParameterCtx getRandom()
          Returns whether the duration of the activity is random or not.
 int getResourceCount()
          Return the number of resources associated with the activity.
 java.util.Enumeration getResources()
          Returns a list of all the resources (ParameterCtx).
 void removeResource(ParameterCtx resource)
          Removes the specified resource as a resource for this activity.
protected  void sendAbortEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an abort event to the event notifier.
protected  void sendCompleteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a complete event to the event notifier.
protected  void sendContinueEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a continue event to the event notifier.
protected  void sendContinueFromImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a continue from impasse event to the event notifier.
protected  void sendEndEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an end event to the event notifier.
protected  void sendImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an impasse event to the event notifier.
protected  void sendInterruptEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends an interrupt event to the event notifier.
protected  void sendStartEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Sends a start event to the event notifier.
 void setElapsedTime(long elapsedTime)
          Specifies the elapsed time when the activity has been active
 
Methods inherited from class gov.nasa.arc.brahms.vm.rt.VMActivityCtx
getDisplayText, getParameterCtx, getPriority, handleDiscreteEvent, handleDiscreteEvent, onAbort, onComplete, onContinue, onContinueFromImpasse, onEnd, onImpasse, onInterrupt, onStart, resolveParameters
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.ActivityCtx
getCompletionCause, getParentFrame, getPerformedBy, getReferencedBy, getState, getStatus, setCompletionCause, setDisplayText, setParentFrame, setPerformedBy, setPriority, setReferencedBy, setState, setState, setStatus, toString
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setContextFor, setEndTime, setID, setStartTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.nasa.arc.brahms.common.rt.IActivityCtx
getCompletionCause, getDisplayText, getParentFrame, getPerformedBy, getPriority, getReferencedBy, getStatus, setCompletionCause, setDisplayText, setParentFrame, setPerformedBy, setReferencedBy, setStatus
 
Methods inherited from interface gov.nasa.arc.brahms.common.rt.IBrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setEndTime, setID, setStartTime
 

Constructor Detail

VMPrimitiveActivityCtx

public VMPrimitiveActivityCtx(PrimitiveActivity act)
Constructor, creates a new context for the specified VMPrimitiveActivity.

Parameters:
act - the VMPrimitiveActivity for which to create a context

VMPrimitiveActivityCtx

protected VMPrimitiveActivityCtx(PrimitiveActivity act,
                                 java.lang.String id)
Constructor, creates a new context for the specified VMPrimitiveActivity.

Parameters:
act - the VMPrimitiveActivity for which to create a context
id - the unique identifier for the activity context
Method Detail

getRandom

public ParameterCtx getRandom()
                       throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns whether the duration of the activity is random or not. The random indicator is set through a parameter context containing either the actual value or a reference to a variable containing the random value.

Specified by:
getRandom in interface IPrimitiveActivityCtx
Returns:
ParameterCtx containing a boolean value defining whether the activity duration is random
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no random indicator is specified

getMinDuration

public ParameterCtx getMinDuration()
                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
returns the minimum duration of the activity. The minimum duration is set through a parameter context containing either the actual value or a reference to a variable containing the value.

Specified by:
getMinDuration in interface IPrimitiveActivityCtx
Returns:
ParameterCtx containing an integer value defining the minimum duration of the activity
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no minimum duration is specified

getMaxDuration

public ParameterCtx getMaxDuration()
                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the maximum duration of the activity. The maximum duration is set through a parameter context containing either the actual value or a reference to a variable containing the value.

Specified by:
getMaxDuration in interface IPrimitiveActivityCtx
Returns:
ParameterCtx containing an integer value defining the maximum duration of the activity
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no maximum duration is specified

getDuration

public long getDuration()
Returns the calculated duration of the activity used by the VM

Specified by:
getDuration in interface IPrimitiveActivityCtx
Returns:
long the total duration of the activity

setElapsedTime

public void setElapsedTime(long elapsedTime)
Specifies the elapsed time when the activity has been active

Specified by:
setElapsedTime in interface IPrimitiveActivityCtx
Parameters:
elapsedTime - the activities elapsed time

getElapsedTime

public long getElapsedTime()
Returns the elapsed time when the activity has been active

Specified by:
getElapsedTime in interface IPrimitiveActivityCtx
Returns:
long the activities elapsed time

addResource

public void addResource(ParameterCtx resource)
                 throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Adds the specified resource as a resource for this activity. The actual resource is the concept referenced by the parameter context where the parameter context specifies when the resource was associated with the activity.

Specified by:
addResource in interface IPrimitiveActivityCtx
Parameters:
resource - the resource (ParameterCtx) to be added
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if resource is null

removeResource

public void removeResource(ParameterCtx resource)
                    throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Removes the specified resource as a resource for this activity. The actual resource is the concept referenced by the parameter context where the parameter context specifies when the resource was (dis)associated with the activity.

Specified by:
removeResource in interface IPrimitiveActivityCtx
Parameters:
resource - the resource (ParameterCtx) to be removed
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if resource is null, no resources are available, or the resource is not found

getResources

public java.util.Enumeration getResources()
                                   throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns a list of all the resources (ParameterCtx).

Specified by:
getResources in interface IPrimitiveActivityCtx
Returns:
Enumeration an enumeration of ParameterCtx
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if there are no resources

getResourceCount

public int getResourceCount()
Return the number of resources associated with the activity.

Specified by:
getResourceCount in interface IPrimitiveActivityCtx
Returns:
int the number of resources

sendStartEvent

protected void sendStartEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a start event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendStartEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendEndEvent

protected void sendEndEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an end event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendEndEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendInterruptEvent

protected void sendInterruptEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an interrupt event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendInterruptEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendContinueEvent

protected void sendContinueEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a continue event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendContinueEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendImpasseEvent

protected void sendImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an impasse event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendImpasseEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendContinueFromImpasseEvent

protected void sendContinueFromImpasseEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a continue from impasse event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendContinueFromImpasseEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendCompleteEvent

protected void sendCompleteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends a complete event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendCompleteEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change

sendAbortEvent

protected void sendAbortEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Sends an abort event to the event notifier.

Note that this method is created for the different implementations by the sub classes of VMActivityCtx.

Overrides:
sendAbortEvent in class VMActivityCtx
Parameters:
evt - the DiscreteEvent that triggered the state change


Copyright © 1997-2012 All Rights Reserved.