DataDirector API
DIS_Producer.h
Go to the documentation of this file.
1 
2 /*! \file DIS_Producer.h
3  \brief The DIS_Producer class. Produces attributes from DIS Data PDUs.
4 
5  \par Copyright Information
6 
7  Copyright (c) 2012 The DiSTI Corporation.<br>
8  11301 Corporate Blvd; Suite 100<br>
9  Orlando, Florida 32817<br>
10  USA<br>
11  <br>
12  All rights reserved.<br>
13 
14  This Software contains proprietary trade secrets of DiSTI and may not be
15 reproduced, in whole or part, in any form, or by any means of electronic,
16 mechanical, or otherwise, without the written permission of DiSTI. Said
17 permission may be derived through the purchase of applicable DiSTI product
18 licenses which detail the distribution rights of this content and any
19 Derivative Works based on this or other copyrighted DiSTI Software.
20 
21  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
22 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
23 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
24 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
25 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
26 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
27 
28  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
29 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
30 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
31 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
32 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
33 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
34 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
35 EXCEED FIVE DOLLARS (US$5.00).
36 
37  The aforementioned terms and restrictions are governed by the laws of the
38 State of Florida and the United States of America.
39 
40 */
41 
42 #ifndef _DIS_PRODUCER_H
43 #define _DIS_PRODUCER_H
44 
45 #include "ChunkProducer.h"
46 #include "DDD_AttributeUInt.h"
47 #include <map>
48 
49 namespace disti
50 {
51 
52 typedef unsigned char UINT_8; /**< Unsigned int, 8 bits */
53 typedef unsigned short UINT_16; /**< Unsigned int, 16 bits */
54 typedef unsigned int UINT_32; /**< Unsigned int, 32 bits */
55 
56 /** DIS Entity ID */
57 typedef struct
58 {
59  UINT_16 site;
60  UINT_16 host;
61  UINT_16 entity;
62 } ENTITY_ID;
63 
64 /** DIS Protocol typedefs */
65 typedef UINT_8 DIS_EXERCISE_ID;
66 typedef UINT_8 DIS_VERSION;
67 typedef UINT_8 PROTOCOL_FAMILY;
68 typedef UINT_8 DIS_PDU_KIND;
69 typedef UINT_32 TIME_STAMP;
70 
71 /** DIS Protocol defines */
72 #define SIMULATION_MANAGEMENT_FAMILY 5
73 #define SET_DATA_PDU_KIND 19
74 
75 /** DIS Protocol header */
76 typedef struct
77 {
78  DIS_VERSION version;
79  DIS_EXERCISE_ID exercise;
80  UINT_8 kind;
81  PROTOCOL_FAMILY family;
82  TIME_STAMP time_stamp;
83  UINT_16 length;
84  UINT_16 unused_16_2;
86 
87 /** DIS Set Data PDU structure */
88 typedef struct
89 {
90  DIS_PDU_HEADER header;
91  ENTITY_ID originating_entity_id;
92  ENTITY_ID receiving_entity_id;
93  UINT_32 request_id;
94  UINT_32 padding;
95  UINT_32 number_fixed_datums;
96  UINT_32 number_variable_datums;
98 
99 /** DIS Fixed Datum structure */
100 typedef struct
101 {
102  UINT_32 datum_id;
103  UINT_32 datum_value;
105 
106 /** DIS Variable Datum structure */
107 typedef struct
108 {
109  UINT_32 datum_id;
110  UINT_32 datum_length;
112 
113 /** DIS Producer class */
114 class DDD_EXPORT DIS_Producer : public ChunkProducer
115 {
116  /** Processes an individual fixed or variable datum chunk
117  * \param datumID The DIS Datum ID of the chunk
118  * \param chunk Pointer to the chunk containing the datum minus the datum ID
119  * \param length Length of the datum chunk
120  */
121  void ProcessDatumChunk(unsigned long datumID,unsigned char *chunk,unsigned long length);
122 
123  /** Iterates through and processes the fixed datums of the Set Data PDU
124  * \param pdu Pointer to a SetDataPDU to process
125  */
126  void ProcessFixedDatums(DIS_SET_DATA_VARIANT *pdu);
127 
128  /** Iterates through and processes the variable datums of the Set Data PDU
129  * \param pdu Pointer to a SetDataPDU to process
130  */
131  void ProcessVariableDatums(DIS_SET_DATA_VARIANT *pdu);
132 
133  /** \return Returns true if any of the attributes of the chunk have been updated
134  * param chunk The chunk to check
135  */
136  bool NeedToUpdateChunk(ChunkDescription *chunk);
137 
138 public:
139 
140  /** Constructor */
141  DIS_Producer();
142 
143  /** Processes an inbound message, classifying it into chunks and then updating their associated
144  * attributes.
145  * \param msgBuf A buffer containing a message
146  * \param receivedLength The length of the received message
147  */
148  virtual void ProcessMessage(unsigned char *msgBuf,unsigned int receivedLength);
149 
150  /** Builds an outbound message buffer. Only implemented by ChunkProducers that send data.
151  * \param msgBuf A buffer to contain the message
152  * \param maxMessageLength The max length of the message to build
153  * \return The length of the message built or -1 if no message built
154  */
155  virtual int BuildMessage(unsigned char *msgBuf,unsigned int maxMessageLength, unsigned int chunkNumber);
156 
157  /* Function that implements the DDD_AttributeObserver interface
158  * \param attribute Pointer to the attribute whose value just
159  * changed
160  */
161  virtual void OnAttributeChanged(DDD_AttributeBase *attribute);
162 
163  /** Perform any producer specific initialization
164  */
165  virtual void Start();
166 
167 protected:
168  DDD_AttributeUInt *_exerciseID; /**< DIS Exercise ID.*/
169  DDD_AttributeUInt *_DISVersion; /**< DIS Version. */
170  DDD_AttributeUInt *_sourceSite; /**< Source DIS Site */
171  DDD_AttributeUInt *_sourceHost; /**< Source DIS Host */
172  DDD_AttributeUInt *_sourceEntity; /**< Source DIS Entity */
173  DDD_AttributeUInt *_destSite; /**< Destination DIS Site */
174  DDD_AttributeUInt *_destHost; /**< Destination DIS Host */
175  DDD_AttributeUInt *_destEntity; /**< Destination DIS Entity */
176 
177  std::map<unsigned int,ChunkDescription*> _datumIDMap; /**< Map of datum IDs to ChunkProducers */
178 };
179 
180 /** Creator function for DIS_Producer used by ChunkProducerFactory */
181 DDD_EXPORT extern ChunkProducer *CreateDISProducer();
182 
183 } // end of namespace disti
184 
185 #endif
186 
The ChunkProducer class.
The DDD_AttributeUInt class. Unsigned integer attribute.
Definition: ChunkProducer.h:183
A virtual interface class for all DataDirector attribute types.
Definition: DDD_AttributeBase.h:87
Definition: DIS_Producer.h:107
Definition: ChunkProducer.h:237
DDD_AttributeUInt * _destSite
Definition: DIS_Producer.h:173
std::map< unsigned int, ChunkDescription * > _datumIDMap
Definition: DIS_Producer.h:177
ChunkProducer * CreateDISProducer()
unsigned short UINT_16
Definition: DIS_Producer.h:53
Definition: DIS_Producer.h:57
DDD_AttributeUInt * _sourceEntity
Definition: DIS_Producer.h:172
DDD_AttributeUInt * _sourceSite
Definition: DIS_Producer.h:170
unsigned int UINT_32
Definition: DIS_Producer.h:54
DDD_AttributeUInt * _sourceHost
Definition: DIS_Producer.h:171
DDD_AttributeUInt * _destEntity
Definition: DIS_Producer.h:175
Definition: DIS_Producer.h:114
DDD_AttributeUInt * _destHost
Definition: DIS_Producer.h:174
Definition: DIS_Producer.h:88
Definition: DIS_Producer.h:100
DataDirector attribute class corresponding to a unsigned 32-bit integer datatype. ...
Definition: DDD_AttributeUInt.h:53
DDD_AttributeUInt * _DISVersion
Definition: DIS_Producer.h:169
UINT_8 DIS_EXERCISE_ID
Definition: DIS_Producer.h:65
Definition: AttributeChangedEmitter.h:46
Definition: DIS_Producer.h:76
unsigned char UINT_8
Definition: DIS_Producer.h:52
DDD_AttributeUInt * _exerciseID
Definition: DIS_Producer.h:168