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

java.lang.Object
  extended by gov.nasa.arc.brahms.common.rt.BrahmsObjectCtx
      extended by gov.nasa.arc.brahms.common.rt.ConditionCtx
          extended by gov.nasa.arc.brahms.common.rt.DetectableCtx
              extended by gov.nasa.arc.brahms.vm.rt.VMDetectableCtx
All Implemented Interfaces:
IBrahmsObjectCtx, IConditionCtx, IDetectableCtx, IRuntimeConstants, gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler, java.io.Serializable

public class VMDetectableCtx
extends DetectableCtx
implements gov.nasa.arc.brahms.vm.events.IDiscreteEventData, gov.nasa.arc.brahms.vm.events.IDiscreteEventHandler

The VMDetectableCtx defines the context for a fired detectable defining the detectable that was fired, in what frame or composite activity the detectable was fired, the fact or belief detected and the belief created by the detectable.

Version:
7 January 2004
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
VMDetectableCtx(Detectable detectable)
          Constructor, creates a new detectable context for the specified detectable.
 
Method Summary
 void detect(long time)
          Checks if any of the facts in the world's fact set can be matched with this detectable.
 void detect(long time, VMFactCtx fact)
          Checks if the specified fact can be matched with this detectable.
 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.
 int trigger(long time)
          Checks if any of the beliefs in the belief set of the active instance checking the trigger can be matched with this detectable.
 int trigger(long time, VMBeliefCtx belief)
          Checks if the specified belief can be matched with the detectable.
 boolean triggerImpasseResolution(long time, VMBeliefCtx belief)
          Checks if the specified belief can be matched with the detectable.
 
Methods inherited from class gov.nasa.arc.brahms.common.rt.DetectableCtx
addDetectableAction, getDetectableActions, getParent, removeDetectableAction, setParent, setParent, 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

VMDetectableCtx

public VMDetectableCtx(Detectable detectable)
Constructor, creates a new detectable context for the specified detectable.

Parameters:
detectable - the fired detectable for which this context is the context
Method Detail

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

detect

public void detect(long time)
            throws VMException
Checks if any of the facts in the world's fact set can be matched with this detectable. If so the fact(s) will be detected and belief(s) will be created and scheduled on the detecting active instance's queue.

Parameters:
time - the time at which the detection is performed
Throws:
VMException - if an internal error occurs.

detect

public void detect(long time,
                   VMFactCtx fact)
            throws VMException
Checks if the specified fact can be matched with this detectable. If so the fact(s) will be detected and a belief will be created and scheduled on the detecting active instance's queue.

Parameters:
time - the time at which the detection is performed
fact - the fact to be checked for detection.
Throws:
VMException - if an internal error occurs.

trigger

public int trigger(long time)
            throws VMException
Checks if any of the beliefs in the belief set of the active instance checking the trigger can be matched with this detectable. If so the belief will trigger the detectable's action.

Parameters:
time - the time at which the trigger is checked
Returns:
int -1 if the trigger was not activated, the triggered action if it was activated
Throws:
VMException - if an internal error occurs.

trigger

public int trigger(long time,
                   VMBeliefCtx belief)
            throws VMException
Checks if the specified belief can be matched with the detectable. If so the belief will trigger the detectable's action.

Parameters:
time - the time at which the trigger is checked
belief - the belief to be checked against the trigger.
Returns:
int -1 if the trigger was not activated, the triggered action if it was activated
Throws:
VMException - if an internal error occurs.
See Also:
IConstants.CONTINUE, IConstants.ABORT, IConstants.COMPLETE, IConstants.IMPASSE, IConstants.ENDACTIVITY

triggerImpasseResolution

public boolean triggerImpasseResolution(long time,
                                        VMBeliefCtx belief)
                                 throws VMException
Checks if the specified belief can be matched with the detectable. If so the belief will trigger the resololution of the impasse caused by the trigger. The impassed frame will be continued from the impasse.

Parameters:
time - the time at which the trigger is checked
belief - the belief to be checked against the trigger.
Returns:
boolean true if the belief resolved the impasse, false otherwise
Throws:
VMException - if an internal error occurs.


Copyright © 1997-2012 All Rights Reserved.