VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
DtResourceMonitor Class Reference

This class will be responsible for handling requests to return resources for a particular entity (or entities) on either a one time basis or on a continual basis.

If the request is made on a one time basis the response will be one resource update packet for each entity requested to have resource returned for. If the request is for a continual update, a response will be sent immediately for each entity requested and then a queue will be set up to return information for each entity at the requested update period.

Note that the continuous update requests are additive. Counters will be kept for each entity that has a specific resource request made of it, but, all users that are listening in on this exercise will receive resource updates for all entities that have been requested to be updated. This means if user A requests an update for a particular tank, then users B and C will see the response to that request.

Public Member Functions

 DtResourceMonitor (DtSimulationServices *simManager, DtLocalObjectManager *)
 
virtual ~DtResourceMonitor ()
 
virtual bool init ()
 
virtual bool registerInterfaceCallbacks ()
 
virtual void tick (double simTime)
 
virtual void restart ()
 
virtual void setEnabled (bool b)
 
bool enabled () const
 
virtual void processResourceMonitorRequest (DtSimInterfaceMessage *msg)
 
virtual void processResourceNamesRequestCallback (DtSimInterfaceMessage *msg)
 
virtual void processSimObjectAboutToBeRemoved (const DtSimObject *msg)
 
void setUpdateOnTick (bool b)
 
bool updateOnTick () const
 
virtual void resourcesChangedFor (const DtSimObject *)
 
const std::set< DtUUID > & resourcesChangedList () const
 

Static Public Member Functions

static void resourceMonitorRequestCallback (DtSimMessage *msg, void *usr)
 
static void resourceNamesRequestCallback (DtSimMessage *msg, void *usr)
 

Protected Member Functions

virtual void publishResourcesFor (DtIfResourceMonitorResponse &response, const DtLocalObject *obj, const std::list< DtString > &resources)
 
virtual void publishResourceNamesFor (DtIfResourceNamesResponse &response, const DtLocalObject *obj)
 
virtual void addMonitorResource (DtLocalObject *, const DtString &resourceName, const DtSimulationAddress &sender, int iMonitorBy, const DtFloat64 &iMonitorPeriod, bool stopMonitoring)
 
virtual
DtResourceMonitorList::iterator 
resourceMonitorInfo (const DtUUID &)
 
virtual void removeMonitorReference (const DtUUID &, const DtString &resourceName, const DtSimulationAddress &sender)
 
virtual void removeMonitorReference (const DtUUID &)
 
virtual void removeAllMonitorReferencesTo (const DtSimulationAddress &addr)
 
virtual bool shouldAddResource (const DtSimResource *resourceItem)
 
virtual bool resourceChanged (const DtUUID &) const
 
DtSimulationServicessimulationServices () const
 

Protected Attributes

DtSimulationServicesmySimulationServices
 
DtResourceMonitorList myMonitoringResources
 
bool myEnabled
 
bool myUpdateOnTick
 
std::set< DtUUIDmyResourcesChangedList
 
tbb::spin_mutex myMonitoringResourcesMutex
 
DtLocalObjectManagermyObjectManager
 

Private Member Functions

 DtResourceMonitor (const DtResourceMonitor &orig)
 
const DtResourceMonitoroperator= (const DtResourceMonitor &orig)
 
 DtResourceMonitor ()
 
virtual void processCurrentResourceRequest (DtSimInterfaceMessage *msg)
 
static void currentResourceRequestCallback (DtSimMessage *msg, void *usr)
 

Constructor & Destructor Documentation

DtResourceMonitor::DtResourceMonitor ( const DtResourceMonitor orig)
private

copy constructor; report timer is currently not copied.

DtResourceMonitor::DtResourceMonitor ( )
private
DtResourceMonitor::DtResourceMonitor ( DtSimulationServices simManager,
DtLocalObjectManager  
)

standard constructor

virtual DtResourceMonitor::~DtResourceMonitor ( )
virtual

destructor

Member Function Documentation

const DtResourceMonitor& DtResourceMonitor::operator= ( const DtResourceMonitor orig)
private

assignment operator; see copy constructor above.

virtual bool DtResourceMonitor::init ( )
virtual

Calls register callbacks.

virtual bool DtResourceMonitor::registerInterfaceCallbacks ( )
virtual

Only works if a valid simManager was provided at construction time.

virtual void DtResourceMonitor::tick ( double  simTime)
virtual

If the simulation is not in pause mode, go through all the monitored entries to see if they need to be updated. If they do, then send out a message that contains the resources that want to be updated by calling publishResourcesFor those items that want to be updated. If, during a tick, an object exists in the monitored list that does not exist in the object manager (as a local object) then it will be removed from the monitored list.

All resources published will also have their condition updated for the next publish period

virtual void DtResourceMonitor::restart ( )
virtual

Clear out the array of requests and start over.

virtual void DtResourceMonitor::setEnabled ( bool  b)
virtual

