00001
00002
00004
00005 #ifndef __NQMESSAGE_H_INCLUDED_SW__
00006 #define __NQMESSAGE_H_INCLUDED_SW__
00007
00008
00046
00047
00048
00049
00050 class CNQMessage
00051 {
00052 friend class CNetworkQueue;
00053 friend class CNQPacketQueue;
00054 public:
00055
00056
00058 CNQMessage();
00060 ~CNQMessage();
00061
00063 void clear();
00064
00067 INT32 check_int() const;
00068
00071 bool check_bool() const;
00072
00075 bool isResponse() const;
00076
00079 bool isRequest() const;
00080
00083 bool isTelegram() const;
00084
00088 bool getSenderIPandPort( UINT32 &ip_peer_hostorder, UINT16 &port_peer_hostorder );
00089
00090
00092
00093
00100 bool read_BINARY( UINT16 varid, UINT8 *target_buffer, UINT32 &target_buffer_size_bytes);
00106 bool read_FLOAT( UINT16 varid, FLOAT &target_buffer);
00112 bool read_DOUBLE( UINT16 varid, DOUBLE &target_buffer);
00118 bool read_INT8( UINT16 varid, INT8 &target_buffer);
00124 bool read_UINT8( UINT16 varid, UINT8 &target_buffer);
00130 bool read_INT16( UINT16 varid, INT16 &target_buffer);
00136 bool read_UINT16( UINT16 varid, UINT16 &target_buffer);
00142 bool read_INT32( UINT16 varid, INT32 &target_buffer);
00148 bool read_UINT32( UINT16 varid, UINT32 &target_buffer);
00155 bool read_TEXT( UINT16 varid, UINT8 *target_buffer, UINT32 &target_buffer_size_bytes);
00165 bool read( UINT16 varid, UINT16 vartype, VOIDP target_buffer, UINT32 &target_buffer_num_elements);
00166
00168
00169
00171
00172
00180 bool write_BINARY( UINT16 varid, const UINT8 *source_buffer, UINT32 source_buffer_size_bytes );
00187 bool write_FLOAT( UINT16 varid, FLOAT source_buffer);
00194 bool write_DOUBLE( UINT16 varid, DOUBLE source_buffer);
00201 bool write_INT8( UINT16 varid, INT8 source_buffer);
00208 bool write_UINT8( UINT16 varid, UINT8 source_buffer);
00215 bool write_INT16( UINT16 varid, INT16 source_buffer);
00222 bool write_UINT16( UINT16 varid, UINT16 source_buffer);
00229 bool write_INT32( UINT16 varid, INT32 source_buffer);
00236 bool write_UINT32( UINT16 varid, UINT32 source_buffer);
00244 bool write_TEXT( UINT16 varid, const UINT8 *source_buffer, UINT32 source_buffer_size_bytes);
00253 bool write( UINT16 varid, UINT16 vartype, const VOIDP buffer, const UINT32 elements_in_buffer);
00254
00256
00261 void setType( UINT8 aPhysicalType, UINT8 aLogicalType);
00263 UINT8 getPhysicalType();
00265 UINT8 getLogicalType();
00266
00267 public:
00268
00269
00270
00272
00273
00275 UINT32 optAuthorisationID;
00277 UINT16 optSubsystemDeviceID;
00278
00284 UINT16 optPacketTypeParam;
00285
00287
00288 private:
00289
00290
00291
00292 bool matchAckPacket(const CNQMessage &ack_packet);
00293 void constructAckPacket(const CNQMessage &template_packet);
00294
00295 bool isAckPacket() const;
00296 bool wantAckPacket() const;
00297
00298
00299 inline UINT32 sizeof_per_element( const UINT16 vartype );
00300
00301
00302
00303 bool ImportMessageFromPacketBuffer(const UINT8 *buffer, INT32 buffer_length, UINT32 ip_hostorder, UINT16 port_hostorder);
00304 bool ExportMessageToPacketBuffer(UINT8 *buffer, INT32 &buffer_length);
00305
00306
00307
00308 void copy_data_depending_on_vartype( UINT32 *tgtbufpos, const UINT32 *srcbufpos, UINT32 num_elements, UINT16 vartype);
00309
00310
00311
00312 bool check_buffer_against_vartype( UINT16 vartype, const VOIDP buffer, UINT32 buflength);
00313
00314 private:
00315
00316
00317
00318 UINT8 mandatoryLogicalPacketType;
00319 UINT8 mandatoryPhysicalPacketType;
00320
00321
00322 INT32 payload_first_offset;
00323 UINT8 payload_buffer[(NQ_MAX_NUM_ENTRIES*NQ_MIN_SIZE_DATA)+NQ_SIZE_ADD_LINKEDLIST];
00324
00325
00326 UINT16 payload_buffer_left;
00327
00328
00329
00330
00331 UINT16 payload_curlength_net;
00332 UINT16 payload_num_elements;
00333
00334
00335
00336 UINT16 internalPacketIndex;
00337 UINT16 internalRequestID;
00338
00339
00340 UINT16 payload_maxlength_net;
00341
00342 UINT16 internalPacketMagic;
00343 UINT16 internalPacketSize;
00344 UINT16 internalPacketVersion;
00345 UINT16 internalPacketSpecialBits;
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356 UINT16 internalPacketTail;
00357
00358 private:
00359
00361
00362 bool message_came_from_set;
00363 UINT32 message_came_from_ip;
00364 UINT16 message_came_from_port;
00365
00366
00367
00368 UINT32 message_sendto_ip_host;
00369 UINT16 message_sendto_port_host;
00370
00371
00372 HANDLE notifySemaphoreOnReceiveAnswer;
00373 HANDLE notifySemaphoreOnReceiveAck;
00374 };
00375
00376 #endif // __NQMESSAGE_H_INCLUDED_SW__