Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

Platform/Aperios1.3.2/UDPHandler.h

Go to the documentation of this file.
00001 /** 
00002 * @file  Platform/Aperios1.3.2/UDPHandler.h
00003 *
00004 * Class for using NetSender/NetReceivers over UDP 
00005 *
00006 * @author <A href=mailto:robocup@m-wachter.de>Michael Wachter</A>
00007 *
00008 */
00009 
00010 
00011 #ifndef _UDPHandler_H_
00012 #define _UDPHandler_H_
00013 
00014 
00015 #include "UDPEndpoint.h"
00016 #include "DDPHandler.h"
00017 #include "NetHandler.h"
00018 #include "NetSender.h"
00019 #include "NetReceiver.h"
00020 #include "Tools/Player.h"
00021 #include "NetConfig.h"
00022 
00023 class UDPHandler;
00024 
00025 
00026 
00027 /**
00028 *   The UDP-Handler and UDPHandlerEndpoint are used sends team communication data via an UDP-based protocol.
00029 *
00030 *   There are three UDPHandlerEndpoints which are doing the work of sending and receiving the data. 
00031 *   To distinguish between the different teammates the outgoing packages are send to the port number 
00032 *   TEAMPORTBASE + own player number. So the receiving robot knows where the package comes from.
00033 */
00034 
00035 class UDPHandlerEndpoint : public UDPEndpoint , public NetHandler
00036 {
00037 public:
00038   UDPHandlerEndpoint();
00039   ~UDPHandlerEndpoint();
00040     virtual void onSendingDone();  /**< sets the sender active again */
00041     virtual void onReceive(void* data, int size); /**< receives data and hands it over to the reciever */
00042   virtual void sendPackage(int SenderNumber, void* package, int size); /**< called by the sender to send the package */
00043   NetSenderBase* sender; /**< the associated sender */
00044   NetReceiverBase* receiver; /**< the associated reciver */
00045   DDPHandler* ddpHandler; /**< the ddpHandler providing the IPs of the teammates */
00046   UDPHandler* udpHandler; /**< the UDP-Handler which is handling this UDPHandlerEndpoint */
00047   int lastReceivedSerial; /**< serial of the last received package */
00048   int sendSerial; /**< serial of the last send package */
00049 };
00050 
00051 /*
00052  * The UDPHandler manages starting up the UDPHandlerEndpoints
00053  * and associates the senders and receivers to them.
00054  */
00055 
00056 class UDPHandler 
00057 {
00058   public:
00059     UDPHandler();
00060     ~UDPHandler(){};
00061 
00062   /**
00063    * Associates senders and receiver to UDPHandlerEndpoints
00064    */
00065 
00066     void addSenderAndReceiver(NetSenderBase& sender, NetReceiverBase& receiver);
00067     void start(); /**< initializes everything */
00068     void doRegularStuff(); /**< called by the UDPHandlerEndpoints */
00069   
00070   private:
00071   int numberOfEndpoints; /**< actual number of UPDHandlerEndpoints */
00072     UDPHandlerEndpoint endPoints[Player::numOfPlayerNumbers-1]; /**< list of UDPHandlerEndpoints */
00073   DDPHandler ddpHandler; /**< the DDP-Handler */
00074 };
00075 
00076 #endif 
00077 
00078 /*
00079  *
00080  * Changelog :
00081  *
00082  * $Log: UDPHandler.h,v $
00083  * Revision 1.2  2004/09/12 20:10:47  wachter
00084  * Documentation-fixes
00085  *
00086  * Revision 1.1.1.1  2004/05/22 17:23:41  cvsadm
00087  * created new repository GT2004_WM
00088  *
00089  * Revision 1.6  2004/05/14 14:12:08  wachter
00090  * - Added communication support for 5 robots
00091  * - rewrote parts of team-communication to be faster and more stable
00092  *
00093  * Revision 1.5  2004/01/23 18:28:47  wachter
00094  * Added detection of lost packets
00095  *
00096  * Revision 1.4  2004/01/21 17:33:09  wachter
00097  * UDP Team-communication now working with packets<1400 bytes.
00098  * Not activated at the moment.
00099  *
00100  * Revision 1.3  2004/01/20 14:21:41  wachter
00101  * - Added sender-number to NetSender
00102  * - worked on with Team-Communication
00103  *
00104  * Revision 1.2  2004/01/09 15:44:30  wachter
00105  * Worked on with the Dog-Discovery-Protocol
00106  *
00107  * Revision 1.1  2003/12/21 19:27:03  wachter
00108  * Added classes for Sender/Receiver over TCP and UDP.
00109  * ( PLEASE DO NOT USE THIS NOW ! )
00110  *
00111  *
00112  */

Generated on Thu Sep 23 19:57:34 2004 for GT2004 by doxygen 1.3.6