WSF
WsfXIO_TrackService.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_TRACKSERVICE_HPP
13#define WSFXIO_TRACKSERVICE_HPP
14
15#include "wsf_export.h"
16
17#include <map>
18#include <set>
19#include <vector>
20
21#include "GenUniqueId.hpp"
22#include "UtCallbackHolder.hpp"
23#include "WsfEvent.hpp"
24class WsfPlatform;
25class WsfSensor;
26class WsfSimulation;
27class WsfTrack;
28#include "WsfTrackId.hpp"
29class WsfTrackManager;
37
39class WSF_EXPORT WsfXIO_TrackService : public WsfXIO_ServiceT<WsfXIO_RequestTracksPkt, WsfXIO_SimService>
40{
41public:
43
44 WsfXIO_TrackService(WsfXIO_Simulation& aXIO_Simulation);
45
46 void SubscriptionCancelledT(WsfXIO_Subscription* aSubscriptionPtr, WsfXIO_RequestTracksPkt& aRequest) override;
47
48private:
49 void SensorTrackCoasted(double aSimTime, WsfSensor* aSensorPtr, const WsfTrack* aTrackPtr);
50 void SensorTrackDropped(double aSimTime, WsfSensor* aSensorPtr, const WsfTrack* aTrackPtr);
51 // void SensorTrackInitiated(double aSimTime,
52 // WsfSensor* aSensorPtr,
53 // const WsfTrack* aTrackPtr);
54 void SensorTrackUpdated(double aSimTime, WsfSensor* aSensorPtr, const WsfTrack* aTrackPtr);
55
56 void UpdateSensorCallbacks();
57
58 // Services requests for track data which do have an update interval.
59 // Sends track data on a regular interval, possibly reducing bandwidth.
60 class UpdateSendEvent : public WsfEvent
61 {
62 public:
63 UpdateSendEvent(WsfXIO_Subscription* aSubscriptionPtr, WsfPlatform* aPlatformPtr);
64 ~UpdateSendEvent() override = default;
65 EventDisposition Execute() override;
66
67 void Disable();
68
69 using TrackIdSet = std::set<WsfTrackId>;
70
71 double mUpdateInterval;
72 bool mEnabled{true};
73 int mRequiredData{0};
74 WsfXIO_Subscription* mSubscriptionPtr;
75 WsfPlatform* mPlatformPtr;
76 WsfTrackManager* mTrackManagerPtr;
77
78 TrackIdSet mLocalUpdateSet;
79 TrackIdSet mLocalDropSet;
80 TrackIdSet mRawUpdateSet;
81 TrackIdSet mRawDropSet;
82
83 UtCallbackHolder mCallbacks;
84 };
85
86 // Services requests for track updates which do not have an update interval.
87 // Sends track data immediately upon update.
88 class PlatformObserver : public WsfXIO_Destination
89 {
90 public:
91 PlatformObserver(WsfPlatform* aPlatformPtr);
92
93 int mRequiredData;
94 WsfPlatform* mPlatformPtr;
95 WsfTrackManager* mTrackManagerPtr;
96 UtCallbackHolder mCallbacks;
97 };
98
99 class SensorObserver : public WsfXIO_Destination
100 {
101 public:
102 int mRequiredData;
103 WsfSensor* mSensorPtr;
104 };
105
106 PlatformObserver* FindPlatformObserver(int aPlatformIndex);
107
108 void HandleRequest(WsfXIO_RequestTracksPkt& aPkt);
109 void HandleExtendedTrackInfoRequest(WsfXIO_ExtendedTrackInfoRequestPkt& aPkt);
110
111 void SelectSensorTracks(WsfXIO_ExtendedTrackInfoPkt& aPkt,
112 const WsfTrackId& aOtherTrackId,
113 std::set<WsfTrackId>& aSelectedTrackIds,
114 std::set<WsfTrackId>& aSearchedTrackIds);
115
116 using PlatformObserverMap = std::map<int, PlatformObserver*>;
117 using SensorObserverMap = std::map<WsfSensor*, SensorObserver*>;
118
119 WsfSimulation& mSimulation;
120 UtCallbackHolder mCallbacks;
121 UtCallbackHolder mSensorCallbacks;
122 PlatformObserverMap mPlatformObservers;
123 SensorObserverMap mSensorObservers;
125 std::vector<UpdateSendEvent*> mUpdateSendEvents;
126};
127
128#endif
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfEvent.hpp:29
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
Definition WsfSensor.hpp:92
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfTrackManager.hpp:62
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
The response from a WsfXIO_ExtendedTrackInfoRequestPkt.
Definition WsfXIO_PacketRegistry.hpp:1374
Used by the IWARS control panel to request the tracks of contributing sensors.
Definition WsfXIO_PacketRegistry.hpp:1359
Requests that an application begin sending track information for a specified platform.
Definition WsfXIO_PacketRegistry.hpp:230
virtual void SubscriptionCancelledT(WsfXIO_Subscription *aSubscriptionPtr, RequestType &aRequest)
Definition WsfXIO_Service.hpp:99
WsfXIO_ServiceT(WsfXIO_Interface *aInterfacePtr)
Definition WsfXIO_Service.hpp:84
Definition WsfXIO_Simulation.hpp:49
A WsfXIO_Subscription wraps information about a remote request for information.
Definition WsfXIO_Subscription.hpp:30
WsfXIO_ServiceT< WsfXIO_RequestTracksPkt, WsfXIO_SimService > BaseClassType
Definition WsfXIO_TrackService.hpp:42
WsfXIO_TrackService(WsfXIO_Simulation &aXIO_Simulation)
Definition WsfXIO_TrackService.cpp:26
Copyrights Multiple, All Rights Reserved