12#ifndef WSFEXCHANGE_HPP
13#define WSFEXCHANGE_HPP
17#include "UtCallbackHolder.hpp"
20#include "UtScriptAccessible.hpp"
23#include "wsf_export.h"
93 double aQuantity = 0.0,
95 bool aIsService =
false);
111 bool IsCompatibleWith(
const Tender& aRhs)
const;
117 void SetIsService(
bool aValue);
119 void ConstrainQuantityTo(
double aQuantity);
120 void ConstrainRateTo(
double aRate);
121 void ConstrainTo(
const Tender& aLimit);
122 double Decrement(
double aAmount);
123 double Increment(
double aAmount);
171 bool IsDone()
const {
return mResult.IsDone(); }
223 size_t aRequestingIndex,
224 size_t aRespondingIndex,
225 double aDesiredQuantity,
227 unsigned int aRequestId,
233 size_t aRequestingIndex,
234 size_t aRespondingIndex,
235 double aDesiredQuantity,
237 double aOfferedQuantity,
239 unsigned int aRequestId,
248 void DebugDump(ut::log::MessageStream& aStream)
const;
262 unsigned int mRequestId;
263 size_t mRespondingIndex;
264 double mOfferedQuantity;
266 size_t mRequestingIndex;
267 double mDesiredQuantity;
269 double mNegotiatedQuantity;
270 double mNegotiatedRate;
326 double QuantityNeeded()
const;
327 bool IsCompatibleWith(
const Tender& aTender)
const;
329 Tender TenderNeeded()
const;
330 Tender TenderRemaining()
const;
336 bool SetQuantity(
double aValue);
337 double Decrement(
double aAmount);
338 double Increment(
double aAmount);
396 std::string OwningPlatformName()
const;
397 std::string OppositePlatformName()
const;
398 std::string RequestorPlatformName()
const;
399 std::string ResponderPlatformName()
const;
400 std::string MyFullName()
const;
402 bool RequestFrom(
double aSimTime,
const WsfPlatform* aSupplierPtr,
const Tender& aTender);
407 void Cancel(
double aSimTime);
408 bool DebugEnabled()
const;
409 bool IsService()
const {
return mContainerPtr->IsService(); }
410 void DebugDump(
double aSimTime,
const Query& aQuery, ut::log::MessageStream& aMessageStream)
const;
424 bool ProcessInput(UtInput& aInput);
428 bool ExchangeQueried(
double aSimTime,
const Query& aQuery);
434 void TakeQueuedAction(
double aSimTime,
unsigned int aRequestId,
bool aIsTimeOut);
436 bool ReserveAll(
double aSimTime);
438 bool ReserveTender(
double aSimTime,
const Tender& aTender);
454 bool ConsummateNow(
double aSimTime);
455 bool RepairWasCompleted(
double aSimTime);
456 void DetermineFinalResult(
bool aWasTimedOut =
false);
457 bool NegotiationComplete(
double aSimTime,
double aNegotiatedQuantity);
458 bool RequestFrom(
double aSimTime,
size_t aSupplierIndex);
459 bool Offer(
double aSimTime,
const Query& aQuery);
460 bool Accept(
double aSimTime,
const Query& aQuery);
461 bool Supply(
double aSimTime);
462 void SetEnable(
bool aValue);
463 void UnreserveFromContainer();
464 static unsigned int sNextRequestId;
465 bool IsInProximityTo(
size_t aOppositePlatIndex);
473 QueuedEvent(
double aSimTime,
unsigned int aRequestId,
size_t aPlatformIndex,
Transactor* aTransactorPtr,
bool aIsTimeOut);
474 EventDisposition Execute()
override;
478 unsigned int mRequestId;
490 bool mIsContinueToOffer;
491 bool mIsAlwaysHonorRate;
492 bool mIsHookedToFuel;
493 bool mIsHookedToPayload;
494 bool mIsExclusiveHook;
495 double mTimeOutClockInterval;
496 double mProximityLimit;
497 double mReservedFromContainer;
498 double mAttenuatedOfferAmount;
505UT_MAP_CLASS_TO_SCRIPT_NAME(
WsfExchange::Container,
"Container")
506UT_MAP_CLASS_TO_SCRIPT_NAME(
WsfExchange::Query,
"Query")
507UT_MAP_CLASS_TO_SCRIPT_NAME(
WsfExchange::Transactor,
"Transactor")
bool operator==(int aId, const WsfStringInt &aRhs)
Equal relational operator for the case of an integer on the LHS and a StringId on the RHS.
Definition WsfStringId.hpp:69
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfEvent.hpp:29
Definition WsfExchangeProcessor.hpp:45
Definition WsfExchange.hpp:312
double MaximumQuantity() const
Definition WsfExchange.hpp:325
double mQuantity
Definition WsfExchange.hpp:344
bool IsEmpty() const
Definition WsfExchange.cpp:1009
Tender mTender
Definition WsfExchange.hpp:343
bool IsService() const
Definition WsfExchange.hpp:335
Container()
Definition WsfExchange.cpp:860
const char * GetScriptClassName() const
Tender & MaximumTender()
Definition WsfExchange.hpp:333
bool IsFull() const
Definition WsfExchange.cpp:997
bool Initialize()
Definition WsfExchange.cpp:927
bool ProcessInput(UtInput &aInput)
Definition WsfExchange.cpp:898
const Tender & MaximumTender() const
Definition WsfExchange.hpp:332
double CurrentQuantity() const
Definition WsfExchange.hpp:324
static bool LoadInstance(UtInput &aInput, Container *&aContainerPtr)
Definition WsfExchange.cpp:833
Callback Query class.
Definition WsfExchange.hpp:164
WsfStringId StateId() const
Definition WsfExchange.hpp:194
size_t RespondingIndex() const
Definition WsfExchange.hpp:176
WsfSimulation * GetSimulation() const
Definition WsfExchange.hpp:178
size_t OppositeIndex() const
Definition WsfExchange.cpp:392
Tender GetTender() const
Definition WsfExchange.cpp:479
double DesiredQuantity() const
Definition WsfExchange.hpp:182
std::string GetResultString() const
Definition WsfExchange.hpp:188
void ContinuingReset(double aNewOfferQuantity)
This is used for an Offeror who will continue offering,.
Definition WsfExchange.cpp:348
size_t OwningIndex() const
Definition WsfExchange.hpp:173
double OfferedRate() const
Definition WsfExchange.hpp:181
void SetNegotiatedQuantity(double aValue)
Definition WsfExchange.cpp:410
bool IsDone() const
Definition WsfExchange.hpp:171
unsigned int RequestId() const
Definition WsfExchange.hpp:174
void ConstrainTo(double aQuantity)
Definition WsfExchange.cpp:383
void SetOfferedQuantity(double aValue)
Definition WsfExchange.cpp:416
double NegotiatedRate() const
Definition WsfExchange.hpp:185
WsfStringId StateMachine(WsfStringId aEventId) const
Definition WsfExchange.cpp:551
double NegotiatedInterval() const
Definition WsfExchange.cpp:446
void SetRequestId(unsigned int aValue)
Definition WsfExchange.cpp:440
size_t IntendedRecipientIndex() const
void SetOwningIndex(size_t aValue)
Definition WsfExchange.cpp:398
void SetDesiredRate(double aValue)
void SetNegotiatedRate(double aValue)
Definition WsfExchange.cpp:434
void DebugDump(ut::log::MessageStream &aStream) const
Definition WsfExchange.cpp:361
void SetDesiredQuantity(double aValue)
Definition WsfExchange.cpp:422
void SetOfferedRate(double aValue)
Definition WsfExchange.cpp:428
bool IsOfferor() const
Definition WsfExchange.hpp:169
void SetRespondingIndex(size_t aValue)
Definition WsfExchange.cpp:404
double NegotiatedQuantity() const
Definition WsfExchange.hpp:184
WsfStringId EventId() const
Definition WsfExchange.hpp:195
WsfStringId ItemId() const
Definition WsfExchange.hpp:193
double OfferedQuantity() const
Definition WsfExchange.hpp:180
bool FormOffer(size_t aOwningIndex, size_t aRequestingIndex, size_t aRespondingIndex, double aDesiredQuantity, double aDesiredRate, double aOfferedQuantity, double aOfferedRate, unsigned int aRequestId, WsfStringId aItemId, bool aIsOfferor, bool aIsService)
Definition WsfExchange.cpp:517
void SetResult(Result::Value aValue)
Definition WsfExchange.cpp:322
Query(WsfSimulation *aSimulationPtr=nullptr)
Definition WsfExchange.cpp:298
const char * GetScriptClassName() const
bool FormRequest(size_t aOwningIndex, size_t aRequestingIndex, size_t aRespondingIndex, double aDesiredQuantity, double aDesiredRate, unsigned int aRequestId, WsfStringId aItemId, bool aIsOfferor, bool aIsService)
Definition WsfExchange.cpp:488
void SetState(WsfStringId aValue)
Definition WsfExchange.hpp:244
double DesiredRate() const
Definition WsfExchange.hpp:183
bool Initialize(WsfPlatform *aOwningPlatform, bool aIsOfferor, WsfStringId aCommodityId, bool aIsService)
Definition WsfExchange.cpp:456
void SetEvent(WsfStringId aValue)
Definition WsfExchange.hpp:245
bool IsService() const
Definition WsfExchange.hpp:170
Result::Value GetResultValue() const
Definition WsfExchange.hpp:189
size_t RequestingIndex() const
Definition WsfExchange.hpp:175
void FinalReset()
Definition WsfExchange.cpp:334
Definition WsfExchange.hpp:138
Value
Definition WsfExchange.hpp:141
@ cPARTLY_SATISFIED
Definition WsfExchange.hpp:146
@ cPENDING
Definition WsfExchange.hpp:142
@ cTIMED_OUT
Definition WsfExchange.hpp:144
@ cFULLY_SATISFIED
Definition WsfExchange.hpp:147
@ cCANCELLED_REJECTED
Definition WsfExchange.hpp:145
@ cIN_PROGRESS
Definition WsfExchange.hpp:143
Result(Value aStartValue=cPENDING)
Definition WsfExchange.hpp:150
void Set(Value aValue)
Definition WsfExchange.hpp:152
bool IsDone() const
Definition WsfExchange.cpp:328
std::string GetString() const
Definition WsfExchange.cpp:269
Value Get() const
Definition WsfExchange.hpp:153
Value mValue
Definition WsfExchange.hpp:159
Definition WsfExchange.hpp:87
static bool LoadInstance(UtInput &aInput, Tender *&aTenderPtr)
Definition WsfExchange.cpp:624
Tender()
Definition WsfExchange.cpp:652
bool mIsService
Definition WsfExchange.hpp:133
bool ProcessInput(UtInput &aInput)
Definition WsfExchange.cpp:691
bool IsService() const
Definition WsfExchange.hpp:107
void SetRateP(double aQuantity)
Definition WsfExchange.cpp:746
void Null()
Definition WsfExchange.hpp:101
double mQuantity
Definition WsfExchange.hpp:131
double Quantity() const
Definition WsfExchange.hpp:110
void SetQuantity(double aValue)
Definition WsfExchange.hpp:113
double mRate
Definition WsfExchange.hpp:132
bool IsCommodity() const
Definition WsfExchange.hpp:108
bool IsNull() const
Definition WsfExchange.hpp:102
void SetQuantityP(double aQuantity)
Definition WsfExchange.cpp:736
const char * GetScriptClassName() const
double Rate() const
Definition WsfExchange.hpp:106
double Interval() const
Definition WsfExchange.hpp:109
void SetRate(double aValue)
Definition WsfExchange.hpp:114
Tender * Clone() const
Definition WsfExchange.cpp:678
Container * ContainerPtr()
Definition WsfExchange.hpp:391
bool IsReady() const
Definition WsfExchange.hpp:378
static bool IsEvent(WsfStringId aEventId)
Definition WsfExchange.cpp:1057
bool RequestFrom(double aSimTime, const WsfPlatform *aSupplierPtr, const Tender &aTender)
Definition WsfExchange.cpp:1567
WsfSimulation * GetSimulation() const
Definition WsfExchange.cpp:1555
Query * GetQueryPtr()
Definition WsfExchange.hpp:421
void SetProximityLimit(double aValue)
Definition WsfExchange.hpp:417
void SetIsOfferor(bool aValue)
Definition WsfExchange.hpp:412
void SetTimeOutClockInterval(double aValue)
Definition WsfExchange.hpp:416
static bool LoadInstance(UtInput &aInput, Transactor *&aInstancePtr)
Definition WsfExchange.cpp:1186
void SetContinueToOffer(bool aValue)
Definition WsfExchange.hpp:413
const char * GetScriptClassName() const
void SetIsHookedToPayload(bool aValue)
Definition WsfExchange.hpp:414
bool Initialize(double aSimTime, WsfExchangeProcessor *aProcessorPtr)
Definition WsfExchange.cpp:1456
bool IsInProgress() const
Definition WsfExchange.hpp:379
bool IsOfferor() const
Definition WsfExchange.hpp:383
bool IsHookedToPayload() const
Definition WsfExchange.hpp:387
bool ReserveFor(double aSimTime, const Tender &aTender, WsfPlatform *aReceiverPtr)
const Query & GetQuery() const
Definition WsfExchange.hpp:422
Query & GetQuery()
Definition WsfExchange.hpp:420
bool IsRequester() const
Definition WsfExchange.hpp:384
bool SetDesiredTender(const Tender &aTender)
Definition WsfExchange.cpp:1112
bool IsInConflictWith(const Transactor &aRhs) const
Definition WsfExchange.cpp:1133
static bool IsState(WsfStringId aState)
Definition WsfExchange.cpp:1170
const Container * ContainerPtr() const
Definition WsfExchange.hpp:392
void Disable()
Definition WsfExchange.cpp:1281
double ProximityLimit() const
Definition WsfExchange.hpp:418
bool IsService() const
Definition WsfExchange.hpp:409
static void ResetNextSerialRequestId()
Definition WsfExchange.cpp:1066
bool AlwaysHonorRate() const
Definition WsfExchange.hpp:381
bool IsExclusiveHook() const
Definition WsfExchange.hpp:388
bool IsHookedToFuel() const
Definition WsfExchange.hpp:386
static unsigned int NextSerialRequestId()
Definition WsfExchange.cpp:1024
bool SetOfferedTender(const Tender &aTender)
Definition WsfExchange.cpp:1072
double TimeOutClockInterval() const
Definition WsfExchange.hpp:394
void SetIsHookedToFuel(bool aValue)
Definition WsfExchange.hpp:415
Transactor()
Definition WsfExchange.cpp:1034
bool IsEnabled() const
Definition WsfExchange.hpp:382
WsfStringId ContainerNameId() const
Definition WsfExchange.hpp:390
bool ContinueToOffer() const
Definition WsfExchange.hpp:380
WsfNamed()
Definition WsfNamed.cpp:17
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfExchange.cpp:66
static WsfStringId sSTATE_ACCEPTING
Definition WsfExchange.hpp:67
void SetCapabilityFlag(WsfPlatform *aPlatformPtr, CapabilityType aCapability, bool aValue)
Definition WsfExchange.cpp:113
static WsfStringId sEVENT_RECEIVED
Definition WsfExchange.hpp:76
CapabilityType BitNumberToCapability(unsigned int aBitNumber)
Definition WsfExchange.cpp:165
static WsfStringId sEVENT_REQUESTOR_RESPONDED
Definition WsfExchange.hpp:79
static WsfStringId sEVENT_OFFERED
Definition WsfExchange.hpp:73
void InitializeStatics()
Definition WsfExchange.cpp:69
static WsfStringId sSTATE_SUPPLYING
Definition WsfExchange.hpp:69
static WsfStringId sSTATE_READY
Definition WsfExchange.hpp:65
static WsfStringId sEVENT_SUPPLIED
Definition WsfExchange.hpp:75
void ModifyCapabilities(WsfPlatform *aPlatformPtr, unsigned int aOldCapability, unsigned int aNewCapability)
Definition WsfExchange.cpp:95
static WsfStringId sEVENT_ACCEPTED
Definition WsfExchange.hpp:74
WsfStringId CapabilityToNameId(CapabilityType aCapability)
Definition WsfExchange.cpp:235
static WsfStringId sSTATE_OFFERING
Definition WsfExchange.hpp:68
unsigned int CapabilityToBitNumber(CapabilityType aCapability)
Definition WsfExchange.cpp:144
CapabilityType NameIdToCapability(WsfStringId aCapabilityNameId)
Definition WsfExchange.cpp:194
bool IsCapable(unsigned int aCapabilityWord, CapabilityType aCapability)
Definition WsfExchange.cpp:133
static WsfStringId sEVENT_CANCELLED
Definition WsfExchange.hpp:77
static WsfStringId sEVENT_OFFEROR_COMPLETED
Definition WsfExchange.hpp:78
static WsfStringId sSTATE_REQUESTING
Definition WsfExchange.hpp:66
static WsfStringId sEVENT_REQUESTED
Definition WsfExchange.hpp:72
CapabilityType
Definition WsfExchange.hpp:278
@ cSUPPLY_FUEL
Definition WsfExchange.hpp:282
@ cNO_CAPABILITY
Definition WsfExchange.hpp:286
@ cSUPPLY_ADS_B
Definition WsfExchange.hpp:285
@ cVEHICLE_RECOVERY
Definition WsfExchange.hpp:283
@ cSUPPLY_PAYLOAD
Definition WsfExchange.hpp:281
@ cVEHICLE_REPAIR
Definition WsfExchange.hpp:284