VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
resourceMonitor.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 
10 #pragma once
11 
14 #include <vlutil/vlMachineTypes.h>
15 #include <vlutil/vlString.h>
16 #include <vrfutil/rwUUID.h>
17 #include <tbb/spin_mutex.h>
18 
19 #include <set>
20 
22 class DtSimMessage;
24 class DtLocalObject;
26 class DtSimResource;
28 class DtSimulationAddress;
29 class DtSimCondExpr;
30 class DtSimObject;
32 
33 #include <list>
34 
35 typedef std::map<DtUUID, DtResourceMonitorInfo> DtResourceMonitorList;
36 
55 {
56 private:
57 
60 
62  const DtResourceMonitor & operator=(const DtResourceMonitor & orig);
63 
65 
66 public:
69 
71  virtual ~DtResourceMonitor();
72 
74  virtual bool init();
75 
77  virtual bool registerInterfaceCallbacks();
78 
88  virtual void tick(double simTime);
89 
91  virtual void restart();
92 
95  virtual void setEnabled(bool b);
96  bool enabled() const { return myEnabled; };
97 
98 public:
100  static void resourceMonitorRequestCallback(DtSimMessage* msg, void* usr);
101  virtual void processResourceMonitorRequest(DtSimInterfaceMessage* msg);
102 
107  static void currentResourceRequestCallback(DtSimMessage* msg, void* usr);
108  virtual void processCurrentResourceRequest(DtSimInterfaceMessage* msg);
110 
113  static void resourceNamesRequestCallback(DtSimMessage* msg, void* usr);
114  virtual void processResourceNamesRequestCallback(DtSimInterfaceMessage* msg);
115 
117  virtual void processSimObjectAboutToBeRemoved(const DtSimObject* msg);
118 
122  void setUpdateOnTick(bool b) { myUpdateOnTick = b; };
123  bool updateOnTick() const { return myUpdateOnTick; };
124 
128  virtual void resourcesChangedFor(const DtSimObject*);
129  const std::set<DtUUID>& resourcesChangedList() const;
130 
131 protected:
134  virtual void publishResourcesFor(DtIfResourceMonitorResponse& response,
135  const DtLocalObject* obj, const std::list<DtString>& resources);
136 
138  virtual void publishResourceNamesFor(DtIfResourceNamesResponse& response,
139  const DtLocalObject* obj);
140 
145  virtual void addMonitorResource(DtLocalObject*,
146  const DtString& resourceName, const DtSimulationAddress& sender,
147  int iMonitorBy, const DtFloat64& iMonitorPeriod, bool stopMonitoring);
148 
151  virtual DtResourceMonitorList::iterator resourceMonitorInfo(const DtUUID&);
152 
157  virtual void removeMonitorReference(const DtUUID&, const DtString& resourceName,
158  const DtSimulationAddress& sender);
159 
161  virtual void removeMonitorReference(const DtUUID&);
162 
164  virtual void removeAllMonitorReferencesTo(const DtSimulationAddress& addr);
165 
168  virtual bool shouldAddResource(const DtSimResource* resourceItem);
169 
170  virtual bool resourceChanged(const DtUUID&) const;
171 
172  DtSimulationServices* simulationServices() const { return mySimulationServices; };
173 
174 protected:
175  DtSimulationServices* mySimulationServices;
177  bool myEnabled;
179 
180  std::set<DtUUID> myResourcesChangedList;
181  tbb::spin_mutex myMonitoringResourcesMutex;
182 
184 };
185 
186 inline const std::set<DtUUID>& DtResourceMonitor::resourcesChangedList() const
187 {
188  return myResourcesChangedList;
189 }
190 
UUID is a unique ID wrapper class.
Definition: rwUUID.h:229
bool myEnabled
Definition: resourceMonitor.h:177
class DtLocalObjectManager:
Definition: localObjectManager.h:151
This class will be responsible for handling requests to return resources for a particular entity (or ...
Definition: resourceMonitor.h:54
DtLocalObjectManager * myObjectManager
Definition: resourceMonitor.h:183
void setUpdateOnTick(bool b)
Set to make sure the resource monitor updates the network with any requested resources even if the si...
Definition: resourceMonitor.h:122
Content-Type: DtNetIfResourceMonitorResponse.
Definition: ifResourceMonitorResponse.h:43
Variable portion List of resouce names.
Definition: ifResourceNamesResponse.h:42
DtSimulationServices * simulationServices() const
Definition: resourceMonitor.h:172
DtSimInterfaceMessage is used to send a message to the front end or the back end. It derives from a s...
Definition: simInterfaceMessage.h:23
Contains the DtUUID class declaration.
std::set< DtUUID > myResourcesChangedList
Definition: resourceMonitor.h:180
bool updateOnTick() const
Definition: resourceMonitor.h:123
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
File: simMsg.h.
Definition: simMessage.h:35
bool myUpdateOnTick
Definition: resourceMonitor.h:178
double DtFloat64
Definition: vrvControlStructTypes.h:36
DtSimCondExpr is an abstract base class representing various Conditional Expressions used by the Plan...
Definition: simCondExpr.h:53
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:90
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:79
DtSimResource is an abstract base class that can be used to create a hierarchical resource list of a ...
Definition: simResource.h:41
const std::set< DtUUID > & resourcesChangedList() const
Definition: resourceMonitor.h:186
bool enabled() const
Definition: resourceMonitor.h:96
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtResourceMonitorList myMonitoringResources
Definition: resourceMonitor.h:176
tbb::spin_mutex myMonitoringResourcesMutex
Definition: resourceMonitor.h:181
std::map< DtUUID, DtResourceMonitorInfo > DtResourceMonitorList
Definition: resourceMonitor.h:31
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)