KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LE_Fire_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_Fire_PDU
32  DIS: (6) 1278.1a - 1998
33  created: 20/08/2010
34  author: Karl Jones
35 
36  purpose:
37  size: 280 bits / 35 octets - Min size
38 *********************************************************************/
39 
40 #pragma once
41 
42 #include "./LE_Header.h"
43 #include "./../../DataTypes/RelativeWorldCoordinates.h"
44 #include "./../../DataTypes/MunitionDescriptor.h"
45 #include "./../../DataTypes/RelativeWorldCoordinates.h"
46 #include "./../../DataTypes/LE_Vector.h"
47 
48 namespace KDIS {
49 namespace PDU {
50 
52 {
53 protected:
54 
55  union
56  {
57  struct
58  {
59  KUINT8 m_ui8TargetId : 1;
60  KUINT8 m_ui8MunitionSiteApp : 1;
61  KUINT8 m_ui8MunitionId : 1;
62  KUINT8 m_ui8EventSiteAppId : 1;
63  KUINT8 m_ui8WarheadFuse : 1;
64  KUINT8 m_ui8QuantRate : 1;
65  KUINT8 m_ui8Location : 1;
66  KUINT8 m_ui8Reserved : 1;
67  };
69  } m_FireFlagUnion;
70 
72 
74 
76 
78 
80 
82 
84 
85  //************************************
86  // FullName: KDIS::PDU::LE_Header::checkSiteApplicationFlags
87  //!Description: Checks the site and application values to see if we need to include them during
88  //! encoding. The values are set when the set id functions are called however it is
89  //! possible that a change may have occurred since, I.E by calling the GetID function
90  //! and setting through it.
91  //************************************
92  void checkSiteApplicationFlags();
93 
94 public:
95 
96  static const KUINT16 LE_FIRE_PDU_SIZE = 35; // Min size, not including optional fields
97 
98  LE_Fire_PDU();
99 
100  LE_Fire_PDU( KDataStream & stream ) throw( KException );
101 
102  LE_Fire_PDU( const Header & H, KDataStream & stream ) throw( KException );
103 
105 
106  virtual ~LE_Fire_PDU();
107 
108  //************************************
109  // FullName: KDIS::PDU::LE_Fire_PDU::SetTargetEntityIDFlag
110  // KDIS::PDU::LE_Fire_PDU::GetTargetEntityIDFlag
111  // KDIS::PDU::LE_Fire_PDU::SetMunitionEntityIDFlag
112  // KDIS::PDU::LE_Fire_PDU::GetMunitionEntityIDFlag
113  // KDIS::PDU::LE_Fire_PDU::SetMunitionEntityIDSiteAppIncludedFlag
114  // KDIS::PDU::LE_Fire_PDU::GetMunitionEntityIDSiteAppIncludedFlag
115  // KDIS::PDU::LE_Fire_PDU::SetEventIDSiteAppIncludedFlag
116  // KDIS::PDU::LE_Fire_PDU::GetEventIDSiteAppIncludedFlag
117  // KDIS::PDU::LE_Fire_PDU::SetWarheadFuseFlag
118  // KDIS::PDU::LE_Fire_PDU::GetWarheadFuseFlag
119  // KDIS::PDU::LE_Fire_PDU::SetQuantityRateFlag
120  // KDIS::PDU::LE_Fire_PDU::GetQuantityRateFlag
121  // KDIS::PDU::LE_Fire_PDU::SetLocationFlag
122  // KDIS::PDU::LE_Fire_PDU::GetLocationFlag
123  //!Description: Identifies optional data fields that are being transmitted with
124  //! this PDU.
125  // Parameter: KBOOL F
126  //************************************
127  void SetTargetEntityIDFlag( KBOOL F );
128  KBOOL GetTargetEntityIDFlag() const;
129  void SetMunitionEntityIDFlag( KBOOL F );
130  KBOOL GetMunitionEntityIDFlag() const;
131  void SetMunitionEntityIDSiteAppIncludedFlag( KBOOL F );
132  KBOOL GetMunitionEntityIDSiteAppIncludedFlag() const;
133  void SetEventIDSiteAppIncludedFlag( KBOOL F );
134  KBOOL GetEventIDSiteAppIncludedFlag() const;
135  void SetWarheadFuseFlag( KBOOL F );
136  KBOOL GetWarheadFuseFlag() const;
137  void SetQuantityRateFlag( KBOOL F );
138  KBOOL GetQuantityRateFlag() const;
139  void SetLocationFlag( KBOOL F );
140  KBOOL GetLocationFlag() const;
141 
142  //************************************
143  // FullName: KDIS::PDU::LE_Header::SetTargetEntityID
144  // KDIS::PDU::LE_Header::GetTargetEntityID
145  //!Description: Optional field.The intended target. If the intended target is unknown, this field
146  //! shall not be included in the PDU however, the Location field shall be present.
147  //! Note: Setting this value will also cause the relevant flag to be set to true.
148  // Parameter: const LE_EntityIdentifier & ID
149  //************************************
150  void SetTargetEntityID( const KDIS::DATA_TYPE::LE_EntityIdentifier & ID );
151  const KDIS::DATA_TYPE::LE_EntityIdentifier & GetTargetEntityID() const;
152  KDIS::DATA_TYPE::LE_EntityIdentifier & GetTargetEntityID();
153 
154  //************************************
155  // FullName: KDIS::PDU::LE_Fire_PDU::SetMunitionEntityID
156  // KDIS::PDU::LE_Fire_PDU::GetMunitionEntityID
157  //!Description: Optional field. Identifies the fired munition if tracking data is required.
158  //! If tracking data for the munition are not required, this field
159  //! shall not be included in the PDU.
160  //! If the Site Number and Application Number fields are the same as
161  //! those in the Firing Entity ID, they shall not be included;
162  //! and the associated Fire Flag field bit will be set to zero.
163  //! Note: Setting this value will also cause the relevant flags to be set to true.
164  //! A check is automatically made when encoding to see if the site/app fields match the
165  //! firing entity and the relevant flags are set accordingly.
166  // Parameter: const LE_EntityIdentifier & ID
167  //************************************
168  void SetMunitionEntityID( const KDIS::DATA_TYPE::LE_EntityIdentifier & ID );
169  const KDIS::DATA_TYPE::LE_EntityIdentifier & GetMunitionEntityID() const;
170  KDIS::DATA_TYPE::LE_EntityIdentifier & GetMunitionEntityID();
171 
172  //************************************
173  // FullName: KDIS::PDU::LE_Fire_PDU::SetEventID
174  // KDIS::PDU::LE_Fire_PDU::GetEventID
175  //!Description: Contains an identification generated by the firing entity to associate related
176  //! firing and detonation events.
177  //! If the Site Number and Application Number are the same as those in the
178  //! Firing Entity ID, they will not be included.
179  //! Note: Setting this value will also cause the relevant flags to be set to true.
180  //! A check is automatically made when encoding to see if the site/app fields match the
181  //! firing entity and the relevant flags are set accordingly.
182  // Parameter: const LE_EntityIdentifier & ID
183  //************************************
184  void SetEventID( const KDIS::DATA_TYPE::LE_EntityIdentifier & ID );
185  const KDIS::DATA_TYPE::LE_EntityIdentifier & GetEventID() const;
187 
188  //************************************
189  // FullName: KDIS::PDU::LE_Fire_PDU::SetEntityLocation
190  // KDIS::PDU::LE_Fire_PDU::GetEntityLocation
191  //!Description: Optional field. Location from which the munition was launched.
192  //! This field is optional if the Target Entity ID is provided and mandatory
193  //! if the Target Entity ID field is not included in the PDU.
194  //! If the Location field is not included in the PDU, the firing location
195  //! shall be the current dead reckoned location of the firing entity.
196  // Parameter: const RelativeWorldCoordinates & L
197  //************************************
198  void SetLocation( const KDIS::DATA_TYPE::RelativeWorldCoordinates & L );
199  const KDIS::DATA_TYPE::RelativeWorldCoordinates & GetLocation() const;
201 
202  //************************************
203  // FullName: KDIS::PDU::LE_Fire_PDU::SetMunitionDescriptor
204  // KDIS::PDU::LE_Fire_PDU::GetMunitionDescriptor
205  //!Description: Describes the type of munition fired, warhead, fuse, quantity,
206  //! and rate. The warhead, fuse, quantity, and rate fields of this record
207  //! are optional. If you wish to have them included then the relevant flag field must be set:
208  //! void SetWarheadFuseFlag( true ) - To include Warhead and fuse fields.
209  //! void SetQuantityRateFlag( true ) - To include Quantity and Rate fields.
210  //! This field is also known as the BurstDescriptor in older versions of the DIS standard.
211  // Parameter: const MunitionDescriptor & MD
212  //************************************
213  void SetMunitionDescriptor( const KDIS::DATA_TYPE::MunitionDescriptor & MD );
214  const KDIS::DATA_TYPE::MunitionDescriptor & GetMunitionDescriptor() const;
215  KDIS::DATA_TYPE::MunitionDescriptor & GetMunitionDescriptor();
216 
217  //************************************
218  // FullName: KDIS::PDU::LE_Fire_PDU::SetVelocity
219  // KDIS::PDU::LE_Fire_PDU::GetVelocity
220  //!Description: Specifies the velocity of the fired munition at the point when the
221  //! issuing simulation application intends the externally visible effects
222  //! of the launch (e.g., exhaust plume or muzzle blast) to first become
223  //! apparent. In decimeters per second.
224  // Parameter: const LE_Vector16_3 & V
225  //************************************
226  void SetVelocity( const KDIS::DATA_TYPE::LE_Vector16_3 & V );
227  const KDIS::DATA_TYPE::LE_Vector16_3 & GetVelocity() const;
228  KDIS::DATA_TYPE::LE_Vector16_3 & GetVelocity();
229 
230  //************************************
231  // FullName: KDIS::PDU::LE_Fire_PDU::SetRange
232  // KDIS::PDU::LE_Fire_PDU::GetRange
233  //!Description: Range in meters that an entity�s fire control system has assumed in
234  //! computing the fire control solution. For systems where range is
235  //! unknown or unavailable, this field shall contain the value zero.
236  // Parameter: KUINT16 R
237  //************************************
238  void SetRange( KUINT16 R );
239  KUINT16 GetRange() const;
240 
241  //************************************
242  // FullName: KDIS::PDU::LE_Fire_PDU::GetAsString
243  //!Description: Returns a string representation of the PDU
244  //************************************
245  virtual KString GetAsString() const;
246 
247  //************************************
248  // FullName: KDIS::PDU::LE_Fire_PDU::Decode
249  //!Description: Convert From Network Data.
250  // Parameter: KDataStream & stream
251  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
252  //************************************
253  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
254 
255  //************************************
256  // FullName: KDIS::PDU::LE_Fire_PDU::Encode
257  //!Description: Convert To Network Data.
258  // Parameter: KDataStream & stream
259  //************************************
260  virtual KDataStream Encode() const;
261  virtual void Encode( KDataStream & stream ) const;
262 
263  KBOOL operator == ( const LE_Fire_PDU & Value ) const;
264  KBOOL operator != ( const LE_Fire_PDU & Value ) const;
265 };
266 
267 } // END namespace PDU
268 } // END namespace KDIS
Definition: LE_Vector.h:48
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: KDefines.h:182
KUINT8 m_ui8Flag
Definition: LE_Fire_PDU.h:68
Definition: RelativeWorldCoordinates.h:47
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
Definition: MunitionDescriptor.h:48
KDIS::DATA_TYPE::LE_EntityIdentifier m_TargetID
Definition: LE_Fire_PDU.h:71
KUINT16 m_ui16Range
Definition: LE_Fire_PDU.h:83
std::string KString
Definition: KDefines.h:116
KDIS::DATA_TYPE::MunitionDescriptor m_MunitionDesc
Definition: LE_Fire_PDU.h:77
KDIS::DATA_TYPE::LE_Vector16_3 m_Vel
Definition: LE_Fire_PDU.h:81
Definition: Header7.h:142
Definition: LE_Header.h:49
unsigned char KUINT8
Definition: KDefines.h:99
KDIS::DATA_TYPE::RelativeWorldCoordinates m_Loc
Definition: LE_Fire_PDU.h:79
#define KDIS_EXPORT
Definition: KDefines.h:82
KDIS::DATA_TYPE::LE_EntityIdentifier m_MunitionID
Definition: LE_Fire_PDU.h:73
KDIS::DATA_TYPE::LE_EntityIdentifier m_EventID
Definition: LE_Fire_PDU.h:75
Definition: LE_Fire_PDU.h:51
Definition: LE_EntityIdentifier.h:48