org.gscg.gameleader.interactionlayer
Class GameLeaderInteractionLayer

java.lang.Object
  extended bynl.tudelft.simulation.event.EventProducer
      extended byorg.gscg.common.interactionlayer.ThreadedEventProducer
          extended byorg.gscg.gameleader.interactionlayer.GameLeaderInteractionLayer
All Implemented Interfaces:
nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface, java.util.EventListener, nl.tudelft.simulation.event.EventListenerInterface, nl.tudelft.simulation.event.EventProducerInterface, ExperimentInterface, GlobalInteractionLayerInterface, javax.naming.event.NamespaceChangeListener, javax.naming.event.NamingListener, java.rmi.Remote, nl.tudelft.simulation.event.remote.RemoteEventProducerInterface, RemoteInteractionLayerInterface, java.io.Serializable, nl.tudelft.simulation.dsol.simulators.SimulatorInterface

public class GameLeaderInteractionLayer
extends ThreadedEventProducer
implements RemoteInteractionLayerInterface, javax.naming.event.NamespaceChangeListener

The game leader interaction layer is the layer between server-side game control logic and a client-side game administrator application.

Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information www.simulation.tudelft.nl . The source code and binary code of this software is proprietary information of Delft University of Technology.

Since:
1.0.0
Version:
$Revision: 1.2 $ $Date: 2005/08/03 08:52:50 $
Author:
Stijn-Pieter van Houten
See Also:
Serialized Form

Field Summary
static nl.tudelft.simulation.event.EventType ANIMATION_UPDATE_EVENT
          the animation changed event
static nl.tudelft.simulation.event.EventType OBJECT_ADDED_EVENT
          the object added event
static nl.tudelft.simulation.event.EventType OBJECT_REMOVED_EVENT
          the object removed event
 
Fields inherited from class org.gscg.common.interactionlayer.ThreadedEventProducer
DIJKSTRASEMAPHORE
 
Fields inherited from class nl.tudelft.simulation.event.EventProducer
listeners
 
Fields inherited from interface nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface
DEFAULT_TIME_STEP, TIME_STEP_CHANGED_EVENT
 
Fields inherited from interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
END_OF_REPLICATION_EVENT, START_EVENT, START_REPLICATION_EVENT, STEP_EVENT, STOP_EVENT, TIME_CHANGED_EVENT, WARMUP_EVENT
 
Fields inherited from interface nl.tudelft.simulation.event.EventProducerInterface
FIRST_POSITION, LAST_POSITION
 
Constructor Summary
GameLeaderInteractionLayer(java.lang.String id)
          constructs a new GameLeaderInteractionLayer
 
