fix: replaced invalid UTF8 characters
[KDIS.git] / include / KDIS / PDU / Minefield / Minefield_Data_PDU.hpp
blob2289531dd2f10c4c35b36fec20d8b22d1d1d9199
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
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.
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.
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 /********************************************************************
31 class: Minefield_Data_PDU
32 DIS: (6) 1278.1a - 1998
33 created: 25/05/2010
34 author: Karl Jones
36 purpose: Provides information on individual mines contained within a
37 minefield.
39 Note: This is a very complex PDU(The hardest one in the
40 standard!), I do not have access to any software to test Minefield PDU's so it
41 may contain traces of nuts(bugs). Please let me know if you have any problems.
42 Karl.
44 size: 352 bits / 44 octets - Min size
45 *********************************************************************/
47 #pragma once
49 #include <vector>
51 #include "KDIS/DataTypes/EntityType.hpp"
52 #include "KDIS/DataTypes/EulerAngles.hpp"
53 #include "KDIS/DataTypes/Mine.hpp"
54 #include "KDIS/DataTypes/MinefieldDataFilter.hpp"
55 #include "KDIS/DataTypes/Vector.hpp"
56 #include "KDIS/PDU/Minefield/Minefield_Header.hpp"
58 namespace KDIS {
59 namespace PDU {
61 class KDIS_EXPORT Minefield_Data_PDU : public Minefield_Header {
62 protected:
63 KDIS::DATA_TYPE::EntityIdentifier m_ReqID;
65 union {
66 struct {
67 KUINT16 m_ui16Reserved : 1;
68 KUINT16 m_ui16SeqNum15 : 15;
70 KUINT16 m_ui16SeqNum;
71 } m_SeqNumUnion;
73 KUINT8 m_ui8ReqID;
75 KUINT8 m_ui8PduSeqNum;
77 KUINT8 m_ui8NumPdus;
79 KUINT8 m_ui8NumMines;
81 KUINT8 m_ui8NumSensTyp;
83 KUINT8 m_ui8Padding1;
85 KDIS::DATA_TYPE::MinefieldDataFilter m_DataFilter;
87 KDIS::DATA_TYPE::EntityType m_MineTyp;
89 std::vector<KUINT16> m_vui16SensorTypes;
91 std::vector<KDIS::DATA_TYPE::Mine> m_vMines;
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
97 // unused PDU lies on a 32 bit boundary.
98 //************************************
99 KUINT8 calcPaddingPaintScheme() const;
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;
107 public:
108 static const KUINT16 MINEFIELD_DATA_PDU_SIZE = 44; // Min size
110 Minefield_Data_PDU();
112 Minefield_Data_PDU(KDataStream& stream);
114 Minefield_Data_PDU(const Header& H, KDataStream& stream);
116 Minefield_Data_PDU(
117 const KDIS::DATA_TYPE::EntityIdentifier& MinefieldID,
118 const KDIS::DATA_TYPE::EntityIdentifier& RequestingSimulationID,
119 KUINT16 SeqNum, KUINT8 RequestID, KUINT8 PduSeqNum, KUINT8 NumPdus,
120 const KDIS::DATA_TYPE::MinefieldDataFilter& DF,
121 const KDIS::DATA_TYPE::EntityType& MineType);
123 virtual ~Minefield_Data_PDU();
125 //************************************
126 // FullName: KDIS::PDU::Minefield_Data_PDU::SetRequestingSimulationID
127 // KDIS::PDU::Minefield_Data_PDU::GetRequestingSimulationID
128 // Description: The simulation that is requesting the information.
129 // Parameter: const EntityIdentifier & ID
130 //************************************
131 void SetRequestingSimulationID(const KDIS::DATA_TYPE::EntityIdentifier& ID);
132 const KDIS::DATA_TYPE::EntityIdentifier& GetRequestingSimulationID() const;
133 KDIS::DATA_TYPE::EntityIdentifier& GetRequestingSimulationID();
135 //************************************
136 // FullName: KDIS::PDU::Minefield_Data_PDU::SetSequenceNumber
137 // KDIS::PDU::Minefield_Data_PDU::GetSequenceNumber
138 // Description: Identifies the matching minefield sequence number
139 // from the associated Minefield State PDU.
140 // Parameter: KUINT16 S
141 //************************************
142 void SetSequenceNumber(KUINT16 S);
143 KUINT16 GetSequenceNumber() const;
145 //************************************
146 // FullName: KDIS::PDU::Minefield_Data_PDU::SetRequestID
147 // KDIS::PDU::Minefield_Data_PDU::GetRequestID
148 // Description: The matching response to a request for mine information from
149 // the
150 // minefield simulation made by means of a Minefield Query PDU
151 // in QRP mode. In heartbeat mode, this field shall contain the
152 // value zero.
153 // Parameter: KUINT8 ID
154 //************************************
155 void SetRequestID(KUINT8 ID);
156 KUINT8 GetRequestID() const;
158 //************************************
159 // FullName: KDIS::PDU::Minefield_Data_PDU::SetPDUSequenceNumber
160 // KDIS::PDU::Minefield_Data_PDU::GetPDUSequenceNumber
161 // Description: Specifies the number of the current Minefield Data PDU in a
162 // sequence of Minefield Data PDUs sent in response to a
163 // Minefield Query PDU when operating in QRP mode. When operating
164 // in heartbeat mode, this field is unused and shall contain the
165 // value zero.
166 // Parameter: KUINT8 SN
167 //************************************
168 void SetPDUSequenceNumber(KUINT8 SN);
169 KUINT8 GetPDUSequenceNumber() const;
171 //************************************
172 // FullName: KDIS::PDU::Minefield_Data_PDU::GetNumberOfPDUs
173 // KDIS::PDU::Minefield_Data_PDU::SetNumberOfPDUs
174 // Description: The total number of Minefield Data PDUs being sent in
175 // response to a Minefield Query PDU when operating in QRP mode.
176 // When operating in heartbeat mode, this field is unused and
177 // shall contain the value zero.
178 // Parameter: KUINT8 N
179 //************************************
180 void SetNumberOfPDUs(KUINT8 N);
181 KUINT8 GetNumberOfPDUs() const;
183 //************************************
184 // FullName: KDIS::PDU::Minefield_Data_PDU::GetNumberOfMines
185 // Description: The number of mines of the same type contained in this PDU.
186 //************************************
187 KUINT8 GetNumberOfMines() const;
189 //************************************
190 // FullName: KDIS::PDU::Minefield_Data_PDU::GetNumberOfSensorsTypes
191 // Description: In QRP mode, this field shall specify the number of sensor
192 // types employed
193 // by the requesting simulation as specified in the Minefield
194 // Query PDU. In heartbeat mode, this field shall specify the
195 // number of sensor types employed in the exercise.
196 //************************************
197 KUINT8 GetNumberOfSensorsTypes() const;
199 //************************************
200 // FullName: KDIS::PDU::Minefield_Data_PDU::SetDataFilter
201 // KDIS::PDU::Minefield_Data_PDU::GetDataFilter
202 // Description: Identifies which of the optional data fields are set in
203 // the mines contained in this Minefield Data PDU.
204 // Parameter: const MinefieldDataFilter & DF
205 //************************************
206 void SetDataFilter(const KDIS::DATA_TYPE::MinefieldDataFilter& DF);
207 const KDIS::DATA_TYPE::MinefieldDataFilter& GetDataFilter() const;
208 KDIS::DATA_TYPE::MinefieldDataFilter& GetDataFilter();
210 //************************************
211 // FullName: KDIS::PDU::Minefield_Data_PDU::SetMineType
212 // KDIS::PDU::Minefield_Data_PDU::GetMineType
213 // Description: The type of mine contained in this PDU.
214 // Parameter: const MinefieldDataFilter & DF
215 //************************************
216 void SetMineType(const KDIS::DATA_TYPE::EntityType& MT);
217 const KDIS::DATA_TYPE::EntityType& GetMineType() const;
218 KDIS::DATA_TYPE::EntityType& GetMineType();
220 //************************************
221 // FullName: KDIS::PDU::Minefield_Data_PDU::AddSensorType
222 // KDIS::PDU::Minefield_Data_PDU::SetSensorTypes
223 // KDIS::PDU::Minefield_Data_PDU::GetSensorTypes
224 // Description: In QRP mode, this field shall specify the requesting sensor
225 // types
226 // which were specified in the Minefield Query PDU. In heartbeat
227 // mode, this field shall specify the sensor types that are being
228 // served by the minefield The sensor type is represented as a 16
229 // bit enumeration where bits 0-3 identify the category of the
230 // sensor type and bits 4-15 identify the subcategory within the
231 // specified category. The enum SensorType(EnumMinefield.h)
232 // provides all sensor types from SISO-REF-10-2006 which have all
233 // the bits set correctly for each sensor type.
234 // Parameter: SensorType ST, vector<KUINT16> & ST
235 //************************************
236 void AddSensorType(KDIS::DATA_TYPE::ENUMS::SensorType ST);
237 void SetSensorTypes(const std::vector<KUINT16>& ST);
238 const std::vector<KUINT16>& GetSensorTypes() const;
240 //************************************
241 // FullName: KDIS::PDU::Minefield_Data_PDU::AddMine
242 // KDIS::PDU::Minefield_Data_PDU::SetMines
243 // KDIS::PDU::Minefield_Data_PDU::GetMines
244 // Description: The Mine class encapsulates the common attributes for a mine.
245 // Note: All the mines must have the same optional values set as
246 // stated by the MinefieldDataFilter, if they are not then an
247 // INVALID_OPERATION exception is thrown.
248 // Parameter: const Mine & M, const vector<Mine> & M
249 //************************************
250 void AddMine(const KDIS::DATA_TYPE::Mine& M);
251 void SetMines(const std::vector<KDIS::DATA_TYPE::Mine>& M);
252 const std::vector<KDIS::DATA_TYPE::Mine>& GetMines() const;
254 //************************************
255 // FullName: KDIS::PDU::Minefield_Data_PDU::GetAsString
256 // Description: Returns a string representation of the PDU.
257 //************************************
258 virtual KString GetAsString() const;
260 //************************************
261 // FullName: KDIS::PDU::Minefield_Data_PDU::Decode
262 // Description: Convert From Network Data.
263 // Parameter: KDataStream & stream
264 // Parameter: bool ignoreHeader = false - Decode the header from the stream?
265 //************************************
266 virtual void Decode(KDataStream& stream, bool ignoreHeader = false);
268 //************************************
269 // FullName: KDIS::PDU::Minefield_Data_PDU::Encode
270 // Description: Convert To Network Data. Exception is thrown if each mine does
271 // not
272 // have a ScalarDetectionCoefficient value for each sensor type.
273 // Parameter: KDataStream & stream
274 //************************************
275 virtual KDataStream Encode() const;
276 virtual void Encode(KDataStream& stream) const;
278 KBOOL operator==(const Minefield_Data_PDU& Value) const;
279 KBOOL operator!=(const Minefield_Data_PDU& Value) const;
282 } // END namespace PDU
283 } // END namespace KDIS