Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

oxygen::SpadesServer Class Reference

#include <spadesserver.h>

Inheritance diagram for oxygen::SpadesServer:

Inheritance graph
[legend]
Collaboration diagram for oxygen::SpadesServer:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SpadesServer ()
 ~SpadesServer ()
virtual bool ConstructInternal ()
 setup script variables used to customize the SpadesServer
virtual void OnLink ()
 set up GameControlServer and MonitorServer reference
virtual void OnUnlink ()
 reset GameControlServer and MonitorServer reference
boost::shared_ptr< GameControlServerGetGameControlServer () const
 helper function to locate the game control server
float GetTimePerStep () const
 returns the amount of time in seconds a single simulation step corresponds to.
bool GetRunIntegratedCommserver () const
 Get the value of the Spades.RunIntegratedCommserver variable.
int GetCommServersWanted () const
 Get the value of the Spades.CommServersWanted variable.
int GetMonitorInterval () const
 Get the value of the Spades.MonitorInterval variable.
bool GetSendAgentThinkTimes () const
 Get the value of the Spades.SendAgentThinkTimes variable.
void QueueAgents (const std::string &agentType="default", int num=1)
 queue up agents to be started.
void Unpause ()
 set simulation mode to normal
virtual void UpdateCached ()
 update cached variables
spades::EngineParam * parseParameters (int argc, const char *const *argv)
 You probably want to inherit some parameters from EngineParam and use that to parse the commandline.
bool initialize (spades::SimEngine *pSE)
 Most of the real initialization/finalization work should be done here.
spades::SimEngine * GetSimEngine ()
 returns a pointer to the spades simulation engine
bool finalize ()
spades::SimTime simToTime (spades::SimTime time_curr, spades::SimTime time_desired)
 This function should advance the world forward.
spades::DataArray getMonitorHeaderInfo ()
 This function is called once for every monitor.
spades::DataArray getMonitorInfo (spades::SimTime time)
 This function will be called periodically to get information about the current state of the world.
void parseMonitorMessage (const char *data, unsigned datalen)
 If a monitor sends information to the world model, this function is called to process it.
spades::SimTime getMinActionLatency () const
 There is a latency (in simulation time) between when an action is sent by the agent and when it takes effect.
spades::SimTime getMinSenseLatency () const
 Similar to getMinActionLatency, but the latency between when the sensation is generated from the world and when it is received by the agent.
spades::ActEvent * parseAct (spades::SimTime t, spades::AgentID a, const char *data, unsigned datalen) const
 This function parses the action string received from the agents Note that this method is const! parsing the act can *not* affect the world at all, since this could then violate causality.
void pauseModeCallback ()
 When the simulation is paused, this is called peridically At some point, this function should unpause the simulation The simulation starts out in paused mode.
bool agentConnect (spades::AgentID agent, spades::AgentTypeDB::AgentTypeConstIterator at)
 The world model initiates startup requests for agents.
bool agentDisappear (spades::AgentID agent, spades::AgentLostReason reason)
 Any time an agent leaves the simulation (whether by crash, graceful exit request, etc.
void notifyCommserverConnect (spades::ServerID s)
 Called every time a comm server connects.
void notifyCommserverDisconnect (spades::ServerID s)
 Called every time a comm server dsiconnects.

Protected Types

typedef std::list< AgentItemTAgentQueue

Protected Member Functions

void StartAgents (const AgentItem &ai)
 Start up a number of agents of a given type.

Private Attributes

spades::SimEngine * mSimEngine
 the Spades simulation engine
boost::shared_ptr< ParamReadermParamReader
 our commandline parser
bool mSimulationModeChanged
 flag if there is a simulation mode change scheduled
spades::SimulationMode mNewSimulationMode
 the next simulation mode for a mode change
TAgentQueue mAgentQueue
 a queue of agents to be started up
float mOffsetCreateSense
 the simTime offset in the scheduled times for the agents CreateSenseEvent
float mNextInitialCreateSense
 the initial CreateSenseEvent simTime scheduled for the next connecing agent
boost::shared_ptr< MonitorServermMonitorServer
 a cached reference to the monitor server
boost::shared_ptr< GameControlServermGameControlServer
 a cached reference to the GameControlServer
boost::shared_ptr< SceneServermSceneServer
 a cached reference to the SceneServer
float mTimePerStep
 the cached Spades.TimePerStep value

Classes

struct  AgentItem

Detailed Description

The SpadesServer serves as an interface between the SceneServer and the agents

Definition at line 40 of file spadesserver.h.


Member Typedef Documentation

typedef std::list<AgentItem> oxygen::SpadesServer::TAgentQueue [protected]
 

Definition at line 228 of file spadesserver.h.


Constructor & Destructor Documentation

SpadesServer::SpadesServer  ) 
 

