| 
      
      
      From: <he...@us...> - 2011-03-25 00:54:23
      
     | 
| Revision: 261
          http://simspark.svn.sourceforge.net/simspark/?rev=261&view=rev
Author:   hedayat
Date:     2011-03-25 00:54:16 +0000 (Fri, 25 Mar 2011)
Log Message:
-----------
* Added TimerSystemSDL
* Added Id SVN keyword to the new files
* Some cleanups
Modified Paths:
--------------
    trunk/spark/ChangeLog
    trunk/spark/lib/kerosin/inputserver/us.scan.rb
    trunk/spark/lib/oxygen/simulationserver/simulationserver.h
    trunk/spark/plugin/CMakeLists.txt
    trunk/spark/plugin/timersystemboost/timersystemboost.cpp
Added Paths:
-----------
    trunk/spark/plugin/timersystemsdl/
    trunk/spark/plugin/timersystemsdl/CMakeLists.txt
    trunk/spark/plugin/timersystemsdl/export.cpp
    trunk/spark/plugin/timersystemsdl/timersystemsdl.cpp
    trunk/spark/plugin/timersystemsdl/timersystemsdl.h
    trunk/spark/plugin/timersystemsdl/timersystemsdl_c.cpp
Property Changed:
----------------
    trunk/spark/lib/oxygen/simulationserver/timersystem.h
    trunk/spark/lib/oxygen/simulationserver/timersystem_c.cpp
    trunk/spark/plugin/timersystemboost/CMakeLists.txt
    trunk/spark/plugin/timersystemboost/export.cpp
    trunk/spark/plugin/timersystemboost/timersystemboost.cpp
    trunk/spark/plugin/timersystemboost/timersystemboost.h
    trunk/spark/plugin/timersystemboost/timersystemboost_c.cpp
Modified: trunk/spark/ChangeLog
===================================================================
--- trunk/spark/ChangeLog	2011-03-25 00:29:08 UTC (rev 260)
+++ trunk/spark/ChangeLog	2011-03-25 00:54:16 UTC (rev 261)
@@ -1,3 +1,22 @@
+2011-03-25  Hedayat Vatankhah  <hed...@gm...>
+
+	* lib/oxygen/simulationserver/simulationserver.h (SimulationServer): 
+	- modify SetAutoTimeMode() documents to reflect new changes
+	
+	* plugin/timersystemboost/timersystemboost.cpp: 
+	- small cleanups
+	
+	* plugin/timersystemsdl/timersystemsdl.h: 
+	* plugin/timersystemsdl/timersystemsdl.cpp: 
+	* plugin/timersystemsdl/timersystemsdl_c.cpp: 
+	* plugin/timersystemsdl/export.cpp: 
+	* plugin/timersystemsdl/CMakeLists.txt:
+	- added TimerSystemSDL based on inputsdl/timersdl implementation to replace
+	  it.
+	
+	* lib/kerosin/inputserver/us.scan.rb: 
+	- added a missing comma!
+
 2011-03-24  Hedayat Vatankhah  <hed...@gm...>
 
 	* spark/CMakeLists.txt: 
Modified: trunk/spark/lib/kerosin/inputserver/us.scan.rb
===================================================================
--- trunk/spark/lib/kerosin/inputserver/us.scan.rb	2011-03-25 00:29:08 UTC (rev 260)
+++ trunk/spark/lib/kerosin/inputserver/us.scan.rb	2011-03-25 00:54:16 UTC (rev 261)
@@ -65,7 +65,7 @@
 	theInputSystem.addCode (Input.IC_KP8, 'kp8', '8'[0], '8'[0], 0);
 	theInputSystem.addCode (Input.IC_KP9, 'kp9', '9'[0], '9'[0], 0);
 	theInputSystem.addCode (Input.IC_KP_DECIMAL, 'kp_decimal',	'.'[0], '.'[0], 0);
-	theInputSystem.addCode (Input.IC_KP_DIVIDE,   'kp_divide'	'/'[0], '/'[0], 0);
+	theInputSystem.addCode (Input.IC_KP_DIVIDE,   'kp_divide',	'/'[0], '/'[0], 0);
 	theInputSystem.addCode (Input.IC_KP_MULTIPLY,'kp_multiply',	'*'[0], '*'[0], 0);
 	theInputSystem.addCode (Input.IC_KP_MINUS,	'kp_minus',	'-'[0], '-'[0], 0);
 	theInputSystem.addCode (Input.IC_KP_PLUS,	'kp_plus',	'+'[0], '+'[0], 0);
Modified: trunk/spark/lib/oxygen/simulationserver/simulationserver.h
===================================================================
--- trunk/spark/lib/oxygen/simulationserver/simulationserver.h	2011-03-25 00:29:08 UTC (rev 260)
+++ trunk/spark/lib/oxygen/simulationserver/simulationserver.h	2011-03-25 00:54:16 UTC (rev 261)
@@ -98,8 +98,8 @@
     /** sets the auto time mode of the SimulationServer. if set to
         true the SimulationServer automatically advances the
         simulation mSimStep time every cycle, this is the default
-        mode. Otherwise a registered ControlNode takes the
-        responsibility to do so (by calling AdvanceTime regularly)
+        mode. Otherwise a TimerSystem must provide SimulationServer with
+        timing features.
      */
     void SetAutoTimeMode(bool set);
 
