KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TSPI_PDU.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
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.
13 
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.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  class: TSPI_PDU
32  DIS: (6) 1278.1a - 1998
33  created: 30/06/2010
34  author: Karl Jones
35 
36  purpose: Time Space Position Information(TSPI).
37  The TSPI PDU shall communicate information about a LE�s state vector.
38  This PDU includes state information that is necessary for the receiving
39  simulation applications to represent the issuing LE�s location and
40  movement in its own simulation.
41 
42  size: 200 bits / 25 octets - Min size
43 *********************************************************************/
44 
45 #pragma once
46 
47 #include "./LE_Header.h"
48 #include "./../../DataTypes/RelativeWorldCoordinates.h"
49 #include "./../../DataTypes/LE_Vector.h"
50 #include "./../../DataTypes/LE_EulerAngles.h"
51 #include "./../../DataTypes/PositionError.h"
52 #include "./../../DataTypes/OrientationError.h"
53 #include "./../../DataTypes/LE_DeadReckoningParameter.h"
54 
55 namespace KDIS {
56 namespace PDU {
57 
59 {
60 protected:
61 
62  union
63  {
64  struct
65  {
66  KUINT8 m_ui8LinVel : 1;
67  KUINT8 m_ui8Ori : 1;
68  KUINT8 m_ui8PosErr : 1;
69  KUINT8 m_ui8OriErr : 1;
70  KUINT8 m_ui8DRM : 1;
71  KUINT8 m_ui8Spd : 1;
72  KUINT8 m_ui8Data : 1;
73  KUINT8 m_ui8Reserved : 1;
74  };
76  } m_TSPIFlagUnion;
77 
79 
81 
83 
85 
87 
89 
91 
93 
94  std::vector<KOCTET> m_vSSD;
95 
96 public:
97 
98  static const KUINT16 TSPI_PDU_SIZE = 25; // Min size, not including optional fields
99 
100  TSPI_PDU();
101 
102  TSPI_PDU( KDataStream & stream ) throw( KException );
103 
104  TSPI_PDU( const Header & H, KDataStream & stream ) throw( KException );
105 
107 
108  virtual ~TSPI_PDU();
109 
110  //************************************
111  // FullName: KDIS::PDU::TSPI_PDU::SetEntityLinearVelocityFlag
112  // KDIS::PDU::TSPI_PDU::GetEntityLinearVelocityFlag
113  // KDIS::PDU::TSPI_PDU::SetEntityOrientationFlag
114  // KDIS::PDU::TSPI_PDU::GetEntityOrientationFlag
115  // KDIS::PDU::TSPI_PDU::SetPositionErrorFlag
116  // KDIS::PDU::TSPI_PDU::GetPositionErrorFlag
117  // KDIS::PDU::TSPI_PDU::SetOrientationErrorFlag
118  // KDIS::PDU::TSPI_PDU::GetOrientationErrorFlag
119  // KDIS::PDU::TSPI_PDU::SetDeadReckoningParameterFlag
120  // KDIS::PDU::TSPI_PDU::GetDeadReckoningParameterFlag
121  // KDIS::PDU::TSPI_PDU::SetMeasuredSpeedFlag
122  // KDIS::PDU::TSPI_PDU::GetMeasuredSpeedFlag
123  // KDIS::PDU::TSPI_PDU::SetSystemSpecificDataFlag
124  // KDIS::PDU::TSPI_PDU::GetSystemSpecificDataFlag
125  //!Description: These flags are used to indicate which optional fields are
126  //! included in the PDU. When setting one of the optional fields the
127  //! flag will also be set to true automatically.
128  // Parameter: KBOOL F
129  //************************************
130  void SetEntityLinearVelocityFlag( KBOOL F );
131  KBOOL GetEntityLinearVelocityFlag() const;
132  void SetEntityOrientationFlag( KBOOL F );
133  KBOOL GetEntityOrientationFlag() const;
134  void SetPositionErrorFlag( KBOOL F );
135  KBOOL GetPositionErrorFlag() const;
136  void SetOrientationErrorFlag( KBOOL F );
137  KBOOL GetOrientationErrorFlag() const;
138  void SetDeadReckoningParameterFlag( KBOOL F );
139  KBOOL GetDeadReckoningParameterFlag() const;
140  void SetMeasuredSpeedFlag( KBOOL F );
141  KBOOL GetMeasuredSpeedFlag() const;
142  void SetSystemSpecificDataFlag( KBOOL F );
143  KBOOL GetSystemSpecificDataFlag() const;
144 
145  //************************************
146  // FullName: KDIS::PDU::TSPI_PDU::SetEntityLocation
147  // KDIS::PDU::TSPI_PDU::GetEntityLocation
148  //!Description: The entity�s physical location in the real world.
149  //! Each delta distance component shall represent distance in decimeters.
150  // Parameter: const RelativeWorldCoordinates & L
151  //************************************
152  void SetEntityLocation( const KDIS::DATA_TYPE::RelativeWorldCoordinates & L );
153  const KDIS::DATA_TYPE::RelativeWorldCoordinates & GetEntityLocation() const;
154  KDIS::DATA_TYPE::RelativeWorldCoordinates & GetEntityLocation();
155 
156  //************************************
157  // FullName: KDIS::PDU::TSPI_PDU::SetEntityLinearVelocity
158  // KDIS::PDU::TSPI_PDU::GetEntityLinearVelocity
159  //!Description: Optional field. Specifies an entity�s linear velocity.
160  //! The coordinate system for an entity�s linear velocity depends on the dead
161  //! reckoning algorithm used. Each vector component shall represent velocity
162  //! in decimeters per second.
163  //! Note: Setting this value will also cause the relevant flag to be set to true.
164  // Parameter: const LE_Vector16_3 & V
165  //************************************
166  void SetEntityLinearVelocity( const KDIS::DATA_TYPE::LE_Vector16_3 & V );
167  const KDIS::DATA_TYPE::LE_Vector16_3 & GetEntityLinearVelocity() const;
168  KDIS::DATA_TYPE::LE_Vector16_3 & GetEntityLinearVelocity();
169 
170  //************************************
171  // FullName: KDIS::PDU::TSPI_PDU::SetEntityLinearOrientation
172  // KDIS::PDU::TSPI_PDU::GetEntityLinearOrientation
173  //!Description: Optional field. The entity�s orientation.
174  //! Note: Setting this value will also cause the relevant flag to be set to true.
175  // Parameter: const LE_EulerAngles & O
176  //************************************
177  void SetEntityLinearOrientation( const KDIS::DATA_TYPE::LE_EulerAngles & O );
178  const KDIS::DATA_TYPE::LE_EulerAngles & GetEntityLinearOrientation() const;
179  KDIS::DATA_TYPE::LE_EulerAngles & GetEntityLinearOrientation();
180 
181  //************************************
182  // FullName: KDIS::PDU::TSPI_PDU::SetPositionError
183  // KDIS::PDU::TSPI_PDU::GetPositionError
184  //!Description: Optional field. Specifies the potential horizontal and vertical
185  //! position error of the reporting entity.
186  //! Note: Setting this value will also cause the relevant flag to be set to true.
187  // Parameter: const PositionError & PE
188  //************************************
189  void SetPositionError( const KDIS::DATA_TYPE::PositionError & PE );
190  const KDIS::DATA_TYPE::PositionError & GetPositionError() const;
191  KDIS::DATA_TYPE::PositionError & GetPositionError();
192 
193  //************************************
194  // FullName: KDIS::PDU::TSPI_PDU::SetOrientationError
195  // KDIS::PDU::TSPI_PDU::GetOrientationError
196  //!Description: Optional field. Specifies the potential orientation error of the reporting entity.
197  //! Note: Setting this value will also cause the relevant flag to be set to true.
198  // Parameter: const OrientationError & OE
199  //************************************
200  void SetOrientationError( const KDIS::DATA_TYPE::OrientationError & OE );
201  const KDIS::DATA_TYPE::OrientationError & GetOrientationError() const;
202  KDIS::DATA_TYPE::OrientationError & GetOrientationError();
203 
204  //************************************
205  // FullName: KDIS::PDU::TSPI_PDU::SetDeadReckoningParameter
206  // KDIS::PDU::TSPI_PDU::GetDeadReckoningParameter
207  //!Description: Optional field. Dead reckoning algorithm in use, entity linear acceleration (optional based
208  //! on dead reckoning algorithm in use), and entity angular velocity (optional
209  //! based on dead reckoning algorithm in use) shall be included as part of the
210  //! dead reckoning parameters. If the Dead Reckoning Parameters field is not
211  //! included in the PDU, the recipient shall assume the use of a linear
212  //! dead reckoning algorithm [DRM (FPW)] and shall assume all angular velocity
213  //! and linear acceleration parameters to be zero.
214  //! Note: Setting this value will also cause the relevant flag to be set to true.
215  // Parameter: const DeadReckoningParameter & DRP
216  //************************************
217  void SetDeadReckoningParameter( const KDIS::DATA_TYPE::LE_DeadReckoningParameter & DRP );
218  const KDIS::DATA_TYPE::LE_DeadReckoningParameter & GetDeadReckoningParameter() const;
219  KDIS::DATA_TYPE::LE_DeadReckoningParameter & GetDeadReckoningParameter();
220 
221  //************************************
222  // FullName: KDIS::PDU::TSPI_PDU::SetMeasuredSpeed
223  // KDIS::PDU::TSPI_PDU::GetMeasuredSpeed
224  //!Description: Optional field. Specifies the entity�s own measurement of speed (e.g., air speed for aircraft).
225  //! Speed in deci-meters per second.
226  //! Note: The position of the binary point is not defined in the standard for
227  //! this parameter so I have assumed it is 3.
228  //! Note: Setting this value will also cause the relevant flag to be set to true.
229  // Parameter: KFIXED16_3 S
230  //************************************
231  void SetMeasuredSpeed( KDIS::DATA_TYPE::KFIXED16_3 S );
232  KDIS::DATA_TYPE::KFIXED16_3 GetMeasuredSpeed() const;
233 
234  //************************************
235  // FullName: KDIS::PDU::TSPI_PDU::GetSystemSpecificDataLength
236  //!Description: The number of octets of system-specific data stored in this PDU.
237  //************************************
238  KUINT8 GetSystemSpecificDataLength() const;
239 
240  //************************************
241  // FullName: KDIS::PDU::TSPI_PDU::SetSystemSpecificData
242  // KDIS::PDU::TSPI_PDU::SetSystemSpecificData
243  // KDIS::PDU::TSPI_PDU::ClearSystemSpecificData
244  //!Description: Optional. User-defined data.
245  //! The contents of this field are arbitrary and outside the bounds of the DIS specification
246  //! with the exception that no data shall be transmitted in this field that duplicates or can be derived
247  //! from the data transmitted in this or other LE Information/Interaction PDU.
248  //! Note: Setting this value will also cause the relevant flag to be set to true.
249  // Parameter: const vector<KOCTET> & SSD, const KOCTET * Data
250  // Parameter: KUINT8 Length
251  //************************************
252  void SetSystemSpecificData( const std::vector<KOCTET> & SSD );
253  void SetSystemSpecificData( const KOCTET * Data, KUINT8 Length );
254  const std::vector<KOCTET> & GetSystemSpecificData() const;
255  void ClearSystemSpecificData();
256 
257  //************************************
258  // FullName: KDIS::PDU::TSPI_PDU::GetAsString
259  //!Description: Returns a string representation of the PDU
260  //************************************
261  virtual KString GetAsString() const;
262 
263  //************************************
264  // FullName: KDIS::PDU::TSPI_PDU::Decode
265  //!Description: Convert From Network Data.
266  // Parameter: KDataStream & stream
267  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
268  //************************************
269  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
270 
271  //************************************
272  // FullName: KDIS::PDU::TSPI_PDU::Encode
273  //!Description: Convert To Network Data.
274  // Parameter: KDataStream & stream
275  //************************************
276  virtual KDataStream Encode() const;
277  virtual void Encode( KDataStream & stream ) const;
278 
279  KBOOL operator == ( const TSPI_PDU & Value ) const;
280  KBOOL operator != ( const TSPI_PDU & Value ) const;
281 };
282 
283 } // END namespace PDU
284 } // END namespace KDIS
Definition: LE_Vector.h:48
KDIS::DATA_TYPE::LE_DeadReckoningParameter m_DeadReckoningParameter
Definition: TSPI_PDU.h:88
KDIS::DATA_TYPE::PositionError m_PosErr
Definition: TSPI_PDU.h:84
KDIS::DATA_TYPE::LE_Vector16_3 m_LinVel
Definition: TSPI_PDU.h:80
unsigned short int KUINT16
Definition: KDefines.h:101
KDIS::DATA_TYPE::OrientationError m_OriErr
Definition: TSPI_PDU.h:86
Definition: LE_DeadReckoningParameter.h:50
KUINT8 m_ui8SSDLen
Definition: TSPI_PDU.h:92
Definition: KDefines.h:182
Definition: RelativeWorldCoordinates.h:47
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: Header7.h:142
Definition: OrientationError.h:52
Definition: LE_Header.h:49
unsigned char KUINT8
Definition: KDefines.h:99
KUINT8 m_ui8Flag
Definition: TSPI_PDU.h:75
char KOCTET
Definition: KDefines.h:108
Definition: TSPI_PDU.h:58
KDIS::DATA_TYPE::KFIXED16_3 m_MeasureSpd
Definition: TSPI_PDU.h:90
Definition: PositionError.h:48
KDIS::DATA_TYPE::LE_EulerAngles m_Ori
Definition: TSPI_PDU.h:82
KDIS::DATA_TYPE::RelativeWorldCoordinates m_Loc
Definition: TSPI_PDU.h:78
#define KDIS_EXPORT
Definition: KDefines.h:82
std::vector< KOCTET > m_vSSD
Definition: TSPI_PDU.h:94
Definition: LE_EulerAngles.h:50
Definition: LE_EntityIdentifier.h:48