KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Environmental_Process_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: Environmental_Process_PDU
32  DIS: (6) 1278.1a - 1998 & (7) 1278.1-2012
33  created: 10/08/2009
34  author: Karl Jones
35 
36  purpose: Used to communicate information about environmental effects and processes.
37 
38  size: 256 bits / 32 octets - Min size
39 *********************************************************************/
40 
41 #pragma once
42 
43 #include "./../Header.h"
44 #include "./../../DataTypes/EntityIdentifier.h"
45 #include "./../../DataTypes/EnvironmentType.h"
46 #include "./../../DataTypes/EnvironmentRecord.h"
47 #include "./../../Extras/KRef_Ptr.h"
48 #include <vector>
49 
50 // Geometry records available
51 #include "./../../DataTypes/PointRecord1.h"
52 #include "./../../DataTypes/PointRecord2.h"
53 #include "./../../DataTypes/LineRecord1.h"
54 #include "./../../DataTypes/LineRecord2.h"
55 #include "./../../DataTypes/BoundingSphereRecord.h"
56 #include "./../../DataTypes/SphereRecord1.h"
57 #include "./../../DataTypes/SphereRecord2.h"
58 #include "./../../DataTypes/EllipsoidRecord1.h"
59 #include "./../../DataTypes/EllipsoidRecord2.h"
60 #include "./../../DataTypes/ConeRecord1.h"
61 #include "./../../DataTypes/ConeRecord2.h"
62 #include "./../../DataTypes/RectangularVolumeRecord1.h"
63 #include "./../../DataTypes/RectangularVolumeRecord2.h"
64 #include "./../../DataTypes/RectangularVolumeRecord3.h"
65 #include "./../../DataTypes/GaussianPlumeRecord.h"
66 #include "./../../DataTypes/GaussianPuffRecord.h"
67 
68 // State records available
69 #include "./../../DataTypes/COMBICState.h"
70 #include "./../../DataTypes/FlareState.h"
71 
72 namespace KDIS {
73 namespace PDU {
74 
76 {
77 protected:
78 
80 
82 
84 
85  union
86  {
87  struct
88  {
89  KUINT8 m_ui8EnvStatusBit0 : 1;
90  KUINT8 m_ui8EnvStatusBit1 : 1;
91  KUINT8 m_ui8EnvStatusUnused : 6;
92  };
93 
95  };
96 
98 
100 
101  std::vector<KDIS::DATA_TYPE::EnviromentRecordPtr> m_vEnvRecords;
102 
103 public:
104 
105  static const KUINT16 ENVIROMENTAL_PROCESS_PDU_SIZE = 32; // Min size
106 
108 
109  Environmental_Process_PDU( KDataStream & stream ) throw( KException );
110 
111  Environmental_Process_PDU( const Header & H, KDataStream & stream ) throw( KException );
112 
114  KUINT8 ModelType, KBOOL EnvironmentStatusLast, KBOOL EnvironmentStatusOn,
115  KUINT16 SequenceNumber );
116 
118  KUINT8 ModelType, KBOOL EnvironmentStatusLast, KBOOL EnvironmentStatusOn,
119  KUINT16 SequenceNumber, const std::vector<KDIS::DATA_TYPE::EnviromentRecordPtr> & ERL );
120 
121  virtual ~Environmental_Process_PDU();
122 
123  //************************************
124  // FullName: KDIS::PDU::Environmental_Process_PDU::SetEnvironmentalProcessID
125  // KDIS::PDU::Environmental_Process_PDU::GetEnvironmentalProcessID
126  //!Description: Identifies the environmental process issuing the Environmental Process PDU.
127  // Parameter: const EntityIdentifier & ID
128  //************************************
129  void SetEnvironmentalProcessID( const KDIS::DATA_TYPE::EntityIdentifier & ID );
130  const KDIS::DATA_TYPE::EntityIdentifier & GetEnvironmentalProcessID() const;
131  KDIS::DATA_TYPE::EntityIdentifier & GetEnvironmentalProcessID();
132 
133  //************************************
134  // FullName: KDIS::PDU::Environmental_Process_PDU::SetEnvironmentType
135  // KDIS::PDU::Environmental_Process_PDU::GetEnvironmentType
136  //!Description: DIS enumeration identifying the type of environmental effect being described.
137  // Parameter: const EnvironmentType & ET
138  //************************************
139  void SetEnvironmentType( const KDIS::DATA_TYPE::EnvironmentType & ET );
140  const KDIS::DATA_TYPE::EnvironmentType & GetEnvironmentType() const;
141  KDIS::DATA_TYPE::EnvironmentType & GetEnvironmentType();
142 
143  //************************************
144  // FullName: KDIS::PDU::Environmental_Process_PDU::SetModelType
145  // KDIS::PDU::Environmental_Process_PDU::GetModelType
146  //!Description: Specifies the particular model being used to generate this
147  //! environmental condition or entity.
148  //! values for this enumeration shall be defined by the
149  //! Exercise Manager prior to a simulation exercise.
150  // Parameter: const EnvironmentType & ET
151  //************************************
152  void SetModelType( KUINT8 MT );
153  KUINT8 GetModelType() const;
154 
155  //************************************
156  // FullName: KDIS::PDU::Environmental_Process_PDU::SetEnvironmentStatus
157  // KDIS::PDU::Environmental_Process_PDU::SetEnvironmentStatus
158  // KDIS::PDU::Environmental_Process_PDU::SetEnvironmentStatusLast
159  // KDIS::PDU::Environmental_Process_PDU::SetEnvironmentStatusOn
160  // KDIS::PDU::Environmental_Process_PDU::GetEnvironmentStatus
161  // KDIS::PDU::Environmental_Process_PDU::IsEnvironmentStatusLast
162  // KDIS::PDU::Environmental_Process_PDU::IsEnvironmentStatusOn
163  //!Description: Identifies the status of the environmental condition or entity.
164  //! Represented as a 8 bit boolean array where:
165  //! bit 0 (Last) = Indicates that the current PDU shall be the last PDU for the specified process.
166  //! bit 1 (On) = Indicates that the specified environmental process is active.
167  //! bits 2 - 7 = Unused.
168  // Parameter: KUINT8 ES, KBOOL Last
169  // Parameter: KBOOL On
170  //************************************
171  void SetEnvironmentStatus( KUINT8 ES );
172  void SetEnvironmentStatus( KBOOL Last, KBOOL On );
173  void SetEnvironmentStatusLast( KBOOL L );
174  void SetEnvironmentStatusOn( KBOOL O );
175  KUINT8 GetEnvironmentStatus() const;
176  KBOOL IsEnvironmentStatusLast() const;
177  KBOOL IsEnvironmentStatusOn() const;
178 
179  //************************************
180  // FullName: KDIS::PDU::Environmental_Process_PDU::GetNumberOfEnvironmentRecords
181  //!Description: Returns the number of environment records stored in the PDU.
182  //************************************
183  KUINT16 GetNumberOfEnvironmentRecords() const;
184 
185  //************************************
186  // FullName: KDIS::PDU::Environmental_Process_PDU::SetSequenceNumber
187  // FullName: KDIS::PDU::Environmental_Process_PDU::GetSequenceNumber
188  //!Description: Indicates the PDU sequence number for the environmental process if PDU sequencing is required.
189  //! If PDU sequencing is not required, then this field shall contain EP_NO_SEQUENCE.
190  //! If PDU sequencing is required, this field shall be set to zero for each exercise and sequentially
191  //! incremented by one each time a PDU is issued by an environmental process.
192  //! When all possible values are exhausted, the numbers shall be reused beginning at one.
193  // Parameter: KKUINT16 SN
194  //************************************
195  void SetSequenceNumber( KUINT16 SN );
196  KUINT16 GetSequenceNumber() const;
197 
198  //************************************
199  // FullName: KDIS::PDU::Environmental_Process_PDU::SetEnvironmentRecords
200  // KDIS::PDU::Environmental_Process_PDU::GetEnvironmentRecords
201  // KDIS::PDU::Environmental_Process_PDU::AddEnviromentRecord
202  // KDIS::PDU::Environmental_Process_PDU::ClearEnviromentRecords
203  //!Description: Contains specific geometry, state, or bounding volume information.
204  //! EnviromentRecordLst is a vector of safe pointers(referenced) to EnviromentRecord base classes.
205  //
206  //! - Geometry Records -
207  //! These records describe a geometry within the engagement space. They may also describe the method by
208  //! which that geometry shall be dead reckoned and the parameters used in that dead reckoning.
209  //! If there are multiple geometry records in an Environmental Process PDU, then the first environmental
210  //! record attached to the PDU shall be a bounding volume geometry record. The bounding volume is a
211  //! sphere that encloses all the geometries described by this environmental process. The bounding volume shall
212  //! not be dead reckoned. The bounding volume record is intended to be used for filtering by receiving applications.
213  //! The following geometry records are available in KDIS. You can also create custom ones. See FactoryDecoder example.:
214  //! - PointRecord1
215  //! - PointRecord2
216  //! - LineRecord1
217  //! - LineRecord2
218  //! - BoundingSphereRecord
219  //! - SphereRecord1
220  //! - SphereRecord2
221  //! - EllipsoidRecord1
222  //! - EllipsoidRecord2
223  //! - ConeRecord1
224  //! - ConeRecord2
225  //! - RectangularVolumeRecord1
226  //! - RectangularVolumeRecord2
227  //! - RectangularVolumeRecord3
228  //! - GaussianPlumeRecord
229  //! - GaussianPuffRecord
230  //
231  //! - State Records -
232  //! State records specify the value of environmental parameters within the specified volume or volumes. Each
233  //! state record shall follow the geometry record that describes the region of influence for the parameters contained
234  //! in that state record. They may also describe the method by which that parameter shall be dead reckoned
235  //! and the parameters used in that dead reckoning. If an environmental process is associated with a
236  //! particular entity within the simulation, then the associated Entity Identifier may be included within a state
237  //! record. The state record may also contain the update rate for the environmental model it represents.
238  //! The following state records are available:
239  //! - COMBICState
240  //! - FlareState
241  //
242  // Parameter: const EnviromentRecordLst & ER, void, const EnviromentRecordPtr & ER
243  //************************************
244  void SetEnvironmentRecords( const std::vector<KDIS::DATA_TYPE::EnviromentRecordPtr> & ER );
245  const std::vector<KDIS::DATA_TYPE::EnviromentRecordPtr> & GetEnvironmentRecords() const;
246  void AddEnviromentRecord( KDIS::DATA_TYPE::EnviromentRecordPtr ER );
247  void ClearEnviromentRecords();
248 
249  //************************************
250  // FullName: KDIS::PDU::Environmental_Process_PDU::GetAsString
251  //!Description: Returns a string representation of the PDU.
252  //************************************
253  virtual KString GetAsString() const;
254 
255  //************************************
256  // FullName: KDIS::PDU::Environmental_Process_PDU::Decode
257  //!Description: Convert From Network Data.
258  // Parameter: KDataStream & stream
259  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
260  //************************************
261  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
262 
263  //************************************
264  // FullName: KDIS::PDU::Environmental_Process_PDU::Encode
265  //!Description: Convert To Network Data.
266  // Parameter: KDataStream & stream
267  //************************************
268  virtual KDataStream Encode() const;
269  virtual void Encode( KDataStream & stream ) const;
270 
271  KBOOL operator == ( const Environmental_Process_PDU & Value ) const;
272  KBOOL operator != ( const Environmental_Process_PDU & Value ) const;
273 };
274 
275 } // END namespace PDU
276 } // END namespace KDIS
KUINT16 m_ui16NumEnvRec
Definition: Environmental_Process_PDU.h:97
Definition: Environmental_Process_PDU.h:75
KUINT8 m_ui8ModelType
Definition: Environmental_Process_PDU.h:83
unsigned short int KUINT16
Definition: KDefines.h:101
KDIS::DATA_TYPE::EntityIdentifier m_EnvProcID
Definition: Environmental_Process_PDU.h:79
Definition: EnvironmentType.h:46
KUINT16 m_ui16SeqNum
Definition: Environmental_Process_PDU.h:99
Definition: KDefines.h:182
Definition: KDataStream.h:48
std::vector< KDIS::DATA_TYPE::EnviromentRecordPtr > m_vEnvRecords
Definition: Environmental_Process_PDU.h:101
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
Definition: Header7.h:142
unsigned char KUINT8
Definition: KDefines.h:99
#define KDIS_EXPORT
Definition: KDefines.h:82
KUINT8 m_ui8EnvStatus
Definition: Environmental_Process_PDU.h:94
Definition: KRef_Ptr.h:73
KDIS::DATA_TYPE::EnvironmentType m_EnvType
Definition: Environmental_Process_PDU.h:81