WSF
Interface.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI//REL TO USA ONLY
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#ifndef L16_LINK16INTERFACE_HPP
12#define L16_LINK16INTERFACE_HPP
13
14#include <list>
15#include <map>
16#include <set>
17#include <utility>
18
19class UtInput;
20#include "DisEntityId.hpp"
21#include "HeaderTDL.hpp"
22#include "Interface_J11.hpp"
23#include "MessagesPreDef.hpp"
24#include "UtCallback.hpp"
25#include "UtCallbackHolder.hpp"
26class WsfDisInterface;
27class WsfDisSignal;
28class DisTransmitter;
29#include "WsfEvent.hpp"
30class WsfPlatform;
32#include "WsfTrack.hpp"
33
34namespace wsf
35{
36namespace comm
37{
38class Comm;
39}
40} // namespace wsf
41
42#ifdef _WIN32
43#undef GetCurrentTime // avoid conflict with windows macro
44#endif
45
46namespace WsfL16
47{
49class SlotParameters;
50
52{
58
64
65 InterfaceSetup(WsfScenario& aScenario);
66 bool ProcessInput(UtInput& aInput);
67 void PrintScriptUsage();
69 bool SetNPGTable(int aMsgType, int aNPG);
70 bool IsRequested() const { return mIsRequested; }
71
72
77 Messages::HeaderTDL100 mHeaderTDL100;
78 Messages::WSF_HeaderTDL100 mWSF_HeaderTDL100;
80 Messages::HeaderTDL100 mTdlHeader;
88 bool mIncludeJ3xTrackDEI; // Set true to include J3.X DIS Entity Id
89 std::map<unsigned, WsfStringId> mAirPlatformTypes; // from air specific types
90 std::map<WsfStringId, unsigned> mAirSpecificTypes; // from platform type
91 std::map<unsigned, WsfStringId> mLandPlatformTypes; // from land specific types
92 std::map<WsfStringId, unsigned> mLandSpecificTypes; // from platform type
93
95
97 {
98 public:
99 bool IsFiltered(int aLabel, int aSublabel);
100
102 std::set<std::pair<int, int>> mFilteredSpecificTypes;
103 };
104
105 std::map<size_t, MessageFilter> mPlatformFilters;
107
108 std::set<std::pair<int, int>> mNPGTable;
109
111};
112
116{
117public:
118 Interface(InterfaceSetup& aScenario);
119 void AddedToSimulation() override;
120
121 ~Interface() override;
122
123 bool Initialize() override;
124
125 // These callbacks allow other interfaces (e.g. JREAP) to send/receive JMessages
126 // through the WsfL16 interface
127 UtCallbackListN<void(double, const WsfL16::Messages::InitialBase&)> JMessageReceived;
128 UtCallbackListN<void(const WsfL16::Messages::InitialBase&)> JMessageSent;
129
130 static int GetJ3xIdentityFromIFF(WsfTrack::IFF_Status aIFF_Status);
131 static void SetIFF_FromJ3xIdentity(WsfTrack& aTrack, int aJ3xIdentity);
132
135
136 void SendJMessage(double aSimTime, WsfPlatform& aSender, const Messages::InitialBase* aMessage);
137
138 void SendJMessage(double aSimTime,
139 WsfPlatform& aSender,
140 const Messages::InitialBase* aMessage,
141 const SlotParameters& aSlotParameters);
142
143 void SendRawJMessage(double aSimTime,
144 // WsfPlatform& aSender,
145 WsfPlatform* aSender,
146 const char* aDataPtr,
147 int aMessageBytes,
148 int aNPG);
149
150 void SendUserDefinedJMessage(double aSimTime,
151 WsfPlatform* aSender,
152 unsigned short* aMessage,
153 int aNPG,
154 int aMessageBytes,
155 int aLabel,
156 int aSubLabel,
157 int aNumMsgs);
158
159 void SendUserDefinedJMessage(double aSimTime,
160 WsfPlatform* aSender,
161 unsigned short* aMessage,
162 const SlotParameters& aSlotParameters,
163 int aMessageBytes,
164 int aLabel,
165 int aSubLabel,
166 int aNumMsgs);
167
168 void FilterMessageSend(WsfPlatform& aSenderPlatform, int aLabel, int aSubLabel = -1);
169
170 void UnfilterMessageSend(WsfPlatform& aSenderPlatform, int aLabel, int aSubLabel = -1);
171
172 void FilterMessageSend(WsfPlatform* aSenderPlatform, int aLabel, int aSubLabel = -1);
173
174 void UnfilterMessageSend(WsfPlatform* aSenderPlatform, int aLabel, int aSubLabel = -1);
175
176 unsigned GetAirSpecificType(WsfStringId aPlatformTypeId);
177 unsigned GetLandSpecificType(WsfStringId aPlatformTypeId);
178 WsfStringId GetAirPlatformType(unsigned aAirSpecificTypeId);
179 WsfStringId GetLandPlatformType(unsigned aLandSpecificTypeId);
180
181 WsfDisInterface* GetDisInterface() const { return mDisInterfacePtr; }
182
185
186 using GetWeaponTrackNumbersFn = void (*)(WsfSimulation& aSimulation,
187 size_t aWeaponIndex,
188 unsigned int& aWeaponTrackNumber,
189 unsigned int& aControllerTrackNumber);
190
192 {
193 mGetWeaponTrackNumberFunctionPtr = aFunctionPtr;
194 }
195
196 void GetWeaponTrackNumbers(size_t aWeaponIndex, unsigned int& aWeaponTrackNumber, unsigned int& aControllerTrackNumber);
197
198 static WSF_L16_EXPORT WsfPlatform* GetControllerFromTrackNumber(WsfSimulation* aSimulationPtr,
199 unsigned int aTrackNumber);
200
201 static WSF_L16_EXPORT void SetPlatformTrackNumber(WsfPlatform* aPlatformPtr, unsigned int aTrackNumber);
202
203
205private:
206 bool IsFiltered(WsfPlatform& aPlatform, const Messages::InitialBase* aMsg);
207
208 bool IsFiltered(WsfPlatform* aPlatform, int aLabel, int aSublabel);
209
210
211 void HandleSignalPDU(WsfDisInterface* aInterfacePtr, const WsfDisSignal& aPdu);
212
213 void CreateHeader(double aSimTime, const SlotParameters& aSlotParameters);
214
215 void CreateHeaderWSF(double aSimTime, const SlotParameters& aSlotParameters);
216
217 // unsigned int ConvertWsfSlotNumberToDIS(int aSlotNumber);
218 int ConvertDIS_SlotNumberToWsf(unsigned int aSlotNumber);
219
220 void GetCurrentTime(double aSimTime,
221 unsigned int aWsfSlotIndex,
222 unsigned int& aSecondsSinceJan1_1900,
223 unsigned int& aSecondFraction,
224 unsigned int& aEpoch,
225 unsigned int& aTimeSlotIndex);
226
227 void MessageQueued(double aSimTime, wsf::comm::Comm* aXmtrPtr, const WsfMessage& aMessage, size_t aQueueSize);
228
229 void MessageTransmitted(double aSimTime, wsf::comm::Comm* aXmtrPtr, const WsfMessage& aMessage);
230
231 void MessageTransmitEnded(double aSimTime, wsf::comm::Comm* aXmtrPtr, const WsfMessage& aMessage);
232
233 void MessageTransmittedHeartbeat(double aSimTime, wsf::comm::Comm* aXmtrPtr, const WsfMessage& aMessage);
234
243 void SendTransmitterPDU(double aSimTime,
244 WsfPlatform* aSenderPlatformPtr,
245 DisEntityId aDisEntityId,
246 int aRadioId,
247 unsigned int aStatus);
248
250
251 void WeaponFired(double aSimTime, const WsfWeaponEngagement* aEngagementPtr, const WsfTrack* aTargetTrackPtr);
252
253 void WeaponTerminated(double aSimTime, const WsfWeaponEngagement* aEngagementPtr);
255
256 Interface_J11* mInterface_J11;
257 UtCallbackHolder mCallbacks;
258 WsfDisInterface* mDisInterfacePtr;
259 GetWeaponTrackNumbersFn mGetWeaponTrackNumberFunctionPtr;
260};
261
262} // namespace WsfL16
263
264#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Definition WsfDisInterface.hpp:83
Definition WsfDisSignal.hpp:24
Sends and receives link16 messages.
Definition ComputerProcessor.hpp:50
Definition Interface.hpp:97
bool IsFiltered(int aLabel, int aSublabel)
Definition Interface.cpp:365
std::set< int > mFilteredMessageTypes
Definition Interface.hpp:101
std::set< std::pair< int, int > > mFilteredSpecificTypes
Definition Interface.hpp:102
Definition Interface_J11.hpp:44
WsfL16::Interface_J11 is an interface to DisSignal PDUs conveying J11 messages.
Definition Interface_J11.hpp:79
void FilterMessageSend(WsfPlatform &aSenderPlatform, int aLabel, int aSubLabel=-1)
Definition Interface.cpp:773
static void SetIFF_FromJ3xIdentity(WsfTrack &aTrack, int aJ3xIdentity)
Definition Interface.cpp:450
Interface(InterfaceSetup &aScenario)
Definition Interface.cpp:371
UtCallbackListN< void(double, const WsfL16::Messages::InitialBase &)> JMessageReceived
Definition Interface.hpp:127
void(*)(WsfSimulation &aSimulation, size_t aWeaponIndex, unsigned int & aWeaponTrackNumber, unsigned int & aControllerTrackNumber) GetWeaponTrackNumbersFn
Definition Interface.hpp:186
bool IncludeJ3xTrackDisEntityId()
Returns a boolean used to determine whether or not to include track DIS entity id inside J3....
Definition Interface.hpp:134
unsigned GetLandSpecificType(WsfStringId aPlatformTypeId)
Definition Interface.cpp:1168
WsfDisInterface * GetDisInterface() const
Definition Interface.hpp:181
UtCallbackListN< void(const WsfL16::Messages::InitialBase &)> JMessageSent
Definition Interface.hpp:128
void AddedToSimulation() override
Definition Interface.cpp:381
WsfStringId GetAirPlatformType(unsigned aAirSpecificTypeId)
Definition Interface.cpp:1179
unsigned GetAirSpecificType(WsfStringId aPlatformTypeId)
Definition Interface.cpp:1157
~Interface() override
Definition Interface.cpp:386
void SetWeaponTrackNumbersFunction(GetWeaponTrackNumbersFn aFunctionPtr)
Definition Interface.hpp:191
static WSF_L16_EXPORT void SetPlatformTrackNumber(WsfPlatform *aPlatformPtr, unsigned int aTrackNumber)
Definition Interface.cpp:1457
void SendUserDefinedJMessage(double aSimTime, WsfPlatform *aSender, unsigned short *aMessage, int aNPG, int aMessageBytes, int aLabel, int aSubLabel, int aNumMsgs)
Definition Interface.cpp:659
void SendJMessage(double aSimTime, WsfPlatform &aSender, const Messages::InitialBase *aMessage)
Definition Interface.cpp:630
void GetWeaponTrackNumbers(size_t aWeaponIndex, unsigned int &aWeaponTrackNumber, unsigned int &aControllerTrackNumber)
Definition Interface.cpp:1417
void UnfilterMessageSend(WsfPlatform &aSenderPlatform, int aLabel, int aSubLabel=-1)
Definition Interface.cpp:799
WsfStringId GetLandPlatformType(unsigned aLandSpecificTypeId)
Definition Interface.cpp:1190
static int GetJ3xIdentityFromIFF(WsfTrack::IFF_Status aIFF_Status)
Definition Interface.cpp:426
bool Initialize() override
Definition Interface.cpp:391
static WSF_L16_EXPORT WsfPlatform * GetControllerFromTrackNumber(WsfSimulation *aSimulationPtr, unsigned int aTrackNumber)
Definition Interface.cpp:1427
void SendRawJMessage(double aSimTime, WsfPlatform *aSender, const char *aDataPtr, int aMessageBytes, int aNPG)
Definition Interface.cpp:1024
Definition SlotParameters.hpp:20
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
WsfSimulationExtension()
Definition WsfSimulationExtension.cpp:23
friend class WsfSimulation
Definition WsfSimulationExtension.hpp:43
The main controller for a simulation.
Definition WsfSimulation.hpp:109
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
IFF_Status
An enumeration for IFF.
Definition WsfTrack.hpp:149
Definition WsfWeaponEngagement.hpp:43
Definition WsfComm.hpp:43
This file should be included prior to defining a message. Currently there is a limit of 32 fields per...
Definition AllMessages.hpp:55
Definition WsfComm.cpp:34
Function definitions for those who need run-time access to the version.
Definition WsfComm.cpp:32
bool mIncludeJ3xTrackDEI
Definition Interface.hpp:88
bool SetNPGTable(int aMsgType, int aNPG)
Definition Interface.cpp:355
bool mIsRequested
Definition Interface.hpp:81
std::map< unsigned, WsfStringId > mAirPlatformTypes
Definition Interface.hpp:89
TdlHeaderType mHeaderType
Definition Interface.hpp:73
Messages::HeaderTDL100 mHeaderTDL100
Definition Interface.hpp:77
TdlSwapType mSwapMethod
Definition Interface.hpp:74
double mSecondsSinceMidnight
Definition Interface.hpp:87
bool mFillWith31_7
Definition Interface.hpp:84
bool mIgnoreInboundMessages
Definition Interface.hpp:85
int mSlotOffset
Definition Interface.hpp:79
bool ProcessInput(UtInput &aInput)
Definition Interface.cpp:68
std::map< WsfStringId, unsigned > mLandSpecificTypes
Definition Interface.hpp:92
InterfaceSetup(WsfScenario &aScenario)
Definition Interface.cpp:53
WsfScenario * mWsfSetupPtr
Definition Interface.hpp:110
void PrintScriptUsage()
Scripting language.
Definition Interface.cpp:193
Interface_J11_Setup mInterface_J11_Setup
Definition Interface.hpp:94
bool mSendPPLI
Definition Interface.hpp:83
Messages::WSF_HeaderTDL100 mWSF_HeaderTDL100
Definition Interface.hpp:78
std::map< size_t, MessageFilter > mPlatformFilters
Definition Interface.hpp:105
int mTimeSlotType
Definition Interface.hpp:76
double mSecondsTillSimStartSinceJan1_1900
Definition Interface.hpp:86
std::map< unsigned, WsfStringId > mLandPlatformTypes
Definition Interface.hpp:91
MessageFilter mGlobalFilters
Definition Interface.hpp:106
std::map< WsfStringId, unsigned > mAirSpecificTypes
Definition Interface.hpp:90
bool mDebugEnabled
Definition Interface.hpp:82
Messages::HeaderTDL100 mTdlHeader
Definition Interface.hpp:80
TdlSwapType
Definition Interface.hpp:60
@ cTRAP_TOOL
Definition Interface.hpp:62
@ cWSF
Definition Interface.hpp:61
TdlHeaderType
Definition Interface.hpp:54
@ cTDL_100
Definition Interface.hpp:56
@ cTDL_6
Definition Interface.hpp:55
std::set< std::pair< int, int > > mNPGTable
Definition Interface.hpp:108
int mTSALevel
Definition Interface.hpp:75
void PrintScriptUsageRst()
Definition Interface.cpp:248
bool IsRequested() const
Definition Interface.hpp:70
Copyrights Multiple, All Rights Reserved