WSF
WsfJTIDS_SlotGroup.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 2003-2015 The Boeing 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 WSFJTIDS_SLOTGROUP_HPP
13#define WSFJTIDS_SLOTGROUP_HPP
14
15#include "wsf_mil_export.h"
16
17#include <list>
18#include <string>
19#include <unordered_set>
20#include <vector>
21
22namespace wsf
23{
24namespace comm
25{
26class Comm;
28} // namespace comm
29} // namespace wsf
30
31#include "UtCallback.hpp"
32class UtInput;
33class WsfCommandChain;
34#include "WsfCommMessage.hpp"
35class WsfScenario;
36#include "WsfEvent.hpp"
37class WsfMessage;
38class WsfPlatform;
39#include "WsfStringId.hpp"
40
47class WSF_MIL_EXPORT WsfJTIDS_SlotGroup
48{
49public:
51 const std::string& aGroupName,
52 const std::string& aSourceGroupName);
53
55
56 virtual ~WsfJTIDS_SlotGroup();
57
58 static void ClearNetGroups();
59
60 void AddToNetwork();
61
62 double BeginTransmitEvent(double aSimTime);
63
65
66 UtCallbackListN<void(double, const WsfMessage*, int, WsfJTIDS_SlotGroup*)> MessageSent;
68
70 WsfStringId GetNameId() const { return mGroupName; }
71
73 int GetNetwork() const { return mNetwork; }
74
76 int GetTSEC() const { return mTSEC; }
77
79 int GetMSEC() const { return mMSEC; }
80
82 int GetNPG() const { return mNPG; }
83
85 int GetSlotsPerFrame() const { return mSlotsPerFrame; }
86
88 int GetTransmitSlotsPerFrame() const { return static_cast<int>(mTransmitSlots.size()); }
89
90 double GetNextTransmitTime(double aSimTime);
91
92 bool DebugEnabled() const;
93 wsf::comm::Comm* GetTerminal() const;
94 WsfSimulation* GetSimulation() const;
95
96 bool Initialize(double aSimTime);
97
98 bool ProcessInput(UtInput& aInput);
99
100 void PurgeQueuedMessages();
101
102 void RemoveFromNetwork();
103
104 bool SendMessage(double aSimTime, const WsfMessage& aMessage, WsfPlatform* aRecipientPtr, bool aSource = true);
105
106 void StartupTransmitEvents(double aSimTime);
107
108 double TransmitCompleteEvent(double aSimTime);
109
110 void TransmitEventsStopped();
111
113 {
114 public:
115 using RecipientList = std::unordered_set<size_t>;
116 QueueEntry(double aTimeQueued, std::unique_ptr<WsfMessage> aMessage, RecipientList&& aRecipients);
117 QueueEntry(const QueueEntry& aSrc);
118 ~QueueEntry();
119
127 };
128
130 {
131 public:
133 TransmitHeartbeatEvent(double aSimTime)
134 : WsfEvent(aSimTime)
135 {
136 }
137 void InitializeEvent(double aSimTime,
138 double aEndTime,
139 double aInterval,
140 WsfSimulation* aSimulationPtr,
141 QueueEntry* aEntry,
142 wsf::comm::Comm* aTerminal)
143 {
144 mTimeNow = aSimTime;
145 mEndTime = aEndTime;
146 mInterval = aInterval;
147 mSimulationPtr = aSimulationPtr;
148 mEntry = aEntry;
149 mTerminal = aTerminal;
150 }
151 EventDisposition Execute() override;
152
153 double mTimeNow;
154 double mEndTime;
155 double mInterval;
159 };
160
161private:
162 enum AccessMode
163 {
164 cDEDICATED = -1
165 // Access Modes 0 - 15 are used for contention access.
166 };
167
168 enum PackingFormat
169 {
170 cSTD, // Standard double pulse ( 3x70 bits per time slot)
171 cP2SP, // Packed-2 single pulse ( 6x70 bits per time slot)
172 cP2DP, // Packed-2 double pulse ( 6x70 bits per time slot)
173 cP4SP // Packed-4 single pulse (12x70 bits per time slot)
174 };
175
177 class CommEvent : public WsfEvent
178 {
179 public:
180 enum EventType
181 {
182 cBEGIN_TRANSMIT,
183 cTRANSMIT_COMPLETE
184 };
185
186 EventDisposition Execute() override;
187
188 static void ScheduleBeginTransmitEvent(double aSimTime, WsfSimulation& aSimulation, WsfJTIDS_SlotGroup* aGroupPtr);
189 static void ScheduleTransmitCompleteEvent(double aSimTime, WsfSimulation& aSimulation, WsfJTIDS_SlotGroup* aGroupPtr);
190
191 protected:
192 CommEvent(double aSimTime, EventType aEventType, WsfJTIDS_SlotGroup* aGroupPtr);
193
194 double mLastStatusChangeTime;
195 EventType mEventType;
196 size_t mPlatformIndex;
197 WsfJTIDS_SlotGroup* mGroupPtr;
198 };
199
201 struct make_unique_comm_event : CommEvent
202 {
203 template<typename... Args>
204 make_unique_comm_event(Args&&... args)
205 : CommEvent(std::forward<Args>(args)...)
206 {
207 }
208 };
209
212 class NetGroup
213 {
214 public:
215 NetGroup(WsfStringId aGroupName, int aNetwork, int aTSEC);
216 ~NetGroup() = default;
217
218 WsfStringId mGroupName;
219 int mNetwork;
220 int mTSEC;
221 std::vector<WsfJTIDS_SlotGroup*> mGroupList;
222 };
223
224 class TimeSlotBlock
225 {
226 public:
227 TimeSlotBlock(int aOffset, int aInterval, char aType)
228 : mOffset(aOffset)
229 , mInterval(aInterval)
230 , mType(aType)
231 {
232 }
233 int mOffset;
234 int mInterval;
235 char mType;
236 };
237
238 void AddToTransmitQueue(double aSimTime, QueueEntry* aEntryPtr);
239
240 int ComputeTimeSlotsNeeded(const WsfMessage& aMessage) const;
241
242 void ComputeTransmitStartStopTime(double aSimTime,
243 int aTimeSlotsNeeded,
244 double& aStartTime,
245 double& aStopTime,
246 int& aTransmitSlotIndex);
247
248 void DeliverMessage(double aSimTime, QueueEntry& aQueueEntry);
249
250 virtual std::string GetFullName() const;
251
252 void ProcessPackingFormat(UtInput& aInput, PackingFormat& aPackingFormat);
253
254 void ProcessTimeSlotBlock(UtInput& aInput, char aBlockType);
255
256 bool ProcessNPG(UtInput& aInput);
257
258 wsf::comm::SlotGroupLayerJTIDS* mLayerPtr;
259 WsfStringId mGroupName;
260
261 int mNetwork;
262 int mTSEC;
263 int mMSEC;
264 int mNPG;
265 int mAccessMode;
266 PackingFormat mPackingLimit;
267
268 int mSlotsPerFrame;
269 int mPerUnitSlotsPerFrame;
270 std::vector<TimeSlotBlock> mTimeSlotBlocks;
271
272 std::vector<int> mSlots;
273 std::vector<int> mTransmitSlots;
274
275 int mQueueLimit;
276 std::list<QueueEntry*> mTransmitQueue;
277
279 WsfStringId mPairedRelaySourceName;
280
282 int mPairedRelaySlotOffset;
283
285 bool mRelay;
286
288 WsfJTIDS_SlotGroup* mPairedRelayPtr;
289
291 std::vector<NetGroup>::size_type mNetGroupIndex;
292
293 static std::vector<NetGroup> mNetGroups;
294
295 bool mIsUsingTransmitEvents;
296};
297
298#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Definition WsfCommandChain.hpp:36
WsfEvent()=default
Definition WsfJTIDS_SlotGroup.hpp:113
std::unordered_set< size_t > RecipientList
Definition WsfJTIDS_SlotGroup.hpp:115
RecipientList mRecipients
Definition WsfJTIDS_SlotGroup.hpp:126
double mBeginTransmitTime
Definition WsfJTIDS_SlotGroup.hpp:121
QueueEntry(double aTimeQueued, std::unique_ptr< WsfMessage > aMessage, RecipientList &&aRecipients)
Definition WsfJTIDS_SlotGroup.cpp:1120
wsf::comm::Message * mMessagePtr
Definition WsfJTIDS_SlotGroup.hpp:123
int mTransmitSlotIndex
Definition WsfJTIDS_SlotGroup.hpp:125
double mTransmitCompleteTime
Definition WsfJTIDS_SlotGroup.hpp:122
double mTimeQueued
Definition WsfJTIDS_SlotGroup.hpp:120
int mTimeSlotsNeeded
Definition WsfJTIDS_SlotGroup.hpp:124
double mEndTime
Definition WsfJTIDS_SlotGroup.hpp:154
QueueEntry * mEntry
Definition WsfJTIDS_SlotGroup.hpp:157
WsfSimulation * mSimulationPtr
Definition WsfJTIDS_SlotGroup.hpp:156
void InitializeEvent(double aSimTime, double aEndTime, double aInterval, WsfSimulation *aSimulationPtr, QueueEntry *aEntry, wsf::comm::Comm *aTerminal)
Definition WsfJTIDS_SlotGroup.hpp:137
TransmitHeartbeatEvent(double aSimTime)
Definition WsfJTIDS_SlotGroup.hpp:133
double mInterval
Definition WsfJTIDS_SlotGroup.hpp:155
wsf::comm::Comm * mTerminal
Definition WsfJTIDS_SlotGroup.hpp:158
double mTimeNow
Definition WsfJTIDS_SlotGroup.hpp:153
int GetTransmitSlotsPerFrame() const
Returns the number of slots allocated for transmitting.
Definition WsfJTIDS_SlotGroup.hpp:88
double BeginTransmitEvent(double aSimTime)
Definition WsfJTIDS_SlotGroup.cpp:825
int GetNPG() const
Return the Network Participation Group.
Definition WsfJTIDS_SlotGroup.hpp:82
void AddToNetwork()
Add the slot group to the corresponding network.
Definition WsfJTIDS_SlotGroup.cpp:114
UtCallbackListN< void(double, const WsfMessage *, int, WsfJTIDS_SlotGroup *)> MessageSent
Definition WsfJTIDS_SlotGroup.hpp:66
WsfJTIDS_SlotGroup(wsf::comm::SlotGroupLayerJTIDS *aLayerPtr, const std::string &aGroupName, const std::string &aSourceGroupName)
Construct a slot group.
Definition WsfJTIDS_SlotGroup.cpp:36
int GetMSEC() const
Return the JTIDS MSEC value.
Definition WsfJTIDS_SlotGroup.hpp:79
int GetNetwork() const
Return the JTIDS network number.
Definition WsfJTIDS_SlotGroup.hpp:73
static void ClearNetGroups()
Definition WsfJTIDS_SlotGroup.cpp:108
int GetSlotsPerFrame() const
Returns the number of slots per frame.
Definition WsfJTIDS_SlotGroup.hpp:85
WsfStringId GetNameId() const
Return the name ID of the slot group.
Definition WsfJTIDS_SlotGroup.hpp:70
int GetTSEC() const
Return the JTIDS TSEC value.
Definition WsfJTIDS_SlotGroup.hpp:76
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfComm.hpp:43
Definition WsfCommMessage.hpp:51
Definition WsfCommSlotGroupLayerJTIDS.hpp:35
str args
Definition MessageDefines_Generate.py:21
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