WSF
WsfCommNetworkAdHoc.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2019 Infoscitex, a DCS Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFCOMMNETWORKADHOC_HPP
13#define WSFCOMMNETWORKADHOC_HPP
14
15#include "wsf_export.h"
16
18#include "WsfRandomVariable.hpp"
19class WsfSimulation;
20
21namespace wsf
22{
23namespace comm
24{
25
38{
39public:
44 using NamedRateMap = std::unordered_map<NamedComm, WsfRandomVariable>;
45 using AddressRateMap = std::unordered_map<Address, WsfRandomVariable>;
46
47 NetworkAdHoc() = default;
48 ~NetworkAdHoc() override = default;
49 NetworkAdHoc(const NetworkAdHoc& aSrc);
51 NetworkAdHoc(const std::string& aNetworkName, const Address& aAddress);
52
53 bool ProcessInput(UtInput& aInput) override;
54 NetworkAdHoc* Clone() const override;
55 const char* GetScriptClassName() const override { return "WsfNetworkAdHoc"; }
56 bool Initialize(WsfSimulation& aSim) override;
57
62 void ChangeRate(WsfSimulation& aSim, const WsfRandomVariable& aRate);
63
68
69 void AddNamedRate(const NamedComm& aComm, const WsfRandomVariable& aRate, WsfSimulation* aSimPtr = nullptr);
70 void AddAddressRate(const Address& aAddress, const WsfRandomVariable& aRate, WsfSimulation* aSimPtr = nullptr);
71 bool RemoveNamedRate(const NamedComm& aComm);
72 bool RemoveAddressRate(const Address& aAddress);
74
77
78 WsfRandomVariable* GetNamedRate(const NamedComm& aComm);
79 WsfRandomVariable* GetAddressRate(const Address& aAddress);
81
82protected:
84
85 bool ProcessNamedRate(UtInput& aInput);
86 bool ProcessAddressRate(UtInput& aInput);
88
97
98 void Update(WsfSimulation& aSim);
99 void Update(WsfSimulation& aSim, const NamedComm& aComm);
100 void Update(WsfSimulation& aSim, const Address& aAddress);
102
103private:
107 std::numeric_limits<double>::max(),
108 0.0,
110
115 NamedRateMap mNamedRate{};
116 AddressRateMap mAddressRate{};
117
119 std::shared_ptr<int> mEvents{std::make_shared<int>(0)};
120};
121
123{
124public:
125 ScriptNetworkAdHocClass(const std::string& aClassName, UtScriptTypes* aTypesPtr);
126
127 void* Create(const UtScriptContext& aInstance) override;
128 void Destroy(void* aNetworkPtr) override;
129
130 UT_DECLARE_SCRIPT_METHOD(ChangeUpdateRate);
131 UT_DECLARE_SCRIPT_METHOD(AddMemberUpdateRate);
132 UT_DECLARE_SCRIPT_METHOD(RemoveMemberUpdateRate);
133};
134
135} // namespace comm
136} // namespace wsf
137
138#endif
aObjectPtr Update(simTime)
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfRandomVariable.hpp:33
@ cCONSTANT
The random values will always have a constant value.
Definition WsfRandomVariable.hpp:38
@ cPOSITIVE
Value must be greater than zero.
Definition WsfRandomVariable.hpp:49
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfCommAddress.hpp:57
NetworkAdHoc & operator=(const NetworkAdHoc &aRhs)
Definition WsfCommNetworkAdHoc.cpp:45
NetworkAdHoc * Clone() const override
Definition WsfCommNetworkAdHoc.cpp:60
~NetworkAdHoc() override=default
std::unordered_map< NamedComm, WsfRandomVariable > NamedRateMap
Definition WsfCommNetworkAdHoc.hpp:44
std::unordered_map< Address, WsfRandomVariable > AddressRateMap
Definition WsfCommNetworkAdHoc.hpp:45
const char * GetScriptClassName() const override
Definition WsfCommNetworkAdHoc.hpp:55
bool ProcessInput(UtInput &aInput) override
Definition WsfCommNetworkAdHoc.cpp:117
UT_DECLARE_SCRIPT_METHOD(RemoveMemberUpdateRate)
void Destroy(void *aNetworkPtr) override
Definition WsfCommNetworkAdHoc.cpp:453
UT_DECLARE_SCRIPT_METHOD(ChangeUpdateRate)
void * Create(const UtScriptContext &aInstance) override
Definition WsfCommNetworkAdHoc.cpp:447
ScriptNetworkAdHocClass(const std::string &aClassName, UtScriptTypes *aTypesPtr)
Definition WsfCommNetworkAdHoc.cpp:435
UT_DECLARE_SCRIPT_METHOD(AddMemberUpdateRate)
ScriptNetworkGenericClass(const std::string &aClassName, UtScriptTypes *aTypesPtr)
Definition WsfCommNetworkGeneric.cpp:131
Definition WsfComm.cpp:34
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
Copyrights Multiple, All Rights Reserved