KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
GridDataType1.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: GridDataType1
32  created: 20/11/2009
33  author: Karl Jones
34 
35  purpose: The Grid Data record contains the actual environmental state variable data for
36  each grid location. This record specifes the data sample type, the format by
37  which the data are represented, feld scale factor and offset values,
38  and the actual data values in 16-bit.
39 
40  size: 128 bits / 16 octets - Min size
41 *********************************************************************/
42 
43 #pragma once
44 
45 #include "./GridData.h"
46 #include <vector>
47 
48 namespace KDIS {
49 namespace DATA_TYPE {
50 
52 {
53 protected:
54 
56 
58 
60 
61  std::vector<KUINT16> m_vui16Values;
62 
64 
65 public:
66 
67  static const KUINT16 GRID_DATA_TYPE1_SIZE = 16; // Min size
68 
69  GridDataType1();
70 
71  GridDataType1( KDataStream & stream ) throw( KException );
72 
73  // This constructor is used by the Gridded_Data_PDU. In order to know what type of grid
74  // data we have we must decode the first 2 values.So this constructor is here to aid in this process.
75  GridDataType1( KUINT16 SampleType, KUINT16 DataRepresentation, KDataStream & stream );
76 
77  GridDataType1( KUINT16 SampleType, KFLOAT32 FieldScale, KFLOAT32 FieldOffset,
78  const std::vector<KUINT16> & Values );
79 
80  virtual ~GridDataType1();
81 
82  //************************************
83  // FullName: KDIS::DATA_TYPE::GridDataType1::SetFieldScale
84  // KDIS::DATA_TYPE::GridDataType1::GetFieldScale
85  //!Description: Specifies the constant scale factor used to scale the environmental
86  //! state variable data values contained in this record.
87  // Parameter: KFLOAT32 FS
88  //************************************
89  void SetFieldScale( KFLOAT32 FS );
90  KFLOAT32 GetFieldScale() const;
91 
92  //************************************
93  // FullName: KDIS::DATA_TYPE::GridDataType1::SetFieldOffset
94  // KDIS::DATA_TYPE::GridDataType1::GetFieldOffset
95  //!Description: Specifies the constant offset used to scale the environmental state
96  //! variable data values contained in this record.
97  // Parameter: KFLOAT32 FO
98  //************************************
99  void SetFieldOffset( KFLOAT32 FO );
100  KFLOAT32 GetFieldOffset() const;
101 
102  //************************************
103  // FullName: KDIS::DATA_TYPE::GridDataType1::SetFieldOffset
104  // KDIS::DATA_TYPE::GridDataType1::GetFieldOffset
105  //!Description: The Number of environmental state variable data values contained in this record.
106  //************************************
107  KUINT16 GetNumberOfValues() const;
108 
109  //************************************
110  // FullName: KDIS::DATA_TYPE::GridDataType1::AddValue
111  // KDIS::DATA_TYPE::GridDataType1::SetValues
112  // KDIS::DATA_TYPE::GridDataType1::GetValues
113  // KDIS::DATA_TYPE::GridDataType1::ClearValues
114  //!Description: The environmental state variable data values.
115  // Parameter: KUINT16 V, const vector<KUINT16> & V
116  //************************************
117  void AddValue( KUINT16 V );
118  void SetValues( const std::vector<KUINT16> & V );
119  const std::vector<KUINT16> & GetValues() const;
120  void ClearValues();
121 
122  //************************************
123  // FullName: KDIS::DATA_TYPE::GridDataType1::GetDataRepresentation
124  //!Description: Returns the size of the whole Grid Data type object in octets.
125  //! Note: This information is not encoded into the PDU, it is here for the
126  //! internal calculation of the PDU length value.
127  //************************************
128  virtual KUINT16 GetSize() const;
129 
130  //************************************
131  // FullName: KDIS::DATA_TYPE::GridDataType1::GetAsString
132  //!Description: Returns a string representation
133  //************************************
134  virtual KString GetAsString() const;
135 
136  //************************************
137  // FullName: KDIS::DATA_TYPE::GridDataType1::Decode
138  //!Description: Convert From Network Data.
139  // Parameter: KDataStream & stream
140  //************************************
141  virtual void Decode( KDataStream & stream ) throw( KException );
142 
143  //************************************
144  // FullName: KDIS::DATA_TYPE::GridDataType1::Encode
145  //!Description: Convert To Network Data.
146  // Parameter: KDataStream & stream
147  //************************************
148  virtual KDataStream Encode() const;
149  virtual void Encode( KDataStream & stream ) const;
150 
151  KBOOL operator == ( const GridDataType1 & Value ) const;
152  KBOOL operator != ( const GridDataType1 & Value ) const;
153 };
154 
155 } // END namespace DATA_TYPES
156 } // END namespace KDIS
157 
KUINT16 m_ui16NumValues
Definition: GridDataType1.h:59
KFLOAT32 m_f32FieldOffset
Definition: GridDataType1.h:57
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT16 m_ui16Padding
Definition: GridDataType1.h:63
float KFLOAT32
Definition: KDefines.h:113
Definition: GridData.h:48
Definition: KDefines.h:182
Definition: KDataStream.h:48
bool KBOOL
Definition: KDefines.h:119
std::vector< KUINT16 > m_vui16Values
Definition: GridDataType1.h:61
std::string KString
Definition: KDefines.h:116
Definition: GridDataType1.h:51
KFLOAT32 m_f32FieldScale
Definition: GridDataType1.h:55
#define KDIS_EXPORT
Definition: KDefines.h:82