JACK 5.4 Application Interface

aos.jack.sim.run
Class Loader

java.lang.Object
  extended byaos.jack.sim.run.Loader

public class Loader
extends java.lang.Object

The Loader class is the entry point for most JACK Sim applications. It has a main() method, which should be passed the name of a simulation scenario definition file.


Field Summary
 aos.apib.TypeDict dict
          The JACOB input stream dictionary used when loading scenario definition files.
static boolean exit_when_done
          This gets set indirectly, based on the value of TimeDispatcher.exit_on_idle.
static Timer sim_timer
          This is the simulation time timer.
static Timer timer
          The original JACK Kernel timer is stored here.
 
Constructor Summary
Loader()
           
 
Method Summary
 void addAgent(java.lang.String name, java.lang.String type, InitialData data)
          Deprecated method, retained for backwards compatability.
 void addBlocking(Agent agent)
          Deprecated method used to block an agent.
 void addEntity(java.lang.String name, java.lang.Object e)
          Add an entity (usually an agent) to this loader.
 void addModel(java.lang.String name, java.lang.Object m)
          Add a (visual) model to this loader.
 void addReflected(java.lang.String name, java.lang.String type, InitialData data)
           
 boolean addTypeDict(java.lang.String d)
           
 void blockAgent(Agent agent)
          Utility method used to block an agent from doing any processing until unblockAgent(agent) is called.
 Agent createAgent(java.lang.String name, java.lang.String type)
          Utility method to dynamically create a new (uninitialised) agent that can be registered with the loader.
 Monitor createMonitor(java.lang.String type, int iterations)
           
 Agent deploy(java.lang.String name, java.lang.String type, InitialData data)
          Utility method to deploy a (possibly) new agent into a running simulation.
static void deregisterEntities()
          This will de-register from the loader any entity that is derived from aos.jack.sim.run.SimAgent and returns "true" via the SimAgent.getIsTransient() method.
 Cursor enumerator(Variable v)
          A JACK Cursor for enumerating entities.
 java.lang.Object[] getEntities()
          Returns the current set of entities as an Object array.
 java.lang.Object getEntity(java.lang.String name)
          Returns the object (entity) associated with the given name.
 java.lang.String[] getEntityNames()
          Returns the current set of entities as an array of names.
static Loader getLoader()
          Return the loader that is currently being used for agent creation/initialisation.
 Monitor getMonitor()
          Return the monitor object which controls multiple iterations of the current scenario.
 Agent initAgent(Agent agent, InitialData data)
          handles local initialisation.
 boolean isAgentBlocked(Agent agent)
          Utility method used to check if an agent is currently blocked.
 void load(java.lang.String filename)
          A support method to load a single scenario definition file.
static void main(java.lang.String[] args)
          Application entry point.
 Agent newAgent(java.lang.String name, java.lang.String type, InitialData data)
          Utility method to create an agent.
 void process(aos.apib.Base b)
           
 Agent readyAgent(Agent agent, java.lang.String name, InitialData data)
          Utility method to register a previously created agent.
 Agent readyInitAgent(java.lang.String name, java.lang.String type, InitialData data)
          Utility method to possibly create and initialise an agent and also register it with the loader if it is not already registered.
 Agent readyInitExistingAgent(java.lang.String name, InitialData data)
          Utility method to register a named agent with the loader.
 Agent readyNewAgent(java.lang.String name, java.lang.String type, InitialData data)
          Utility method to create an agent and add it to the list of registered entities.
 boolean release(java.lang.String name)
          Deprecated method used to unblock an agent blocked by a call to addBlocking().
 void removeAgent(Agent agent)
          Utility method to deregister an agent from the loader.
 void removeEntity(java.lang.String name)
          Utility method to remove a previously added entity.
 long resetTime()
          Reset the clock to the starting time as specified in the current scenario.
static void restart()
           
static void start(java.lang.String[] args)
          Called by Loader.main() to initialise JACK Sim and begin to load scenario definition files.
