VR-Forces 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 #include <boost/signals2.hpp>
21 
23 class DtSimMessage;
25 class DtLocalObject;
26 class DtIfResourceMonitorResponse;
27 class DtSimResource;
28 class DtIfResourceNamesResponse;
29 class DtEntityIdentifier;
30 class DtSimCondExpr;
31 class DtSimObject;
33 
34 #include <list>
35 
36 namespace makVrfEvents
37 {
38  class DtEvent;
39 }
40 
41 typedef std::map<DtUUID, DtResourceMonitorInfo> DtResourceMonitorList;
42 
61 {
62 private:
63 
66 
68  const DtResourceMonitor & operator=(const DtResourceMonitor & orig);
69 
71 
72 public:
75 
77  virtual ~DtResourceMonitor();
78 
80  virtual bool init();
81 
83  virtual bool registerInterfaceCallbacks();
84 
94  virtual void tick(double simTime);
95 
97  virtual void restart();
98 
101  virtual void setEnabled(bool b);
102  bool enabled() const { return myEnabled; };
103 
104 public:
105  virtual void processResourceMonitorRequest(const makVrfEvents::DtEvent&);
106 
108  virtual void processSimObjectAboutToBeRemoved(const DtSimObject* msg);
109 
113  void setUpdateOnTick(bool b) { myUpdateOnTick = b; };
114  bool updateOnTick() const { return myUpdateOnTick; };
115 
119  virtual void resourcesChangedFor(const DtSimObject*, bool nextSendIsFullSend = false);
120  const std::map<DtUUID, bool>& resourcesChangedList() const;
121 
122 protected:
125  virtual void publishResourcesFor(const DtLocalObject* entity, std::vector<DtEntityType> resources, bool includeFull = false, unsigned requestId = 0);
126 
131  virtual void addMonitorResource(DtLocalObject*, const std::vector<DtEntityType>& resourceName, const DtEntityIdentifier& sender,
132  int iMonitorBy, const DtFloat64& iMonitorPeriod, bool stopMonitoring);
133 
136  virtual DtResourceMonitorList::iterator resourceMonitorInfo(const DtUUID&);
137 
142  virtual void removeMonitorReference(const DtUUID&, const std::vector<DtEntityType>& resourceName,
143  const DtEntityIdentifier& sender);
144 
146  virtual void removeMonitorReference(const DtUUID&);
147 
149  virtual void removeAllMonitorReferencesTo(const DtEntityIdentifier& addr);
150 
151  virtual bool resourceChanged(const DtUUID&, bool& fullSend) const;
152 
153  DtSimulationServices* simulationServices() const { return mySimulationServices; };
154 
155 protected:
156  DtSimulationServices* mySimulationServices;
158  bool myEnabled;
160 
161  std::map<DtUUID, bool> myResourcesChangedList;
162  tbb::spin_mutex myMonitoringResourcesMutex;
163  mutable tbb::spin_mutex myResourcesChangedListMutex;
164 
166  boost::signals2::scoped_connection myResourceRequestConnection;
167 };
168 
169 inline const std::map<DtUUID, bool>& DtResourceMonitor::resourcesChangedList() const
170 {
171  return myResourcesChangedList;
172 }
173 
UUID is a unique ID wrapper class.
Definition: uuid.h:59
bool myEnabled
Definition: resourceMonitor.h:158
class DtLocalObjectManager:
Definition: localObjectManager.h:157
This class will be responsible for handling requests to return resources for a particular entity (or ...
Definition: resourceMonitor.h:60
DtLocalObjectManager * myObjectManager
Definition: resourceMonitor.h:165
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:113
const std::map< DtUUID, bool > & resourcesChangedList() const
Definition: resourceMonitor.h:169
DtSimulationServices * simulationServices() const
Definition: resourceMonitor.h:153
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::map< DtUUID, bool > myResourcesChangedList
Definition: resourceMonitor.h:161
Definition: event.h:13
bool updateOnTick() const
Definition: resourceMonitor.h:114
#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:159
boost::signals2::scoped_connection myResourceRequestConnection
Definition: resourceMonitor.h:166
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:96
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:80
DtSimResource is a class which will define a SISO Enumeration to use as a resource and the quantity o...
Definition: simResource.h:32
bool enabled() const
Definition: resourceMonitor.h:102
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtResourceMonitorList myMonitoringResources
Definition: resourceMonitor.h:157
tbb::spin_mutex myMonitoringResourcesMutex
Definition: resourceMonitor.h:162
std::map< DtUUID, DtResourceMonitorInfo > DtResourceMonitorList
Definition: resourceMonitor.h:41
tbb::spin_mutex myResourcesChangedListMutex
Definition: resourceMonitor.h:163
A locally simulated VRF object.
Definition: localObject.h:98

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)