VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
exerciseConnDIS.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
8 
9 #pragma once
10 
11 #if DtDIS
12 
13 
14 #include <vlutil/vlMachineTypes.h>
15 #include "pduCallbackManager.h"
16 #include <vlpi/disEnums.h>
17 #include "packets/pduHeader.h"
18 #include "baseExerciseConn.h"
19 #include "stateMsgDIS.h"
20 #include "interactionDIS.h"
21 #include <matrix/vlMath.h>
22 #include <vlutil/vlHashlist.h>
23 #include "pduFactory.h"
24 #include <vlutil/vlTimeStampType.h>
25 #include "eventId.h"
26 #include <vlutil/vlVersion.h>
27 
28 #include <vlutil/vlInetDevice.h>
29 #include <vlutil/vlInetEndpoint.h>
30 #include <vlutil/vlInetAddr.h>
31 #include <vlutil/vlInetSocket.h>
32 
33 class DtPdu;
34 class DtDisObjectManager;
36 class DtInetDevice;
37 class DtDisSocket;
38 class DtOwnershipHandler;
43 
48 
50 typedef DtPdu* (*DtPduInterceptFcn)(DtPdu* pdu, int *retCode);
51 
62 {
63 public:
64 
65  typedef int (*DtPredicate)(DtPdu *pdu, void *arg);
66 
68  enum {
69  DtNET_READ_SUCCESS =0,
70  DtNET_READ_NO_PACKETS =1,
71  DtNET_READ_BAD_PACKET =2,
72  DtNET_READ_SERVER_MSG =3,
73  DtNET_READ_SIZE_MISMATCH =4
74  };
75  enum
76  {
77  DtPROCESS_PDU_SUCCESS =0,
78  DtPROCESS_PDU_WRONG_EXID =5,
79  DtPROCESS_PDU_NO_PDU =6,
80  DtNET_READ_FILTERED_PACKET =7
81  };
82 
92  DtINIT_SUCCESS =0,
93  DtCOULD_NOT_CREATE_SOCKET =1
94  };
95 
96 public:
97 
104  DtExerciseConn(const DtExerciseConnInitializer& initial, InitializationStatus* status = 0);
105 
108  DtExerciseConn(int port, int exercise_id,
109  int site_id, int application_num,
110  InitializationStatus* status = 0, bool use_async_io = false,
111  bool useIpv6 = false, bool suppressSelfReflect = false);
112 
115  DtExerciseConn(int port, const DtInetAddr& destAddr, int exercise_id,
116  int site_id, int application_num, InitializationStatus* status = 0,
117  bool use_async_io = false, bool suppressSelfReflect = false);
118 
121  DtExerciseConn(DtInetSocket* skt, int exercise_id,
122  int site_id, int application_num, InitializationStatus* status = 0);
123 
125  virtual ~DtExerciseConn();
126 
127 private:
128 
130  DtExerciseConn(const DtExerciseConn& orig);
131 
134 
135 public:
136 
137 
141  virtual void addPduCallback( DtPduKind pduKind, DtPduCallbackFcn fcn, void *usr);
142 
146  virtual void removePduCallback( DtPduKind pduKind, DtPduCallbackFcn fcn, void *usr);
147 
153  virtual int drainInput(DtTime timeout=-1, int nReadPerTimeCheck=100);
154 
157  virtual int readAndProcess(void);
158 
162  virtual int processPdu(DtPdu *pdu);
163 
168  virtual DtPdu *netRead(int *retCode = 0);
169 
175  virtual void addInterestInPduKind(DtPduKind kind);
176 
182  virtual void subtractInterestInPduKind(DtPduKind kind);
183 
188  virtual DtPduKind readUntil(DtPredicate predicate, void *arg,
189  DtTime timeout, DtTime sleepTime=0.1);
190 
193  virtual void addInterestInMcastAddr(const DtInetAddr& addr);
194 
197  virtual void subtractInterestInMcastAddr(const DtInetAddr& addr);
198 
200  virtual void send(const DtStateMsg &msg);
201 
203  virtual void send(const DtInteraction &msg);
204 
206  virtual void sendStamped(const DtStateMsg &msg);
207 
209  virtual void sendStamped(const DtInteraction &msg);
210 
215  virtual int send(
216  const DtPdu &pdu, const DtInetAddr* addr = 0);
217 
223  virtual int sendStamped(
224  const DtPdu &pdu, const DtInetAddr* addr = 0);
225 
228  virtual DtInetAddr* destinationAddr(const DtPdu &pdu);
229 
236  virtual bool addDestination(const DtInetAddr& destination, DtU16 port=0);
237 
244  virtual bool removeDestination(const DtInetAddr& destination, DtU16 port=0);
245 
247  virtual void setExerciseId(int exercise_id);
248 
250  virtual DtExerciseId exerciseId() const;
251 
254  virtual const DtEventID& nextEventId();
255 
257  virtual DtInetSocket* socket();
258 
259 
267  virtual DtPduFactory *pduFactory();
268 
272  virtual DtPduEncoderFactory* pduEncoderFactory();
273 
277  virtual DtPduDecoderFactory* pduDecoderFactory();
278 
284  virtual void setPduFactory(DtPduFactory* fact);
285 
288  virtual DtStateRepositoryExtensionEncoderFactory* stateRepoExtensionEncoderFactory();
289 
292  virtual DtStateRepositoryExtensionDecoderFactory* stateRepoExtensionDecoderFactory();
293 
295  virtual void enableFiltering();
296 
298  virtual void disableFiltering();
299 
301  virtual void setTimeStampType(DtTimeStampType relOrAbs);
302 
304  virtual DtTimeStampType timeStampType() const;
305 
309  virtual void setTimeStampType(int relOrAbs);
310 
312  virtual DtDisObjectManager* disObjectManager();
313 
314 
318 
319  virtual void setDefaultOwnershipHandler(DtOwnershipHandler* ownershipHandler);
320  virtual DtOwnershipHandler* defaultOwnershipHandler();
321 
322  void setRelativeTimeRatio(float ratio);
323  float relativeTimeRatio();
324 
326  virtual void setAttributePduStrategy(DtAttributePduStrategy strat);
327  virtual DtAttributePduStrategy attributePduStrategy() const;
328 
330  void setPduInterceptor(DtPduInterceptFcn interceptor);
331  DtPduInterceptFcn pduInterceptor() const;
332 
333 public:
334 
336  static DtString vrlinkVersion();
337 
339  static const int nSizeMismatchComplain;
340 
341 protected:
342 
343 
347  virtual DtTime currentTimeForStamping();
348 
350  void init0(int port, int exerId, int siteId, int applNum,
351  InitializationStatus* status, bool async_io, bool useIpv6,
352  bool suppressSelfReflect);
353 
355  void init0(DtInetSocket* s, int exerId, int siteId, int applNum,
356  InitializationStatus* status);
357 
358  virtual void setRemoteEndpoint( const DtInetAddr& addr, int port );
359 
361  void init(DtInetSocket* s, int deleteSkt,
362  int exerId, int siteId, int applNum, InitializationStatus* status);
363 
364  DtDisSocket* initializeSocket(const DtInetAddr& address, int port,
365  bool useAsyncIo, DtInetDevice* device, bool suppressSelfReflect);
366 
367 protected:
372  int pduInterest[DtMAX_PDU_KINDS + 1];
373  void zeroPduInterestList();
375  bool filtering;
388 
395 
396  // Correction coefficient for relative time correction
398 
399  // How we should send attribute PDUs
401 };
402 
403 
404 inline DtExerciseConn::DtExerciseConn(int po, int ex, int si,
405  int ap, InitializationStatus* status, bool use_async_io, bool useIpv6,
406  bool suppressSelfReflect)
407  : mcastAddrs()
408  , myRelOrAbs(DtTimeStampRelative)
409  , myBufferChain()
410  , myBuffer(DtDEFAULT_SOCK_BUFF_SIZE)
411  , myPacketBuffer(0)
412  , myEndpointReceivedFrom()
413  , myOwnershipHandler(0)
414  , myPduInterceptor(0)
416 {
417  init0(po, ex, si, ap, status, use_async_io, useIpv6, suppressSelfReflect);
418 }
419 
421  DtInetSocket* so, int ex, int si,
422  int ap, InitializationStatus* status)
423  : mcastAddrs()
424  , myRelOrAbs(DtTimeStampRelative)
425  , myBufferChain()
426  , myBuffer(DtDEFAULT_SOCK_BUFF_SIZE)
427  , myPacketBuffer(0)
428  , myEndpointReceivedFrom()
429  , myOwnershipHandler(0)
430  , myPduInterceptor(0)
432 {
433  init0(so, ex, si, ap, status);
434 }
435 
437 {
438  int result;
439  DtPdu *pdu = netRead(&result);
440  if (result == DtNET_READ_SUCCESS)
441  {
442  result = processPdu(pdu);
443  }
444  if (pdu)
445  {
446  delete pdu;
447  }
448  return result;
449 }
450 
452 {
453  return myExerciseId;
454 }
455 
457 {
458  return myPduFact;
459 }
460 
461 
463 {
464  return myPduEncFact;
465 }
466 
467 
469 {
470  return myPduDecFact;
471 }
472 
474 {
476 }
477 
479 {
481 }
482 
483 
485 {
486  return mySocket;
487 }
488 
490 {
491  return myDisObjectManager;
492 }
493 
494 
495 #endif
DtInteraction is an base class for representing DIS PDUs which don&#39;t have state.
Definition: interactionDIS.h:24
This file contains the declaration of the DtInetSocket base class.
Instances of DtExerciseConn are used to provide an application&#39;s interface or connection to the netwo...
Definition: exerciseConnDIS.h:61
DtInetEndpoint myRemoteEndpoint
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:390
DtDisObjectManager * myDisObjectManager
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:385
#define DT_DLL_VL
Definition: vlMachineTypes.h:108
Instances of DtExerciseConnInitializer are used to provide the DtExerciseConn with initialization dat...
Definition: exerciseConnInitializerDIS.h:36
bool filtering
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:375
A DIS Exercise connection will create an instance of this class which allows state repository extensi...
Definition: stateRepositoryExtensionDecoderFactory.h:23
DtBaseExerciseConn & operator=(const DtBaseExerciseConn &)
Assignment Operator – Not Implemented.
std::vector< DtInetBuffer * > DtInetBufferChain
Socket state enumeration.
Definition: vlInetSocket.h:105
DtPduFactory * myPduFact
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:377
virtual DtInetSocket * socket()
Returns the current DtDisSocket that we are using for communication.
Definition: exerciseConnDIS.h:484
Definition: vlTimeStampType.h:18
No error, call was sucessful.
Definition: exerciseConnDIS.h:69
The DtInetSocket class provides a protocol independant, address family independant base class for TCP...
Definition: vlInetSocket.h:201
DtBaseExerciseConn is an abstract base class.
Definition: baseExerciseConn.h:31
DtPduInterceptFcn myPduInterceptor
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:387
This file declares macros which specify the VR-Link version.
DtPduEncoderFactory * myPduEncFact
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:379
DtTimeStampType myRelOrAbs
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:384
class DtPduFactory:
Definition: pduFactory.h:38
DtHashlist mcastAddrs
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:376
DtPdu *(* DtPduInterceptFcn)(DtPdu *pdu, int *retCode)
PDU intercept function signature.
Definition: exerciseConnDIS.h:50
virtual DtDisObjectManager * disObjectManager()
Get the disObjectManager.
Definition: exerciseConnDIS.h:489
void init0(int port, int exerId, int siteId, int applNum, InitializationStatus *status, bool async_io, bool useIpv6, bool suppressSelfReflect)
Called by constructor.
virtual int processPdu(DtPdu *pdu)
Called by readAndProcess (which is called by drainInput).
This file contains the declaration of the DtInetEndpoint class.
float myRelativeTimeRatio
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:397
The DtInetEndpoint class provides a protocol independant, address family independent mechanism to rep...
Definition: vlInetEndpoint.h:33
Instances of DtPduEncoderFactory are used to create encoders which know how to encode a state reposit...
Definition: pduEncoderFactory.h:19
The DtDisSocket class provides an address family independent datagram socket.
Definition: vlDisSocket.h:75
static const int nSizeMismatchComplain
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:339
This file defines math constants and methods which may be useful in simulations.
DtInetEndpoint myEndpointReceivedFrom
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:394
virtual void sendStamped(const DtStateMsg &msg)=0
Send a state message to the network which has been time stamped with the current time.
virtual DtPduDecoderFactory * pduDecoderFactory()
Get the factory used to convert pdu information to the VR-Link State Repositories.
Definition: exerciseConnDIS.h:468
Defines DtHashlist and several helper functions.
Represents a IPv4 or IPv6 address.
Definition: vlInetAddr.h:36
Definition: vlAttributePduStrategy.h:19
DtAttributePduStrategy myAttributePduStrategy
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:400
DtInetBuffer myBuffer
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:392
DtEventID myCurrentEventId
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:383
virtual void send(const DtStateMsg &msg)=0
Send a state message to the network.
DtPdu is the base class for all PDU&#39;s in VR-Link.
Definition: pdu.h:69
const DtExerciseId DtAnyExercise
Used to indicate we are interested in all exercises.
Definition: exerciseConnDIS.h:47
InitializationStatus
InitializationStatus enumerates possible values to be returned by the ExerciseConns&#39;s optional &#39;statu...
Definition: exerciseConnDIS.h:91
DtStateRepositoryExtensionEncoderFactory * myStateRepoExtensionEncFac
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:381
std::vector< char > DtInetBuffer
Socket state enumeration.
Definition: vlInetSocket.h:104
DtAttributePduStrategy
Definition: vlAttributePduStrategy.h:16
const DtExerciseId DtMaxExerciseId
A total of 255 exercises can be supported.
Definition: exerciseConnDIS.h:45
DtInetBufferChain myBufferChain
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:391
Represents Events in DIS.
Definition: eventId.h:154
This file contains the declaration of the DtInetAddr class.
DtPduDecoderFactory * myPduDecFact
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:380
Definition: vlInetDevice.h:101
int availEventNum
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:369
DtInetSocket * mySocket
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:389
virtual DtExerciseId exerciseId() const
Get the current exercise ID.
Definition: exerciseConnDIS.h:451
virtual DtPdu * netRead(int *retCode=0)
Reads the network, users should seldom need to call this function.
DtPduCallbackManager myPduCbMgr
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:371
char * myPacketBuffer
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:393
int socket(int, int, int)
#define DtDEFAULT_SOCK_BUFF_SIZE
Definition: vlInet.h:69
DtExerciseConn(const DtExerciseConnInitializer &initial, InitializationStatus *status=0)
The preferred constructor.
virtual DtPduEncoderFactory * pduEncoderFactory()
Get the factory used to convert pdu information from the VR-Link State Repositories.
Definition: exerciseConnDIS.h:462
class DtPduCallbackManager:
Definition: pduCallbackManager.h:27
This file contains the declaration of the DtInetDevice class.
virtual DtStateRepositoryExtensionEncoderFactory * stateRepoExtensionEncoderFactory()
Get the factory used to convert information from the VR-Link State Repositories Extensions to attribu...
Definition: exerciseConnDIS.h:473
DtHashlist is deprecated and provided for backwards compatibility only.
Definition: vlHashlist.h:69
This is a base class meant to encapsulate user callbacks on ownership management services.
Definition: ownershipHandlerDIS.h:39
DtOwnershipHandler * myOwnershipHandler
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:386
unsigned short DtU16
A 16 bit unsigned integer value.
Definition: vlMachineTypes.h:140
Contains the standard DIS enumerations.
void(* DtPduCallbackFcn)(DtPdu *pdu, void *usr)
PDU callback function signature.
Definition: pduCallbackManager.h:19
Definition: vlAttributePduStrategy.h:20
DtStateRepositoryExtensionDecoderFactory * myStateRepoExtensionDecFac
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:382
virtual DtStateRepositoryExtensionDecoderFactory * stateRepoExtensionDecoderFactory()
Get the factory used to convert PDU attribute records to the VR-Link State Repositories Extensions...
Definition: exerciseConnDIS.h:478
DtTimeStampType
Definition: vlTimeStampType.h:16
int DtProtocolVersionToSend
Contains the DtEventId class declaration.
DtPduKind
([UID 4]) - PDU Type
Definition: disEnums.h:238
#define DtMAX_PDU_KINDS
Definition: pduCallbackManager.h:73
int nSizeMismatch
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:374
Instances of DtString are used to represent strings.
Definition: vlString.h:29
DtPduFactory * myDfltPduFact
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:378
DtExerciseId myExerciseId
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:368
This file provides a declaration of the class DtBaseExerciseConn.
virtual int readAndProcess(void)
Called by drainInput, so application code rarely needs to use this.
Definition: exerciseConnDIS.h:436
Instances of DtStateMsg are used to represent state data communicated via the network in a DIS (as op...
Definition: stateMsgDIS.h:21
Instances of DtPduDecoderFactory are used to create Decoders which know how to encode a state reposit...
Definition: pduDecoderFactory.h:18
int deleteSocket
For VR-Link use only, should not be considered part of the public interface.
Definition: exerciseConnDIS.h:370
DtU16 DtExerciseId
Definition: baseExerciseConn.h:16
This file contains typedefs for machine dependant types.
virtual DtPduFactory * pduFactory()
Get the PDU factory used by netRead to create the right kind of derived DtPDU.
Definition: exerciseConnDIS.h:456
A DIS Exercise connection will create an instance of this class which allows state repository extensi...
Definition: stateRepositoryExtensionEncoderFactory.h:23
Instances of DtDisObjectManager are used to manage the set of DIS objects known to the federate...
Definition: disObjectManager.h:21

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)