1 /*********************************************************************
2 Copyright 2017 Karl Jones
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions are met:
9 1. Redistributions of source code must retain the above copyright notice, this
10 list of conditions and the following disclaimer.
11 2. Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 For Further Information Please Contact me at
28 http://p.sf.net/kdis/UserGuide
29 *********************************************************************/
31 #include "./BeamStatus.h"
32 #include "Enums/EnumEmitter.h"
35 using namespace DATA_TYPE
;
36 using namespace ENUMS
;
43 const int s_BeamStateBitmask
= 0x1;
44 const int s_PaddingBitmask
= 0xfe;
47 //////////////////////////////////////////////////////////////////////////
49 //////////////////////////////////////////////////////////////////////////
51 BeamStatus::BeamStatus() :
57 //////////////////////////////////////////////////////////////////////////
59 BeamStatus::BeamStatus( KDataStream
& stream
) :
66 //////////////////////////////////////////////////////////////////////////
68 BeamStatus::BeamStatus( BeamState BS
) :
70 m_ui8BeamStatus( BS
& s_BeamStateBitmask
)
74 //////////////////////////////////////////////////////////////////////////
76 BeamStatus::~BeamStatus()
80 //////////////////////////////////////////////////////////////////////////
82 void BeamStatus::SetBeamState( BeamState BS
)
84 m_ui8BeamStatus
= (BS
& s_BeamStateBitmask
);
87 //////////////////////////////////////////////////////////////////////////
89 BeamState
BeamStatus::GetBeamState() const
91 return static_cast<BeamState
>(m_ui8BeamStatus
& s_BeamStateBitmask
);
94 //////////////////////////////////////////////////////////////////////////
96 KString
BeamStatus::GetAsString() const
100 ss
<< "Beam State: " << GetEnumAsStringBeamState(m_ui8BeamStatus
& s_BeamStateBitmask
) << endl
101 << "Padding: " << static_cast<KUINT16
>(m_ui8BeamStatus
& s_PaddingBitmask
) << endl
;
106 //////////////////////////////////////////////////////////////////////////
108 void BeamStatus::Decode( KDataStream
& stream
)
110 if( stream
.GetBufferSize() < BEAM_STATUS_SIZE
)throw KException( __FUNCTION__
, NOT_ENOUGH_DATA_IN_BUFFER
);
112 stream
>> m_ui8BeamStatus
;
115 //////////////////////////////////////////////////////////////////////////
117 KDataStream
BeamStatus::Encode() const
121 BeamStatus::Encode( stream
);
126 //////////////////////////////////////////////////////////////////////////
128 void BeamStatus::Encode( KDataStream
& stream
) const
130 stream
<< m_ui8BeamStatus
;
133 //////////////////////////////////////////////////////////////////////////
135 KBOOL
BeamStatus::operator == ( const BeamStatus
& Value
) const
137 if( m_ui8BeamStatus
!= Value
.m_ui8BeamStatus
) return false;
141 //////////////////////////////////////////////////////////////////////////
143 KBOOL
BeamStatus::operator != ( const BeamStatus
& Value
) const
145 return !( *this == Value
);
148 //////////////////////////////////////////////////////////////////////////