Property changes on: trunk/spark/lib/oxygen/simulationserver/timersystem.h
___________________________________________________________________
Added: svn:keywords
   + Id
Property changes on: trunk/spark/lib/oxygen/simulationserver/timersystem_c.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Modified: trunk/spark/plugin/CMakeLists.txt
===================================================================
--- trunk/spark/plugin/CMakeLists.txt	2011-03-25 00:29:08 UTC (rev 260)
+++ trunk/spark/plugin/CMakeLists.txt	2011-03-25 00:54:16 UTC (rev 261)
@@ -31,6 +31,7 @@
 add_subdirectory(sceneeffector)
 add_subdirectory(soundsystemfmod)
 add_subdirectory(timersystemboost)
+add_subdirectory(timersystemsdl)
 if (APPLE)
    if (DEVEL)
       add_subdirectory(imageperceptor)
Property changes on: trunk/spark/plugin/timersystemboost/CMakeLists.txt
___________________________________________________________________
Added: svn:keywords
   + Id
Property changes on: trunk/spark/plugin/timersystemboost/export.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Modified: trunk/spark/plugin/timersystemboost/timersystemboost.cpp
===================================================================
--- trunk/spark/plugin/timersystemboost/timersystemboost.cpp	2011-03-25 00:29:08 UTC (rev 260)
+++ trunk/spark/plugin/timersystemboost/timersystemboost.cpp	2011-03-25 00:54:16 UTC (rev 261)
@@ -40,10 +40,11 @@
 void TimerSystemBoost::WaitFromLastQueryUntil(float deadline)
 {
     int milliseconds = round(deadline * 1000);
+    boost::thread::sleep(mLastQueryTime +
+        boost::posix_time::milliseconds(milliseconds));
+
 //    GetLog()->Debug() << "(TimerSystemBoost) Waiting for " << deadline
 //            << " seconds or " << milliseconds << " millisecs\n";
-    boost::thread::sleep(mLastQueryTime +
-        boost::posix_time::milliseconds(milliseconds));
 //    GetLog()->Debug() << "CURRENT TIME: " << boost::get_system_time() << '\n';
 }
 
Property changes on: trunk/spark/plugin/timersystemboost/timersystemboost.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Property changes on: trunk/spark/plugin/timersystemboost/timersystemboost.h
___________________________________________________________________
Added: svn:keywords
   + Id
Property changes on: trunk/spark/plugin/timersystemboost/timersystemboost_c.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: trunk/spark/plugin/timersystemsdl/CMakeLists.txt
===================================================================
--- trunk/spark/plugin/timersystemsdl/CMakeLists.txt	                        (rev 0)
+++ trunk/spark/plugin/timersystemsdl/CMakeLists.txt	2011-03-25 00:54:16 UTC (rev 261)
@@ -0,0 +1,19 @@
+########### next target ###############
+
+set(timersystemsdl_LIB_SRCS
+   export.cpp
+   timersystemsdl.cpp
+   timersystemsdl_c.cpp
+   timersystemsdl.h
+)
+
+include_directories(${SDL_INCLUDE_DIR})
+add_library(timersystemsdl MODULE ${timersystemsdl_LIB_SRCS})
+
+target_link_libraries(timersystemsdl ${spark_libs})
+
+if (NOT APPLE)
+   set_target_properties(timersystemsdl PROPERTIES VERSION 0.0.0 SOVERSION 0)
+endif (NOT APPLE)
+
+install(TARGETS timersystemsdl DESTINATION ${LIBDIR}/${CMAKE_PROJECT_NAME})
Property changes on: trunk/spark/plugin/timersystemsdl/CMakeLists.txt
___________________________________________________________________
Added: svn:keywords
   + Id
