WSF
WsfXIO_RemotePlatformList.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 WSFXIO_REMOTEPLATFORMLIST_HPP
13#define WSFXIO_REMOTEPLATFORMLIST_HPP
14
15#include "wsf_export.h"
16
17#include "UtCallback.hpp"
18#include "UtMath.hpp"
19class WsfClockSource;
30
37{
38private:
39 class PlatformListRequest;
40 class ConnectionInfo;
41
42 typedef std::map<unsigned int, WsfXIO_PlatformInfo*> IndexMap;
43 // typedef std::map<WsfXIO_EntityId,WsfXIO_PlatformInfo*> EntityIdMap;
44
45 typedef std::map<GenUniqueId, ConnectionInfo*> ConnectionMap;
46 typedef std::vector<WsfXIO_CommandChain> CommandChainList;
47 typedef std::map<WsfXIO_EntityId, CommandChainList> CommandChainMap;
48
49public:
50 typedef std::multimap<WsfXIO_EntityId, WsfXIO_PlatformInfo*> EntityIdMap;
51 typedef std::map<WsfXIO_PlatformId, WsfXIO_PlatformInfo*> PlatformIdMap;
52 typedef std::pair<WsfStringId, unsigned int> PlatformNameId;
53 typedef std::map<PlatformNameId, WsfXIO_PlatformInfo*> PlatformNameIdMap;
54
64
67 void Send(WsfXIO_Packet& aPkt);
68
72
74
75 void SetReliableEntityState(bool aIsReliable) { mReliableEntityState = aIsReliable; }
76
77 void SetIgnoreExternalPlatforms(bool aIgnore) { mIgnoreExternalPlatforms = aIgnore; }
78
79 void SetInformationLevels(int aPlatformInformationLevel);
80
81 void SetDeadReckonParameters(double aDeadReckonInterval,
82 double aMaxDeadReckonError = 5.0,
83 double aMaxDeadReckonOrientationError = 3.0 * UtMath::cRAD_PER_DEG);
84
85 void SetInformationLevels(int aPlatformInformationLevel,
86 WsfXIO_PlatformInfo* aPlatformPtr,
87 double aDeadReckonInterval = 1.0,
88 double aMaxDeadReckonError = 5.0,
89 double aMaxDeadReckonOrientationError = 3.0 * UtMath::cRAD_PER_DEG);
90
92 void Destroy();
93
96 bool AddConnection(WsfXIO_Connection* aConnectionPtr, const WsfClockSource* aClockPtr);
97
100 void DropConnection(WsfXIO_Connection* aConnectionPtr);
101
104 WsfXIO_Connection* GetConnectionByEntityId(const WsfXIO_EntityId& aEntityId);
105
108 WsfXIO_PlatformInfo* GetPlatformByEntityId(const WsfXIO_EntityId& aEntityId);
109
113 WsfXIO_PlatformInfo* GetPlatformByIndex(const WsfXIO_Connection* aConnectionPtr, const unsigned int aPlatformIndex);
114
115 WsfXIO_PlatformInfo* FindPlatform(WsfXIO_PlatformId aPlaformId);
116 WsfXIO_PlatformInfo* FindPlatform(WsfXIO_EntityId aId, int aConnectionId);
117 WsfXIO_PlatformInfo* FindPlatformByIndex(int aPlatformIndex, const WsfXIO_Connection* aConnectionPtr = nullptr);
118 WsfXIO_PlatformInfo* FindPlatformByName(WsfStringId aPlatformName, const WsfXIO_Connection* aConnectionPtr = nullptr);
119
122 CommandChainList GetCommandChainByEntityId(const WsfXIO_EntityId& aEntityId) const;
123
127 std::list<WsfXIO_PlatformInfo*> GetCurrentPlatforms() const;
128
131 UtCallbackListN<void(WsfXIO_PlatformInfo&)> PlatformAdded;
132
135 UtCallbackListN<void(WsfXIO_PlatformInfo&)> PlatformRemoved;
136
139
142
145
147 UtCallbackListN<void(WsfXIO_PlatformInfo&, const std::vector<WsfXIO_CommandChain>&)> CommandChainInitialized;
148
149 UtCallbackListN<void(WsfXIO_PlatformInfo&)> RouteUpdated;
152 unsigned int GetConnectionCount() const { return (unsigned int)mConnectionMap.size(); }
153
154 const PlatformIdMap& GetAllPlatforms() const { return mPlatforms; }
156
157private:
160
161 void RemoveConnectionInfo(const GenUniqueId& aConnectionId);
162 void RemoveConnectionInfo();
163
164 void HandlePlatformAdded(WsfXIO_PlatformInfo* aPlatformPtr);
165 void HandlePlatformDeleted(WsfXIO_PlatformInfo* aPlatformPtr);
166 void HandleEntityState(WsfXIO_EntityStateRawPkt& aState);
167 void HandlePartState(WsfXIO_PlatformPartStatePkt& aState);
168
169 void HandleRouteUpdate(WsfXIO_RouteUpdatePkt& aRouteUpdate);
170
173 class ConnectionInfo
174 {
175 public:
176 friend class WsfXIO_RemotePlatformList;
177
178 ConnectionInfo(WsfXIO_RemotePlatformList* aParentPtr,
179 int aPlatformInfoLevel,
180 WsfXIO_Connection* aConnectionPtr,
181 const WsfClockSource* aClockSourcePtr);
182
183 ~ConnectionInfo();
184
185 void Destroy();
186 void HandlePlatformList(WsfXIO_PlatformListUpdatePkt& aPkt);
187 void HandleInfoResponse(const int aPlatformIndex, WsfXIO_ResponsePkt& aPkt);
188 void HandleEntityState(WsfXIO_EntityStateData& aState);
189 void HandlePartState(WsfXIO_PlatformPartStatePkt& aState);
190 void HandleRouteUpdate(WsfXIO_RouteUpdatePkt& aRouteUpdate);
191
192 void RemoveRequest() { mInterfacePtr->GetRequestManager().RemoveRequest(mPlatformListRequestPtr); }
193 void AddRequest() { mInterfacePtr->GetRequestManager().AddRequest(mPlatformListRequestPtr); }
194
195 void SetInformationLevels(WsfXIO_PlatformInfo* aPlatformPtr,
196 int aPlatformInformationLevel,
197 double aDefaultDeadReckonInterval,
198 double aDefaultMaxDeadReckonError,
199 double aDefaultMaxDeadReckonOrientationError);
200
201 WsfXIO_PlatformInfo* GetPlatformByIndex(const unsigned int aPlatformIndex);
202 WsfXIO_Connection* GetConnection() { return mConnectionPtr; }
203
204 unsigned int ToUINT(const int aVal) { return static_cast<unsigned int>(aVal); }
205
206 private:
207 ConnectionInfo();
208 ConnectionInfo(const ConnectionInfo& aRhs);
209 ConnectionInfo& operator=(const ConnectionInfo& aRhs);
210
211 WsfXIO_RemotePlatformList* mParentPtr;
212 int mPlatformInfoLevel;
213 WsfXIO_Connection* mConnectionPtr;
214 WsfXIO_Interface* mInterfacePtr;
215 PlatformListRequest* mPlatformListRequestPtr;
216 WsfXIO_RequestManager& mPlatformInfoRequestManager;
217 IndexMap mPlatformInfoMap;
218 const WsfClockSource* mClockSourcePtr;
219 }; // end ConnectionInfo
220
221 friend class ConnectionInfo;
222
223 class PlatformListRequest : public WsfXIO_PlatformListRequest
224 {
225 public:
226 PlatformListRequest(ConnectionInfo& aConnectionInfo)
227 : WsfXIO_PlatformListRequest(aConnectionInfo.GetConnection())
228 , mConnectionInfo(aConnectionInfo)
229 {
230 }
231
232 void HandlePlatformList(WsfXIO_PlatformListUpdatePkt& aPkt) override { mConnectionInfo.HandlePlatformList(aPkt); }
233
234 private:
235 ConnectionInfo& mConnectionInfo;
236 };
237
238 class PlatformInfoRequest : public WsfXIO_PlatformInfoRequest
239 {
240 public:
241 PlatformInfoRequest(int aPlatformIndex, unsigned int aInformationTypes, ConnectionInfo& aConnectionInfo, bool aIsReliable)
242 : WsfXIO_PlatformInfoRequest(aPlatformIndex, aInformationTypes, aConnectionInfo.GetConnection(), aIsReliable)
243 , mConnectionInfo(aConnectionInfo)
244 {
245 }
246
247 void HandleResponse(WsfXIO_ResponsePkt& aPkt) override;
248
249 protected:
250 ConnectionInfo& mConnectionInfo;
251 }; // end class PlatformInfoRequest
252
253protected:
254 unsigned int GetInfoType(int aInfoLevel);
255
256 ConnectionInfo* FindConnection(const GenUniqueId& aId);
257
259
263 ConnectionMap mConnectionMap;
265 CommandChainMap mCommandChainMap;
266
269 UtCallbackHolder mCallbacks;
270
275};
276
277#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Maintain the current simulation clock.
Definition WsfClockSource.hpp:22
Definition WsfXIO_Connection.hpp:37
Definition WsfXIO_PacketRegistry.hpp:973
Definition WsfXIO_PacketRegistry.hpp:1112
Definition WsfXIO_Interface.hpp:54
Base class for XIO Packets. Provides the header information.
Definition WsfXIO_Packet.hpp:46
Definition WsfXIO_PlatformId.hpp:20
Definition WsfXIO_ObjectInfo.hpp:567
Definition WsfXIO_PlatformListRequest.hpp:24
virtual void HandlePlatformList(WsfXIO_PlatformListUpdatePkt &aPkt)=0
Definition WsfXIO_PacketRegistry.hpp:195
Definition WsfXIO_ObjectInfo.hpp:249
Requests that an application begin sending state information for a specified platform part.
Definition WsfXIO_PacketRegistry.hpp:1157
Definition WsfXIO_RemotePlatformList.hpp:37
const PlatformIdMap & GetAllPlatforms() const
Definition WsfXIO_RemotePlatformList.hpp:154
UtCallbackListN< void(WsfXIO_PlatformInfo &)> PlatformEntityStateChanged
Provides information about a platform when its entity state changes.
Definition WsfXIO_RemotePlatformList.hpp:138
UtCallbackListN< void(WsfXIO_PlatformInfo &, const std::vector< WsfXIO_CommandChain > &)> CommandChainInitialized
Provides information about a platform when its entity state changes.
Definition WsfXIO_RemotePlatformList.hpp:147
const EntityIdMap & GetPlatformsByEntityId() const
Definition WsfXIO_RemotePlatformList.hpp:155
bool mIgnoreExternalPlatforms
Definition WsfXIO_RemotePlatformList.hpp:262
bool mReliableEntityState
Definition WsfXIO_RemotePlatformList.hpp:260
std::pair< WsfStringId, unsigned int > PlatformNameId
Definition WsfXIO_RemotePlatformList.hpp:52
std::map< PlatformNameId, WsfXIO_PlatformInfo * > PlatformNameIdMap
Definition WsfXIO_RemotePlatformList.hpp:53
bool mUseDefaultDR_Params
Definition WsfXIO_RemotePlatformList.hpp:261
PlatformNameIdMap mPlatformsByName
Definition WsfXIO_RemotePlatformList.hpp:268
UtCallbackListN< void(WsfXIO_PlatformInfo &)> TrackManagerStateChanged
Provides information about a platform when its track manager state changes.
Definition WsfXIO_RemotePlatformList.hpp:144
ConnectionMap mConnectionMap
Definition WsfXIO_RemotePlatformList.hpp:263
InformationLevel
Definition WsfXIO_RemotePlatformList.hpp:58
@ cNO_CHANGE
Definition WsfXIO_RemotePlatformList.hpp:62
@ cBASIC_INFORMATION
Provides Platform identity and list of platform parts.
Definition WsfXIO_RemotePlatformList.hpp:59
@ cROUTE_INFORMATION
Definition WsfXIO_RemotePlatformList.hpp:61
@ cSTATE_INFORMATION
Provides kinematic information in addition to the basic information.
Definition WsfXIO_RemotePlatformList.hpp:60
UtCallbackListN< void(WsfXIO_PlatformInfo &)> PlatformRemoved
Definition WsfXIO_RemotePlatformList.hpp:135
double mDefaultMaxDeadReckonError
Definition WsfXIO_RemotePlatformList.hpp:273
CommandChainMap mCommandChainMap
Definition WsfXIO_RemotePlatformList.hpp:265
EntityIdMap mAllPlatformsMap
Definition WsfXIO_RemotePlatformList.hpp:264
std::map< WsfXIO_PlatformId, WsfXIO_PlatformInfo * > PlatformIdMap
Definition WsfXIO_RemotePlatformList.hpp:51
WsfXIO_RemotePlatformList(WsfXIO_Interface *aInterfacePtr)
Definition WsfXIO_RemotePlatformList.cpp:22
UtCallbackListN< void(WsfXIO_PlatformInfo &, WsfXIO_PlatformPartInfo &)> PlatformPartStateChanged
Provides information about a platform when a platform part state changes.
Definition WsfXIO_RemotePlatformList.hpp:141
WsfXIO_Interface * mInterfacePtr
Definition WsfXIO_RemotePlatformList.hpp:258
void SetIgnoreExternalPlatforms(bool aIgnore)
Definition WsfXIO_RemotePlatformList.hpp:77
UtCallbackListN< void(WsfXIO_PlatformInfo &)> PlatformAdded
Definition WsfXIO_RemotePlatformList.hpp:131
UtCallbackListN< void(WsfXIO_PlatformInfo &)> RouteUpdated
Definition WsfXIO_RemotePlatformList.hpp:149
double mDefaultDeadReckonInterval
Definition WsfXIO_RemotePlatformList.hpp:272
unsigned int GetConnectionCount() const
Definition WsfXIO_RemotePlatformList.hpp:152
std::multimap< WsfXIO_EntityId, WsfXIO_PlatformInfo * > EntityIdMap
Definition WsfXIO_RemotePlatformList.hpp:50
int mDefaultPlatformInfoLevel
Definition WsfXIO_RemotePlatformList.hpp:271
void SetReliableEntityState(bool aIsReliable)
Definition WsfXIO_RemotePlatformList.hpp:75
PlatformIdMap mPlatforms
Definition WsfXIO_RemotePlatformList.hpp:267
UtCallbackHolder mCallbacks
Definition WsfXIO_RemotePlatformList.hpp:269
double mDefaultMaxDeadReckonOrientationError
Definition WsfXIO_RemotePlatformList.hpp:274
Definition WsfXIO_PacketRegistry.hpp:171
Definition WsfXIO_PacketRegistry.hpp:1118
Definition WsfXIO_SerializeTypes.hpp:64
Copyrights Multiple, All Rights Reserved