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 /********************************************************************
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 and the actual data values in 8-bit.
39 NOTE: Data Representation Type 0 is specifcally designed to be fexible to accommodate anything
40 from character data to data expressed as foating point numbers.
42 size: 48 bits / 6 octets - Min size
43 *********************************************************************/
47 #include "./GridData.h"
55 class KDIS_EXPORT GridDataType0
: public GridData
59 KUINT16 m_ui16NumBytes
;
61 std::vector
<KUINT8
> m_vui8DataVals
;
67 static const KUINT16 GRID_DATA_TYPE0_SIZE
= 6; // Min size
71 GridDataType0( KDataStream
& stream
) ;
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 GridDataType0( KUINT16 SampleType
, KUINT16 DataRepresentation
, KDataStream
& stream
);
77 GridDataType0( KUINT16 SampleType
, KUINT8
* Data
, KUINT16 NumBytes
);
79 virtual ~GridDataType0();
81 //************************************
82 // FullName: KDIS::DATA_TYPE::GridDataType0::Encode
83 // Description: The number of bytes of environmental state variable data
84 // values contained in this record.
85 // Parameter: KDataStream & stream
86 //************************************
87 KUINT16
GetNumberOfBytes() const;
89 //************************************
90 // FullName: KDIS::DATA_TYPE::GridDataType0::AddGridAxisDescriptor
91 // KDIS::DATA_TYPE::GridDataType0::SetGridAxisDescriptors
92 // KDIS::DATA_TYPE::GridDataType0::GetSetGridAxisDescriptors
93 // KDIS::DATA_TYPE::GridDataType0::ClearValues
94 // Description: Specifies the environmental state variable data values. The data shall
95 // be represented as a stream of bytes, the interpretation of which shall be
96 // agreed to prior to the start of the exercise.
97 // Parameter: KUINT8 D, KUINT8 * Data,, const vector<KUINT8> & DV
98 // Parameter: KUINT16 NumBytes
99 //************************************
100 void AddDataValue( KUINT8 D
);
101 void SetDataValues( KUINT8
* Data
, KUINT16 NumBytes
);
102 void SetDataValues( const std::vector
<KUINT8
> & DV
);
103 const std::vector
<KUINT8
> & GetDataValues() const;
106 //************************************
107 // FullName: KDIS::DATA_TYPE::GridDataType0::GetDataRepresentation
108 // Description: Returns the size of the whole Grid Data type object in octets.
109 // Note: This information is not encoded into the PDU, it is here for the
110 // internal calculation of the PDU length value.
111 //************************************
112 virtual KUINT16
GetSize() const;
114 //************************************
115 // FullName: KDIS::DATA_TYPE::GridDataType0::GetAsString
116 // Description: Returns a string representation
117 //************************************
118 virtual KString
GetAsString() const;
120 //************************************
121 // FullName: KDIS::DATA_TYPE::GridDataType0::Decode
122 // Description: Convert From Network Data.
123 // Parameter: KDataStream & stream
124 //************************************
125 virtual void Decode( KDataStream
& stream
) ;
127 //************************************
128 // FullName: KDIS::DATA_TYPE::GridDataType0::Encode
129 // Description: Convert To Network Data.
130 // Parameter: KDataStream & stream
131 //************************************
132 virtual KDataStream
Encode() const;
133 virtual void Encode( KDataStream
& stream
) const;
135 KBOOL
operator == ( const GridDataType0
& Value
) const;
136 KBOOL
operator != ( const GridDataType0
& Value
) const;
139 } // END namespace DATA_TYPES
140 } // END namespace KDIS