Method Summary
 void addEventTypeSentByClient(nl.tudelft.simulation.event.EventType eventType)
          Method addEventTypeSentByClient.
 void addEventTypeToAnnounceList(nl.tudelft.simulation.event.EventType eventType, AnnounceInterface announceObject)
          Method addEventTypeToAnnounceList.
 void addStatisticEventType(nl.tudelft.simulation.event.EventType eventType)
          Method addStatisticEventType adds an event to a set with event types only used for statistical updates.
 java.util.Map getActorKeys()
           
 long getAnimationDelay()
           
 java.util.Map getBindings()
           
 void getCache(java.lang.Object remoteEventListener, nl.tudelft.simulation.event.EventType eventType, boolean cache)
          this method is used by a remote client to indicate that it is 'online' the server side object is then able to subscribe to client side events and to send cached data
 java.lang.String getId()
           
 IntrospectionData getIntrospectedObjectData(java.lang.String key)
          Method getIntrospectedObjectData returns the date of the object which has been introspected on a client-side animationpanel.
 nl.tudelft.simulation.dsol.experiment.Replication getReplication()
           
 double getSimulatorTime()
           
 nl.tudelft.simulation.event.EventType[] getStatisticEventTypes()
           
 double getTimeStep()
           
 int getTotalNumberOfDays()
           
 void initialize(nl.tudelft.simulation.dsol.experiment.Replication replication)
           
 boolean isRunning()
           
 boolean login(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface client)
           
 void namingExceptionThrown(javax.naming.event.NamingExceptionEvent evt)
           
 void notify(nl.tudelft.simulation.event.EventInterface event)
           
 void objectAdded(javax.naming.event.NamingEvent namingEvent)
           
 void objectRemoved(javax.naming.event.NamingEvent namingEvent)
           
 void objectRenamed(javax.naming.event.NamingEvent evt)
           
 void parseExperiment(org.jdom.Element experimentElement)
          method parseExperiment
 void removeAnimationRefreshDelayListener(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface listener)
          removes a listener for a refresh delay
 boolean removeListener(nl.tudelft.simulation.event.EventListenerInterface listener, nl.tudelft.simulation.event.EventType eventType)
           
 void saveSimulation()
          saves a simulation to a persitent storage
 void setAnimationDelay(long arg0)
           
 void setAnimationRefreshDelay(double times, nl.tudelft.simulation.event.remote.RemoteEventListenerInterface listener)
          sets the refresh delay for the client side animation panel; the server responds with a GameLeaderInteractionLayer.ANIMATION_UPDATE_EVENT
 void setTimeStep(double arg0)
           
 void start()
           
 void step()
           
 void stop()
           
 void updateIntrospectedObject(IntrospectionData data)
          Method updateIntrospectedObject updates an introspected object.
 
Methods inherited from class org.gscg.common.interactionlayer.ThreadedEventProducer
fireEvent
 
Methods inherited from class nl.tudelft.simulation.event.EventProducer
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, getEventTypes, removeAllListeners, removeAllListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.tudelft.simulation.event.EventProducerInterface
addListener, addListener, addListener, addListener, getEventTypes
 

Field Detail

OBJECT_ADDED_EVENT

public static final nl.tudelft.simulation.event.EventType OBJECT_ADDED_EVENT
the object added event


OBJECT_REMOVED_EVENT

public static final nl.tudelft.simulation.event.EventType OBJECT_REMOVED_EVENT
the object removed event


ANIMATION_UPDATE_EVENT

public static final nl.tudelft.simulation.event.EventType ANIMATION_UPDATE_EVENT
the animation changed event

Constructor Detail

GameLeaderInteractionLayer

public GameLeaderInteractionLayer(java.lang.String id)
constructs a new GameLeaderInteractionLayer

Parameters:
id - the id of the game administrator
Method Detail

notify

public void notify(nl.tudelft.simulation.event.EventInterface event)
            throws java.rmi.RemoteException
Specified by:
notify in interface nl.tudelft.simulation.event.EventListenerInterface
Throws:
java.rmi.RemoteException
See Also:
EventListenerInterface.notify(nl.tudelft.simulation.event.EventInterface)

addStatisticEventType

public void addStatisticEventType(nl.tudelft.simulation.event.EventType eventType)
Method addStatisticEventType adds an event to a set with event types only used for statistical updates. Upon initialization, a remote game leader graphical user interface asks for this set. EventTypes which are added to this set should follow the following convention ACTORROLE_ + description of eventtype. E.g. CUSTOMER_DEMAND_CHANGED_EVENT.

Parameters:
eventType - the event type to add

getCache

public void getCache(java.lang.Object remoteEventListener,
                     nl.tudelft.simulation.event.EventType eventType,
                     boolean cache)
              throws java.rmi.RemoteException
Description copied from interface: GlobalInteractionLayerInterface
this method is used by a remote client to indicate that it is 'online' the server side object is then able to subscribe to client side events and to send cached data

