org.primordion.xholon.base
Class XholonTime

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.XholonWithPorts
          extended byorg.primordion.xholon.base.XholonTime
All Implemented Interfaces:
IXholon, IXholonTime

public class XholonTime
extends XholonWithPorts
implements IXholonTime, IXholon

Handle time in a Xholon application.

Since:
0.3 (Created on April 15, 2006)
Author:
Ken Webb

Field Summary
static int timeStep
          Current time step.
static int timeStepInterval
          Time step interval.
static IXholon xhtXholonTime
           
 
Fields inherited from class org.primordion.xholon.base.XholonWithPorts
port
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
Fields inherited from interface org.primordion.xholon.base.IXholonTime
NUM_MILLISECONDS_PER_SECOND, TIMERTYPE_ABSOLUTE, TIMERTYPE_RELATIVE, TIMERTYPE_REPEAT
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Constructor Summary
XholonTime()
          constructor
 
Method Summary
 void cancel(XholonTimerTask xhTimerTask)
          Cancel a relative, repeat or absolute timeout.
 void cancelAll()
          Cancel all timeouts.
 java.lang.String getName()
          Get name, unique within this application, of this Xholon instance.
static int getTimeStep()
          Get the current time step of the executing application.
static int getTimeStepInterval()
          Get time step interval defined for this application.
static void setTimeStep(int ts)
          Set the current time step of the executing application.
static void setTimeStepInterval(int tsInterval)
          Set time step interval defined for this application.
static void sleep(long delay)
           
 XholonTimerTask timeoutAbsolute(IXholon clientNode, java.util.Date time)
          Timeout at a specified absolute time in the future.
 XholonTimerTask timeoutRelative(IXholon clientNode, long delay)
          Timeout after a specified number of milliseconds, relative to the current time.
 XholonTimerTask timeoutRelative(IXholon clientNode, java.lang.Object data, long delay)
          Timeout after a specified number of milliseconds, relative to the current time.
 XholonTimerTask timeoutRepeat(IXholon clientNode, long delay, long period)
          Timeout repeatedly every so many milliseconds.
 XholonTimerTask timeoutRepeat(IXholon clientNode, java.lang.Object data, long delay, long period)
          Timeout repeatedly every so many milliseconds.
 
Methods inherited from class org.primordion.xholon.base.XholonWithPorts
configure, getMaxPorts, getPort, initialize, isActiveObject, isBound, isContainer, isPassiveObject, postConfigure, setMaxPorts, setPorts, terminate
 
Methods inherited from class org.primordion.xholon.base.Xholon
act, appendChild, appendChild, appendChild, cleanup, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPreviousSibling, getRoleName, getRootNode, getSiblings, getSizeMessageQ, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isExternal, isInternal, isLeaf, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setRoleName, setSizeMessageQ, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, toString, treeSize, writeXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize, writeXml
 

Field Detail

xhtXholonTime

public static IXholon xhtXholonTime

timeStepInterval

public static int timeStepInterval
Time step interval. Number of milliseconds per time step. 0 = max speed. 10 = 10 milliseconds per time step = 100 time steps per second. 1000 = 1000 milliseconds per time step = 1 second per time step = 1 time step per second. 0 = logical time. Any other positive value = physical time (clock time).


timeStep

public static int timeStep
Current time step.

Constructor Detail

XholonTime

public XholonTime()
constructor

Method Detail

setTimeStepInterval

public static void setTimeStepInterval(int tsInterval)
Set time step interval defined for this application.

Parameters:
tsInterval - Time step interval in ms.

getTimeStepInterval

public static int getTimeStepInterval()
Get time step interval defined for this application.

Returns:
Time step interval in ms.

setTimeStep

public static void setTimeStep(int ts)
Set the current time step of the executing application.

Parameters:
ts - The current time step.

getTimeStep

public static int getTimeStep()
Get the current time step of the executing application.

Returns:
The current time step.

timeoutRelative

public XholonTimerTask timeoutRelative(IXholon clientNode,
                                       long delay)
Description copied from interface: IXholonTime
Timeout after a specified number of milliseconds, relative to the current time.

Specified by:
timeoutRelative in interface IXholonTime
Parameters:
clientNode - The xholon client node that will receive a message when the timeout occurs.
delay - The number of milliseconds to wait before timing out.

timeoutRelative

public XholonTimerTask timeoutRelative(IXholon clientNode,
                                       java.lang.Object data,
                                       long delay)
Description copied from interface: IXholonTime
Timeout after a specified number of milliseconds, relative to the current time.

Specified by:
timeoutRelative in interface IXholonTime
Parameters:
clientNode - The xholon client node that will receive a message when the timeout occurs.
data - User data to return as part of the message when the timeout occurs.
delay - The number of milliseconds to wait before timing out.

timeoutRepeat

public XholonTimerTask timeoutRepeat(IXholon clientNode,
                                     long delay,
                                     long period)
Description copied from interface: IXholonTime
Timeout repeatedly every so many milliseconds.

Specified by:
timeoutRepeat in interface IXholonTime
Parameters:
clientNode - The xholon client node that will receive a message each time the timeout occurs.
delay - The number of milliseconds to delay before the first timeout occurs.
period - The number of milliseconds in each timeout period, after the first timeout.

timeoutRepeat

public XholonTimerTask timeoutRepeat(IXholon clientNode,
                                     java.lang.Object data,
                                     long delay,
                                     long period)
Description copied from interface: IXholonTime
Timeout repeatedly every so many milliseconds.

Specified by:
timeoutRepeat in interface IXholonTime
Parameters:
clientNode - The xholon client node that will receive a message each time the timeout occurs.
data - User data to return as part of the message when the timeout occurs.
delay - The number of milliseconds to delay before the first timeout occurs.
period - The number of milliseconds in each timeout period, after the first timeout.

timeoutAbsolute

public XholonTimerTask timeoutAbsolute(IXholon clientNode,
                                       java.util.Date time)
Description copied from interface: IXholonTime
Timeout at a specified absolute time in the future.

Specified by:
timeoutAbsolute in interface IXholonTime
Parameters:
time - The absolute time and date at which the timeout will occur.
clientNode - The xholon client node that will receive a message when the timeout occurs.

cancel

public void cancel(XholonTimerTask xhTimerTask)
Description copied from interface: IXholonTime
Cancel a relative, repeat or absolute timeout.

Specified by:
cancel in interface IXholonTime

cancelAll

public void cancelAll()
Description copied from interface: IXholonTime
Cancel all timeouts. This should probably only be called when an application has finished running, and especially before another application is subsequently opened.

Specified by:
cancelAll in interface IXholonTime

sleep

public static void sleep(long delay)

getName

public java.lang.String getName()
Description copied from interface: IXholon
Get name, unique within this application, of this Xholon instance. The name is a concatenation of the IXholonClass name and the Xholon unique ID. The first letter is converted to lowercase, and a "_" is used to separate the name and ID. ex: "helloWorld_123"

Specified by:
getName in interface IXholon
Overrides:
getName in class Xholon