jsim.process
Class Model

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by jsim.process.Model
All Implemented Interfaces:
java.awt.event.AdjustmentListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible

public class Model
extends java.awt.Frame
implements java.lang.Runnable, java.awt.event.WindowListener, java.awt.event.AdjustmentListener

The Model class allows application specific simulation models to be derived from it. It generalizes all models. Simulation models run in their own frame and multiple frames (models) can be active simultaneously.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  double stopTime
          Maximum time until sources are shut down (for safety).
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Model(java.lang.String mName, double slowness)
          Construct a JSIM simulation model to run in an embedded frame.
Model(java.lang.String mName, Prop[] pList, Transport[] tList, AnimationQueue sharedQueue)
          Construct a JSIM simulation model to run in an embedded frame.
 
Method Summary
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
          Handle event by adjusting the view of the design canvas based on position of scrollbars.
 void beginSim()
          Set the flag to start the simulation.
 java.util.Vector collectStatData()
          Collect data from all the nodes (except Source FIX) in model.
 void endSim()
          Set the flag to end the simulation.
 java.util.HashMap<java.lang.Integer,Coroutine> getJoinEntity()
          Return hash map contains entities waiting on AND join
 java.util.HashMap<java.lang.Integer,Coroutine> getLostJoinEntity()
          Return hash map containing entities that are lost
 java.lang.String getPrimaryStat()
          Get the primary statistic for the stopping rule.
 void initModel(DynamicNode[] dynNode)
          Finish initializing the mode.
 void injectAnEntity()
          Method to inject an entity in every source node of the model.
 boolean isDone()
          Is the simulation over?
 FinalReport prepareReport()
          Prepare a report to ModelAgent.
 void run()
          Run the display thread.
 void setBatchProperties(int bSize, int nBatch)
          Set the batch size and number of batches for all batch statistics.
 void setPrimaryStat()
          Set the primary statistic to analyze for the stopping rule.
 void setPrimaryStat(java.lang.String statNodeName)
          Set the primary statistic to analyze for the stopping rule.
 void showStats()
          Display statistical results as a table in a window.
 void start()
          Start the display thread.
 void triggerModelReportEvent(StatException ex)
          Trigger a model report event (call mBean's fire).
 void windowActivated(java.awt.event.WindowEvent evt)
           
 void windowClosed(java.awt.event.WindowEvent evt)
          The rest of the WindowEvent handlers are not implemented.
 void windowClosing(java.awt.event.WindowEvent evt)
          Handle window closing event by exiting/disposing of window.
 void windowDeactivated(java.awt.event.WindowEvent evt)
           
 void windowDeiconified(java.awt.event.WindowEvent evt)
           
 void windowIconified(java.awt.event.WindowEvent evt)
           
 void windowOpened(java.awt.event.WindowEvent evt)
           
 
Methods inherited from class java.awt.Frame
addNotify, getAccessibleContext, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, paramString, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

stopTime

protected double stopTime
Maximum time until sources are shut down (for safety).

Constructor Detail

Model

public Model(java.lang.String mName,
             Prop[] pList,
             Transport[] tList,
             AnimationQueue sharedQueue)
Construct a JSIM simulation model to run in an embedded frame. The model will use a virtual time clock at full speed.

Parameters:
mlName - name of the simulation model
mBean - bean holding the model

Model

public Model(java.lang.String mName,
             double slowness)
Construct a JSIM simulation model to run in an embedded frame. The model will use a virtual time clock at full speed, unless slowness is positive (> 0); then the model's execution will be slowed down for better animation.

Parameters:
mName - name of the simulation model
mBean - bean holding the model
slowness - factor to slow down animation
Method Detail

initModel

public void initModel(DynamicNode[] dynNode)
Finish initializing the mode. Create a canvas to diplay animation of model in the center. Put scrollbars to East and South.

Parameters:
dynNodes - nodes to display on canvas

getPrimaryStat

public java.lang.String getPrimaryStat()
Get the primary statistic for the stopping rule.

Returns:
the primary statistic

setPrimaryStat

public void setPrimaryStat(java.lang.String statNodeName)
Set the primary statistic to analyze for the stopping rule.

Parameters:
statNodeName - the primary statistic

setPrimaryStat

public void setPrimaryStat()
Set the primary statistic to analyze for the stopping rule.

Parameters:
statNodeName - the primary statistic

setBatchProperties

public void setBatchProperties(int bSize,
                               int nBatch)
Set the batch size and number of batches for all batch statistics. This is done on a node by node basis (where Facility is a special case).

Parameters:
bSize - batch size
nNatch - number of batches

start

public void start()
Start the display thread.


beginSim

public void beginSim()
Set the flag to start the simulation.


endSim

public void endSim()
Set the flag to end the simulation.


isDone

public boolean isDone()
Is the simulation over?

Returns:
boolean whether simulation is over

run

public void run()
Run the display thread. The actual display is done by the ModelCanvas.

Specified by:
run in interface java.lang.Runnable

showStats

public void showStats()
Display statistical results as a table in a window.


prepareReport

public FinalReport prepareReport()
Prepare a report to ModelAgent. The report will consist of information about the model, its input node properties, and its output statistcal data.

Parameters:
FinalReport - The final report to be sent to the model agent

collectStatData

public java.util.Vector collectStatData()
Collect data from all the nodes (except Source FIX) in model.

Returns:
Vector collected statistical data for model

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent evt)
Handle event by adjusting the view of the design canvas based on position of scrollbars.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Parameters:
evt - scrollbar adjustment event

windowClosing

public void windowClosing(java.awt.event.WindowEvent evt)
Handle window closing event by exiting/disposing of window. Use of exit () under the BeanBox will cause the whole BeanBox to exit.

Specified by:
windowClosing in interface java.awt.event.WindowListener
Parameters:
evt - window closing event

windowClosed

public void windowClosed(java.awt.event.WindowEvent evt)
The rest of the WindowEvent handlers are not implemented.

Specified by:
windowClosed in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent evt)
Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent evt)
Specified by:
windowIconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent evt)
Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent evt)
Specified by:
windowDeactivated in interface java.awt.event.WindowListener

windowOpened

public void windowOpened(java.awt.event.WindowEvent evt)
Specified by:
windowOpened in interface java.awt.event.WindowListener

triggerModelReportEvent

public void triggerModelReportEvent(StatException ex)
Trigger a model report event (call mBean's fire). Send an interim report on primary stat.


injectAnEntity

public void injectAnEntity()
Method to inject an entity in every source node of the model.


getJoinEntity

public java.util.HashMap<java.lang.Integer,Coroutine> getJoinEntity()
Return hash map contains entities waiting on AND join


getLostJoinEntity

public java.util.HashMap<java.lang.Integer,Coroutine> getLostJoinEntity()
Return hash map containing entities that are lost