Enables/disables monitor. Flag is checked in tick() call and tick will not be executed if monitor is disabled.

bool DtResourceMonitor::enabled ( ) const
inline
static void DtResourceMonitor::resourceMonitorRequestCallback ( DtSimMessage msg,
void *  usr 
)
static

Callbacks to do message processing for resource monitoring requests.

virtual void DtResourceMonitor::processResourceMonitorRequest ( DtSimInterfaceMessage msg)
virtual
static void DtResourceMonitor::currentResourceRequestCallback ( DtSimMessage msg,
void *  usr 
)
static

Callbacks to do message processing for immediate return of current resource values. Responses to this request will include the request ID from the DtIfCurrentResourceRequest.

virtual void DtResourceMonitor::processCurrentResourceRequest ( DtSimInterfaceMessage msg)
virtual

Callbacks to do message processing for immediate return of current resource values. Responses to this request will include the request ID from the DtIfCurrentResourceRequest.

static void DtResourceMonitor::resourceNamesRequestCallback ( DtSimMessage msg,
void *  usr 
)
static

Callbacks to do message processing for immediate return of current resource names associated with supplied entities.

virtual void DtResourceMonitor::processResourceNamesRequestCallback ( DtSimInterfaceMessage msg)
virtual
virtual void DtResourceMonitor::processSimObjectAboutToBeRemoved ( const DtSimObject msg)
virtual

Remove entity from resource monitor list.

void DtResourceMonitor::setUpdateOnTick ( bool  b)
inline

Set to make sure the resource monitor updates the network with any requested resources even if the simulation is paused. When the tick occurs, this value will be set back to false.

bool DtResourceMonitor::updateOnTick ( ) const
inline
virtual void DtResourceMonitor::resourcesChangedFor ( const DtSimObject )
virtual

Call to add an entity to the list (in between ticks) of resources that have been changed, so, if someone is monitoring the resources for that entity, it will be sent out right away. This list will be cleared each tick.

const std::set< DtUUID > & DtResourceMonitor::resourcesChangedList ( ) const
inline
virtual void DtResourceMonitor::publishResourcesFor ( DtIfResourceMonitorResponse response,
const DtLocalObject obj,
const std::list< DtString > &  resources 
)
protectedvirtual

If the specified object has a resource manager, then publish either all information associated with the resources or just the selected items.

virtual void DtResourceMonitor::publishResourceNamesFor ( DtIfResourceNamesResponse response,
const DtLocalObject obj 
)
protectedvirtual

Adds resource names for the specified object to response structure.

virtual void DtResourceMonitor::addMonitorResource ( DtLocalObject ,
const DtString resourceName,
const DtSimulationAddress &  sender,
int  iMonitorBy,
const DtFloat64 &  iMonitorPeriod,
bool  stopMonitoring 
)
protectedvirtual

Adds a new resource item to be monitored and reported on by the system. If the item is already being monitored, it will take the better type of monitoring request. Sets myUpdateOnTick to be true so an update will be forced for the current request so the requesting user can see the current resources.

virtual DtResourceMonitorList::iterator DtResourceMonitor::resourceMonitorInfo ( const DtUUID )
protectedvirtual

Returns an iterator to the slot of the requested info. If the info does not exist, will return the end iterator of the monitor resource list.

virtual void DtResourceMonitor::removeMonitorReference ( const DtUUID ,
const DtString resourceName,
const DtSimulationAddress &  sender 
)
protectedvirtual

Removes the specified reference to the specified resource for the object name asked for by the sender. If no more references to the particular resource exist after removal the resource entry is removed. If no more resource monitoring items for the specified entity exist, that resource monitor info item is removed.

virtual void DtResourceMonitor::removeMonitorReference ( const DtUUID )
protectedvirtual

Removes all references to the object specified.

virtual void DtResourceMonitor::removeAllMonitorReferencesTo ( const DtSimulationAddress &  addr)
protectedvirtual

Removes all monitored items by the specified sender.

virtual bool DtResourceMonitor::shouldAddResource ( const DtSimResource resourceItem)
protectedvirtual

Override to provide additional tests to see whether or not this resource item can be monitored. Currently only makes sure that the resource is a leaf node.

virtual bool DtResourceMonitor::resourceChanged ( const DtUUID ) const
protectedvirtual
DtSimulationServices* DtResourceMonitor::simulationServices ( ) const
inlineprotected

Member Data Documentation

DtSimulationServices* DtResourceMonitor::mySimulationServices
protected
DtResourceMonitorList DtResourceMonitor::myMonitoringResources
protected
bool DtResourceMonitor::myEnabled
protected
bool DtResourceMonitor::myUpdateOnTick
protected
std::set<DtUUID> DtResourceMonitor::myResourcesChangedList
protected

Referenced by resourcesChangedList().

tbb::spin_mutex DtResourceMonitor::myMonitoringResourcesMutex
protected
DtLocalObjectManager* DtResourceMonitor::myObjectManager
protected

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

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)