Added: trunk/spark/plugin/timersystemsdl/export.cpp
===================================================================
--- trunk/spark/plugin/timersystemsdl/export.cpp	                        (rev 0)
+++ trunk/spark/plugin/timersystemsdl/export.cpp	2011-03-25 00:54:16 UTC (rev 261)
@@ -0,0 +1,27 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+   This file is part of rcssserver3D
+   Thu Mar 24 2011
+   Copyright (C) 2003-1011 RoboCup Soccer Server 3D Maintenance Group
+   $Id$
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+#include "timersystemsdl.h"
+#include <zeitgeist/zeitgeist.h>
+
+    using namespace oxygen;
+ZEITGEIST_EXPORT_BEGIN()
+    ZEITGEIST_EXPORT(TimerSystemSDL);
+ZEITGEIST_EXPORT_END()
Property changes on: trunk/spark/plugin/timersystemsdl/export.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: trunk/spark/plugin/timersystemsdl/timersystemsdl.cpp
===================================================================
--- trunk/spark/plugin/timersystemsdl/timersystemsdl.cpp	                        (rev 0)
+++ trunk/spark/plugin/timersystemsdl/timersystemsdl.cpp	2011-03-25 00:54:16 UTC (rev 261)
@@ -0,0 +1,73 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+   This file is part of rcssserver3D
+   Thu Mar 24 2011
+   Copyright (C) 2003-1011 RoboCup Soccer Server 3D Maintenance Group
+   $Id$
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+#include "timersystemsdl.h"
+#include <zeitgeist/logserver/logserver.h>
+#include <SDL.h>
+
+using namespace oxygen;
+
+void TimerSystemSDL::Initialize()
+{
+    if (!SDL_WasInit(SDL_INIT_TIMER))
+    {
+        if (SDL_Init(SDL_INIT_TIMER) < 0)
+        {
+            GetLog()->Error() << "ERROR: (TimerSystemSDL) SDL Timer not initialized!\n";
+        }
+    }
+
+    mLastTicks = SDL_GetTicks();
+}
+
+float TimerSystemSDL::GetTimeSinceLastQuery()
+{
+    unsigned int ticks = SDL_GetTicks();
+
+    // FIXME: ticks might wrap
+    unsigned int timeDiff = ticks - mLastTicks;
+    mLastTicks = ticks;
+
+    return timeDiff / 1000.0f;
+}
+
+void TimerSystemSDL::WaitFromLastQueryUntil(float deadline)
+{
+    int milliseconds = round(deadline * 1000);
+    int expectedTime = mLastTicks + milliseconds;
+
+    int delayTime = expectedTime - SDL_GetTicks();
+    while (delayTime > 0)
+    {
+        SDL_Delay(delayTime);
+        // sometimes, even with the above SDL_Delay() call we will not reach
+        // the desired delay; so we check if we've actually reched the desired
+        // time
+        delayTime = expectedTime - SDL_GetTicks();
+    }
+
+//    GetLog()->Debug() << "(TimerSystemSDL) Waiting for " << deadline
+//            << " seconds or " << milliseconds << " millisecs\n";
+//    GetLog()->Debug() << "CURRENT TIME: " << SDL_GetTicks() << '\n';
+}
+
+//void TimerSystemSDL::Finalize()
+//{
+//}
Property changes on: trunk/spark/plugin/timersystemsdl/timersystemsdl.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
Added: trunk/spark/plugin/timersystemsdl/timersystemsdl.h
===================================================================
--- trunk/spark/plugin/timersystemsdl/timersystemsdl.h	                        (rev 0)
+++ trunk/spark/plugin/timersystemsdl/timersystemsdl.h	2011-03-25 00:54:16 UTC (rev 261)
@@ -0,0 +1,61 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+   This file is part of rcssserver3D
+   Thu Mar 24 2011
+   Copyright (C) 2003-1011 RoboCup Soccer Server 3D Maintenance Group
+   $Id$
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+#ifndef OXYGEN_SDLTIMERSYSTEM_H
+#define OXYGEN_SDLTIMERSYSTEM_H
+
+#include <oxygen/simulationserver/timersystem.h>
+
+namespace oxygen
+{
+/** \class TimerSystemSDL is a timer system based on SDL timing facilities
+ */
+class TimerSystemSDL: public TimerSystem
+{
+public:
+    /** initialize the timer system. It is called once at the beginning of a
+     * simulation.
+     */
+    virtual void Initialize();
+
+    /** \return the elapsed time since the last call of this function or since
+     * the initialization for the first call.
+     */
+    virtual float GetTimeSinceLastQuery();
+
+    /** waits until \param deadline seconds is passed since the last call to
+     * GetTimeSinceLastQuery(). If that is already passed, it'll return
+     * immediately.
+     */
+    virtual void WaitFromLastQueryUntil(float deadline);
+
+    /** this is called at the end of the simulation */
+    virtual void Finalize() {}
+
+private:
+    /** the last time GetTimeSinceLastQuery is called or zero on Initialize() */
+    unsigned long mLastTicks;
+};
+
+DECLARE_CLASS(TimerSystemSDL);
+
+} // namespace oxygen
+
+#endif // OXYGEN_SDLTIMERSYSTEM_H
Property changes on: trunk/spark/plugin/timersystemsdl/timersystemsdl.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: trunk/spark/plugin/timersystemsdl/timersystemsdl_c.cpp
===================================================================
--- trunk/spark/plugin/timersystemsdl/timersystemsdl_c.cpp	                        (rev 0)
+++ trunk/spark/plugin/timersystemsdl/timersystemsdl_c.cpp	2011-03-25 00:54:16 UTC (rev 261)
@@ -0,0 +1,28 @@
+/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
+
+   This file is part of rcssserver3D
+   Thu Mar 24 2011
+   Copyright (C) 2003-1011 RoboCup Soccer Server 3D Maintenance Group
+   $Id$
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; version 2 of the License.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+#include "timersystemsdl.h"
+
+using namespace oxygen;
+
+void CLASS(TimerSystemSDL)::DefineClass()
+{
+    DEFINE_BASECLASS(oxygen/TimerSystem);
+}
Property changes on: trunk/spark/plugin/timersystemsdl/timersystemsdl_c.cpp
___________________________________________________________________
Added: svn:keywords
   + Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |