VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVreStatusPublisher Class Reference

Detailed Description

This class is responsible for broadcasting status information about a VREngage application to other applications in the distributed simulation environment, such as VR-Forces GUI and other control applications. It sends periodic heartbeat messages containing application identity, player information, and entity state.

The status publisher maintains information such as the application ID, name, player name, controlled entity ID, station name, and operational mode. This information can be updated at runtime, and the publisher will automatically track changes and send updated status messages when necessary.

#include <vrengageStatusPublisher.h>

Public Member Functions

 DtVreStatusPublisher ()
 
virtual ~DtVreStatusPublisher ()
 
virtual void sendStatus ()
 
virtual void setHeartbeatInterval (int heartbeatInterval)
 
virtual int heartbeatInterval ()
 
virtual void tick ()
 
virtual void setId (unsigned long id)
 
virtual unsigned long id () const
 
virtual void setName (const std::string &name)
 
virtual std::string name () const
 
virtual void setPlayerName (const DtString &name)
 
virtual DtString playerName () const
 
virtual void setEntityId (const DtEntityIdentifier &entityId)
 
virtual DtEntityIdentifier entityId () const
 
virtual void setStationName (const std::string &name)
 
virtual std::string stationName () const
 
virtual void setSpectatorMode (bool mode)
 
virtual bool spectatorMode () const
 
virtual void setFinalStatus (bool status)
 
virtual bool finalStatus () const
 

Static Public Member Functions

static DtEntityIdentifier getEntityId ()
 

Protected Member Functions

 DtVreStatusPublisher (const DtVreStatusPublisher &orig)
 
DtVreStatusPublisheroperator= (const DtVreStatusPublisher &orig)
 

Protected Attributes

int myHeartbeatInterval
 
DtTime myTimeLastSent
 
bool myHasBeenModified
 
unsigned long long myId
 
std::string myName
 
std::string myPlayerName
 
DtEntityIdentifier myEntityId
 
std::string myStationName
 
bool mySpectatorMode
 
bool myFinalStatus
 

Static Protected Attributes

static DtEntityIdentifier theEntityId
 

Constructor & Destructor Documentation

◆ DtVreStatusPublisher() [1/2]

makVre::DtVreStatusPublisher::DtVreStatusPublisher ( )

Constructor.

Initializes a new status publisher with default values for all properties. The heartbeat interval is initialized to a default value, and the publisher is marked as modified to ensure a status message is sent on the next tick.

Referenced by DtVreStatusPublisher(), and operator=().

◆ ~DtVreStatusPublisher()

virtual makVre::DtVreStatusPublisher::~DtVreStatusPublisher ( )
virtual

Virtual destructor.

Ensures proper cleanup of derived classes.

◆ DtVreStatusPublisher() [2/2]

makVre::DtVreStatusPublisher::DtVreStatusPublisher ( const DtVreStatusPublisher & orig)
protected

Copy constructor.

Parameters
origOriginal status publisher to copy

This copy constructor creates a new status publisher that is a copy of the specified original. It is protected to prevent unintended copying.

References DtVreStatusPublisher().

Member Function Documentation

◆ sendStatus()

virtual void makVre::DtVreStatusPublisher::sendStatus ( )
virtual

Sends a status message immediately.

This method immediately broadcasts a status message containing the current state of the publisher. It resets the last sent time and clears the modified flag. This method is called automatically by tick() when necessary, but can also be called manually to force an immediate status update.

◆ setHeartbeatInterval()

virtual void makVre::DtVreStatusPublisher::setHeartbeatInterval ( int heartbeatInterval)
virtual

Sets the heartbeat interval.

Parameters
heartbeatIntervalInterval in milliseconds between status messages

This method sets the interval at which status messages are automatically sent. The interval is specified in milliseconds. If the publisher has not been modified since the last status message, a new status message will be sent every heartbeatInterval milliseconds.

References heartbeatInterval().

◆ heartbeatInterval()

virtual int makVre::DtVreStatusPublisher::heartbeatInterval ( )
virtual

Gets the current heartbeat interval.

Returns
Current heartbeat interval in milliseconds

This method returns the current interval at which status messages are automatically sent.

Referenced by setHeartbeatInterval().

◆ tick()

virtual void makVre::DtVreStatusPublisher::tick ( )
virtual

Updates the publisher and sends status messages when necessary.

This method is called periodically (typically by the simulation manager) to update the publisher and send status messages when necessary. It checks if the publisher has been modified or if the heartbeat interval has elapsed, and sends a status message if either condition is true.

Note
This method should be called regularly to ensure timely status updates.

◆ setId()

virtual void makVre::DtVreStatusPublisher::setId ( unsigned long id)
virtual

Sets the application ID.

Parameters
idUnique identifier for this application

This method sets the unique identifier for this VREngage application. The ID should be unique across all participating VREngage applications in an exercise. Setting a new ID marks the publisher as modified.

◆ id()

virtual unsigned long makVre::DtVreStatusPublisher::id ( ) const
virtual

Gets the application ID.

Returns
Current application ID

This method returns the unique identifier for this VREngage application.

◆ setName()

virtual void makVre::DtVreStatusPublisher::setName ( const std::string & name)
virtual

Sets the application name.

Parameters
nameName for this application

This method sets the name for this VREngage application. The name should be unique across all participating VREngage applications in an exercise, but may be changed over the lifetime of an application. Setting a new name marks the publisher as modified.

References name().

◆ name()

virtual std::string makVre::DtVreStatusPublisher::name ( ) const
virtual

Gets the application name.

Returns
Current application name

