KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LE_Detonation_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: LE_Detonation_PDU
32  DIS: (6) 1278.1a - 1998
33  created: 23/08/2010
34  author: Karl Jones
35 
36  purpose: Communicates the detonation or impact of munitions.
37  size: 320 bits / 40 octets - Min size
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./LE_Header.h"
43 #include "./../../DataTypes/WorldCoordinates.h"
44 #include "./../../DataTypes/RelativeWorldCoordinates.h"
45 #include "./../../DataTypes/LE_Vector.h"
46 #include "./../../DataTypes/LE_EulerAngles.h"
47 #include "./../../DataTypes/MunitionDescriptor.h"
48 
49 namespace KDIS {
50 namespace PDU {
51 
53 {
54 protected:
55 
56  union
57  {
58  struct
59  {
60  KUINT8 m_ui8TargetId : 1;
61  KUINT8 m_ui8MunitionSiteApp : 1;
62  KUINT8 m_ui8MunitionId : 1;
63  KUINT8 m_ui8EventSiteAppId : 1;
64  KUINT8 m_ui8WarheadFuse : 1;
65  KUINT8 m_ui8QuantRate : 1;
66  KUINT8 m_ui8LocationTyp : 1;
67  KUINT8 m_ui8Flag2 : 1;
68  };
70  } m_DetonationFlag1Union;
71 
72  union
73  {
74  struct
75  {
76  KUINT8 m_ui8MunitionOri : 1;
77  KUINT8 m_ui8EventNum : 1;
78  KUINT8 m_ui8Unused : 5;
79  KUINT8 m_ui8Reserved : 1;
80  };
81  KUINT8 m_ui8Flag;
82  } m_DetonationFlag2Union;
83 
85 
87 
89 
92 
94 
96 
98 
100 
101  //************************************
102  // FullName: KDIS::PDU::LE_Detonation_PDU::checkSiteApplicationFlags
103  //!Description: Checks the site and application values to see if we need to include them during
104  //! encoding. The values are set when the set id functions are called however it is
105  //! possible that a change may have occurred since, I.E by calling the GetID function
106  //! and setting through it.
107  //************************************
108  void checkSiteApplicationFlags();
109 
110 public:
111 
112  static const KUINT16 LE_DETONATION_PDU_SIZE = 40; // Min size, not including optional fields
113 
115 
116  LE_Detonation_PDU( KDataStream & stream ) throw( KException );
117 
118  LE_Detonation_PDU( const Header & H, KDataStream & stream ) throw( KException );
119 
121 
122  virtual ~LE_Detonation_PDU();
123 
124  //************************************
125  // FullName: KDIS::PDU::LE_Detonation_PDU::SetTargetEntityIDFlag
126  // KDIS::PDU::LE_Detonation_PDU::GetTargetEntityIDFlag
127  // KDIS::PDU::LE_Detonation_PDU::SetMunitionEntityIDFlag
128  // KDIS::PDU::LE_Detonation_PDU::GetMunitionEntityIDFlag
129  // KDIS::PDU::LE_Detonation_PDU::SetMunitionEntityIDSiteAppIncludedFlag
130  // KDIS::PDU::LE_Detonation_PDU::GetMunitionEntityIDSiteAppIncludedFlag
131  // KDIS::PDU::LE_Detonation_PDU::SetEventIDSiteAppIncludedFlag
132  // KDIS::PDU::LE_Detonation_PDU::GetEventIDSiteAppIncludedFlag
133  // KDIS::PDU::LE_Detonation_PDU::SetWarheadFuseFlag
134  // KDIS::PDU::LE_Detonation_PDU::GetWarheadFuseFlag
135  // KDIS::PDU::LE_Detonation_PDU::SetQuantityRateFlag
136  // KDIS::PDU::LE_Detonation_PDU::GetQuantityRateFlag
137  // KDIS::PDU::LE_Detonation_PDU::SetLocationInEntityCoordinatesFlag
138  // KDIS::PDU::LE_Detonation_PDU::GetLocationInEntityCoordinatesFlag
139  //!Description: Identifies optional data fields that are being transmitted with
140  //! this PDU.
141  //! Notes:
142  //! TargetEntityIDFlag - If the value is true then the location must be
143  //! specified using WorldCoordinates otherwise use RelativeWorldCoordinates.
144  //! LocationInEntityCoordinatesFlag - If the value is true the location class is
145  //! in WorldCoordinates otherwise the location is in RelativeWorldCoordinates.
146  // Parameter: KBOOL F
147  //************************************
148  void SetTargetEntityIDFlag( KBOOL F );
149  KBOOL GetTargetEntityIDFlag() const;
150  void SetMunitionEntityIDFlag( KBOOL F );
151  KBOOL GetMunitionEntityIDFlag() const;
152  void SetMunitionEntityIDSiteAppIncludedFlag( KBOOL F );
153  KBOOL GetMunitionEntityIDSiteAppIncludedFlag() const;
154  void SetEventIDSiteAppIncludedFlag( KBOOL F );
155  KBOOL GetEventIDSiteAppIncludedFlag() const;
156  void SetWarheadFuseFlag( KBOOL F );
157  KBOOL GetWarheadFuseFlag() const;
158  void SetQuantityRateFlag( KBOOL F );
159  KBOOL GetQuantityRateFlag() const;
160  void SetLocationInEntityCoordinatesFlag( KBOOL F );
161  KBOOL GetLocationInEntityCoordinatesFlag() const;
162  void SetFlag2Flag( KBOOL F );
163  KBOOL GetFlag2Flag() const;
164  void SetMunitionOrientationFlag( KBOOL F );
165  KBOOL GetMunitionOrientationFlag() const;
166  void SetEventNumberIncludedFlag( KBOOL F );
167  KBOOL GetEventNumberIncludedFlag() const;
168 
169  //************************************
170  // FullName: KDIS::PDU::LE_Detonation_PDU::SetTargetEntityID
171  // KDIS::PDU::LE_Detonation_PDU::GetTargetEntityID
172  //!Description: Optional field.The intended target. If the intended target is unknown, this field
173  //! shall not be included in the PDU.
174  //! Note: Setting this value will also cause the relevant flag to be set to true.
175  // Parameter: const LE_EntityIdentifier & ID
176  //************************************
177  void SetTargetEntityID( const KDIS::DATA_TYPE::LE_EntityIdentifier & ID );
178  const KDIS::DATA_TYPE::LE_EntityIdentifier & GetTargetEntityID() const;
179  KDIS::DATA_TYPE::LE_EntityIdentifier & GetTargetEntityID();
180 
181  //************************************
182  // FullName: KDIS::PDU::LE_Detonation_PDU::SetMunitionEntityID
183  // KDIS::PDU::LE_Detonation_PDU::GetMunitionEntityID
184  //!Description: Optional field. Identifies the fired munition if tracking data is required.
185  //! If tracking data for the munition are not required, this field
186  //! shall not be included in the PDU.
187  //! If the Site Number and Application Number fields are the same as
188  //! those in the Firing Entity ID, they shall not be included;
189  //! and the associated Flag field bit will be set to zero.
190  //! Note: Setting this value will also cause the relevant flags to be set to true.
191  // Parameter: const LE_EntityIdentifier & ID
192  //************************************
193  void SetMunitionEntityID( const KDIS::DATA_TYPE::LE_EntityIdentifier & ID );
194  const KDIS::DATA_TYPE::LE_EntityIdentifier & GetMunitionEntityID() const;
195  KDIS::DATA_TYPE::LE_EntityIdentifier & GetMunitionEntityID();
196 
197  //************************************
198  // FullName: KDIS::PDU::LE_Detonation_PDU::SetEventID
199  // KDIS::PDU::LE_Detonation_PDU::GetEventID
200  //!Description: Optional field. Should contain the same data as in the Event ID field of the
201  //! LE Fire PDU that communicated the launch of the munition.
202  //! If the detonation is not preceded by a corresponding fire event, then the
203  //! Event ID field shall not be included in the current PDU.
204  //! If the Site Number and Application Number fields are the same as those in the
205  //! Firing Entity ID, they shall not be included.
206  //! Note: Setting this value will also cause the relevant flags to be set to true.
207  //! A check is automatically made when encoding to see if the site/app fields match the
208  //! firing entity and the relevant flags are set accordingly.
209  // Parameter: const LE_EntityIdentifier & ID
210  //************************************
211  void SetEventID( const KDIS::DATA_TYPE::LE_EntityIdentifier & ID );
212  const KDIS::DATA_TYPE::LE_EntityIdentifier & GetEventID() const;
214 
215  //************************************
216  // FullName: KDIS::PDU::LE_Detonation_PDU::SetLocation
217  // KDIS::PDU::LE_Detonation_PDU::SetLocationEntityCoordinates
218  // KDIS::PDU::LE_Detonation_PDU::GetLocationEntityCoordinates
219  // KDIS::PDU::LE_Detonation_PDU::SetLocationWorldCoordinates
220  // KDIS::PDU::LE_Detonation_PDU::GetLocationWorldCoordinates
221  //!Description: The location of the detonation.
222  //! If the Target ID field is included the location will be in EntityCoordinates(LE_Vector16_3),
223  //! This information should be used for damage assessment.
224  //! If the Target ID field is not included then this field will be in WorldCoordinates.
225  //! Note: Setting this value will also cause the relevant flag to be set correctly.
226  // Parameter: const LE_Vector16_3 & L, const RelativeWorldCoordinates & L
227  //************************************
228  void SetLocation( const KDIS::DATA_TYPE::LE_Vector16_3 & L );
229  void SetLocation( const KDIS::DATA_TYPE::RelativeWorldCoordinates & L );
230  void SetLocationEntityCoordinates( const KDIS::DATA_TYPE::LE_Vector16_3 & L );
231  const KDIS::DATA_TYPE::LE_Vector16_3 & GetLocationEntityCoordinates() const;
232  KDIS::DATA_TYPE::LE_Vector16_3 & GetLocationEntityCoordinates();
233  void SetLocationWorldCoordinates( const KDIS::DATA_TYPE::RelativeWorldCoordinates & L );
234  const KDIS::DATA_TYPE::RelativeWorldCoordinates & GetLocationWorldCoordinates() const;
235  KDIS::DATA_TYPE::RelativeWorldCoordinates & GetLocationWorldCoordinates();
236 
237  //************************************
238  // FullName: KDIS::PDU::LE_Detonation_PDU::SetVelocity
239  // KDIS::PDU::LE_Detonation_PDU::GetVelocity
240  //!Description: The velocity of the munition immediately before
241  //! detonation/impact in decimeters per second.
242  // Parameter: const LE_Vector16_3 & V
243  //************************************
244  void SetVelocity( const KDIS::DATA_TYPE::LE_Vector16_3 & V );
245  const KDIS::DATA_TYPE::LE_Vector16_3 & GetVelocity() const;
246  KDIS::DATA_TYPE::LE_Vector16_3 & GetVelocity();
247 
248  //************************************
249  // FullName: KDIS::PDU::LE_Detonation_PDU::SetMunitionOrientation
250  // KDIS::PDU::LE_Detonation_PDU::GetMunitionOrientation
251  //!Description: Optional field. Orientation of the munition in entity based
252  //! coordinates at the time of detonation.
253  //! Note: Setting this value will also cause the relevant flag to be set to true.
254  // Parameter: const LE_EulerAngles & O
255  //************************************
256  void SetMunitionOrientation( const KDIS::DATA_TYPE::LE_EulerAngles & O );
257  const KDIS::DATA_TYPE::LE_EulerAngles & GetMunitionOrientation() const;
258  KDIS::DATA_TYPE::LE_EulerAngles & GetMunitionOrientation();
259 
260  //************************************
261  // FullName: KDIS::PDU::LE_Detonation_PDU::SetMunitionDescriptor
262  // KDIS::PDU::LE_Detonation_PDU::GetMunitionDescriptor
263  //!Description: Describes the type of munition fired, warhead, fuse, quantity,
264  //! and rate. The warhead, fuse, quantity, and rate fields of this record
265  //! are optional. If you wish to have them included then the relevant flag field must be set:
266  //! void SetWarheadFuseFlag( true ) - To include Warhead and fuse fields.
267  //! void SetQuantityRateFlag( true ) - To include Quantity and Rate fields.
268  //! This field is also known as the BurstDescriptor in older versions of the DIS standard.
269  // Parameter: const MunitionDescriptor & MD
270  //************************************
271  void SetMunitionDescriptor( const KDIS::DATA_TYPE::MunitionDescriptor & MD );
272  const KDIS::DATA_TYPE::MunitionDescriptor & GetMunitionDescriptor() const;
273  KDIS::DATA_TYPE::MunitionDescriptor & GetMunitionDescriptor();
274 
275  //************************************
276  // FullName: KDIS::PDU::LE_Detonation_PDU::SetDetonationResult
277  // KDIS::PDU::LE_Detonation_PDU::GetDetonationResult
278  //!Description: Represents the result of the detonation.
279  // Parameter: DetonationResult DR
280  //************************************
281  void SetDetonationResult( KDIS::DATA_TYPE::ENUMS::DetonationResult DR );
282  KDIS::DATA_TYPE::ENUMS::DetonationResult GetDetonationResult() const;
283 
284  //************************************
285  // FullName: KDIS::PDU::LE_Detonation_PDU::GetAsString
286  //!Description: Returns a string representation of the PDU
287  //************************************
288  virtual KString GetAsString() const;
289 
290  //************************************
291  // FullName: KDIS::PDU::LE_Detonation_PDU::Decode
292  //!Description: Convert From Network Data.
293  // Parameter: KDataStream & stream
294  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
295  //************************************
296  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
297 
298  //************************************
299  // FullName: KDIS::PDU::LE_Detonation_PDU::Encode
300  //!Description: Convert To Network Data.
301  // Parameter: KDataStream & stream
302  //************************************
303  virtual KDataStream Encode() const;
304  virtual void Encode( KDataStream & stream ) const;
305 
306  KBOOL operator == ( const LE_Detonation_PDU & Value ) const;
307  KBOOL operator != ( const LE_Detonation_PDU & Value ) const;
308 };
309 
310 } // END namespace PDU
311 } // END namespace KDIS
Definition: LE_Vector.h:48
Definition: LE_Detonation_PDU.h:52
KDIS::DATA_TYPE::LE_EulerAngles m_Ori
Definition: LE_Detonation_PDU.h:95
KDIS::DATA_TYPE::LE_EntityIdentifier m_EventID
Definition: LE_Detonation_PDU.h:88
unsigned short int KUINT16
Definition: KDefines.h:101
KDIS::DATA_TYPE::RelativeWorldCoordinates m_LocWrldCoord
Definition: LE_Detonation_PDU.h:91
KUINT8 m_ui8Flag
Definition: LE_Detonation_PDU.h:69
DetonationResult
Definition: EnumDetonationResult.h:54
KDIS::DATA_TYPE::LE_Vector16_3 m_LocEntCoord
Definition: LE_Detonation_PDU.h:90
KUINT8 m_ui8DetonationResult
Definition: LE_Detonation_PDU.h:99
Definition: KDefines.h:182
Definition: RelativeWorldCoordinates.h:47
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
Definition: MunitionDescriptor.h:48
std::string KString
Definition: KDefines.h:116
KDIS::DATA_TYPE::MunitionDescriptor m_MunitionDesc
Definition: LE_Detonation_PDU.h:97
KDIS::DATA_TYPE::LE_EntityIdentifier m_MunitionID
Definition: LE_Detonation_PDU.h:86
Definition: Header7.h:142
Definition: LE_Header.h:49
unsigned char KUINT8
Definition: KDefines.h:99
#define KDIS_EXPORT
Definition: KDefines.h:82
KDIS::DATA_TYPE::LE_Vector16_3 m_Vel
Definition: LE_Detonation_PDU.h:93
KDIS::DATA_TYPE::LE_EntityIdentifier m_TargetID
Definition: LE_Detonation_PDU.h:84
Definition: LE_EulerAngles.h:50
Definition: LE_EntityIdentifier.h:48