Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

sockmasterc.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 1999  Carsten Winkelholz
00003 
00004 Address:  FGAN Forschungsgesellschaft fr Angewandte Naturwissenschaften e. V.
00005       Neuenahrer Str. 20
00006       D - 53343 Wachtberg
00007       
00008 Email:    winkelholz@fgan.de
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 */
00024 
00025 
00026 #ifndef SOCKMASTERC_H
00027 #define SOCKMASTERC_H
00028 
00029 #include "oaw/pdtk/masterc.h"
00030 #include "oaw/misc/stringc.h"
00031 #include "oaw/misc/arrayc.h"
00032 #include "oaw/pdtk/datdef.h"
00033 #include "oaw/misc/socketc.h"
00034 #include "oaw/misc/timec.h"
00035 #include "../oawconfig.h"
00036 
00037 OAW_BEGIN_NAMESPACE
00038 
00039 typedef ArrayC<long> LongArrayC; 
00040 
00042 
00043 #define ESOCKMASTERC_LOST_CONNECTION    0
00044 #define ESOCKMASTERC_SYSTEM_ERROR       1
00045 
00046 class OAW_DLLMAPPING ESockMasterC{
00047 public:
00048   ESockMasterC(const long& l){m_errorCode=l;}
00049   ESockMasterC(const StringC& s,const long& l){m_errorString=s;}
00050 public:
00051   StringC m_errorString;
00052   long m_errorCode;
00053 };
00054 
00056 
00057 class OAW_DLLMAPPING SockMasterC: public MasterC
00058 {
00059 
00060 public:
00061   //enum SocketType {USE_TCP, USE_UDP};
00062   SockMasterC();
00063   virtual ~SockMasterC();
00064   
00065   void InitByFile(const StringC& fileName);
00066   void BroadcastInitData();
00067   short ProcessEvents(const long&);
00068 
00069 protected:
00070   short GetInterface(const char * interfaceName, const char* trobjName, long& id, long & stype);
00071   void AnswerTrObjRequests();
00072   short UpdateSwapLoop();
00073   short LocalUpdateSwapLoop();
00074   void InitReady (long id);
00075   void BroadcastSwap();
00076   void BroadcastStart();
00077   void ReadyToSwap (long id );
00078   void ReadyToStart(long id);
00079 
00080   void DeleteNonConnectedTrObj();
00081   void ReadInterfaceToTrObj(char*& iter, const char* iterEnd, long& znr);
00082   void ConnectToTrObj(char*& iter, const char* iterEnd, long& znr);
00083   void ReadBasics(char*& iter, const char* iterEnd, long& znr);
00084   void InitBroadcastSock();
00085   void InitTrObj();
00086   void WriteFrameRate();
00087   void PrintSysInfo();
00088   void DealDataLengths();
00089   void UpdateLocalLoopData();
00090 
00091 protected:
00092   
00093   ArrayC<SocketC*> m_pSocketToTrObj;
00094   ArrayC<SocketC*> m_pUdpSocketFromTrObj;
00095   ArrayC<long> m_trObjDataMinLength;
00096   ArrayC<long> m_trObjDataMaxLength;
00097   ArrayC<long> m_trObjDataAssignedLength;
00098   ArrayC<long> m_trObjDataPresentLength;
00099   StringC m_initFileName;
00100   SocketSetC m_socketSet;
00101   
00102   StringC m_broadcastBase;
00103   StringC m_broadcastNetAddr;
00104   StringC m_endpoint;
00105   char* m_szLocalIP;
00106 
00107   long* m_swapMsgData;
00108   long m_swapMsgDataSize;
00109   
00110   SockAddressC  m_broadcastAddress;
00111   SocketC*    m_pBroadcastSocket;
00112   //ByteArrayC  m_tmpdata;
00113   ArrayC<ByteArrayC> m_tmpdata;
00114   ArrayC<LongArrayC> m_trobjRequestedInterfaces;
00115   
00116   long m_datagrammLength;
00117   ArrayC<long> m_datagrammLengthList;
00118   
00119   ArrayC<StringC> m_trObjHost;
00120   ArrayC<StringC> m_trObjPort;
00121   ArrayC<StringC> m_hostName;
00122   ArrayC<StringC> m_hostIP;
00123 
00124   StringC m_initData;
00125 
00126   TimeC m_time;
00127   TimeC m_timeLast;
00128   double m_dtMin;
00129   double m_dtMax;
00130   double m_dSleepTime;
00131 
00132   long m_counter;
00133   
00134   int m_isLocal;
00135   short m_bUseTCP;
00136 };
00137 
00138 OAW_END_NAMESPACE
00139 
00140 #endif
00141 
00142 
00143 
00144 
00145 
00146 

Generated on Tue Jul 29 14:24:15 2003 for Open ActiveWrl by doxygen1.3-rc2