Specified by:
getCache in interface GlobalInteractionLayerInterface
Parameters:
remoteEventListener - the remote event producer or the remote event listener, may be null
eventType - the event type given as an argument for the announce method, may not be null
cache - true if this method is called during initialization of a client user interface; false in case of announcing for a statistic
Throws:
java.rmi.RemoteException - thrown in case of a network error
See Also:
GlobalInteractionLayerInterface.getCache(java.lang.Object, nl.tudelft.simulation.event.EventType, boolean)

login

public boolean login(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface client)
Specified by:
login in interface GlobalInteractionLayerInterface
Parameters:
client - The client to login
Returns:
Returns returns true if an interactionlayer is already logged in
See Also:
GlobalInteractionLayerInterface.login(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface)

parseExperiment

public void parseExperiment(org.jdom.Element experimentElement)
                     throws java.rmi.RemoteException
Description copied from interface: ExperimentInterface
method parseExperiment

Specified by:
parseExperiment in interface ExperimentInterface
Parameters:
experimentElement - the client-side parsed experiment as an element; should be serializable
Throws:
java.rmi.RemoteException - thrown in case of network error
See Also:
ExperimentInterface.parseExperiment(org.jdom.Element)

getSimulatorTime

public double getSimulatorTime()
                        throws java.rmi.RemoteException
Specified by:
getSimulatorTime in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
See Also:
SimulatorInterface.getSimulatorTime()

getReplication

public nl.tudelft.simulation.dsol.experiment.Replication getReplication()
                                                                 throws java.rmi.RemoteException
Specified by:
getReplication in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
See Also:
SimulatorInterface.getReplication()

initialize

public void initialize(nl.tudelft.simulation.dsol.experiment.Replication replication)
                throws java.rmi.RemoteException,
                       nl.tudelft.simulation.dsol.SimRuntimeException
Specified by:
initialize in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
nl.tudelft.simulation.dsol.SimRuntimeException
See Also:
SimulatorInterface.initialize(nl.tudelft.simulation.dsol.experiment.Replication)

isRunning

public boolean isRunning()
                  throws java.rmi.RemoteException
Specified by:
isRunning in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
See Also:
SimulatorInterface.isRunning()

start

public void start()
           throws java.rmi.RemoteException,
                  nl.tudelft.simulation.dsol.SimRuntimeException
Specified by:
start in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
nl.tudelft.simulation.dsol.SimRuntimeException
See Also:
SimulatorInterface.start()

step

public void step()
          throws java.rmi.RemoteException,
                 nl.tudelft.simulation.dsol.SimRuntimeException
Specified by:
step in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
nl.tudelft.simulation.dsol.SimRuntimeException
See Also:
SimulatorInterface.step()

stop

public void stop()
          throws java.rmi.RemoteException,
                 nl.tudelft.simulation.dsol.SimRuntimeException
Specified by:
stop in interface nl.tudelft.simulation.dsol.simulators.SimulatorInterface
Throws:
java.rmi.RemoteException
nl.tudelft.simulation.dsol.SimRuntimeException
See Also:
SimulatorInterface.stop()

removeListener

public boolean removeListener(nl.tudelft.simulation.event.EventListenerInterface listener,
                              nl.tudelft.simulation.event.EventType eventType)
Specified by:
removeListener in interface nl.tudelft.simulation.event.EventProducerInterface
See Also:
EventProducerInterface.removeListener(nl.tudelft.simulation.event.EventListenerInterface, nl.tudelft.simulation.event.EventType)

getId

public java.lang.String getId()
Returns:
Returns the id

getTimeStep

public double getTimeStep()
                   throws java.rmi.RemoteException
Specified by:
getTimeStep in interface nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface
Throws:
java.rmi.RemoteException
See Also:
DESSSimulatorInterface.getTimeStep()

setTimeStep

public void setTimeStep(double arg0)
                 throws java.rmi.RemoteException
Specified by:
setTimeStep in interface nl.tudelft.simulation.dsol.simulators.DESSSimulatorInterface
Throws:
java.rmi.RemoteException
See Also:
DESSSimulatorInterface.setTimeStep(double)

