VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
State View Collection Manager

Table of Contents

The makVrf::DtVrfStateViewCollectionManager is the class that contains a collection of all the state data collected from the network thread and sent to the visualization thread.

All the data in these structures are stored in the makVrv::DtDataBank (referenced from the makVrv:DtDe) in the makVrv::DtSimData simData() member. This data contains a series of makVrv::DtSimEntry classes, one for each object in the simulation. Each makVrv::DtSimEntry class contains a simStates() vector. This vector contains a set of data (for example, makVrv::DtVrlinkSimulatedEntityState) for each kind of data for that object. Rather than each object containing one big class that stores all the possible data, each entry will have one sim state of data for each kind of data defined (IFF Data, Sensor Data, Laser Designator Data, etc). The Add State Component GUI example shows how to add one particular kind of new state entry data to an object. You can access this data in multiple ways:

The third way is the way is the makVrf::DtVrfStateViewCollectionManager. This singleton is a single entry point for all the differnt types of data in the system. You can use this class to find data by marking text, DtUUID or by the objects element id. You can use this class to find a particular makVrv::DtStateView:

DtVrfStateViewCollectionManager::instance(myLogic->de()).
objectDataStateViewCollection()->findStateView(state->id());
if (objDataView)
{
boost::optional<int> numHits =
objDataView->state().myStateProperties.findPropertyValue<int>("TargetsHit");
if (numHits)
{
return QString::number(*numHits);
}
}
myLasingStateView = const_cast<DtStateView<DtLaserDesignatorState>*>(
DtVrfStateViewCollectionManager::instance(myDe).laserDesignatorStateViewCollection()->findStateView(myState->id()));

Update Rate

It is important to not that data is sent from the network thread to the main thread via a makVrv::DtAgent subclass. Since this is processed by the main thread, data is not updated on every change for every object. This would cause the main thread (especially in large simulations) to do a large amount of processing, stalling out the application. To get around this, data is refreshed in the main thread either at an update rate or by a force of an update. Both operations are performed on the makVrv::DtStateView representation of the object. The following is an example of forcing an update of a state view for a particular object, and, then getting notified when the state view is updated in the main thread from the network:

// request the simEntry for the shape
DtVrfStateViewCollectionManager& svcMgr = DtVrfStateViewCollectionManager::instance( myDe );
DtUniqueID shapeSimEntryId = svcMgr.simIdFromDisplayId(sceneId);
DtSimEntry* shapeSimEntry = myDe.dataBank().simData().findSimEntry(
shapeSimEntryId );
DtVrfStateViewCollectionManager::instance(myDe).environmentStateViewCollection()->findStateView( shapeSimEntryId ) );
shapeSimEntry->forceUpdate( stateView );
svcMgr.setUpdateRate(shapeSimEntry, DtSimEntryUpdater::At4Hz, stateView );
//stateView->signal_stateViewUpdated.connect( processor );
stateView->signal_stateViewUpdated.connect( boost::bind( &DtVrfObjectManipulationManager::slot_stateReturned,
this, _1, sceneId, processor ) );
void DtVrfObjectManipulationManager::slot_stateReturned( DtEnvironmentStateView* shapeStateView,
const DtUniqueID& sceneId, ProcessEnvStateFunction* processor )
{
// Stop listening...
DtVrfStateViewCollectionManager& svcMgr = DtVrfStateViewCollectionManager::instance( myDe );
DtUniqueID shapeSimEntryId = svcMgr.simIdFromDisplayId(sceneId);
DtSimEntry* shapeEntry = myDe.dataBank().simData().findSimEntry( shapeSimEntryId );
shapeStateView->signal_stateViewUpdated.disconnect( boost::bind( &DtVrfObjectManipulationManager::slot_stateReturned,
this, _1, sceneId, processor ) );
svcMgr.setUpdateRate(shapeEntry, DtSimEntryUpdater::NoUpdates, shapeStateView );

This example shows a few things

Attention
When a state view is updated all connections to that state view for update will be triggered. Also, there is only a single update rate kept per state view, so, the last class to set an update rate on a state view will set the update rate for that view. So, if you set an update rate to 1Hz, but are not getting an update rate at 1Hz, this means some other class also set an update rate on that state view to be different.

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)