static void stopCurrentRun()
          A convenience method for terminating the current simulation run and continuing with the next iteration.
static void terminateTasks()
          This goes through the entire list of registered entities.
 void unblockAgent(Agent agent)
          Utility method used to unblock an agent blocked by a call to blockAgent() or the deprecated, addBlocking().
 boolean unblockByName(java.lang.String name)
          Utility method used to unblock an entity blocked by a call to blockAgent() or the deprecated, addBlocking().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timer

public static Timer timer
The original JACK Kernel timer is stored here.


sim_timer

public static Timer sim_timer
This is the simulation time timer.


exit_when_done

public static boolean exit_when_done
This gets set indirectly, based on the value of TimeDispatcher.exit_on_idle.


dict

public aos.apib.TypeDict dict
The JACOB input stream dictionary used when loading scenario definition files.

Constructor Detail

Loader

public Loader()
Method Detail

main

public static void main(java.lang.String[] args)
Application entry point. The main method will create a Loader object, which is installed as "#global data" for JACK, and then let that object load all scenario definition files mentioned on the command line.


resetTime

public long resetTime()
Reset the clock to the starting time as specified in the current scenario.


getMonitor

public Monitor getMonitor()
Return the monitor object which controls multiple iterations of the current scenario.


stopCurrentRun

public static void stopCurrentRun()
A convenience method for terminating the current simulation run and continuing with the next iteration.


terminateTasks

public static void terminateTasks()
This goes through the entire list of registered entities. If they are not derived from aos.jack.sim.run.SimAgent, (but are still an Agent) they will have all their tasks terminated. If they are derived from SimAgent, then they will have their tasks terminated only if they are NOT marked as being persistent.


deregisterEntities

public static void deregisterEntities()
This will de-register from the loader any entity that is derived from aos.jack.sim.run.SimAgent and returns "true" via the SimAgent.getIsTransient() method. This is called automatically before starting a new iteration of the current scenario in order to stop any transient or dynamically created entities that still exist, from being runnable within the simulation until manually enabled (by re-registering/deploying them when required).


getLoader

public static Loader getLoader()
Return the loader that is currently being used for agent creation/initialisation.


restart

public static void restart()

start

public static void start(java.lang.String[] args)
Called by Loader.main() to initialise JACK Sim and begin to load scenario definition files. Loading the scenario definition files will create agents and cause the simulation to start running.


load

public void load(java.lang.String filename)
A support method to load a single scenario definition file. The load() method can be invoked recursively. The named file will be opened using aos.util.PathEntry.open(..), and its JACOB objects will be read using the "dict" type dictionary. If an object implements the Initialise interface, then its initialise(..) method will be invoked. Note: simulation models and entities need to register themselves with the loader.


process

public void process(aos.apib.Base b)

addTypeDict

public boolean addTypeDict(java.lang.String d)

addModel

public void addModel(java.lang.String name,
                     java.lang.Object m)
Add a (visual) model to this loader.


addEntity

public void addEntity(java.lang.String name,
                      java.lang.Object e)
Add an entity (usually an agent) to this loader.


removeEntity

public void removeEntity(java.lang.String name)
Utility method to remove a previously added entity.


addBlocking

public void addBlocking(Agent agent)
Deprecated method used to block an agent. Use blockAgent(agent) instead.


blockAgent

public void blockAgent(Agent agent)
Utility method used to block an agent from doing any processing until unblockAgent(agent) is called.


unblockAgent

public void unblockAgent(Agent agent)
Utility method used to unblock an agent blocked by a call to blockAgent() or the deprecated, addBlocking(). Unlike unblockByName() and the deprecated, release(), this does not return any value. Use isAgentBlocked(Agent a) if you need to know if the agent is blocked beforehand.


release

public boolean release(java.lang.String name)
Deprecated method used to unblock an agent blocked by a call to addBlocking(). This used to expect a fully qualified agent name (e.g. foo@portal) which is inconsistent with most other methods in this class. Now it ignores the portal name for the purposes of table lookup. Use unblockAgent(Agent agent) instead.


