VR-Forces 4.0.4 Class Documentation
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
DtCgfDispatcher Class Reference

This class handles messages from the front-end for loading and saving scenarios, and controlling the simulation state (run, pause, rewind, etc.). More...

List of all members.

Public Member Functions

 DtCgfDispatcher (DtCgf *cgf, DtVrfMessageInterface *messageIf, int receivePort=8000)
 Constructor.
virtual ~DtCgfDispatcher ()
virtual void closeScenario (DtIfCloseScenario *msg)
 Message processing functions.
virtual void loadScenario (DtIfLoadScenario *msg)
virtual void saveScenario (DtIfSaveScenario *msg, const DtSimulationAddress &requester)
 Handles the given save request, and if successful sends a DtIfSaveComplete message to the given requester address.
virtual void controlScenario (DtIfControl *msgData, const DtSimulationAddress &sender)
 Handles simulation control messages (run, pause, rewind, run for duration) sent from a front-end.
virtual void setEnableResourceMonitor (bool b)
virtual void tick ()
 Perform periodic processing.
virtual void setTimeToQuit (bool yesNo)
 Set/Get whether it's time to quit.
virtual bool timeToQuit () const
virtual DtVrfMessageInterfacemessageInterface () const
 Accessor for the message interface.
virtual DtCgfcgf () const
 Accessor for the cgf.
virtual int port () const
 Get the port for sending files.
virtual const DtFilename & tempDirectory ()
 Set/Get the temperary directory.
virtual void setTempDirectory (const DtFilename &f)
virtual void cleanupSockets ()
 Asks the file transporter to go through it's socket list and see which sockets are still ok.
virtual unsigned int simMgmtPduProcessLevel () const
 Set/Get the type of receiver ids to process when processing a sim mgmt PDU 1={*,*,*}&{*,*,0} <- wildcarded recipients 2={a,b,0} <- specific ids only 3= both 1 and 2.
virtual void setSimMgmtPduProcessLevel (unsigned int level)
virtual void processCapableTaskAndSetQuery (DtSimMessage *msg)
virtual void processDIGuyAppearAndAniamtionsQuery (DtSimMessage *msg)

Static Public Member Functions

static void processMessageCb (DtSimMessage *msg, void *usr)
 Interface message callback.
static void startResumeSimCb (DtStartResumeInteraction *msg, void *usr)
 sim mgmt PDU callback for processing a start/run PDU
static void stopFreezeSimCb (DtStopFreezeInteraction *msg, void *usr)
 sim mgmt PDU callback for processing a stop/freeze PDU
static void receiveFileCb (const DtFilename &f, void *usr)
 New file arrival callback.
static void runDurationCompleteCallback (DtTimer *timer)
 Callback invoked after the duration time has been reached after simulation has been put in run duration mode.

Protected Member Functions

virtual bool shouldTryReload (const DtScenario &scenario)
 Return true/false depending on whether or not scenario that failed to load should be tried to be reloaded on next tick.
virtual void pause ()
 Puts back-end into pause mode (simulation time does not advance).
virtual void run ()
 Puts back-end into run mode (simulation time advances).
virtual void rewind ()
 Rewinds current scenario running in back-end.
virtual void step (const DtSimulationAddress &sender)
 Steps forward one tick.
virtual void runForDuration (double duration, const DtSimulationAddress &sender)
 Puts the back-end into run mode for a specified duration in simulation time.

Protected Attributes

int myPort
bool myTimeToQuit
DtCgfmyCgf
DtVrfMessageInterfacemyMessageIf
DtFilename myDir
DtCompressedFileTransporter myTransporter
DtIfLoadScenariomyPendingLoadScenario
 This pointer is used to keep a scenario load message in queue for those times that a load scenario messages comes in before all the appropriate files are present.
unsigned int mySimMgmtPduProcessLevel

Detailed Description

This class handles messages from the front-end for loading and saving scenarios, and controlling the simulation state (run, pause, rewind, etc.).


Constructor & Destructor Documentation

DtCgfDispatcher::DtCgfDispatcher ( DtCgf cgf,
DtVrfMessageInterface messageIf,
int  receivePort = 8000 
)

Constructor.

Parameters:
cgfDtCgf for which this instance will be acting as a dispatcher
messageIfmessage interface used for communications
receivePortport used by the file transporter to receive order of battle and plan files from a DtVrfRemoteController. If the port requested cannot be opened, the next open port will be used.
virtual DtCgfDispatcher::~DtCgfDispatcher ( ) [virtual]

Member Function Documentation

virtual void DtCgfDispatcher::closeScenario ( DtIfCloseScenario msg) [virtual]

Message processing functions.

