KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Minefield_Data_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: Minefield_Data_PDU
32  DIS: (6) 1278.1a - 1998
33  created: 25/05/2010
34  author: Karl Jones
35 
36  purpose: Provides information on individual mines contained within a minefield.
37 
38  Note: This is a very complex PDU(The hardest one in the standard!), I do not have access to any software to test Minefield
39  PDU's so it may contain traces of nuts(bugs). Please let me know if you have any problems. Karl.
40 
41  size: 352 bits / 44 octets - Min size
42 *********************************************************************/
43 
44 #pragma once
45 
46 #include "./Minefield_Header.h"
47 #include "./../../DataTypes/MinefieldDataFilter.h"
48 #include "./../../DataTypes/EntityType.h"
49 #include "./../../DataTypes/Vector.h"
50 #include "./../../DataTypes/EulerAngles.h"
51 #include "./../../DataTypes/Mine.h"
52 #include <vector>
53 
54 namespace KDIS {
55 namespace PDU {
56 
58 {
59 protected:
60 
62 
63  union
64  {
65  struct
66  {
67  KUINT16 m_ui16Reserved : 1;
68  KUINT16 m_ui16SeqNum15 : 15;
69  };
71  } m_SeqNumUnion;
72 
74 
76 
78 
80 
82 
84 
86 
88 
89  std::vector<KUINT16> m_vui16SensorTypes;
90 
91  std::vector<KDIS::DATA_TYPE::Mine> m_vMines;
92 
93  //************************************
94  // FullName: KDIS::PDU::Minefield_Data_PDU::calcPaddingPaintScheme
95  //!Description: Calculates the padding after the paint scheme.
96  //! Padding � 8{[4 � N(2 F(8) + M F(9) + F(10) + 2)] mod4} bits unused
97  //! PDU lies on a 32 bit boundary.
98  //************************************
99  KUINT8 calcPaddingPaintScheme() const;
100 
101  //************************************
102  // FullName: KDIS::PDU::Minefield_Data_PDU::calcPaddingPaintScheme
103  //!Description: Calculates the padding after the Number of Vertices's field.
104  //************************************
105  KUINT8 calcPaddingVertices() const;
106 
107 public:
108 
109  static const KUINT16 MINEFIELD_DATA_PDU_SIZE = 44; // Min size
110 
112 
113  Minefield_Data_PDU( KDataStream & stream ) throw( KException );
114 
115  Minefield_Data_PDU( const Header & H, KDataStream & stream ) throw( KException );
116 
117  Minefield_Data_PDU( const KDIS::DATA_TYPE::EntityIdentifier & MinefieldID, const KDIS::DATA_TYPE::EntityIdentifier & RequestingSimulationID,
118  KUINT16 SeqNum, KUINT8 RequestID, KUINT8 PduSeqNum, KUINT8 NumPdus,
120 
121  virtual ~Minefield_Data_PDU();
122 
123  //************************************
124  // FullName: KDIS::PDU::Minefield_Data_PDU::SetRequestingSimulationID
125  // KDIS::PDU::Minefield_Data_PDU::GetRequestingSimulationID
126  //!Description: The simulation that is requesting the information.
127  // Parameter: const EntityIdentifier & ID
128  //************************************
129  void SetRequestingSimulationID( const KDIS::DATA_TYPE::EntityIdentifier & ID );
130  const KDIS::DATA_TYPE::EntityIdentifier & GetRequestingSimulationID() const;
131  KDIS::DATA_TYPE::EntityIdentifier & GetRequestingSimulationID();
132 
133  //************************************
134  // FullName: KDIS::PDU::Minefield_Data_PDU::SetSequenceNumber
135  // KDIS::PDU::Minefield_Data_PDU::GetSequenceNumber
136  //!Description: Identifies the matching minefield sequence number
137  //! from the associated Minefield State PDU.
138  // Parameter: KUINT16 S
139  //************************************
140  void SetSequenceNumber( KUINT16 S );
141  KUINT16 GetSequenceNumber() const;
142 
143  //************************************
144  // FullName: KDIS::PDU::Minefield_Data_PDU::SetRequestID
145  // KDIS::PDU::Minefield_Data_PDU::GetRequestID
146  //!Description: The matching response to a request for mine information from the
147  //! minefield simulation made by means of a Minefield Query PDU
148  //! in QRP mode. In heartbeat mode, this field shall contain the value zero.
149  // Parameter: KUINT8 ID
150  //************************************
151  void SetRequestID( KUINT8 ID );
152  KUINT8 GetRequestID() const;
153 
154  //************************************
155  // FullName: KDIS::PDU::Minefield_Data_PDU::SetPDUSequenceNumber
156  // KDIS::PDU::Minefield_Data_PDU::GetPDUSequenceNumber
157  //!Description: Specifies the number of the current Minefield Data PDU in a
158  //! sequence of Minefield Data PDUs sent in response to a Minefield
159  //! Query PDU when operating in QRP mode.
160  //! When operating in heartbeat mode, this field is unused and shall contain the value zero.
161  // Parameter: KUINT8 SN
162  //************************************
163  void SetPDUSequenceNumber( KUINT8 SN );
164  KUINT8 GetPDUSequenceNumber() const;
165 
166  //************************************
167  // FullName: KDIS::PDU::Minefield_Data_PDU::GetNumberOfPDUs
168  // KDIS::PDU::Minefield_Data_PDU::SetNumberOfPDUs
169  //!Description: The total number of Minefield Data PDUs being sent in
170  //! response to a Minefield Query PDU when operating in QRP mode.
171  //! When operating in heartbeat mode, this field is unused and shall contain the value zero.
172  // Parameter: KUINT8 N
173  //************************************
174  void SetNumberOfPDUs( KUINT8 N );
175  KUINT8 GetNumberOfPDUs() const;
176 
177  //************************************
178  // FullName: KDIS::PDU::Minefield_Data_PDU::GetNumberOfMines
179  //!Description: The number of mines of the same type contained in this PDU.
180  //************************************
181  KUINT8 GetNumberOfMines() const;
182 
183  //************************************
184  // FullName: KDIS::PDU::Minefield_Data_PDU::GetNumberOfSensorsTypes
185  //!Description: In QRP mode, this field shall specify the number of sensor types employed
186  //! by the requesting simulation as specified in the Minefield Query PDU.
187  //! In heartbeat mode, this field shall specify the number of sensor types
188  //! employed in the exercise.
189  //************************************
190  KUINT8 GetNumberOfSensorsTypes() const;
191 
192  //************************************
193  // FullName: KDIS::PDU::Minefield_Data_PDU::SetDataFilter
194  // KDIS::PDU::Minefield_Data_PDU::GetDataFilter
195  //!Description: Identifies which of the optional data fields are set in
196  //! the mines contained in this Minefield Data PDU.
197  // Parameter: const MinefieldDataFilter & DF
198  //************************************
199  void SetDataFilter( const KDIS::DATA_TYPE::MinefieldDataFilter & DF );
200  const KDIS::DATA_TYPE::MinefieldDataFilter & GetDataFilter() const;
201  KDIS::DATA_TYPE::MinefieldDataFilter & GetDataFilter();
202 
203  //************************************
204  // FullName: KDIS::PDU::Minefield_Data_PDU::SetMineType
205  // KDIS::PDU::Minefield_Data_PDU::GetMineType
206  //!Description: The type of mine contained in this PDU.
207  // Parameter: const MinefieldDataFilter & DF
208  //************************************
209  void SetMineType( const KDIS::DATA_TYPE::EntityType & MT );
210  const KDIS::DATA_TYPE::EntityType & GetMineType() const;
211  KDIS::DATA_TYPE::EntityType & GetMineType();
212 
213  //************************************
214  // FullName: KDIS::PDU::Minefield_Data_PDU::AddSensorType
215  // KDIS::PDU::Minefield_Data_PDU::SetSensorTypes
216  // KDIS::PDU::Minefield_Data_PDU::GetSensorTypes
217  //!Description: In QRP mode, this field shall specify the requesting sensor types
218  //! which were specified in the Minefield Query PDU. In heartbeat mode,
219  //! this field shall specify the sensor types that are being served by the minefield
220  //! The sensor type is represented as a 16 bit enumeration where bits 0-3
221  //! identify the category of the sensor type and bits 4-15 identify the
222  //! subcategory within the specified category.
223  //! The enum SensorType(EnumMinefield.h) provides all sensor types from SISO-REF-10-2006 which have all the bits set
224  //! correctly for each sensor type.
225  // Parameter: SensorType ST, vector<KUINT16> & ST
226  //************************************
227  void AddSensorType( KDIS::DATA_TYPE::ENUMS::SensorType ST );
228  void SetSensorTypes( const std::vector<KUINT16> & ST );
229  const std::vector<KUINT16> & GetSensorTypes() const;
230 
231  //************************************
232  // FullName: KDIS::PDU::Minefield_Data_PDU::AddMine
233  // KDIS::PDU::Minefield_Data_PDU::SetMines
234  // KDIS::PDU::Minefield_Data_PDU::GetMines
235  //!Description: The Mine class encapsulates the common attributes for a mine.
236  //! Note: All the mines must have the same optional values set as stated by the
237  //! MinefieldDataFilter, if they are not then an INVALID_OPERATION exception is thrown.
238  // Parameter: const Mine & M, const vector<Mine> & M
239  //************************************
240  void AddMine( const KDIS::DATA_TYPE::Mine & M ) throw( KException );
241  void SetMines( const std::vector<KDIS::DATA_TYPE::Mine> & M ) throw( KException );
242  const std::vector<KDIS::DATA_TYPE::Mine> & GetMines() const;
243 
244  //************************************
245  // FullName: KDIS::PDU::Minefield_Data_PDU::GetAsString
246  //!Description: Returns a string representation of the PDU.
247  //************************************
248  virtual KString GetAsString() const;
249 
250  //************************************
251  // FullName: KDIS::PDU::Minefield_Data_PDU::Decode
252  //!Description: Convert From Network Data.
253  // Parameter: KDataStream & stream
254  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
255  //************************************
256  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
257 
258  //************************************
259  // FullName: KDIS::PDU::Minefield_Data_PDU::Encode
260  //!Description: Convert To Network Data. Exception is thrown if each mine does not
261  //! have a ScalarDetectionCoefficient value for each sensor type.
262  // Parameter: KDataStream & stream
263  //************************************
264  virtual KDataStream Encode() const throw( KException );
265  virtual void Encode( KDataStream & stream ) const throw( KException );
266 
267  KBOOL operator == ( const Minefield_Data_PDU & Value ) const;
268  KBOOL operator != ( const Minefield_Data_PDU & Value ) const;
269 };
270 
271 } // END namespace PDU
272 } // END namespace KDIS
Definition: EntityType.h:46
KUINT8 m_ui8ReqID
Definition: Minefield_Data_PDU.h:73
KUINT16 m_ui16SeqNum
Definition: Minefield_Data_PDU.h:70
unsigned short int KUINT16
Definition: KDefines.h:101
SensorType
Definition: EnumMinefield.h:95
KUINT8 m_ui8PduSeqNum
Definition: Minefield_Data_PDU.h:75
std::vector< KUINT16 > m_vui16SensorTypes
Definition: Minefield_Data_PDU.h:89
KDIS::DATA_TYPE::EntityIdentifier m_ReqID
Definition: Minefield_Data_PDU.h:61
Definition: KDefines.h:182
KUINT8 m_ui8NumSensTyp
Definition: Minefield_Data_PDU.h:81
Definition: KDataStream.h:48
KUINT8 m_ui8Padding1
Definition: Minefield_Data_PDU.h:83
bool KBOOL
Definition: KDefines.h:119
Definition: Minefield_Header.h:49
std::vector< KDIS::DATA_TYPE::Mine > m_vMines
Definition: Minefield_Data_PDU.h:91
Definition: Minefield_Data_PDU.h:57
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
KUINT8 m_ui8NumPdus
Definition: Minefield_Data_PDU.h:77
Definition: Header7.h:142
unsigned char KUINT8
Definition: KDefines.h:99
KDIS::DATA_TYPE::MinefieldDataFilter m_DataFilter
Definition: Minefield_Data_PDU.h:85
Definition: Mine.h:55
#define KDIS_EXPORT
Definition: KDefines.h:82
KUINT8 m_ui8NumMines
Definition: Minefield_Data_PDU.h:79
Definition: MinefieldDataFilter.h:49
KDIS::DATA_TYPE::EntityType m_MineTyp
Definition: Minefield_Data_PDU.h:87