VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
resupplyReceiverController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2021 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 #include <vrfMsgTransport/events.h>
14 
21 
24 
25 #include <boost/signals2.hpp>
26 
29 
33 {
34 public:
35 
42  DtSimulationServices* simManager,
43  DtComponentDescriptor* compDesc = 0,
44  DtReaderWriterRegistry* parentRegistry = 0);
45 
48 
49  virtual const char* type() const;
50 
53  virtual bool postAddComponentsInit();
54 
56  virtual bool init();
57 
63  static void setSupplyingCallback(DtSimMessage * msg, void * usr);
64 
68  virtual void processSetSupplying(DtSimMessage * msg);
69 
72  virtual void addSetDataCallbacks();
73 
76  void removeSetDataCallbacks();
77 
80  virtual void preFirstTickInit();
81 
84  virtual void tick();
85 
86  static DtSimComponent* creator(const DtString& name,
87  DtLocalObject* owner,
88  DtSimulationServices* simManager,
90  DtReaderWriterRegistry* parentRegistry);
91 
93  static void transferSuppliesTaskCallback(DtSimMessage* msg, void* usr);
94 
97 
98  static void supplyListRequestCallback(const DtVrfObjectMessage* msg, void* usr);
99  virtual void processSupplyListRequest(const DtVrfObjectMessage* msg);
101 
102 protected:
104  virtual DtResupplyReceiverControllerPSR* createPSR();
105 
107  virtual const DtResupplyReceiverControllerDescriptor* getDescriptor();
108 
110 
111  virtual void resupplyOfferEvent(const makVrfEvents::DtEvent&);
112  virtual void processResupplyOffer(const makVrfEvents::DtResupplyOfferEvent& resupplyOffer);
114 
116 
117  virtual void resupplyCancelEvent(const makVrfEvents::DtEvent&);
118  virtual void processResupplyCancel(const makVrfEvents::DtResupplyCancelEvent& resupplyCancel);
120 
122 
123  virtual makVrfEvents::DtServiceRequestEvent createServiceRequestInteraction();
124 
126  virtual void sendServiceRequestInteraction(const makVrfEvents::DtServiceRequestEvent& serviceRequest);
128  virtual makVrfEvents::DtResupplyReceivedEvent createResupplyReceivedInteraction();
129  virtual void sendResupplyReceivedInteraction(const makVrfEvents::DtResupplyReceivedEvent& resupplyReceived);
130 
131  virtual makVrfEvents::DtResupplyCancelEvent createResupplyCancelInteraction();
133  virtual void sendResupplyCancelInteraction(const makVrfEvents::DtResupplyCancelEvent& resupplyCancel);
135 
136 protected:
137  virtual void processTransferSuppliesTask(DtSimMessage* msg);
138  virtual void processTransferSuppliesTaskPSR();
139 
141  virtual void retrieveTransferSuppliesTaskParams(const DtTransferSuppliesTask* transferSuppliesTask,
142  DtEntityType & supplyType,
143  double & quantityRequestedTotal,
144  double & rate,
145  DtSimObjectReference & supplier);
146 
148  virtual void retrieveTransferSuppliesTaskParamsPSR(const DtTransferSuppliesTask* transferSuppliesTask,
149  std::map<DtString, double> & supplies,
150  std::map<DtString, double> & suppliesRate,
151  DtSimObjectReference & supplier);
152 
153  virtual bool verifyTransferSuppliesTaskParams(double amount, double rate);
154 
155  virtual void transferSupplies();
156  virtual void processReadyState();
157  virtual void processRequestingState();
158  virtual void processReceivingState();
159 
160  virtual void updateTaskedSupplies(const DtEntityType& supplyType,
161  double quantityRequestedTotal,
162  double rate,
163  DtSimObjectReference supplier);
164  virtual void updateTaskedSuppliesPSR(const std::map<DtString, double>& supplies,
165  std::map<DtString, double> & suppliesRate,
166  DtSimObjectReference supplier);
167  virtual void updateOfferedSupplies(const makVrfEvents::DtResupplyOfferEvent& resupplyOffer);
168  virtual void updateReceivedSupplies(DtTime interval);
169  virtual void removeReceivedSupplies();
170  virtual bool checkResourceAvailable(DtEntityType type);
171  virtual double resourceAvailable(DtEntityType type);
172  virtual void updateResource(DtEntityType type, double quantity);
173  virtual void updatePSR();
174 
175  virtual const DtString lookUpSupplyType(const DtEntityType& type) const;
176  virtual const DtEntityType lookupSupplyName(const DtString& name) const;
177 
179  virtual double lookupMaxRate(const DtEntityType& type);
180 
181  virtual double calculateQuantityRequested(double quantityRequestedTotal);
182  virtual DtTime calculateReceivingStateTimeout(double quantityRequestedTotal,
183  double quantityReceivedTotal,
184  double quantityRequested,
185  double quantityOffered,
186  double rate);
187  virtual DtTime determineTimer2Period();
188 
189  virtual DtTime currentSimTime();
190 
191 protected:
195 
198 
201 
202 protected:
206  const DtTime theRequestingStateDefaultTimeout = 30.0;
207 
213  const double theReceivingStateTimeoutPercentage = 0.95;
214 
217  const double theTotalReceivedAmountCompletePercentage = 0.999;
218 
222  const int theNumTransferSessions = 10;
223 
224  boost::signals2::scoped_connection myResupplyOfferEventConnection;
225  boost::signals2::scoped_connection myResupplyCancelEventConnection;
226 };
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
virtual bool postAddComponentsInit() override
Calls enableTaskTypes()
virtual const char * type() const override=0
Returns a string identifies the class type of component. Type values are defined in compTypes...
Definition: resupplyReceivedEvent.h:14
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
This class provides a base class for all controllers that are capable of executing a DtSimTask...
Definition: singleTaskControllerComponent.h:22
DtResupplyReceiverControllerPSR * myProcessState
Container for state data associated with this component. This state is saved and restored as part of ...
Definition: resupplyReceiverController.h:194
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
boost::signals2::scoped_connection myResupplyOfferEventConnection
Definition: resupplyReceiverController.h:224
DtResupplyReceiverControllerDescriptor is a DtComponentDescriptor that has additional information nee...
Definition: resupplyReceiverControllerDescriptor.h:20
Definition: readerWriterRegistry.h:39
This class implements a controller, which gives the unit the capability to receive supplies...
Definition: resupplyReceiverController.h:32
Definition: resupplyOfferEvent.h:14
DtResupplyReceiverStateData myReceiverStateData
Controller state transition class.
Definition: resupplyReceiverController.h:200
virtual bool init() override
Calls setRadio()
Definition: resupplyCancelEvent.h:13
boost::signals2::scoped_connection myResupplyCancelEventConnection
Definition: resupplyReceiverController.h:225
Definition: event.h:13
File: simMsg.h.
Definition: simMessage.h:35
Definition: resupplyReceiverStateData.h:131
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
The base class for all messages to/from a specific DtVrfObject. Various subclasses of this class will...
Definition: vrfObjectMessage.h:30
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:95
const DtResupplyReceiverControllerDescriptor * myResupplyReceiverDesc
Controller descriptor.
Definition: resupplyReceiverController.h:197
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:91
DtResupplyReceiverControllerPSR is a process state repository which holds state variables for the DtR...
Definition: resupplyReceiverControllerPSR.h:22
VR-Link includes.
Definition: transferSuppliesTask.h:21
Definition: serviceRequestEvent.h:14
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 Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)