getAnimationDelay

public long getAnimationDelay()
                       throws java.rmi.RemoteException
Specified by:
getAnimationDelay in interface RemoteInteractionLayerInterface
Returns:
returns the animation delay
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
RemoteInteractionLayerInterface.getAnimationDelay()

setAnimationDelay

public void setAnimationDelay(long arg0)
                       throws java.rmi.RemoteException
Specified by:
setAnimationDelay in interface RemoteInteractionLayerInterface
Parameters:
arg0 - the animation delay
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
RemoteInteractionLayerInterface.setAnimationDelay(long)

getActorKeys

public java.util.Map getActorKeys()
                           throws java.rmi.RemoteException
Specified by:
getActorKeys in interface RemoteInteractionLayerInterface
Returns:
returns the map with the keys for the actors. A key of the map represents a reference type of an actor, e.g. a manufacturer or a retailer. The object belonging to this key is a alfabetically SortedSet, containing they keys for the actors. These keys can be used to get the data for an actor from the server.
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
RemoteInteractionLayerInterface.getActorKeys()

getTotalNumberOfDays

public int getTotalNumberOfDays()
                         throws java.rmi.RemoteException
Specified by:
getTotalNumberOfDays in interface GlobalInteractionLayerInterface
Returns:
Returns an integer representing the total number of days of the simulation. This integer is used for stastistics as a range.
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
GlobalInteractionLayerInterface.getTotalNumberOfDays()

objectAdded

public void objectAdded(javax.naming.event.NamingEvent namingEvent)
Specified by:
objectAdded in interface javax.naming.event.NamespaceChangeListener
See Also:
NamespaceChangeListener.objectAdded(javax.naming.event.NamingEvent)

objectRemoved

public void objectRemoved(javax.naming.event.NamingEvent namingEvent)
Specified by:
objectRemoved in interface javax.naming.event.NamespaceChangeListener
See Also:
NamespaceChangeListener.objectRemoved(javax.naming.event.NamingEvent)

objectRenamed

public void objectRenamed(javax.naming.event.NamingEvent evt)
Specified by:
objectRenamed in interface javax.naming.event.NamespaceChangeListener
See Also:
NamespaceChangeListener.objectRenamed(javax.naming.event.NamingEvent)

namingExceptionThrown

public void namingExceptionThrown(javax.naming.event.NamingExceptionEvent evt)
Specified by:
namingExceptionThrown in interface javax.naming.event.NamingListener
See Also:
NamingListener.namingExceptionThrown(javax.naming.event.NamingExceptionEvent)

getBindings

public java.util.Map getBindings()
                          throws java.rmi.RemoteException
Specified by:
getBindings in interface RemoteInteractionLayerInterface
Returns:
returns the map with animation bindings
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
RemoteInteractionLayerInterface.getBindings()

getIntrospectedObjectData

public IntrospectionData getIntrospectedObjectData(java.lang.String key)
                                            throws java.rmi.RemoteException
Description copied from interface: RemoteInteractionLayerInterface
Method getIntrospectedObjectData returns the date of the object which has been introspected on a client-side animationpanel. Serverside resolving of this object is done using a unique key which is a combination of the toString() and hashCode() methods of the object.

Specified by:
getIntrospectedObjectData in interface RemoteInteractionLayerInterface
Parameters:
key - the key to use
Returns:
Returns the introspected data for the object if found, null otherwise
Throws:
java.rmi.RemoteException - thrown in case of a network failure
See Also:
RemoteInteractionLayerInterface.getIntrospectedObjectData(java.lang.String)

updateIntrospectedObject

public void updateIntrospectedObject(IntrospectionData data)
                              throws java.rmi.RemoteException
Description copied from interface: RemoteInteractionLayerInterface
Method updateIntrospectedObject updates an introspected object.

