KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Entity_State_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: Entity_State_PDU
32  DIS: (5) 1278.1 - 1995 & (7) 1278.1-2012
33  updated: 08/03/2013
34  author: Karl Jones
35 
36  purpose: Contains information about a particular entity.
37  size: 1152 bits / 144 octets + 128/16 * Num var Params
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./../Header.h"
43 #include "./../../DataTypes/WorldCoordinates.h"
44 #include "./../../DataTypes/Vector.h"
45 #include "./../../DataTypes/EntityIdentifier.h"
46 #include "./../../DataTypes/EntityType.h"
47 #include "./../../DataTypes/EulerAngles.h"
48 #include "./../../DataTypes/EntityAppearance.h"
49 #include "./../../DataTypes/DeadReckoningParameter.h"
50 #include "./../../DataTypes/EntityMarking.h"
51 #include "./../../DataTypes/EntityCapabilities.h"
52 #include "./../../DataTypes/VariableParameter.h"
53 #include "./../../Extras/DeadReckoningCalculator.h"
54 #include <vector>
55 
56 namespace KDIS {
57 namespace PDU {
58 
60 {
61 protected:
62 
64 
66 
68 
70 
72 
74 
76 
78 
80 
82 
84 
86 
87  std::vector<KDIS::DATA_TYPE::VarPrmPtr> m_vVariableParameters;
88 
90 
91 public:
92 
93  // Min Size not including variable parameters field
94  static const KUINT16 ENTITY_STATE_PDU_SIZE = 144;
95 
97 
98  Entity_State_PDU( KDataStream & stream ) throw( KException );
99 
100  Entity_State_PDU( const Header & H, KDataStream & stream ) throw( KException );
101 
103  const KDIS::DATA_TYPE::EntityType & AltType, const KDIS::DATA_TYPE::Vector & EntityLinearVelocity,
104  const KDIS::DATA_TYPE::WorldCoordinates & EntityLocation, const KDIS::DATA_TYPE::EulerAngles & EntityOrientation,
107 
108  virtual ~Entity_State_PDU();
109 
110  //************************************
111  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityIdentifier
112  // KDIS::PDU::Entity_State_PDU::GetEntityIdentifier
113  //!Description: ID of entity issuing the PDU. This is a unique identifier made up of 3 values. The first 2 represent
114  //! the simulation address.(site, application) and the final is the entity. This ID should be unqiue to the simulation.
115  // Parameter: const EntityIdentifier & EI
116  //************************************
117  void SetEntityIdentifier( const KDIS::DATA_TYPE::EntityIdentifier & EI );
118  const KDIS::DATA_TYPE::EntityIdentifier & GetEntityIdentifier() const;
119  KDIS::DATA_TYPE::EntityIdentifier & GetEntityIdentifier();
120 
121  //************************************
122  // FullName: KDIS::PDU::Entity_State_PDU::SetForceID
123  // KDIS::PDU::Entity_State_PDU::GetForceID
124  //!Description: Force ID. Enumerated value representing the force the entity belongs to,
125  //! such as friendly, opposing or neutral.
126  // Parameter: ForceID ID
127  //************************************
128  void SetForceID( KDIS::DATA_TYPE::ENUMS::ForceID ID );
129  KDIS::DATA_TYPE::ENUMS::ForceID GetForceID() const;
130 
131  //************************************
132  // FullName: KDIS::PDU::Entity_State_PDU::GetNumberOfVariableParams
133  //!Description: Number of variable parameters.
134  //************************************
135  KUINT8 GetNumberOfVariableParams() const;
136 
137  //************************************
138  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityType
139  // KDIS::PDU::Entity_State_PDU::GetEntityType
140  //!Description: Entity Type. Consists of 7 values used to represent
141  //! the type of entity. Please see DIS Enums document found on
142  //! the SISO website for a full list of enumerations available.
143  // Parameter: const EntityType & Type
144  //************************************
145  void SetEntityType( const KDIS::DATA_TYPE::EntityType & Type );
146  const KDIS::DATA_TYPE::EntityType & GetEntityType() const;
147  KDIS::DATA_TYPE::EntityType & GetEntityType();
148 
149  //************************************
150  // FullName: KDIS::PDU::Entity_State_PDU::SetAltEntityType
151  // KDIS::PDU::Entity_State_PDU::GetAltEntityType
152  //!Description: This identifies the entity type to be displayed by members of forces
153  //! other than that of the issuing entity.
154  //! I.E This could be used to represent an entity in disguise.
155  // Parameter: const EntityType & Type
156  //************************************
157  void SetAltEntityType( const KDIS::DATA_TYPE::EntityType & Type );
158  const KDIS::DATA_TYPE::EntityType & GetAltEntityType() const;
159  KDIS::DATA_TYPE::EntityType & GetAltEntityType();
160 
161  //************************************
162  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityLinearVelocity
163  // KDIS::PDU::Entity_State_PDU::GetEntityLinearVelocity
164  //!Description: Represented as Linear Velocity Vector. m/s.
165  // Parameter: const Vector & ELV
166  //************************************
167  void SetEntityLinearVelocity( const KDIS::DATA_TYPE::Vector & ELV );
168  const KDIS::DATA_TYPE::Vector & GetEntityLinearVelocity() const;
169  KDIS::DATA_TYPE::Vector & GetEntityLinearVelocity();
170 
171  //************************************
172  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityLocation
173  // KDIS::PDU::Entity_State_PDU::GetEntityLocation
174  //!Description: Entity Location in Geocentric world coordinates.
175  //! Note: See KConversions.h for some useful coordinate conversions.
176  // Parameter: const WorldCoordinates & EL
177  //************************************
178  void SetEntityLocation( const KDIS::DATA_TYPE::WorldCoordinates & EL );
179  const KDIS::DATA_TYPE::WorldCoordinates & GetEntityLocation() const;
180  KDIS::DATA_TYPE::WorldCoordinates & GetEntityLocation();
181 
182  //************************************
183  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityOrientation
184  // KDIS::PDU::Entity_State_PDU::GetEntityOrientation
185  //!Description: Orientation of entity. Geocentric Euler Angles.
186  //! Note: See KConversions.h for some useful orientation conversions.
187  // Parameter: const EulerAngles & EO
188  //************************************
189  void SetEntityOrientation( const KDIS::DATA_TYPE::EulerAngles & EO );
190  const KDIS::DATA_TYPE::EulerAngles & GetEntityOrientation() const;
191  KDIS::DATA_TYPE::EulerAngles & GetEntityOrientation();
192 
193  //************************************
194  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityAppearance
195  // KDIS::PDU::Entity_State_PDU::GetEntityAppearance
196  //!Description: Entity Appearance.
197  //! Appearance is communicated via a series of bit flags/values. Such as damage states, smoking, on fire etc.
198  //! Note The "Specific Entity Appearance" varies depending on entity type, E.G Air, Ground, Lifeform etc.
199  // Parameter: const EntityAppearance & EA
200  //************************************
201  void SetEntityAppearance( const KDIS::DATA_TYPE::EntityAppearance & EA );
202  const KDIS::DATA_TYPE::EntityAppearance & GetEntityAppearance() const;
203  KDIS::DATA_TYPE::EntityAppearance & GetEntityAppearance();
204 
205  //************************************
206  // FullName: KDIS::PDU::Entity_State_PDU::SetDeadReckoningParameter
207  // KDIS::PDU::Entity_State_PDU::GetDeadReckoningParameter
208  //!Description: Dead Reckoning Parameter. Dead Reckoning is used to provide an estimate of an entities position between PDUs.
209  //! Using dead reckoning an entity can be given the appearance that it is moving smoothly in an environment.
210  //! The dead reckoning values are used to predict where the entity will be within the foreseeable future.
211  //! When a new entity update is received the entities position is corrected via a process called "smoothing".
212  // Parameter: const DeadReckoningParameter & DRP
213  //************************************
214  void SetDeadReckoningParameter( const KDIS::DATA_TYPE::DeadReckoningParameter & DRP );
215  const KDIS::DATA_TYPE::DeadReckoningParameter & GetDeadReckoningParameter() const;
216  KDIS::DATA_TYPE::DeadReckoningParameter & GetDeadReckoningParameter();
217 
218  /************************************************************************/
219  /* Dead reckoning calculator */
220  /************************************************************************/
221 
222  //************************************
223  // FullName: KDIS::PDU::Entity_State_PDU::SetDeadReckoningCalculator
224  // KDIS::PDU::Entity_State_PDU::GetDeadReckoningCalculator
225  //!Description: Set or return the DeadReckoningCalculator object.
226  //! Returns null pointer if InitDeadReckoning has not been called first.
227  // Parameter: const DeadReckoningParameter & DRP
228  //************************************
229  void SetDeadReckoningCalculator( KDIS::UTILS::DeadReckoningCalculator * DR );
230  KDIS::UTILS::DeadReckoningCalculator * GetDeadReckoningCalculator();
231 
232  //************************************
233  // FullName: KDIS::PDU::Entity_State_PDU::InitDeadReckoning
234  //!Description: Initialise the dead reckoning object. Call this first.
235  //************************************
236  void InitDeadReckoning();
237 
238  //************************************
239  // FullName: KDIS::PDU::Entity_State_PDU::ResetDeadReckoning
240  //!Description: Resets the dead reckoning object. For a local entity should be called before sending out
241  //! an entity state PDU so the local entity can dead-reckon itself.
242  //! For a remote entity should be called when an ES PDU is received.
243  //! Note: Nothing will happen if you have not initialised the dead reckoning calculator first.
244  //************************************
245  void ResetDeadReckoning();
246 
247  //************************************
248  // FullName: KDIS::PDU::Entity_State_PDU::ApplyDeadReckoning
249  //!Description: Applies a dead reckoning transformation to the entity for a time step.
250  //! Throws INVALID_OPERATION exception if InitDeadReckoning has not been called first.
251  // Parameter: KFLOAT64 totalTimeSinceDrReset the time since the DR has been reset. Not the simulation time step.
252  //************************************
253  void ApplyDeadReckoning( KFLOAT64 totalTimeSinceDrReset ) throw( KException );
254 
255  /************************************************************************/
256 
257  //************************************
258  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityMarking
259  // KDIS::PDU::Entity_State_PDU::GetEntityMarking
260  //!Description: Entity Marking. This can be the entities name,Army Markings or Chevrons.
261  // Parameter: const EntityMarking & EM
262  //************************************
263  void SetEntityMarking( const KDIS::DATA_TYPE::EntityMarking & EM );
264  const KDIS::DATA_TYPE::EntityMarking & GetEntityMarking() const;
265  KDIS::DATA_TYPE::EntityMarking & GetEntityMarking();
266 
267  //************************************
268  // FullName: KDIS::PDU::Entity_State_PDU::SetEntityCapabilities
269  // KDIS::PDU::Entity_State_PDU::GetEntityCapabilities
270  //!Description: Entity Capabilities. Such as has fuel/ammo supply etc.
271  // Parameter: const EntityCapabilities & EC
272  //************************************
273  void SetEntityCapabilities( const KDIS::DATA_TYPE::EntityCapabilities & EC );
274  const KDIS::DATA_TYPE::EntityCapabilities & GetEntityCapabilities() const;
275  KDIS::DATA_TYPE::EntityCapabilities & GetEntityCapabilities();
276 
277  //************************************
278  // FullName: KDIS::PDU::Entity_State_PDU::AddVariableParameter
279  // KDIS::PDU::Entity_State_PDU::SetVariableParameter
280  // KDIS::PDU::Entity_State_PDU::GetVariableParameters
281  // KDIS::PDU::Entity_State_PDU::ClearVariableParameters
282  //!Description: Information associated with an entity or detonation, not otherwise accounted
283  // for in a PDU such as Articulated and Attached Parts.
284  //! See VariableParameter for supported/implemented types.
285  // Parameter: VarPrmPtr VP, vector<VarPrmPtr> & VP
286  //************************************
287  void AddVariableParameter( KDIS::DATA_TYPE::VarPrmPtr VP );
288  void SetVariableParameters( const std::vector<KDIS::DATA_TYPE::VarPrmPtr> & VP );
289  const std::vector<KDIS::DATA_TYPE::VarPrmPtr> & GetVariableParameters() const;
290  void ClearVariableParameters();
291 
292  //************************************
293  // FullName: KDIS::PDU::Entity_State_PDU::GetAsString
294  //!Description: Returns a string representation of the PDU. Great for debugging!
295  //************************************
296  virtual KString GetAsString() const;
297 
298  //************************************
299  // FullName: KDIS::PDU::Entity_State_PDU::Decode
300  //!Description: Convert From Network Data.
301  // Parameter: KDataStream & stream
302  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
303  //************************************
304  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
305 
306  //************************************
307  // FullName: KDIS::PDU::Entity_State_PDU::Encode
308  //!Description: Convert To Network Data.
309  // Parameter: KDataStream & stream
310  //************************************
311  virtual KDataStream Encode() const;
312  virtual void Encode( KDataStream & stream ) const;
313 
314  KBOOL operator == ( const Entity_State_PDU & Value ) const;
315  KBOOL operator != ( const Entity_State_PDU & Value ) const;
316 };
317 
318 } // END namespace PDU
319 } // END namespace KDIS
Definition: EntityType.h:46
KDIS::DATA_TYPE::EntityCapabilities m_EntityCapabilities
Definition: Entity_State_PDU.h:85
Definition: EntityCapabilities.h:46
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT8 m_ui8ForceID
Definition: Entity_State_PDU.h:65
KDIS::DATA_TYPE::DeadReckoningParameter m_DeadReckoningParameter
Definition: Entity_State_PDU.h:81
KDIS::DATA_TYPE::EulerAngles m_EntityOrientation
Definition: Entity_State_PDU.h:77
KUINT8 m_ui8NumOfVariableParams
Definition: Entity_State_PDU.h:67
KDIS::DATA_TYPE::EntityIdentifier m_EntityID
Definition: Entity_State_PDU.h:63
Definition: Vector.h:71
Definition: KDefines.h:182
KDIS::DATA_TYPE::EntityType m_EntityType
Definition: Entity_State_PDU.h:69
Definition: KDataStream.h:48
Definition: WorldCoordinates.h:52
Definition: EntityAppearance.h:58
bool KBOOL
Definition: KDefines.h:119
KDIS::UTILS::DeadReckoningCalculator * m_pDrCalc
Definition: Entity_State_PDU.h:89
KDIS::DATA_TYPE::WorldCoordinates m_EntityLocation
Definition: Entity_State_PDU.h:75
Definition: EulerAngles.h:46
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
std::vector< KDIS::DATA_TYPE::VarPrmPtr > m_vVariableParameters
Definition: Entity_State_PDU.h:87
KDIS::DATA_TYPE::EntityAppearance m_EntityAppearance
Definition: Entity_State_PDU.h:79
double KFLOAT64
Definition: KDefines.h:114
ForceID
Definition: EnumEntityInfoInteraction.h:886
Definition: Header7.h:142
unsigned char KUINT8
Definition: KDefines.h:99
Definition: DeadReckoningParameter.h:48
Definition: EntityMarking.h:48
#define KDIS_EXPORT
Definition: KDefines.h:82
KDIS::DATA_TYPE::EntityMarking m_EntityMarking
Definition: Entity_State_PDU.h:83
Definition: KRef_Ptr.h:73
Definition: Entity_State_PDU.h:59
KDIS::DATA_TYPE::Vector m_EntityLinearVelocity
Definition: Entity_State_PDU.h:73
Definition: DeadReckoningCalculator.h:238
KDIS::DATA_TYPE::EntityType m_AltEntityType
Definition: Entity_State_PDU.h:71