Definition at line 42 of file spadesserver.cpp.

SpadesServer::~SpadesServer  ) 
 

Definition at line 49 of file spadesserver.cpp.


Member Function Documentation

bool oxygen::SpadesServer::agentConnect spades::AgentID  agent,
spades::AgentTypeDB::AgentTypeConstIterator  at
 

The world model initiates startup requests for agents.

This function is called once the agent has been started successfully

bool oxygen::SpadesServer::agentDisappear spades::AgentID  agent,
spades::AgentLostReason  reason
 

Any time an agent leaves the simulation (whether by crash, graceful exit request, etc.

), this function is called so that the world model can update it's data structures

bool SpadesServer::ConstructInternal  )  [virtual]
 

setup script variables used to customize the SpadesServer

Reimplemented from zeitgeist::Object.

Definition at line 54 of file spadesserver.cpp.

References zeitgeist::Object::GetScript().

Here is the call graph for this function:

bool SpadesServer::finalize  ) 
 

Returns:
true

Definition at line 247 of file spadesserver.cpp.

int SpadesServer::GetCommServersWanted  )  const
 

Get the value of the Spades.CommServersWanted variable.

On startup SpadesServer will wait until at least 'CommServersWanted' CommServers have connected before it initially unpauses the simulation.

Definition at line 118 of file spadesserver.cpp.

References zeitgeist::Object::GetScript().

Referenced by pauseModeCallback().

Here is the call graph for this function:

boost::shared_ptr< GameControlServer > SpadesServer::GetGameControlServer  )  const
 

helper function to locate the game control server

Definition at line 156 of file spadesserver.cpp.

References mGameControlServer.

Referenced by oxygen::SpadesCreateSenseEvent::createSense(), oxygen::SpadesCreateSenseEvent::realizeEventWorldModel(), and oxygen::SpadesActEvent::realizeEventWorldModel().

SimTime SpadesServer::getMinActionLatency  )  const
 

There is a latency (in simulation time) between when an action is sent by the agent and when it takes effect.

This function needs to return the minimum of all possible values of that latency. This is used to reason about causality

Definition at line 335 of file spadesserver.cpp.

SimTime SpadesServer::getMinSenseLatency  )  const
 

Similar to getMinActionLatency, but the latency between when the sensation is generated from the world and when it is received by the agent.

Definition at line 341 of file spadesserver.cpp.

DataArray SpadesServer::getMonitorHeaderInfo  ) 
 

This function is called once for every monitor.

It should return any header/setup information that is needed.

Definition at line 302 of file spadesserver.cpp.

References mMonitorServer.

spades::DataArray oxygen::SpadesServer::getMonitorInfo spades::SimTime  time  ) 
 

This function will be called periodically to get information about the current state of the world.

The format is completely determined by what the monitors will expect; no processing is done by the simulation engine

int SpadesServer::GetMonitorInterval  )  const
 

Get the value of the Spades.MonitorInterval variable.

Returns:
the number of simulation steps per monitor message.

Definition at line 137 of file spadesserver.cpp.

References zeitgeist::Object::GetScript().

Referenced by parseParameters().

Here is the call graph for this function:

bool SpadesServer::GetRunIntegratedCommserver  )  const
 

Get the value of the Spades.RunIntegratedCommserver variable.

Returns:
true if the variable is set to true, false otherwise.

Definition at line 127 of file spadesserver.cpp.

References zeitgeist::Object::GetScript().

Referenced by parseParameters().

Here is the call graph for this function:

bool SpadesServer::GetSendAgentThinkTimes  )  const
 

Get the value of the Spades.SendAgentThinkTimes variable.

Definition at line 146 of file spadesserver.cpp.

References zeitgeist::Object::GetScript().

