KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Signal_PDU.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: Signal_PDU
32  DIS: (5) 1278.1 - 1995
33  created: 22/10/2008
34  author: Karl Jones
35 
36  purpose: The Signal PDU contains the content of a radio transmission.
37  This content may be digitized audio, binary data, or an index
38  into a database that defines the signal.
39  A Signal PDU shall be issued whenever voice or data is being transmitted.
40 
41  size: 256 bits / 32 - min size
42 *********************************************************************/
43 
44 #pragma once
45 
47 #include "./../../DataTypes/EncodingScheme.h"
48 #include <vector>
49 
50 namespace KDIS {
51 namespace PDU {
52 
54 {
55 protected:
56 
58 
60 
62 
64 
65  std::vector<KOCTET> m_vData;
66 
67 public:
68 
69  static const KUINT16 SIGNAL_PDU_SIZE = 32; // Min Size
70 
71  Signal_PDU();
72 
73  Signal_PDU( const Header & H );
74 
75  Signal_PDU( KDataStream & stream ) throw( KException );
76 
77  Signal_PDU( const Header & H, KDataStream & stream ) throw( KException );
78 
80  KUINT32 SampleRate, KUINT16 Samples, const KOCTET * Data, KUINT16 DataLength );
81 
82  virtual ~Signal_PDU();
83 
84  //************************************
85  // FullName: KDIS::PDU::Signal_PDU::SetEncodingScheme
86  // KDIS::PDU::Signal_PDU::GetEncodingScheme
87  //!Description: Encoding scheme used for the data.
88  // Parameter: const EncodingScheme & ES
89  //************************************
90  void SetEncodingScheme( const KDIS::DATA_TYPE::EncodingScheme & ES );
91  const KDIS::DATA_TYPE::EncodingScheme & GetEncodingScheme() const;
92  KDIS::DATA_TYPE::EncodingScheme & GetEncodingScheme();
93 
94  //************************************
95  // FullName: KDIS::PDU::Signal_PDU::SetSampleRate
96  // KDIS::PDU::Signal_PDU::GetSampleRate
97  //!Description: sample rate in samples per second if the encoding
98  //! class is encoded audio or the data rate in bits
99  //! per second for data transmissions.
100  //! If the Encoding Class is database index,
101  //! this field shall be zero.
102  // Parameter: KUINT32 SR
103  //************************************
104  void SetSampleRate( KUINT32 SR );
105  KUINT32 GetSampleRate() const;
106 
107  //************************************
108  // FullName: KDIS::PDU::Signal_PDU::GetSampleRate
109  //!Description: Returns data length in bits, if encoding class is
110  //! database index then the length shall be 96.
111  //************************************
112  KUINT16 GetDataLength() const;
113 
114  //************************************
115  // FullName: KDIS::PDU::Signal_PDU::SetSamples
116  // KDIS::PDU::Signal_PDU::GetSamples
117  //!Description: Number of samples in PDU
118  // Parameter: KUINT16 S
119  //************************************
120  void SetSamples( KUINT16 S );
121  KUINT16 GetSamples() const;
122 
123  //************************************
124  // FullName: KDIS::PDU::Signal_PDU::SetData
125  // KDIS::PDU::Signal_PDU::GetData
126  //!Description: The data being sent. set function will add
127  //! padding so the PDU size is a multiple of 32 bits.
128  // Parameter: KOCTET * D - buffer for writing/reading
129  // Parameter: KUINT16 Length - size of data in BITS(buffer size should be at least the size GetDataLength)
130  //************************************
131  void SetData( const KOCTET * D, KUINT16 Length );
132  void GetData( KOCTET * D, KUINT16 Length ) const throw( KException );
133 
134  //************************************
135  // FullName: KDIS::PDU::Signal_PDU::GetAsString
136  //!Description: Returns a string representation of the PDU.
137  //************************************
138  virtual KString GetAsString() const;
139 
140  //************************************
141  // FullName: KDIS::PDU::Signal_PDU::Decode
142  //!Description: Convert From Network Data.
143  // Parameter: KDataStream & stream
144  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
145  //************************************
146  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
147 
148  //************************************
149  // FullName: KDIS::PDU::Signal_PDU::Encode
150  //!Description: Convert To Network Data.
151  // Parameter: KDataStream & stream
152  //************************************
153  virtual KDataStream Encode() const;
154  virtual void Encode( KDataStream & stream ) const;
155 
156  KBOOL operator == ( const Signal_PDU & Value ) const;
157  KBOOL operator != ( const Signal_PDU & Value ) const;
158 };
159 
160 } // END namespace PDU
161 } // END namespace KDIS
162 
unsigned int KUINT32
Definition: KDefines.h:103
Definition: Radio_Communications_Header.h:48
std::vector< KOCTET > m_vData
Definition: Signal_PDU.h:65
KUINT16 m_ui16Samples
Definition: Signal_PDU.h:63
unsigned short int KUINT16
Definition: KDefines.h:101
Definition: KDefines.h:182
Definition: KDataStream.h:48
KDIS::DATA_TYPE::EncodingScheme m_EncodingScheme
Definition: Signal_PDU.h:57
Definition: Signal_PDU.h:53
KUINT32 m_ui32SampleRate
Definition: Signal_PDU.h:59
bool KBOOL
Definition: KDefines.h:119
std::string KString
Definition: KDefines.h:116
Definition: EntityIdentifier.h:49
Definition: Header7.h:142
KUINT16 m_ui16DataLength
Definition: Signal_PDU.h:61
char KOCTET
Definition: KDefines.h:108
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: EncodingScheme.h:47