00001 /*************** <auto-copyright.pl BEGIN do not edit this line> ************** 00002 * 00003 * VR Juggler is (C) Copyright 1998-2003 by Iowa State University 00004 * 00005 * Original Authors: 00006 * Allen Bierbaum, Christopher Just, 00007 * Patrick Hartling, Kevin Meinert, 00008 * Carolina Cruz-Neira, Albert Baker 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Library General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2 of the License, or (at your option) any later version. 00014 * 00015 * This library 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 GNU 00018 * Library General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Library General Public 00021 * License along with this library; if not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00023 * Boston, MA 02111-1307, USA. 00024 * 00025 * ----------------------------------------------------------------- 00026 * File: $RCSfile: ClusterDelta.h,v $ 00027 * Date modified: $Date: 2003/07/10 23:58:54 $ 00028 * Version: $Revision: 1.3 $ 00029 * ----------------------------------------------------------------- 00030 * 00031 *************** <auto-copyright.pl END do not edit this line> ***************/ 00032 00033 #ifndef _GADGET_CLUSTER_DELTA_H 00034 #define _GADGET_CLUSTER_DELTA_H 00035 00036 #include <gadget/gadgetConfig.h> 00037 00038 #include <vector> 00039 #include <boost/static_assert.hpp> 00040 00041 00042 // Algorithm to calculate clock diff between the two nodes (as a vpr::Interval) 00043 // - Initialize tolerance value 00044 // Until(passes) 00045 // - Connector sends it's current time 00046 // - Reciever reads and sends back it's current time 00047 // - Connector calculates an approximate difference 00048 // - Connector sends a message with an approximated receive time and the calculated diff 00049 // - Reciever responds with either success or failure 00050 // - If passed exit loop 00051 // - else increase tolerance by 1ms 00052 // @todo: hton crap 00053 // NOTE: 00054 // One of the reasons that this is so convoluted is.... 00055 // InitialState gets triggered explicitly when the previous handler completes 00056 // Otherwise, the only way in is when there is a packet of data waiting for us 00057 // thus, we can't just exist on any state. We have to exit in a state that is waiting for data. 00058 // This leads to much ugliness (like a goto. grrrrr) 00059 00060 namespace vpr 00061 { 00062 // class SocketStream; 00063 class BufferObjectReader; 00064 class BufferObjectWriter; 00065 } 00066 00067 namespace cluster 00068 { 00069 00070 class GADGET_CLASS_API ClusterDelta 00071 { 00072 public: 00073 ClusterDelta(); 00074 void getPacket(unsigned num); 00075 void sendAndClear(); 00076 void clearIntervals(); 00077 void receiveExpectedTime(); 00078 void createExpectedTime(); 00079 void receiveHandshake(); 00080 void createHandshake(); 00081 void createResponce(); 00082 void receiveResponce(); 00083 void clientClusterDelta(vpr::SocketStream* socket_stream); 00084 vpr::Interval getClusterDelta(vpr::SocketStream* socket_stream); 00085 void setSocketStream(vpr::SocketStream* socket_stream) 00086 { 00087 mSocketStream = socket_stream; 00088 } 00089 00090 private: 00091 vpr::Interval mLocalSendTime; 00092 vpr::Interval mLocalReceiveTime; 00093 vpr::Interval mRemoteSendTime; 00094 vpr::Interval mRemoteReceiveTime; 00095 vpr::Interval mExpectedRemoteTime; 00096 vpr::Interval mLatencyTime; 00097 vpr::Interval mDelta; 00098 vpr::Interval mErrorTime; 00099 std::vector<vpr::Uint8> syncPacket; 00100 bool mAccept; 00101 00102 // Tolerance 00103 float mTol; 00104 00105 // Object Reader & Writer 00106 unsigned mCurHeadPos; 00107 vpr::BufferObjectWriter mWriter; 00108 vpr::BufferObjectReader* mReader; 00109 vpr::SocketStream* mSocketStream; 00110 }; 00111 00112 } // namespace gadget 00113 00114 00115 #endif
1.2.14 written by Dimitri van Heesch,
© 1997-2002