unblockByName

public boolean unblockByName(java.lang.String name)
Utility method used to unblock an entity blocked by a call to blockAgent() or the deprecated, addBlocking().

Parameters:
name - This should be a simple, unqualified entity name.

isAgentBlocked

public boolean isAgentBlocked(Agent agent)
Utility method used to check if an agent is currently blocked.


removeAgent

public void removeAgent(Agent agent)
Utility method to deregister an agent from the loader. Once it is deregistered, it will no longer run under JACK Sim control.


readyAgent

public Agent readyAgent(Agent agent,
                        java.lang.String name,
                        InitialData data)
Utility method to register a previously created agent. It also calls the agent's initialize() method with the given data. The agent wil be left in a blocked state under JACK Sim control. If the entity is already registered, an Error will be thrown.


createAgent

public Agent createAgent(java.lang.String name,
                         java.lang.String type)
Utility method to dynamically create a new (uninitialised) agent that can be registered with the loader.


newAgent

public Agent newAgent(java.lang.String name,
                      java.lang.String type,
                      InitialData data)
Utility method to create an agent. If an agent with the given name already exists, an Error will be thrown. If the agent is already registered, an Error will be thrown.


readyNewAgent

public Agent readyNewAgent(java.lang.String name,
                           java.lang.String type,
                           InitialData data)
Utility method to create an agent and add it to the list of registered entities. If an agent with the given name already exists, an Error will be thrown.


addAgent

public void addAgent(java.lang.String name,
                     java.lang.String type,
                     InitialData data)
Deprecated method, retained for backwards compatability. This simply calls readyNewAgent(name, type, data).


initAgent

public Agent initAgent(Agent agent,
                       InitialData data)
handles local initialisation. If the agent is active an Error is thrown.


readyInitAgent

public Agent readyInitAgent(java.lang.String name,
                            java.lang.String type,
                            InitialData data)
Utility method to possibly create and initialise an agent and also register it with the loader if it is not already registered. If it is already registered, then an Error will be thrown. The agent will be left in a blocked state.


readyInitExistingAgent

public Agent readyInitExistingAgent(java.lang.String name,
                                    InitialData data)
Utility method to register a named agent with the loader. If there has been no such agent created, or if the agent is already registered, an Error is thrown. The agent will be left in a blocked state.


deploy

public Agent deploy(java.lang.String name,
                    java.lang.String type,
                    InitialData data)
Utility method to deploy a (possibly) new agent into a running simulation. It calls readyInitAgent(...) with the same parameters and unblocks the agent so it is ready to run. We post a BEGIN event for just this agent (name) to the registered TimeSource agent. It will organise the usual startup events (SETUP & BEGIN) to be delivered in the normal way.


addReflected

public void addReflected(java.lang.String name,
                         java.lang.String type,
                         InitialData data)

createMonitor

public Monitor createMonitor(java.lang.String type,
                             int iterations)

getEntities

public java.lang.Object[] getEntities()
Returns the current set of entities as an Object array.


getEntityNames

public java.lang.String[] getEntityNames()
Returns the current set of entities as an array of names.


getEntity

public java.lang.Object getEntity(java.lang.String name)
Returns the object (entity) associated with the given name.


enumerator

public Cursor enumerator(Variable v)
A JACK Cursor for enumerating entities.


JACK 5.4 Application Interface

Copyright (C) 1999-2008, Agent Oriented Software Pty. Ltd.

US Government Restricted Rights
The JACK Modules and relevant Software Material have been developed entirely at private expense and are accordingly provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of DFARS 252.227-7013 or subparagraph (c)(1) and (2) of the Commercial Computer Software Restricted Rights and 48 CFR 52.2270-19, as applicable.


Agent Oriented Software Pty. Ltd.     http://www.aosgrp.com
PO Box 639, Carlton South, Victoria 3053, Australia
Phone: +61 3 9349 5055, Fax: +61 3 9349 5088