![]() |
VR-Link API Documentation for HLA Evolved
|
VR-Link contains two helper classes, DtLink16Transmitter and DtLink16Signal, which help to fill in RadioTransmitter objects and Signal interactions according to the SISO-STD-002-2006 document.
The values may be filled in the helper class and then a DtSignalInteraction or DtRadioTransmitterRepository may be passed in, so that values will be set in the interaction or state repository. In addition, the helper classes' values may be filled in by a DtSignalInteraction or DtRadioTransmitterRepository that contains Link 16 data.
It should be noted that VR-Link does not provide structures for the actual Link 16 J-words themselves. These can be filled in the data section of the Signal interaction as specified in the Link 16 documentation.
// State Repository/Interaction includes #include <vl/radioXmitSR.h> #include <vl/signalInter.h> // Header files Link 16 helper classes #include <vl/link16Signal.h> #include <vl/link16Transmitter.h> #if DtHLA // FOM Mapping can be set up on the exercise connection's // FOM Mapper #include <vl/exerciseConn.h> #endif // This function demonstrates how the DtLink16Transmitter object // can help the user fill the transmitter state repository. When // initialized, the fidelity level is void fillInTransmitterValues(DtRadioTransmitterRepository* xsr) { // Set the spreadSpectrumType appropriately - this will tell our // transmitter that we are using link16, and the correct attributes // will subsequently be encoded and sent. The default values are as // follows: // myFidelityLevel(0), // myPrimaryMode(1), // mySecondaryMode(0), // mySynchronizationState(0), // myNetworkSynchronizationId(0) xsr->setSpreadSpectrumType(DtJTIDS_MIDS_SpectrumType); // Now that we've got a link16 transmitter, let's set some // values that are different from the defaults. xsr->setFidelityLevel(DtLowFidelityLevel1); xsr->setPrimaryMode(DtJTIDSUnitParticipant); xsr->setSecondaryMode(DtPrimaryNavigationController); xsr->setSynchronizationState(DtCoarseSynchronization); xsr->setNetworkSynchronizationId(12); } // This function demonstrates, on the receiving side, how to retrieve // the Link 16 spreadSpectrum attributes. void retrieveLink16TransmitterValues(DtRadioTransmitterRepository* xsr) { DtU16 tsaLevel = xsr->fidelityLevel(); DtU16 primaryMode = xsr->primaryMode(); DtU16 secondaryMode = xsr->secondaryMode(); DtU16 syncState = xsr->synchronizationState(); int syncId = xsr->networkSynchronizationId(); } #if DtHLA // Some extra FOM Mapping is needed for the Link16 signal classes in HLA. // DtLink16Signal class provides a static method that easily sets up // FOM Mapping for the user. void setUpFomMapping(DtExerciseConn* conn) { DtLink16Signal::setUpRprFomMapper(conn); } #endif // This function demonstrates how to fill Link 16 data into a signal interaction. // When encode is called on the DtLink16Signal, the encoding type of the signal // passed in will be filled with the number of J-words (specified by the user). // The encoding type will be set to raw binary, the TDL type will be set to 100, // and the sample rate and number of samples will be set to 0. The data passed in // should be the actual Link16 message, formatted to be sent to the network. The // Link 16 PDU fields will be set in the signal data preceding the Link 16 message // passed in by the user. void fillInLink16Signal(DtSignalInteraction* inter) { // Test data DtLink16Signal link16Signal; link16Signal.setNpgNumber(2); link16Signal.setNetNumber(5); link16Signal.setTsecCvll(12); link16Signal.setMsecCvll(21); link16Signal.setLink16MessageType(DtRttAB); link16Signal.setTimeIdSlotNumber(1220); link16Signal.setTimeIdEpochNumber(2); link16Signal.setPerceivedTransmitTimeInteger(9660); link16Signal.setPerceivedTransmitTimeFraction(22); char fakeData[8] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8}; // The encode call will actually the set values in the // interaction. The data will come after the Link 16 fields, // and should normally contain a Link 16 message. link16Signal.encode(inter, 4, (void*)fakeData, 8); } // This function demonstrates how to retrieve the data from a signal interaction // and fill it into a DtLink16Singal object. The decode() method // returns a pointer to the data section, past the Link 16 fields, // which should contain a Link 16 message. void retrieveLink16SignalValues(DtSignalInteraction* inter) { // The Link 16 fields take up 20 bytes of the data. int dataSize = inter->numDataBytes() - 20; DtLink16Signal link16Signal; void* data = link16Signal.decode(inter); // The link16Signal object now holds the Link 16 field values, // and we have the size of the data, along with a pointer to it, // so it can be translated to Link 16 messages. }