VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
resupplySupplierController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 #include <vrfMsgTransport/events.h>
14 
20 #include <boost/signals2.hpp>
21 
23 
24 namespace makVrfEvents
25 {
26  class DtServiceRequestEvent;
27  class DtResupplyReceivedEvent;
28  class DtEvent;
29 }
30 
34 {
35 public:
36 
43  DtSimulationServices* simManager,
44  DtComponentDescriptor* compDesc = 0,
45  DtReaderWriterRegistry* parentRegistry = 0);
46 
49 
50  virtual const char* type() const;
51 
54  virtual bool postAddComponentsInit();
55 
57  virtual bool init();
58 
64  static void setSupplyingCallback(DtSimMessage * msg, void * usr);
65 
69  virtual void processSetSupplying(DtSimMessage * msg);
70 
73  virtual void addSetDataCallbacks();
74 
77  void removeSetDataCallbacks();
78 
81  virtual void tick();
82 
83  static DtSimComponent* creator(const DtString& name,
84  DtLocalObject* owner,
85  DtSimulationServices* simManager,
87  DtReaderWriterRegistry* parentRegistry);
88 
89 protected:
90 
93 
96  orig);
97 
101 
103  virtual const DtResupplySupplierControllerDescriptor* getDescriptor();
104 
106 
107  virtual void serviceRequestEvent(const makVrfEvents::DtEvent&);
108  virtual void processServiceRequest(const makVrfEvents::DtServiceRequestEvent& serviceRequest);
109  virtual void resupplyReceivedEvent(const makVrfEvents::DtEvent&);
110  virtual void processResupplyReceived(const makVrfEvents::DtResupplyReceivedEvent& resupplyReceived);
111  virtual void resupplyCancelEvent(const makVrfEvents::DtEvent&);
112  virtual void processResupplyCancel(const makVrfEvents::DtResupplyCancelEvent& resupplyCancel);
114 
116 
117  virtual makVrfEvents::DtResupplyOfferEvent createResupplyOfferInteraction(const DtUUID& receiver);
119  virtual void sendResupplyOfferInteraction(const makVrfEvents::DtResupplyOfferEvent& resupplyOffer);
120 
121  virtual makVrfEvents::DtResupplyCancelEvent createResupplyCancelInteraction(const DtUUID& receiver);
122  virtual void sendResupplyCancelInteraction(const makVrfEvents::DtResupplyCancelEvent& resupplyCancel);
124 
125 protected:
126  void transferSupplies();
127  virtual void processReadyState(const DtUUID& receiver);
128  void processOfferingState(const DtUUID& receiver);
129 
130  virtual void updateRequestedSupplies(const makVrfEvents::DtServiceRequestEvent& serviceRequest);
131  virtual void updateOfferedSupplies(const DtUUID& receiver);
132  virtual void updateSentSupplies(const makVrfEvents::DtResupplyReceivedEvent& resupplyReceived);
133  virtual void removeSentSupplies(const DtUUID& receiver);
134  virtual bool checkSuppliesRequested(const DtUUID& receiver);
135  virtual bool checkResourcesAvailable(const DtUUID& receiver);
136  virtual bool checkResourceAvailable(const DtEntityType& type);
137  virtual bool checkResourceAvailable(const DtString& supplyName);
138  virtual double resourceAvailable(const DtEntityType& type);
139  virtual double resourceAvailable(const DtString& supplyName);
140  virtual void updateResource(const DtEntityType& type, double quantity);
141  virtual void updateResource(const DtString& supplyName, double quantity);
142 
143  virtual const DtString lookUpSupplyType(const DtEntityType& type) const;
144 
145  virtual DtTime currentSimTime();
146 
147 protected:
150 
152  std::map<DtUUID, DtResupplySupplierStateData> mySupplierStateData;
153 
154  boost::signals2::scoped_connection myServiceRequestEventConnection;
155  boost::signals2::scoped_connection myResupplyReceivedEventConnection;
156  boost::signals2::scoped_connection myResupplyCancelEventConnection;
157 
158 protected:
163  const DtTime theOfferingStateDefaultTimeout = 120.0;
164 };
UUID is a unique ID wrapper class.
Definition: rwUUID.h:229
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
Definition: resupplyReceivedEvent.h:14
This class provides a base class for all controllers that are capable of executing a DtSimTask...
Definition: singleTaskControllerComponent.h:20
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Definition: readerWriterRegistry.h:39
virtual const char * type() const =0
Returns a string identifies the class type of component. Type values are defined in compTypes...
virtual bool init()
Calls setRadio()
boost::signals2::scoped_connection myServiceRequestEventConnection
Definition: resupplySupplierController.h:154
const DtResupplySupplierControllerDescriptor * myResupplySupplierDesc
Controller descriptor.
Definition: resupplySupplierController.h:149
Definition: resupplyOfferEvent.h:14
Definition: resupplyCancelEvent.h:13
Definition: event.h:13
File: simMsg.h.
Definition: simMessage.h:35
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:90
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:70
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
This class implements a controller, which gives the unit the capability to provide supplies...
Definition: resupplySupplierController.h:33
boost::signals2::scoped_connection myResupplyReceivedEventConnection
Definition: resupplySupplierController.h:155
Definition: serviceRequestEvent.h:14
virtual bool postAddComponentsInit()
Calls enableTaskTypes()
DtResupplySupplierControllerDescriptor is a DtComponentDescriptor that has additional information nee...
Definition: resupplySupplierControllerDescriptor.h:20
boost::signals2::scoped_connection myResupplyCancelEventConnection
Definition: resupplySupplierController.h:156
std::map< DtUUID, DtResupplySupplierStateData > mySupplierStateData
Controller state transition class.
Definition: resupplySupplierController.h:152
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 Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)