Anonymous avatar Anonymous committed 660e2cc

Repaired real time inaccuracy

Comments (0)

Files changed (1)

SimPy/SimulationRT.py

 import random
 import inspect
 
-# $Revision: 1.1.1.28 $ $Date: 2008/03/03 13:53:42 $ kgm
+# $Revision: 1.1.1.29 $ $Date: 2008/04/02 12:04:55 $ kgm
 
-"""SimulationRT 1.9.1 Provides synchronization of real time and SimPy simulation time.
+"""SimulationRT 1.9.1 patched Provides synchronization of real time and SimPy simulation time.
 Implements SimPy Processes, resources, and the backbone simulation scheduling
 by coroutine calls. 
 Based on generators (Python 2.3 and later)
     1 Mar 2008: - Start of 1.9.1 bugfix release
                 - Delete circular reference in Process instances when event 
                   notice has been processed (caused much circular garbage)
+                  
+    2 Apr 2008: - Repair of wallclock synchronisation algorithm
     
 """
 __TESTING=False
-version=__version__="1.9.1 $Revision: 1.1.1.28 $ $Date: 2008/03/03 13:53:42 $"
+version=__version__="1.9.1 patched $Revision: 1.1.1.29 $ $Date: 2008/04/02 12:04:55 $"
 if __TESTING: 
     print "SimPy.SimulationRT %s" %__version__,
     if __debug__:
         _t=_tnotice
         ## Calculate any wait time
         ## event clock time = rtlast + (sim_time - stlast)/rel_speed
+        ## delay=(1.0*earliest/self.rel_speed)-rtnow()
         if self.real_time:                                 
-            next_time = 1.0*(_t - self.stlast)/self.rel_speed 
-            next_time += self.rtlast
-            delay=next_time - wallclock()               
+##          delay=next_time - wallclock()
+            delay=(1.0*_t/self.rel_speed)-rtnow()
             if delay > 0:
             	time.sleep(delay)                  
             self.rtlast = wallclock()                   
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.