Referenced by parseParameters().

Here is the call graph for this function:

spades::SimEngine * SpadesServer::GetSimEngine  ) 
 

returns a pointer to the spades simulation engine

Definition at line 106 of file spadesserver.cpp.

References mSimEngine.

Referenced by oxygen::SpadesCreateSenseEvent::realizeEventWorldModel().

float SpadesServer::GetTimePerStep  )  const
 

returns the amount of time in seconds a single simulation step corresponds to.

Definition at line 112 of file spadesserver.cpp.

References mTimePerStep.

Referenced by oxygen::SpadesCreateSenseEvent::createSense(), pauseModeCallback(), and oxygen::SpadesCreateSenseEvent::realizeEventWorldModel().

bool oxygen::SpadesServer::initialize spades::SimEngine *  pSE  ) 
 

Most of the real initialization/finalization work should be done here.

We do this so that the SimEngine can initialize after this class is created.

Parameters:
pSE a pointer to the spades simulation engine
Returns:
true

void oxygen::SpadesServer::notifyCommserverConnect spades::ServerID  s  ) 
 

Called every time a comm server connects.

Usually, this can be ignored as the WorldModel does not need to know when and how many commservers connect, unless it wants to do it's own load balancing

void oxygen::SpadesServer::notifyCommserverDisconnect spades::ServerID  s  ) 
 

Called every time a comm server dsiconnects.

Usually, this can be ignored as the WorldModel does not need to know when and how many commservers connect, unless it wants to do it's own load balancing

void SpadesServer::OnLink  )  [virtual]
 

set up GameControlServer and MonitorServer reference

Reimplemented from zeitgeist::Leaf.

Definition at line 67 of file spadesserver.cpp.

References zeitgeist::Object::GetCore(), zeitgeist::Object::GetLog(), mGameControlServer, mMonitorServer, mSceneServer, and mTimePerStep.

Here is the call graph for this function:

void SpadesServer::OnUnlink  )  [virtual]
 

reset GameControlServer and MonitorServer reference

Reimplemented from zeitgeist::Leaf.

Definition at line 98 of file spadesserver.cpp.

References mGameControlServer, mMonitorServer, and mSceneServer.

spades::ActEvent* oxygen::SpadesServer::parseAct spades::SimTime  t,
spades::AgentID  a,
const char *  data,
unsigned  datalen
const
 

This function parses the action string received from the agents Note that this method is const! parsing the act can *not* affect the world at all, since this could then violate causality.

Also, at some point this functionality may be moved to the communication server (which manages communication with the agents)

void SpadesServer::parseMonitorMessage const char *  data,
unsigned  datalen
 

If a monitor sends information to the world model, this function is called to process it.

Note that only the data section of the message (not the ID part which indicates that it is a message for the world model and not the simulation engine) is included here. If you need to keep the data, you must copy it

Definition at line 324 of file spadesserver.cpp.

References mMonitorServer.

EngineParam * SpadesServer::parseParameters int  argc,
const char *const *  argv
 

You probably want to inherit some parameters from EngineParam and use that to parse the commandline.

See the ParamReader class.

Definition at line 216 of file spadesserver.cpp.

References zeitgeist::Object::GetCore(), GetMonitorInterval(), GetRunIntegratedCommserver(), GetSendAgentThinkTimes(), and mParamReader.

Here is the call graph for this function:

void SpadesServer::pauseModeCallback  ) 
 

When the simulation is paused, this is called peridically At some point, this function should unpause the simulation The simulation starts out in paused mode.

Definition at line 374 of file spadesserver.cpp.

References GetCommServersWanted(), zeitgeist::Object::GetLog(), GetTimePerStep(), mAgentQueue, mGameControlServer, mNewSimulationMode, mNextInitialCreateSense, mOffsetCreateSense, mSimEngine, mSimulationModeChanged, StartAgents(), and Unpause().

Here is the call graph for this function:

void SpadesServer::QueueAgents const std::string &  agentType = "default",
int  num = 1
 

queue up agents to be started.

Parameters:
agentType agent type to be found in the SPADES agent database.
num number of agents to be started of the given type.

Definition at line 208 of file spadesserver.cpp.

References mAgentQueue.

