VR-Forces 4.7 Class Documentation
 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
DtResourceMonitor Class Reference

Class: DtResourceMonitor. More...

Public Member Functions

 DtResourceMonitor ()
 Default constructor; note that if this form is used and a sim manager is not set, reports will not be sent (but console output can still be generated.)
virtual ~DtResourceMonitor ()
 destructor
 DtResourceMonitor (DtSimManager *simManager)
 standard constructor
 DtResourceMonitor (const DtResourceMonitor &orig)
 copy constructor; report timer is currently not copied.
const DtResourceMonitoroperator= (const DtResourceMonitor &orig)
 assignment operator; see copy constructor above.
virtual bool init ()
 Calls register callbacks.
void setSimManager (DtSimManager *simManager)
 If the default constructor was used, you can supply a sim manager later; however, if you do, you must also call registerInterfaceCallbacks().
DtSimManagersimManager () const
virtual bool registerInterfaceCallbacks ()
 Only works if a valid simManager was provided at construction time.
virtual void tick (double simTime)
 If the simulation is not in pause mode, go through all the monitored entries to see if they need to be updated.
virtual void restart ()
 Clear out the array of requests and start over.
virtual void setEnabled (bool b)
 Enables/disables monitor.
bool enabled () const
virtual void processResourceMonitorRequest (DtSimInterfaceMessage *msg)
virtual void processResourceNamesRequestCallback (DtSimInterfaceMessage *msg)
virtual void processSimObjectAboutToBeRemoved (DtVrfObject *msg)
void setUpdateOnTick (bool b)
 Set to make sure the resource monitor updates the network with any requested resources even if the simulation is paused.
bool updateOnTick () const
virtual void resourcesChangedFor (const DtVrfObject *)
 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.
const std::set< DtUUID > & resourcesChangedList () const

Static Public Member Functions

static void resourceMonitorRequestCallback (DtSimMessage *msg, void *usr)
 Callbacks to do message processing for resource monitoring requests.
static void resourceNamesRequestCallback (DtSimMessage *msg, void *usr)
 Callbacks to do message processing for immediate return of current resource names associated with supplied entities.
static void simObjectAboutToBeRemoved (DtVrfObject *msg, void *usr)
 Remove entity from resource monitor list.

Protected Member Functions

virtual void publishResourcesFor (DtIfResourceMonitorResponse &response, DtVrfObject *obj, const std::list< DtString > &resources)
 If the specified object has a resource manager, then publish either all information associated with the resources or just the selected items.
virtual void publishResourceNamesFor (DtIfResourceNamesResponse &response, DtVrfObject *obj)
 Adds resource names for the specified object to response structure.
virtual void addMonitorResource (const DtUUID &, const DtString &resourceName, const DtSimulationAddress &sender, int iMonitorBy, const DtFloat64 &iMonitorPeriod, bool stopMonitoring)
 Adds a new resource item to be monitored and reported on by the system.
virtual
DtResourceMonitorList::iterator 
resourceMonitorInfo (const DtUUID &)
 Returns an iterator to the slot of the requested info.
virtual void removeMonitorReference (const DtUUID &, const DtString &resourceName, const DtSimulationAddress &sender)
 Removes the specified reference to the specified resource for the object name asked for by the sender.
virtual void removeMonitorReference (const DtUUID &)
 Removes all references to the object specified.
virtual void removeAllMonitorReferencesTo (const DtSimulationAddress &addr)
 Removes all monitored items by the specified sender.
virtual bool shouldAddResource (const DtSimResource *resourceItem)
 Override to provide additional tests to see whether or not this resource item can be monitored.
virtual bool resourceChanged (const DtUUID &) const

Protected Attributes

DtSimManagermySimManager
DtResourceMonitorList myMonitoringResources
bool myEnabled
bool myUpdateOnTick
std::set< DtUUIDmyResourcesChangedList
virtual void processCurrentResourceRequest (DtSimInterfaceMessage *msg)
static void currentResourceRequestCallback (DtSimMessage *msg, void *usr)
 Callbacks to do message processing for immediate return of current resource values.

Detailed Description

Class: DtResourceMonitor.

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.

Constructor & Destructor Documentation

DtResourceMonitor::DtResourceMonitor ( )

Default constructor; note that if this form is used and a sim manager is not set, reports will not be sent (but console output can still be generated.)

virtual DtResourceMonitor::~DtResourceMonitor ( )
virtual

destructor

DtResourceMonitor::DtResourceMonitor ( DtSimManager simManager)

standard constructor

DtResourceMonitor::DtResourceMonitor ( const DtResourceMonitor orig)

copy constructor; report timer is currently not copied.

Member Function Documentation

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

assignment operator; see copy constructor above.

virtual bool DtResourceMonitor::init ( )
virtual

Calls register callbacks.

void DtResourceMonitor::setSimManager ( DtSimManager simManager)
inline

If the default constructor was used, you can supply a sim manager later; however, if you do, you must also call registerInterfaceCallbacks().

DtSimManager* DtResourceMonitor::simManager ( ) const
inline
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
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
static void DtResourceMonitor::simObjectAboutToBeRemoved ( DtVrfObject msg,
void *  usr 
)
static

Remove entity from resource monitor list.

virtual void DtResourceMonitor::processSimObjectAboutToBeRemoved ( DtVrfObject msg)
virtual
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 DtVrfObject )
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,
DtVrfObject 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,
DtVrfObject obj 
)
protectedvirtual

Adds resource names for the specified object to response structure.

virtual void DtResourceMonitor::addMonitorResource ( const DtUUID ,
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

Member Data Documentation

DtSimManager* DtResourceMonitor::mySimManager
protected
DtResourceMonitorList DtResourceMonitor::myMonitoringResources
protected
bool DtResourceMonitor::myEnabled
protected
bool DtResourceMonitor::myUpdateOnTick
protected
std::set<DtUUID> DtResourceMonitor::myResourcesChangedList
protected

Referenced by resourcesChangedList().


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

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)