Specified by:
updateIntrospectedObject in interface RemoteInteractionLayerInterface
Parameters:
data - the data for the oject
Throws:
java.rmi.RemoteException - thrown in case of a network failure
See Also:
RemoteInteractionLayerInterface.updateIntrospectedObject(org.gscg.gameleader.animation2D.mouse.IntrospectionData)

setAnimationRefreshDelay

public void setAnimationRefreshDelay(double times,
                                     nl.tudelft.simulation.event.remote.RemoteEventListenerInterface listener)
                              throws java.rmi.RemoteException
Description copied from interface: RemoteInteractionLayerInterface
sets the refresh delay for the client side animation panel; the server responds with a GameLeaderInteractionLayer.ANIMATION_UPDATE_EVENT

Specified by:
setAnimationRefreshDelay in interface RemoteInteractionLayerInterface
Parameters:
times - the number of times per second the animation should be refreshed (only if an update is present)
listener - the listener for the event
Throws:
java.rmi.RemoteException - thrown in case of a network error
See Also:
org.gscg.gameleader.interactionlayer.RemoteInteractionLayerInterface#setAnimationRefreshDelay(int, nl.tudelft.simulation.event.remote.RemoteEventListenerInterface)

removeAnimationRefreshDelayListener

public void removeAnimationRefreshDelayListener(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface listener)
                                         throws java.rmi.RemoteException
Description copied from interface: RemoteInteractionLayerInterface
removes a listener for a refresh delay

Specified by:
removeAnimationRefreshDelayListener in interface RemoteInteractionLayerInterface
Parameters:
listener - the listener to remove
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
RemoteInteractionLayerInterface.removeAnimationRefreshDelayListener(nl.tudelft.simulation.event.remote.RemoteEventListenerInterface)

saveSimulation

public void saveSimulation()
                    throws java.rmi.RemoteException
Description copied from interface: RemoteInteractionLayerInterface
saves a simulation to a persitent storage

Specified by:
saveSimulation in interface RemoteInteractionLayerInterface
Throws:
java.rmi.RemoteException - thrown in case of network failure
See Also:
RemoteInteractionLayerInterface.saveSimulation()

getStatisticEventTypes

public nl.tudelft.simulation.event.EventType[] getStatisticEventTypes()
Specified by:
getStatisticEventTypes in interface GlobalInteractionLayerInterface
Returns:
Returns an array with event types for statistics
See Also:
GlobalInteractionLayerInterface.getStatisticEventTypes()

addEventTypeSentByClient

public void addEventTypeSentByClient(nl.tudelft.simulation.event.EventType eventType)
Description copied from interface: GlobalInteractionLayerInterface
Method addEventTypeSentByClient. EventTypes added using this method are fired by a client. Object which are interested in these events subscribe them as listeners to these events. At the same time, when the interaction layer receives one of these events, the event is checked with a list of known events.

Specified by:
addEventTypeSentByClient in interface GlobalInteractionLayerInterface
Parameters:
eventType - the event type to add
See Also:
GlobalInteractionLayerInterface.addEventTypeSentByClient(nl.tudelft.simulation.event.EventType)

addEventTypeToAnnounceList

public void addEventTypeToAnnounceList(nl.tudelft.simulation.event.EventType eventType,
                                       AnnounceInterface announceObject)
Description copied from interface: GlobalInteractionLayerInterface
Method addEventTypeToAnnounceList. Adds an event type and the corresponding announce object to a hashmap.

Specified by:
addEventTypeToAnnounceList in interface GlobalInteractionLayerInterface
Parameters:
eventType - the event type
announceObject - the object to announce
See Also:
GlobalInteractionLayerInterface.addEventTypeToAnnounceList(nl.tudelft.simulation.event.EventType, org.gscg.common.interactionlayer.AnnounceInterface)


Copyright © 2002-2005 Delft University of Technology, the Netherlands. All Rights Reserved.