This method returns the name for this VREngage application.

Referenced by setName(), setPlayerName(), and setStationName().

◆ setPlayerName()

virtual void makVre::DtVreStatusPublisher::setPlayerName ( const DtString & name)
virtual

Sets the player name.

Parameters
nameName of the player using this application

This method sets the name of the player using this VREngage application. The player name is optional and can be used to identify the human user controlling the application. Setting a new player name marks the publisher as modified.

References name().

◆ playerName()

virtual DtString makVre::DtVreStatusPublisher::playerName ( ) const
virtual

Gets the player name.

Returns
Current player name

This method returns the name of the player using this VREngage application.

◆ setEntityId()

virtual void makVre::DtVreStatusPublisher::setEntityId ( const DtEntityIdentifier & entityId)
virtual

Sets the controlled entity ID.

Parameters
entityIdIdentifier of the entity controlled by this application

This method sets the identifier of the entity controlled by this VREngage application. This is typically the primary entity that the player is controlling or inhabiting. Setting a new entity ID marks the publisher as modified and updates the static entity ID.

References entityId().

◆ entityId()

virtual DtEntityIdentifier makVre::DtVreStatusPublisher::entityId ( ) const
virtual

Gets the controlled entity ID.

Returns
Current entity ID

This method returns the identifier of the entity controlled by this VREngage application.

Referenced by setEntityId().

◆ getEntityId()

static DtEntityIdentifier makVre::DtVreStatusPublisher::getEntityId ( )
static

Gets the static controlled entity ID.

Returns
Current static entity ID

This static method provides access to the entity ID from anywhere in the application without needing a reference to the status publisher instance.

◆ setStationName()

virtual void makVre::DtVreStatusPublisher::setStationName ( const std::string & name)
virtual

Sets the station name (player role)

Parameters
nameName of the station/role this player is operating

This method sets the station name, which identifies the player's role. Available string identifiers for roles are defined in VR-Engage player definition lua files (e.g., "Pilot", "Human", "LAV Driver", etc.). Setting a new station name marks the publisher as modified.

References name().

◆ stationName()

virtual std::string makVre::DtVreStatusPublisher::stationName ( ) const
virtual

Gets the station name (player role)

Returns
Current station name

This method returns the station name, which identifies the player's role.

◆ setSpectatorMode()

virtual void makVre::DtVreStatusPublisher::setSpectatorMode ( bool mode)
virtual

Sets the spectator mode flag.

Parameters
modeTrue if the player is in spectator mode, false otherwise

This method sets the flag indicating whether the player is in spectator mode. In spectator mode, the player is observing the simulation but not actively controlling an entity. Setting a new spectator mode marks the publisher as modified.

◆ spectatorMode()

virtual bool makVre::DtVreStatusPublisher::spectatorMode ( ) const
virtual

Gets the spectator mode flag.

Returns
True if the player is in spectator mode, false otherwise

This method returns the flag indicating whether the player is in spectator mode.

◆ setFinalStatus()

virtual void makVre::DtVreStatusPublisher::setFinalStatus ( bool status)
virtual

Sets the final status flag.

Parameters
statusTrue if this is the final status message, false otherwise

This method sets the flag indicating if this is a final status message for the VREngage application. A final status message indicates that the application is shutting down and will no longer be sending status updates. Setting the final status flag to true marks the publisher as modified.

◆ finalStatus()

virtual bool makVre::DtVreStatusPublisher::finalStatus ( ) const
virtual

Gets the final status flag.

Returns
True if this is the final status message, false otherwise

This method returns the flag indicating if this is a final status message for the VREngage application.

◆ operator=()

DtVreStatusPublisher & makVre::DtVreStatusPublisher::operator= ( const DtVreStatusPublisher & orig)
protected

Assignment operator.

Parameters
origOriginal status publisher to assign from
Returns
Reference to this status publisher

This assignment operator assigns the state of the specified original status publisher to this status publisher. It is protected to prevent unintended assignment.

References DtVreStatusPublisher().

Member Data Documentation

◆ myHeartbeatInterval

int makVre::DtVreStatusPublisher::myHeartbeatInterval
protected

Interval in milliseconds between status messages.

◆ myTimeLastSent

DtTime makVre::DtVreStatusPublisher::myTimeLastSent
protected

Time when the last status message was sent.

◆ myHasBeenModified

bool makVre::DtVreStatusPublisher::myHasBeenModified
protected

Flag indicating if the publisher has been modified since the last message.

◆ myId

unsigned long long makVre::DtVreStatusPublisher::myId
protected

Unique identifier for this application.

◆ myName

std::string makVre::DtVreStatusPublisher::myName
protected

Name of this application.

◆ myPlayerName

std::string makVre::DtVreStatusPublisher::myPlayerName
protected

Name of the player using this application.

◆ myEntityId

DtEntityIdentifier makVre::DtVreStatusPublisher::myEntityId
protected

Identifier of the entity controlled by this application.

◆ myStationName

std::string makVre::DtVreStatusPublisher::myStationName
protected

Name of the station/role this player is operating.

◆ mySpectatorMode

bool makVre::DtVreStatusPublisher::mySpectatorMode
protected

Flag indicating whether the player is in spectator mode.

◆ myFinalStatus

bool makVre::DtVreStatusPublisher::myFinalStatus
protected

Flag indicating if this is a final status message.

◆ theEntityId

DtEntityIdentifier makVre::DtVreStatusPublisher::theEntityId
staticprotected

Static entity identifier for global access.

This static member provides access to the entity ID from anywhere in the application without needing a reference to the status publisher instance.


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