VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Types | 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...

Classes

struct  dtSimRunDurationUsrData

Public Types

typedef struct
DtCgfDispatcher::dtSimRunDurationUsrData 
DtSimRunDurationUsrData

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 saveSimulationObjectGroup (DtIfSaveSimulationObjectGroup *msg, const DtSimulationAddress &requester)
 Handles the given simulation object group save request, and if successful sends a DtIfSavedSimulationObjectGroup message to the given requester address.
virtual void createSimulationObjectGroup (DtIfCreateSimulationObjectGroup *msg, const DtSimulationAddress &requester)
 Handles the given simulation object group create request.
virtual void importScenarioDescriptionFile (DtIfImportScenarioDescriptionFile *)
 Makes sure import description file is present then tells cgf to import if.
virtual void exportScenarioDescriptionFile (DtIfExportScenarioDescriptionFile *)
 Exports current scenario to scenario description file.
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 void clearSimulationObjects ()
 Clears out all simulation objects in scenario.
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 processDIGuyAppearAndAnimationsQuery (DtSimMessage *msg)
virtual void processRunDurationComplete (DtSimRunDurationUsrData *)

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 (void *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 bool shouldTryReload (const DtIfImportScenarioDescriptionFile *)
 Return true/false depending on whether or not scenario description import 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 (int scenarioRunId=0)
 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
DtIfImportScenarioDescriptionFilemyPendingScenarioDescriptionImport

Detailed Description

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

Member Typedef Documentation

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::saveSimulationObjectGroup ( DtIfSaveSimulationObjectGroup msg,
const DtSimulationAddress &  requester 
)
virtual

Handles the given simulation object group save request, and if successful sends a DtIfSavedSimulationObjectGroup message to the given requester address.

virtual void DtCgfDispatcher::createSimulationObjectGroup ( DtIfCreateSimulationObjectGroup msg,
const DtSimulationAddress &  requester 
)
virtual

Handles the given simulation object group create request.

Will make sure all files are present (as like load or import) before continuing

virtual void DtCgfDispatcher::importScenarioDescriptionFile ( DtIfImportScenarioDescriptionFile )
virtual

Makes sure import description file is present then tells cgf to import if.

virtual void DtCgfDispatcher::exportScenarioDescriptionFile ( DtIfExportScenarioDescriptionFile )
virtual

Exports current scenario to scenario description file.

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
virtual void DtCgfDispatcher::clearSimulationObjects ( )
virtual

Clears out all simulation objects in scenario.

virtual DtVrfMessageInterface* DtCgfDispatcher::messageInterface ( ) 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
virtual void DtCgfDispatcher::processCapableTaskAndSetQuery ( DtSimMessage msg)
virtual
virtual void DtCgfDispatcher::processDIGuyAppearAndAnimationsQuery ( DtSimMessage msg)
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 ( void *  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 void DtCgfDispatcher::processRunDurationComplete ( DtSimRunDurationUsrData )
virtual
virtual bool DtCgfDispatcher::shouldTryReload ( const DtScenario scenario)
protectedvirtual

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 bool DtCgfDispatcher::shouldTryReload ( const DtIfImportScenarioDescriptionFile )
protectedvirtual

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

By default returns true

virtual void DtCgfDispatcher::pause ( )
protectedvirtual

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

virtual void DtCgfDispatcher::run ( )
protectedvirtual

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

virtual void DtCgfDispatcher::rewind ( int  scenarioRunId = 0)
protectedvirtual

Rewinds current scenario running in back-end.

virtual void DtCgfDispatcher::step ( const DtSimulationAddress &  sender)
protectedvirtual

Steps forward one tick.

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

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
bool DtCgfDispatcher::myTimeToQuit
protected
DtCgf* DtCgfDispatcher::myCgf
protected
DtVrfMessageInterface* DtCgfDispatcher::myMessageIf
protected
DtFilename DtCgfDispatcher::myDir
protected
DtCompressedFileTransporter DtCgfDispatcher::myTransporter
protected
DtIfLoadScenario* DtCgfDispatcher::myPendingLoadScenario
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.

unsigned int DtCgfDispatcher::mySimMgmtPduProcessLevel
protected
DtIfImportScenarioDescriptionFile* DtCgfDispatcher::myPendingScenarioDescriptionImport
protected

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

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)