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

sockeventbrokerc.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 SOCKEVENTBROKERC_H
00027 #define SOCKEVENTBROKERC_H
00028 
00029 #include "oaw/pdtk/eventbrokerc.h"
00030 #include "oaw/misc/stringc.h"
00031 #include "oaw/misc/arrayc.h"
00032 #include "oaw/misc/socketc.h"
00033 
00035 
00036 #define ESOCKTROBJC_NO_CONNECTION_TO_MASTER 0
00037 #define ESOCKTROBJC_SYSTEM_ERROR      1
00038 #define ESOCKTROBJC_SWAP_UNEXSPECTED      2
00039 #define ESOCKTROBJC_LOST_CONNECTION      3
00040 #include "../oawconfig.h"
00041 
00042 OAW_BEGIN_NAMESPACE
00043 
00044 const long cMsgDataLength = 3;
00045 
00046 class OAW_DLLMAPPING ESockEventBrokerC{
00047 public:
00048   ESockEventBrokerC(const long& l){m_errorCode=l;}
00049   ESockEventBrokerC(const StringC& s,const long&){m_errorString=s;}
00050 public:
00051   StringC m_errorString;
00052   long m_errorCode;
00053 };
00054 
00056 
00057 class OAW_DLLMAPPING SockEventBrokerC : public EventBrokerC
00058 {
00059 public:
00060   SockEventBrokerC(const StringC& name, const StringC& endpoint,const char*);
00061   SockEventBrokerC();
00062   virtual ~SockEventBrokerC();
00063 
00064    
00065   virtual int AssignInterface(const StringC&,InterfaceC*);
00066   virtual void InitializationReady();
00067   virtual int ProcessEvents();
00068 
00069 public:
00070   struct MsgDataStruct{
00071     long m_msg;
00072     long m_dataMinLength;
00073     long m_dataMaxLength;
00074   };
00075 
00076 protected:
00077   
00078   void Init(const StringC& name, const StringC& endpoint,const char*);
00079 
00080   void SetInitData(const char*, long);
00081   void CalcInterfacesMaxLengths();
00082 
00083   virtual void Update();
00084   virtual void PostUpdate();
00085   virtual void Swap();
00086   virtual void SetSleep();
00087   virtual void SetWake();
00088 
00089   void ExchangeData();
00090   void BroadcastDataOfInterfaces(long& sockIter, long& dataIter);
00091   void RecvDataOfInterfaces(long& sockIter, long& dataIter);
00092   
00093   void WaitOnMaster();
00094   void SetDataOfInterfaces(char* data);
00095   void SetDataOfInterfacesTCP(char* data,char* ownData);
00096   void UpdateDatapackage();
00097   void CalcDataMinMaxLength();
00098   
00099   void WaitOnInitData(SockAddressC&);
00100   void InitAsSlave();
00101   void InitAsNormal();
00102   void GetInterface(StringC interfacename, StringC trobjname, long& id, long& stype);
00103 
00104   void ExchangeDataSlave();
00105   void ExchangeDataNormal();
00106   
00107   int ProcessEventsNormal();
00108   int ProcessEventsSlave();
00109   
00110 protected:
00111  
00112 
00113   StringC m_name;
00114  
00115 
00116   SocketC m_socketToMaster;
00117 
00118   ByteArrayC m_data;
00119   ArrayC<ByteArrayC> m_tmpdata;
00120   
00121   ArrayC<InterfaceC*> m_pInterface;
00122   ArrayC<long> m_interfaceDataAssignedLength;
00123   ArrayC<long> m_interfaceDataMinLength;
00124   ArrayC<long> m_interfaceDataMaxLength;
00125     
00126   long m_dataAssignedLength;
00127   long m_dataPresentLength;
00128   int m_datapackageUpdated;
00129 
00130   long m_dataPortBase;
00131   long m_anzahlTrObj;
00132   
00133   int m_init;
00134   int m_start;
00135   int m_dataBroadcasted;
00136   long m_anzahlDataPorts;
00137   
00138   StringC m_endpoint;
00139   
00140   SockAddressC m_udpAddressToMaster;
00141   ArrayC<SockAddressC> m_dataBroadcastAddress;
00142 
00143   ArrayC<SocketC*> m_pUdpSocket;
00144   SocketC* m_pUdpSocketSyncSwap;
00145   
00146   long m_broadcastBase;
00147   StringC m_broadcastNetAddr;
00148   
00149   //Fuer die lokale Behandlung
00150   long m_localType;
00151   char* m_szLocalIP;
00152  
00153   long* m_swapMsgData;
00154   long m_swapMsgDataSize;
00155 
00156   MsgDataStruct m_msgData;
00157 
00158 };
00159 
00160 OAW_END_NAMESPACE
00161 
00162 #endif
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 

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