KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ModeXCodeRecord.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: ModeXCodeRecord
32  DIS: (7) 1278.1 - 2012
33  created: 30/03/2014
34  author: Karl Jones
35 
36  purpose: Base class for many of the Mode Code records, contains the shared properties.
37 
38  Size: 16 bits / 2 octets
39 *********************************************************************/
40 
41 #pragma once
42 
43 #include "./DataTypeBase.h"
44 
45 namespace KDIS {
46 namespace DATA_TYPE {
47 
49 {
50 protected:
51 
52  union
53  {
54  struct
55  {
56  KUINT16 m_ui16Bits0_2 : 3;
57  KUINT16 m_ui16Bits3_5 : 3;
58  KUINT16 m_ui16Bits6_8 : 3;
59  KUINT16 m_ui16Bits9_11 : 3;
60  KUINT16 m_ui16Padding : 1;
61  KUINT16 m_ui16OnOff : 1;
62  KUINT16 m_ui16Dmg : 1;
63  KUINT16 m_ui16MalFnc : 1;
64  };
66 
67  } m_CodeUnion;
68 
69 public:
70 
71  static const KUINT16 MODE_X_CODE_RECORD_SIZE = 2;
72 
74 
75  ModeXCodeRecord( KDataStream & stream ) throw( KException );
76 
77  virtual ~ModeXCodeRecord();
78 
79  //************************************
80  // FullName: KDIS::DATA_TYPE::ModeXCodeRecord::SetStatus
81  // KDIS::DATA_TYPE::ModeXCodeRecord::GetStatus
82  //!Description: Indicates whether the device is On (true or Off (false).
83  // Parameter: KBOOL S
84  //************************************
85  void SetStatus( KBOOL S );
86  KBOOL GetStatus() const;
87 
88  //************************************
89  // FullName: KDIS::DATA_TYPE::ModeXCodeRecord::SetDamaged
90  // KDIS::DATA_TYPE::ModeXCodeRecord::IsDamaged
91  //!Description: Indicates whether there is damage to the device.
92  // Parameter: KBOOL S
93  //************************************
94  void SetDamaged( KBOOL D );
95  KBOOL IsDamaged() const;
96 
97  //************************************
98  // FullName: KDIS::DATA_TYPE::ModeXCodeRecord::SetMalfunctioning
99  // KDIS::DATA_TYPE::ModeXCodeRecord::IsMalfunctioning
100  //!Description: Indicates whether there is damage to the device.
101  // Parameter: KBOOL M
102  //************************************
103  void SetMalfunctioning( KBOOL M );
104  KBOOL IsMalfunctioning() const;
105 
106  //************************************
107  // FullName: KDIS::DATA_TYPE::ModeXCodeRecord::GetAsString
108  //!Description: Returns a string representation
109  //************************************
110  virtual KString GetAsString() const;
111 
112  //************************************
113  // FullName: KDIS::DATA_TYPE::ModeXCodeRecord::Decode
114  //!Description: Convert From Network Data.
115  // Parameter: KDataStream & stream
116  //************************************
117  virtual void Decode( KDataStream & stream ) throw( KException );
118 
119  //************************************
120  // FullName: KDIS::DATA_TYPE::ModeXCodeRecord::Encode
121  //!Description: Convert To Network Data.
122  // Parameter: KDataStream & stream
123  //************************************
124  virtual KDataStream Encode() const;
125  virtual void Encode( KDataStream & stream ) const;
126 
127  KBOOL operator == ( const ModeXCodeRecord & Value ) const;
128  KBOOL operator != ( const ModeXCodeRecord & Value ) const;
129 };
130 
131 } // END namespace DATA_TYPE
132 } // END namespace KDIS
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT16 m_ui16Code
Definition: ModeXCodeRecord.h:65
Definition: KDefines.h:182
Definition: KDataStream.h:48
Definition: DataTypeBase.h:49
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: ModeXCodeRecord.h:48
#define KDIS_EXPORT
Definition: KDefines.h:82