1 /*********************************************************************
2 Copyright 2013 Karl Jones
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
8 1. Redistributions of source code must retain the above copyright notice, this
9 list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11 this list of conditions and the following disclaimer in the documentation
12 and/or other materials provided with the distribution.
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 For Further Information Please Contact me at
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 /********************************************************************
32 DIS: (6) 1278.1a - 1998
36 purpose: Time Space Position Information(TSPI).
37 The TSPI PDU shall communicate information about a LE's state
38 vector. This PDU includes state information that is necessary for the receiving
39 simulation applications to represent the issuing LE's location
40 and movement in its own simulation.
42 size: 200 bits / 25 octets - Min size
43 *********************************************************************/
47 #include "KDIS/DataTypes/LE_DeadReckoningParameter.hpp"
48 #include "KDIS/DataTypes/LE_EulerAngles.hpp"
49 #include "KDIS/DataTypes/LE_Vector.hpp"
50 #include "KDIS/DataTypes/OrientationError.hpp"
51 #include "KDIS/DataTypes/PositionError.hpp"
52 #include "KDIS/DataTypes/RelativeWorldCoordinates.hpp"
53 #include "KDIS/PDU/Live_Entity/LE_Header.hpp"
58 class KDIS_EXPORT TSPI_PDU
: public LE_Header
{
62 KUINT8 m_ui8LinVel
: 1;
64 KUINT8 m_ui8PosErr
: 1;
65 KUINT8 m_ui8OriErr
: 1;
69 KUINT8 m_ui8Reserved
: 1;
74 KDIS::DATA_TYPE::RelativeWorldCoordinates m_Loc
;
76 KDIS::DATA_TYPE::LE_Vector16_3 m_LinVel
;
78 KDIS::DATA_TYPE::LE_EulerAngles m_Ori
;
80 KDIS::DATA_TYPE::PositionError m_PosErr
;
82 KDIS::DATA_TYPE::OrientationError m_OriErr
;
84 KDIS::DATA_TYPE::LE_DeadReckoningParameter m_DeadReckoningParameter
;
86 KDIS::DATA_TYPE::KFIXED16_3 m_MeasureSpd
;
90 std::vector
<KOCTET
> m_vSSD
;
93 static const KUINT16 TSPI_PDU_SIZE
=
94 25; // Min size, not including optional fields
98 TSPI_PDU(KDataStream
& stream
);
100 TSPI_PDU(const Header
& H
, KDataStream
& stream
);
102 TSPI_PDU(const KDIS::DATA_TYPE::LE_EntityIdentifier
& ID
);
106 //************************************
107 // FullName: KDIS::PDU::TSPI_PDU::SetEntityLinearVelocityFlag
108 // KDIS::PDU::TSPI_PDU::GetEntityLinearVelocityFlag
109 // KDIS::PDU::TSPI_PDU::SetEntityOrientationFlag
110 // KDIS::PDU::TSPI_PDU::GetEntityOrientationFlag
111 // KDIS::PDU::TSPI_PDU::SetPositionErrorFlag
112 // KDIS::PDU::TSPI_PDU::GetPositionErrorFlag
113 // KDIS::PDU::TSPI_PDU::SetOrientationErrorFlag
114 // KDIS::PDU::TSPI_PDU::GetOrientationErrorFlag
115 // KDIS::PDU::TSPI_PDU::SetDeadReckoningParameterFlag
116 // KDIS::PDU::TSPI_PDU::GetDeadReckoningParameterFlag
117 // KDIS::PDU::TSPI_PDU::SetMeasuredSpeedFlag
118 // KDIS::PDU::TSPI_PDU::GetMeasuredSpeedFlag
119 // KDIS::PDU::TSPI_PDU::SetSystemSpecificDataFlag
120 // KDIS::PDU::TSPI_PDU::GetSystemSpecificDataFlag
121 // Description: These flags are used to indicate which optional fields are
122 // included in the PDU. When setting one of the optional fields
123 // the flag will also be set to true automatically.
124 // Parameter: KBOOL F
125 //************************************
126 void SetEntityLinearVelocityFlag(KBOOL F
);
127 KBOOL
GetEntityLinearVelocityFlag() const;
128 void SetEntityOrientationFlag(KBOOL F
);
129 KBOOL
GetEntityOrientationFlag() const;
130 void SetPositionErrorFlag(KBOOL F
);
131 KBOOL
GetPositionErrorFlag() const;
132 void SetOrientationErrorFlag(KBOOL F
);
133 KBOOL
GetOrientationErrorFlag() const;
134 void SetDeadReckoningParameterFlag(KBOOL F
);
135 KBOOL
GetDeadReckoningParameterFlag() const;
136 void SetMeasuredSpeedFlag(KBOOL F
);
137 KBOOL
GetMeasuredSpeedFlag() const;
138 void SetSystemSpecificDataFlag(KBOOL F
);
139 KBOOL
GetSystemSpecificDataFlag() const;
141 //************************************
142 // FullName: KDIS::PDU::TSPI_PDU::SetEntityLocation
143 // KDIS::PDU::TSPI_PDU::GetEntityLocation
144 // Description: The entity's physical location in the real world.
145 // Each delta distance component shall represent distance in
147 // Parameter: const RelativeWorldCoordinates & L
148 //************************************
149 void SetEntityLocation(const KDIS::DATA_TYPE::RelativeWorldCoordinates
& L
);
150 const KDIS::DATA_TYPE::RelativeWorldCoordinates
& GetEntityLocation() const;
151 KDIS::DATA_TYPE::RelativeWorldCoordinates
& GetEntityLocation();
153 //************************************
154 // FullName: KDIS::PDU::TSPI_PDU::SetEntityLinearVelocity
155 // KDIS::PDU::TSPI_PDU::GetEntityLinearVelocity
156 // Description: Optional field. Specifies an entity's linear velocity.
157 // The coordinate system for an entity's linear velocity depends
158 // on the dead reckoning algorithm used. Each vector component
159 // shall represent velocity in decimeters per second. Note:
160 // Setting this value will also cause the relevant flag to be set
162 // Parameter: const LE_Vector16_3 & V
163 //************************************
164 void SetEntityLinearVelocity(const KDIS::DATA_TYPE::LE_Vector16_3
& V
);
165 const KDIS::DATA_TYPE::LE_Vector16_3
& GetEntityLinearVelocity() const;
166 KDIS::DATA_TYPE::LE_Vector16_3
& GetEntityLinearVelocity();
168 //************************************
169 // FullName: KDIS::PDU::TSPI_PDU::SetEntityLinearOrientation
170 // KDIS::PDU::TSPI_PDU::GetEntityLinearOrientation
171 // Description: Optional field. The entity's orientation.
172 // Note: Setting this value will also cause the relevant flag to
174 // Parameter: const LE_EulerAngles & O
175 //************************************
176 void SetEntityLinearOrientation(const KDIS::DATA_TYPE::LE_EulerAngles
& O
);
177 const KDIS::DATA_TYPE::LE_EulerAngles
& GetEntityLinearOrientation() const;
178 KDIS::DATA_TYPE::LE_EulerAngles
& GetEntityLinearOrientation();
180 //************************************
181 // FullName: KDIS::PDU::TSPI_PDU::SetPositionError
182 // KDIS::PDU::TSPI_PDU::GetPositionError
183 // Description: Optional field. Specifies the potential horizontal and
185 // position error of the reporting entity.
186 // Note: Setting this value will also cause the relevant flag to
188 // Parameter: const PositionError & PE
189 //************************************
190 void SetPositionError(const KDIS::DATA_TYPE::PositionError
& PE
);
191 const KDIS::DATA_TYPE::PositionError
& GetPositionError() const;
192 KDIS::DATA_TYPE::PositionError
& GetPositionError();
194 //************************************
195 // FullName: KDIS::PDU::TSPI_PDU::SetOrientationError
196 // KDIS::PDU::TSPI_PDU::GetOrientationError
197 // Description: Optional field. Specifies the potential orientation error of
198 // the reporting entity.
199 // Note: Setting this value will also cause the relevant flag to
201 // Parameter: const OrientationError & OE
202 //************************************
203 void SetOrientationError(const KDIS::DATA_TYPE::OrientationError
& OE
);
204 const KDIS::DATA_TYPE::OrientationError
& GetOrientationError() const;
205 KDIS::DATA_TYPE::OrientationError
& GetOrientationError();
207 //************************************
208 // FullName: KDIS::PDU::TSPI_PDU::SetDeadReckoningParameter
209 // KDIS::PDU::TSPI_PDU::GetDeadReckoningParameter
210 // Description: Optional field. Dead reckoning algorithm in use, entity linear
211 // acceleration (optional based
212 // on dead reckoning algorithm in use), and entity angular
213 // velocity (optional based on dead reckoning algorithm in use)
214 // shall be included as part of the dead reckoning parameters. If
215 // the Dead Reckoning Parameters field is not included in the
216 // PDU, the recipient shall assume the use of a linear dead
217 // reckoning algorithm [DRM (FPW)] and shall assume all angular
218 // velocity and linear acceleration parameters to be zero. Note:
219 // Setting this value will also cause the relevant flag to be set
221 // Parameter: const DeadReckoningParameter & DRP
222 //************************************
223 void SetDeadReckoningParameter(
224 const KDIS::DATA_TYPE::LE_DeadReckoningParameter
& DRP
);
225 const KDIS::DATA_TYPE::LE_DeadReckoningParameter
& GetDeadReckoningParameter()
227 KDIS::DATA_TYPE::LE_DeadReckoningParameter
& GetDeadReckoningParameter();
229 //************************************
230 // FullName: KDIS::PDU::TSPI_PDU::SetMeasuredSpeed
231 // KDIS::PDU::TSPI_PDU::GetMeasuredSpeed
232 // Description: Optional field. Specifies the entity's own measurement of
233 // speed (e.g., air speed for aircraft).
234 // Speed in deci-meters per second.
235 // Note: The position of the binary point is not defined in the
236 // standard for this parameter so I have assumed it is 3. Note:
237 // Setting this value will also cause the relevant flag to be set
239 // Parameter: KFIXED16_3 S
240 //************************************
241 void SetMeasuredSpeed(KDIS::DATA_TYPE::KFIXED16_3 S
);
242 KDIS::DATA_TYPE::KFIXED16_3
GetMeasuredSpeed() const;
244 //************************************
245 // FullName: KDIS::PDU::TSPI_PDU::GetSystemSpecificDataLength
246 // Description: The number of octets of system-specific data stored in this
248 //************************************
249 KUINT8
GetSystemSpecificDataLength() const;
251 //************************************
252 // FullName: KDIS::PDU::TSPI_PDU::SetSystemSpecificData
253 // KDIS::PDU::TSPI_PDU::SetSystemSpecificData
254 // KDIS::PDU::TSPI_PDU::ClearSystemSpecificData
255 // Description: Optional. User-defined data.
256 // The contents of this field are arbitrary and outside the
257 // bounds of the DIS specification with the exception that no
258 // data shall be transmitted in this field that duplicates or can
259 // be derived from the data transmitted in this or other LE
260 // Information/Interaction PDU. Note: Setting this value will
261 // also cause the relevant flag to be set to true.
262 // Parameter: const vector<KOCTET> & SSD, const KOCTET * Data
263 // Parameter: KUINT8 Length
264 //************************************
265 void SetSystemSpecificData(const std::vector
<KOCTET
>& SSD
);
266 void SetSystemSpecificData(const KOCTET
* Data
, KUINT8 Length
);
267 const std::vector
<KOCTET
>& GetSystemSpecificData() const;
268 void ClearSystemSpecificData();
270 //************************************
271 // FullName: KDIS::PDU::TSPI_PDU::GetAsString
272 // Description: Returns a string representation of the PDU
273 //************************************
274 virtual KString
GetAsString() const;
276 //************************************
277 // FullName: KDIS::PDU::TSPI_PDU::Decode
278 // Description: Convert From Network Data.
279 // Parameter: KDataStream & stream
280 // Parameter: bool ignoreHeader = false - Decode the header from the stream?
281 //************************************
282 virtual void Decode(KDataStream
& stream
, bool ignoreHeader
= false);
284 //************************************
285 // FullName: KDIS::PDU::TSPI_PDU::Encode
286 // Description: Convert To Network Data.
287 // Parameter: KDataStream & stream
288 //************************************
289 virtual KDataStream
Encode() const;
290 virtual void Encode(KDataStream
& stream
) const;
292 KBOOL
operator==(const TSPI_PDU
& Value
) const;
293 KBOOL
operator!=(const TSPI_PDU
& Value
) const;
296 } // END namespace PDU
297 } // END namespace KDIS