virtual void DtCgfDispatcher::loadScenario ( DtIfLoadScenario msg) [virtual]
virtual void DtCgfDispatcher::saveScenario ( DtIfSaveScenario msg,
const DtSimulationAddress &  requester 
) [virtual]

Handles the given save request, and if successful sends a DtIfSaveComplete message to the given requester address.

virtual void DtCgfDispatcher::controlScenario ( DtIfControl msgData,
const DtSimulationAddress &  sender 
) [virtual]

Handles simulation control messages (run, pause, rewind, run for duration) sent from a front-end.

Parameters:
msgDataInterface message content for controlling back-end simulation state.
senderSimulation address of the front-end that sent the message.
virtual void DtCgfDispatcher::setEnableResourceMonitor ( bool  b) [virtual]
virtual void DtCgfDispatcher::tick ( ) [virtual]

Perform periodic processing.

virtual void DtCgfDispatcher::setTimeToQuit ( bool  yesNo) [virtual]

Set/Get whether it's time to quit.

virtual bool DtCgfDispatcher::timeToQuit ( ) const [virtual]

Accessor for the message interface.

virtual DtCgf* DtCgfDispatcher::cgf ( ) const [virtual]

Accessor for the cgf.

virtual int DtCgfDispatcher::port ( ) const [virtual]

Get the port for sending files.

virtual const DtFilename& DtCgfDispatcher::tempDirectory ( ) [virtual]

Set/Get the temperary directory.

virtual void DtCgfDispatcher::setTempDirectory ( const DtFilename &  f) [virtual]
virtual void DtCgfDispatcher::cleanupSockets ( ) [virtual]

Asks the file transporter to go through it's socket list and see which sockets are still ok.

Any that are not will be removed from the socket list

virtual unsigned int DtCgfDispatcher::simMgmtPduProcessLevel ( ) const [virtual]

Set/Get the type of receiver ids to process when processing a sim mgmt PDU 1={*,*,*}&{*,*,0} <- wildcarded recipients 2={a,b,0} <- specific ids only 3= both 1 and 2.

virtual void DtCgfDispatcher::setSimMgmtPduProcessLevel ( unsigned int  level) [virtual]
static void DtCgfDispatcher::processMessageCb ( DtSimMessage msg,
void *  usr 
) [static]

Interface message callback.

Forwards the msg's interface content to the appropriate message processing function.

static void DtCgfDispatcher::startResumeSimCb ( DtStartResumeInteraction *  msg,
void *  usr 
) [static]

sim mgmt PDU callback for processing a start/run PDU

static void DtCgfDispatcher::stopFreezeSimCb ( DtStopFreezeInteraction *  msg,
void *  usr 
) [static]

sim mgmt PDU callback for processing a stop/freeze PDU

static void DtCgfDispatcher::receiveFileCb ( const DtFilename &  f,
void *  usr 
) [static]

New file arrival callback.

static void DtCgfDispatcher::runDurationCompleteCallback ( DtTimer timer) [static]

Callback invoked after the duration time has been reached after simulation has been put in run duration mode.

Parameters:
timerObject maintained by the scheduler, containing a pointer to the callback, the simulation time the callback should be invoked, and and user-specified data to pass into the callback.
virtual bool DtCgfDispatcher::shouldTryReload ( const DtScenario scenario) [protected, virtual]

Return true/false depending on whether or not scenario that failed to load should be tried to be reloaded on next tick.

By default returns true

virtual void DtCgfDispatcher::pause ( ) [protected, virtual]

Puts back-end into pause mode (simulation time does not advance).

virtual void DtCgfDispatcher::run ( ) [protected, virtual]

Puts back-end into run mode (simulation time advances).

virtual void DtCgfDispatcher::rewind ( ) [protected, virtual]

Rewinds current scenario running in back-end.

virtual void DtCgfDispatcher::step ( const DtSimulationAddress &  sender) [protected, virtual]

Steps forward one tick.

Parameters:
senderSimulation address of the front-end that made the request.
virtual void DtCgfDispatcher::runForDuration ( double  duration,
const DtSimulationAddress &  sender 
) [protected, virtual]

Puts the back-end into run mode for a specified duration in simulation time.

Puts back-end into run mode (simulation time advances), and registers runDurationCompleteCallback with the scheduler, to be invoked at the future time specified in the control message (current simulation time + duration). In the callback, back-end will be put into pause mode.

Parameters:
durationSimulation time in seconds that the back-end should run before pausing.
senderSimulation address of the front-end that made the request.

Member Data Documentation

int DtCgfDispatcher::myPort [protected]
DtFilename DtCgfDispatcher::myDir [protected]

This pointer is used to keep a scenario load message in queue for those times that a load scenario messages comes in before all the appropriate files are present.


The documentation for this class was generated from the following file:

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)