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

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
All Implemented Interfaces:
IActivityCtx, IBrahmsObjectCtx, IRuntimeConstants, gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler, java.io.Serializable
Direct Known Subclasses:
VMCompositeActivityCtx, VMPrimitiveActivityCtx

public class VMActivityCtx
extends ActivityCtx
implements gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler

The VMActivityCtx is an ActivityCtx with extensions for use in the virtual machine. An ActivityCtx maintains the context of an activity being or to be executed by an active instance. The context maintains the start and end times for an activity, the duration, priority, and status.

Version:
$Revision: 1.5 $ $Date: 2009/11/24 00:01:29 $ $Author: rnado $
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
  VMActivityCtx(Activity act)
          Constructor, creates a new context for the specified Activity.
protected VMActivityCtx(Activity act, java.lang.String id)
          Constructor, creates a new context for the specified Activity.
 
Method Summary
 ParameterCtx getDisplayText()
          Returns the activities display text.
 ParameterCtx getParameterCtx(Parameter p)
          Returns the context of the parameter with the specified name.
 ParameterCtx getPriority()
          Returns the activities priority.
 boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Process the specified discrete event.
 boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandlerFactory ehf)
          Handles the specified discrete event by selecting the appropriate event handler from the specified event handler factory.
protected  void onAbort(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Aborts the activity, an early termination of the activity caused by a detectable's abort trigger.
protected  void onComplete(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Completes the activity, an early termination of the activity caused by a detectable's complete trigger.
protected  void onContinue(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Continues the activity from an interrupt.
protected  void onContinueFromImpasse(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Continues the activity from an impasse.
protected  void onEnd(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Ends the activity, handling any completion initializations and executing any actions that are to be executed at the end of the activity as specified for the activity.
protected  void onImpasse(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Impasses the activity.
protected  void onInterrupt(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Interrupts the activity.
protected  boolean onStart(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
          Starts the activity, handling any startup initialization and executing any actions that are to be executed at the start of the activity as specified for the activity.
 void resolveParameters()
          Resolves all parameters specified for the 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.
 
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.IBrahmsObjectCtx
addNote, getContextFor, getEndTime, getID, getNote, getNotes, getStartTime, removeNote, setEndTime, setID, setStartTime
 

Constructor Detail

VMActivityCtx

public VMActivityCtx(Activity act)
Constructor, creates a new context for the specified Activity.

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

VMActivityCtx

protected VMActivityCtx(Activity act,
                        java.lang.String id)
Constructor, creates a new context for the specified Activity.

Parameters:
act - the Activity for which to create a context
Method Detail

getParameterCtx

public final ParameterCtx getParameterCtx(Parameter p)
                                   throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the context of the parameter with the specified name.

Parameters:
p - the Parameter for which the context is requested
Returns:
ParameterCtx the parameter context for the parameter with the specified name defined for this activity
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no parameter with the specified name is defined for this activity

resolveParameters

public final void resolveParameters()
                             throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Resolves all parameters specified for the activity. Parameters that have as value a variable are not resolved to a specific value as they can be used in different situations where one or more of its values have to be used.

Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if an internal error occurs

getDisplayText

public ParameterCtx getDisplayText()
                            throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the activities display text. The display text is set through a parameter context containing either the actual value or a reference to a variable containing the display text value.

Specified by:
getDisplayText in interface IActivityCtx
Overrides:
getDisplayText in class ActivityCtx
Returns:
ParameterCtx the display text of the activity
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no display text is defined

getPriority

public ParameterCtx getPriority()
                         throws gov.nasa.arc.brahms.common.exceptions.BrahmsException
Returns the activities priority. The priority is set through a parameter context containing either the actual value or a reference to a variable containing the priority value.

Specified by:
getPriority in interface IActivityCtx
Overrides:
getPriority in class ActivityCtx
Returns:
ParameterCtx the priority of the activity
Throws:
gov.nasa.arc.brahms.common.exceptions.BrahmsException - if no priority is defined

handleDiscreteEvent

public boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt,
                                   gov.nasa.arc.brahms.vm.events.IDiscreteEventHandlerFactory ehf)
Handles the specified discrete event by selecting the appropriate event handler from the specified event handler factory. The specified event contains as its data the object implementing this interface. The following should be the case: evt.getData() == this

Specified by:
handleDiscreteEvent in interface gov.nasa.arc.brahms.vm.events.IDiscreteEventData
Parameters:
evt - the DiscreteEvent to be handled
ehf - the EventHandlerFactory containing handlers from which this DiscreteEventData selects the appropriate handler
Returns:
boolean true if the event could be processed, false if not

handleDiscreteEvent

public boolean handleDiscreteEvent(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Process the specified discrete event.

Specified by:
handleDiscreteEvent in interface gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler
Parameters:
evt - the DiscreteEvent to be processed.
Returns:
boolean true if the event could be processed, false if not

onStart

protected boolean onStart(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Starts the activity, handling any startup initialization and executing any actions that are to be executed at the start of the activity as specified for the activity.

Parameters:
evt - the DiscreteEvent that initiated the start of the activity
Returns:
boolean true if the activity was started, false if not

onEnd

protected void onEnd(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Ends the activity, handling any completion initializations and executing any actions that are to be executed at the end of the activity as specified for the activity.

Parameters:
evt - the DiscreteEvent that initiated the end of the activity

onInterrupt

protected void onInterrupt(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Interrupts the activity.

Parameters:
evt - the DiscreteEvent that initiated the interruption

onContinue

protected void onContinue(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Continues the activity from an interrupt.

Parameters:
evt - the DiscreteEvent that initiated the continuation

onImpasse

protected void onImpasse(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Impasses the activity.

Parameters:
evt - the DiscreteEvent that initiated the impasse

onContinueFromImpasse

protected void onContinueFromImpasse(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Continues the activity from an impasse.

Parameters:
evt - the DiscreteEvent that initiated the continuation

onAbort

protected void onAbort(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Aborts the activity, an early termination of the activity caused by a detectable's abort trigger.

Parameters:
evt - the DiscreteEvent that initiated the abort

onComplete

protected void onComplete(gov.nasa.arc.brahms.vm.events.DiscreteEvent evt)
Completes the activity, an early termination of the activity caused by a detectable's complete trigger.

Parameters:
evt - the DiscreteEvent that initiated the complete

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.

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.

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.

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.

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.

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.

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.

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.

Parameters:
evt - the DiscreteEvent that triggered the state change


Copyright © 1997-2012 All Rights Reserved.