spades::SimTime oxygen::SpadesServer::simToTime spades::SimTime  time_curr,
spades::SimTime  time_desired
 

This function should advance the world forward.

Events can be enqueed from this function. The time does *not* have to advance all the way to the time_desired, and if you put events in the queue, you should not advance past the time of those events. The simulation time here is an integer type, so the SpadesServer has to know how big a simulation step is.

Parameters:
time_curr the current simulation step
time_desired the desired simulation step
Returns:
a new simulation time t (time_curr <= t <= time_desired)

void SpadesServer::StartAgents const AgentItem ai  )  [protected]
 

Start up a number of agents of a given type.

Parameters:
ai contains the agent type from the agent database and the number of agents to start.

Definition at line 162 of file spadesserver.cpp.

References zeitgeist::Object::GetLog(), oxygen::SpadesServer::AgentItem::mAgentType, oxygen::SpadesServer::AgentItem::mNumber, and mSimEngine.

Referenced by pauseModeCallback().

Here is the call graph for this function:

void SpadesServer::Unpause  ) 
 

set simulation mode to normal

Definition at line 201 of file spadesserver.cpp.

References mNewSimulationMode, and mSimulationModeChanged.

Referenced by pauseModeCallback().

void SpadesServer::UpdateCached  )  [virtual]
 

update cached variables

Reimplemented from zeitgeist::Node.

Definition at line 496 of file spadesserver.cpp.

References zeitgeist::Object::GetScript(), and mTimePerStep.

Here is the call graph for this function:


Member Data Documentation

TAgentQueue oxygen::SpadesServer::mAgentQueue [private]
 

a queue of agents to be started up

Definition at line 250 of file spadesserver.h.

Referenced by pauseModeCallback(), and QueueAgents().

boost::shared_ptr<GameControlServer> oxygen::SpadesServer::mGameControlServer [private]
 

a cached reference to the GameControlServer

Definition at line 266 of file spadesserver.h.

Referenced by GetGameControlServer(), OnLink(), OnUnlink(), and pauseModeCallback().

boost::shared_ptr<MonitorServer> oxygen::SpadesServer::mMonitorServer [private]
 

a cached reference to the monitor server

Definition at line 263 of file spadesserver.h.

Referenced by getMonitorHeaderInfo(), OnLink(), OnUnlink(), and parseMonitorMessage().

spades::SimulationMode oxygen::SpadesServer::mNewSimulationMode [private]
 

the next simulation mode for a mode change

Definition at line 247 of file spadesserver.h.

Referenced by pauseModeCallback(), and Unpause().

float oxygen::SpadesServer::mNextInitialCreateSense [private]
 

the initial CreateSenseEvent simTime scheduled for the next connecing agent

Definition at line 260 of file spadesserver.h.

Referenced by pauseModeCallback().

float oxygen::SpadesServer::mOffsetCreateSense [private]
 

the simTime offset in the scheduled times for the agents CreateSenseEvent

Definition at line 255 of file spadesserver.h.

Referenced by pauseModeCallback().

boost::shared_ptr<ParamReader> oxygen::SpadesServer::mParamReader [private]
 

our commandline parser

Definition at line 241 of file spadesserver.h.

Referenced by parseParameters().

boost::shared_ptr<SceneServer> oxygen::SpadesServer::mSceneServer [private]
 

a cached reference to the SceneServer

Definition at line 269 of file spadesserver.h.

Referenced by OnLink(), and OnUnlink().

spades::SimEngine* oxygen::SpadesServer::mSimEngine [private]
 

the Spades simulation engine

Definition at line 238 of file spadesserver.h.

Referenced by GetSimEngine(), pauseModeCallback(), and StartAgents().

bool oxygen::SpadesServer::mSimulationModeChanged [private]
 

flag if there is a simulation mode change scheduled

Definition at line 244 of file spadesserver.h.

Referenced by pauseModeCallback(), and Unpause().

float oxygen::SpadesServer::mTimePerStep [private]
 

the cached Spades.TimePerStep value

Definition at line 272 of file spadesserver.h.

Referenced by GetTimePerStep(), OnLink(), and UpdateCached().


The documentation for this class was generated from the following files:
Generated on Thu Apr 6 15:48:12 2006 for rcssserver3d by  doxygen 1.4.4