1 /*********************************************************************
2 Copyright 2013 Karl Jones
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
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 #include "./GED_GroundLogisticsVehicle.h"
33 using namespace DATA_TYPE
;
34 using namespace ENUMS
;
35 using namespace UTILS
;
37 //////////////////////////////////////////////////////////////////////////
39 //////////////////////////////////////////////////////////////////////////
41 GED_GroundLogisticsVehicle::GED_GroundLogisticsVehicle() :
45 for( KINT8 i
= 0; i
< 3; ++i
)
52 //////////////////////////////////////////////////////////////////////////
54 GED_GroundLogisticsVehicle::GED_GroundLogisticsVehicle( KDataStream
& stream
)
59 //////////////////////////////////////////////////////////////////////////
61 GED_GroundLogisticsVehicle::GED_GroundLogisticsVehicle( KUINT16 ID
, KINT16 XOffset
, KINT16 YOffset
, KINT16 ZOffset
, const EntityAppearance
& EA
, KINT8 Psi
, KINT8 Theta
,
62 KINT8 Phi
, KINT8 Speed
) :
67 m_i16Offsets
[0] = XOffset
;
68 m_i16Offsets
[1] = YOffset
;
69 m_i16Offsets
[2] = ZOffset
;
75 //////////////////////////////////////////////////////////////////////////
77 GED_GroundLogisticsVehicle::~GED_GroundLogisticsVehicle()
81 //////////////////////////////////////////////////////////////////////////
83 GroupedEntityCategory
GED_GroundLogisticsVehicle::GetGroupedEntityCategory() const
85 return BasicFixedWingAircraftGEC
;
88 //////////////////////////////////////////////////////////////////////////
90 KUINT8
GED_GroundLogisticsVehicle::GetLength() const
92 return GED_GROUND_LOGISTICS_VEHICLE_SIZE
;
95 //////////////////////////////////////////////////////////////////////////
97 void GED_GroundLogisticsVehicle::SetEntityID( KUINT16 ID
)
102 //////////////////////////////////////////////////////////////////////////
104 KUINT16
GED_GroundLogisticsVehicle::GetEntityID() const
106 return m_ui16EntityID
;
109 //////////////////////////////////////////////////////////////////////////
111 void GED_GroundLogisticsVehicle::SetEntityLocation( KINT16 XOffset
, KINT16 YOffset
, KINT16 ZOffset
)
113 m_i16Offsets
[0] = XOffset
;
114 m_i16Offsets
[1] = YOffset
;
115 m_i16Offsets
[2] = ZOffset
;
118 //////////////////////////////////////////////////////////////////////////
120 void GED_GroundLogisticsVehicle::SetEntityLocation( KINT16 Offsets
[3] )
122 for( KUINT8 i
= 0; i
< 3; ++i
)
124 m_i16Offsets
[i
] = Offsets
[i
];
128 //////////////////////////////////////////////////////////////////////////
130 void GED_GroundLogisticsVehicle::SetEntityLocationXOffset( KINT16 X
)
135 //////////////////////////////////////////////////////////////////////////
137 void GED_GroundLogisticsVehicle::SetEntityLocationYOffset( KINT16 Y
)
142 //////////////////////////////////////////////////////////////////////////
144 void GED_GroundLogisticsVehicle::SetEntityLocationZOffset( KINT16 Z
)
149 //////////////////////////////////////////////////////////////////////////
151 KINT16
GED_GroundLogisticsVehicle::GetEntityLocationXOffset() const
153 return m_i16Offsets
[0];
156 //////////////////////////////////////////////////////////////////////////
158 KINT16
GED_GroundLogisticsVehicle::GetEntityLocationYOffset() const
160 return m_i16Offsets
[1];
163 //////////////////////////////////////////////////////////////////////////
165 KINT16
GED_GroundLogisticsVehicle::GetEntityLocationZOffset() const
167 return m_i16Offsets
[2];
170 //////////////////////////////////////////////////////////////////////////
172 void GED_GroundLogisticsVehicle::SetEntityAppearance( const EntityAppearance
& EA
)
177 //////////////////////////////////////////////////////////////////////////
179 const EntityAppearance
& GED_GroundLogisticsVehicle::GetEntityAppearance() const
184 //////////////////////////////////////////////////////////////////////////
186 EntityAppearance
& GED_GroundLogisticsVehicle::GetEntityAppearance()
191 //////////////////////////////////////////////////////////////////////////
193 void GED_GroundLogisticsVehicle::SetEntityOrientation( KINT8 Psi
, KINT8 Theta
, KINT8 Phi
)
200 //////////////////////////////////////////////////////////////////////////
202 void GED_GroundLogisticsVehicle::SetEntityOrientation( KINT8 Ori
[3] )
204 for( KINT8 i
= 0; i
< 3; ++i
)
210 //////////////////////////////////////////////////////////////////////////
212 void GED_GroundLogisticsVehicle::SetEntityOrientationPsi( KINT8 P
)
217 //////////////////////////////////////////////////////////////////////////
219 void GED_GroundLogisticsVehicle::SetEntityOrientationTheta( KINT8 T
)
224 //////////////////////////////////////////////////////////////////////////
226 void GED_GroundLogisticsVehicle::SetEntityOrientationPhi( KINT8 P
)
231 //////////////////////////////////////////////////////////////////////////
233 KINT8
GED_GroundLogisticsVehicle::GetEntityOrientationPsi() const
238 //////////////////////////////////////////////////////////////////////////
240 KINT8
GED_GroundLogisticsVehicle::GetEntityOrientationTheta() const
245 //////////////////////////////////////////////////////////////////////////
247 KINT8
GED_GroundLogisticsVehicle::GetEntityOrientationPhi() const
252 //////////////////////////////////////////////////////////////////////////
254 void GED_GroundLogisticsVehicle::SetSpeed( KINT8 S
)
259 //////////////////////////////////////////////////////////////////////////
261 KINT8
GED_GroundLogisticsVehicle::GetSpeed() const
266 //////////////////////////////////////////////////////////////////////////
268 KString
GED_GroundLogisticsVehicle::GetAsString() const
272 ss
<< "GED Basic Fixed Wing Aircraft\n"
273 << "\tEntity ID: " << m_ui16EntityID
<< "\n"
274 << "\tLocation Offsets(x,y,z): " << m_i16Offsets
[0] << " " << m_i16Offsets
[1] << " " << m_i16Offsets
[2] << "\n"
275 << IndentString( m_EA
.GetAsString( EntityType( Platform
, Air
, 0, 0, 0, 0, 0 ) ), 1 )
276 << "\tOrientation(Psi,Theta,Phi): " << ( KINT16
)m_i8Ori
[0] << " " << ( KINT16
)m_i8Ori
[1] << " " << ( KINT16
)m_i8Ori
[2] << "\n"
277 << "\tSpeed: " << ( KINT16
)m_i8Spd
<< "\n";
282 //////////////////////////////////////////////////////////////////////////
284 void GED_GroundLogisticsVehicle::Decode( KDataStream
& stream
)
286 if( stream
.GetBufferSize() < GED_GROUND_LOGISTICS_VEHICLE_SIZE
)throw KException( __FUNCTION__
, NOT_ENOUGH_DATA_IN_BUFFER
);
288 stream
>> m_ui16EntityID
299 //////////////////////////////////////////////////////////////////////////
301 KDataStream
GED_GroundLogisticsVehicle::Encode() const
305 GED_GroundLogisticsVehicle::Encode( stream
);
310 //////////////////////////////////////////////////////////////////////////
312 void GED_GroundLogisticsVehicle::Encode( KDataStream
& stream
) const
314 stream
<< m_ui16EntityID
325 //////////////////////////////////////////////////////////////////////////
327 KBOOL
GED_GroundLogisticsVehicle::operator == ( const GED_GroundLogisticsVehicle
& Value
) const
329 if( m_ui16EntityID
!= Value
.m_ui16EntityID
) return false;
330 if( m_i16Offsets
[0] != Value
.m_i16Offsets
[0] ) return false;
331 if( m_i16Offsets
[1] != Value
.m_i16Offsets
[1] ) return false;
332 if( m_i16Offsets
[2] != Value
.m_i16Offsets
[2] ) return false;
333 if( m_EA
!= Value
.m_EA
) return false;
334 if( m_i8Ori
[0] != Value
.m_i8Ori
[0] ) return false;
335 if( m_i8Ori
[1] != Value
.m_i8Ori
[1] ) return false;
336 if( m_i8Ori
[2] != Value
.m_i8Ori
[2] ) return false;
337 if( m_i8Spd
!= Value
.m_i8Spd
) return false;
341 //////////////////////////////////////////////////////////////////////////
343 KBOOL
GED_GroundLogisticsVehicle::operator != ( const GED_GroundLogisticsVehicle
& Value
) const
345 return !( *this == Value
);
348 //////////////////////////////////////////////////////////////////////////