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 "KDIS/DataTypes/Mode5InterrogatorBasicData.hpp"
32 //////////////////////////////////////////////////////////////////////////
36 using namespace UTILS
;
37 using namespace DATA_TYPE
;
39 //////////////////////////////////////////////////////////////////////////
41 //////////////////////////////////////////////////////////////////////////
43 Mode5InterrogatorBasicData::Mode5InterrogatorBasicData()
49 //////////////////////////////////////////////////////////////////////////
51 Mode5InterrogatorBasicData::Mode5InterrogatorBasicData(
52 const Mode5InterrogatorStatus
& Status
, KUINT32 FormatsPresent
,
53 const EntityIdentifier
& ID
)
57 m_ui32MsgFormats(FormatsPresent
),
61 //////////////////////////////////////////////////////////////////////////
63 Mode5InterrogatorBasicData::Mode5InterrogatorBasicData(KDataStream
& stream
) {
67 //////////////////////////////////////////////////////////////////////////
69 Mode5InterrogatorBasicData::~Mode5InterrogatorBasicData() {}
71 //////////////////////////////////////////////////////////////////////////
73 void Mode5InterrogatorBasicData::SetStatus(const Mode5InterrogatorStatus
& S
) {
77 //////////////////////////////////////////////////////////////////////////
79 const Mode5InterrogatorStatus
& Mode5InterrogatorBasicData::GetStatus() const {
83 //////////////////////////////////////////////////////////////////////////
85 Mode5InterrogatorStatus
& Mode5InterrogatorBasicData::GetStatus() {
89 //////////////////////////////////////////////////////////////////////////
91 void Mode5InterrogatorBasicData::SetMessageFormatsPresent(KUINT32 MFP
) {
92 m_ui32MsgFormats
= MFP
;
95 //////////////////////////////////////////////////////////////////////////
97 void Mode5InterrogatorBasicData::SetMessageFormatsPresent(
98 const std::bitset
<32>& MFP
) {
99 m_ui32MsgFormats
= MFP
.to_ulong();
102 //////////////////////////////////////////////////////////////////////////
104 const std::bitset
<32>
105 Mode5InterrogatorBasicData::GetMessageFormatsPresentBitSet() const {
106 return bitset
<32>((KINT32
)m_ui32MsgFormats
);
109 //////////////////////////////////////////////////////////////////////////
111 KUINT32
Mode5InterrogatorBasicData::GetMessageFormatsPresent() const {
112 return m_ui32MsgFormats
;
115 //////////////////////////////////////////////////////////////////////////
117 KBOOL
Mode5InterrogatorBasicData::operator!=(
118 const Mode5InterrogatorBasicData
& Value
) const {
119 return !(*this == Value
);
122 //////////////////////////////////////////////////////////////////////////
124 void Mode5InterrogatorBasicData::SetInterrogatedEntityID(
125 const EntityIdentifier
& ID
) {
126 m_InterrogatedID
= ID
;
129 //////////////////////////////////////////////////////////////////////////
131 const EntityIdentifier
& Mode5InterrogatorBasicData::GetInterrogatedEntityID()
133 return m_InterrogatedID
;
136 //////////////////////////////////////////////////////////////////////////
138 EntityIdentifier
& Mode5InterrogatorBasicData::GetInterrogatedEntityID() {
139 return m_InterrogatedID
;
142 //////////////////////////////////////////////////////////////////////////
144 KString
Mode5InterrogatorBasicData::GetAsString() const {
146 ss
<< "Mode 5 Interrogator Basic Data:"
147 << IndentString(m_Status
.GetAsString())
148 << GetMessageFormatsPresentBitSet().to_string()
149 << IndentString(m_InterrogatedID
.GetAsString());
154 //////////////////////////////////////////////////////////////////////////
156 void Mode5InterrogatorBasicData::Decode(KDataStream
& stream
) {
157 if (stream
.GetBufferSize() < MODE_5_INTERROGATOR_BASIC_DATA_SIZE
)
158 throw KException(__FUNCTION__
, NOT_ENOUGH_DATA_IN_BUFFER
);
160 stream
>> KDIS_STREAM m_Status
>> m_ui8Padding
>> m_ui16Padding1
>>
161 m_ui32MsgFormats
>> KDIS_STREAM m_InterrogatedID
>> m_ui16Padding2
;
164 //////////////////////////////////////////////////////////////////////////
166 KDataStream
Mode5InterrogatorBasicData::Encode() const {
169 Mode5InterrogatorBasicData::Encode(stream
);
174 //////////////////////////////////////////////////////////////////////////
176 void Mode5InterrogatorBasicData::Encode(KDataStream
& stream
) const {
177 stream
<< KDIS_STREAM m_Status
<< m_ui8Padding
<< m_ui16Padding1
178 << m_ui32MsgFormats
<< KDIS_STREAM m_InterrogatedID
<< m_ui16Padding2
;
181 //////////////////////////////////////////////////////////////////////////
183 KBOOL
Mode5InterrogatorBasicData::operator==(
184 const Mode5InterrogatorBasicData
& Value
) const {
185 if (m_Status
!= Value
.m_Status
) return false;
186 if (m_ui32MsgFormats
!= Value
.m_ui32MsgFormats
) return false;
187 if (m_InterrogatedID
!= Value
.m_InterrogatedID
) return false;
191 //////////////////////////////////////////////////////////////////////////