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

Class: DtResourceMonitor. More...

List of all members.

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 processVrfObjectDeletedCallback (DtSimInterfaceMessage *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::list< DtString > & 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 vrfObjectDeletedCallback (DtSimMessage *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 DtEntityIdentifier &id, 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 DtEntityIdentifier &id)
 Returns an iterator to the slot of the requested info.
virtual void removeMonitorReference (const DtEntityIdentifier &id, 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 DtEntityIdentifier &id)
 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 DtString &) const

Protected Attributes

DtSimManagermySimManager
DtResourceMonitorList myMonitoringResources
bool myEnabled
bool myUpdateOnTick
std::list< DtStringmyResourcesChangedList
virtual void processCurrentResourceRequest (DtSimInterfaceMessage *msg)
 Callbacks to do message processing for immediate return of current resource values.
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

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.)

destructor

standard constructor

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().

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.

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.

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.

static void DtResourceMonitor::vrfObjectDeletedCallback ( DtSimMessage msg,
void *  usr 
) [static]

Remove entity from resource monitor list.

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

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::list< DtString > & DtResourceMonitor::resourcesChangedList ( ) const [inline]
virtual void DtResourceMonitor::publishResourcesFor ( DtIfResourceMonitorResponse response,
DtVrfObject obj,
const std::list< DtString > &  resources 
) [protected, virtual]

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 
) [protected, virtual]

Adds resource names for the specified object to response structure.

virtual void DtResourceMonitor::addMonitorResource ( const DtEntityIdentifier &  id,
const DtString resourceName,
const DtSimulationAddress &  sender,
int  iMonitorBy,
const DtFloat64 &  iMonitorPeriod,
bool  stopMonitoring 
) [protected, virtual]

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 DtEntityIdentifier &  id) [protected, virtual]

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 DtEntityIdentifier &  id,
const DtString resourceName,
const DtSimulationAddress &  sender 
) [protected, virtual]

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 DtEntityIdentifier &  id) [protected, virtual]

Removes all references to the object specified.

virtual void DtResourceMonitor::removeAllMonitorReferencesTo ( const DtSimulationAddress &  addr) [protected, virtual]

Removes all monitored items by the specified sender.

virtual bool DtResourceMonitor::shouldAddResource ( const DtSimResource resourceItem) [protected, virtual]

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 DtString ) const [protected, virtual]

Member Data Documentation

Referenced by resourcesChangedList().


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)