Revision: 8435
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8435&view=rev
Author:   natepak
Date:     2009-11-22 20:49:26 +0000 (Sun, 22 Nov 2009)

Log Message:
-----------
Fixed reading time

Modified Paths:
--------------
    code/gazebo/trunk/server/Time.cc
    code/gazebo/trunk/server/Time.hh
    code/gazebo/trunk/server/gui/StatusBar.cc

Modified: code/gazebo/trunk/server/Time.cc
===================================================================
--- code/gazebo/trunk/server/Time.cc    2009-11-22 20:16:52 UTC (rev 8434)
+++ code/gazebo/trunk/server/Time.cc    2009-11-22 20:49:26 UTC (rev 8435)
@@ -88,8 +88,7 @@
 void Time::Set(double seconds)
 {
   this->sec = (int32_t)(floor(seconds));
-  this->nsec = (int32_t)(round(seconds - this->sec) * 1e9);
-
+  this->nsec = (int32_t)(round((seconds - this->sec) * 1e9));
   this->Correct();
 }
 

Modified: code/gazebo/trunk/server/Time.hh
===================================================================
--- code/gazebo/trunk/server/Time.hh    2009-11-22 20:16:52 UTC (rev 8434)
+++ code/gazebo/trunk/server/Time.hh    2009-11-22 20:49:26 UTC (rev 8435)
@@ -26,6 +26,8 @@
 #ifndef TIME_HH
 #define TIME_HH
 
+#include <stdlib.h>
+
 #include <time.h>
 #include <iostream>
 

Modified: code/gazebo/trunk/server/gui/StatusBar.cc
===================================================================
--- code/gazebo/trunk/server/gui/StatusBar.cc   2009-11-22 20:16:52 UTC (rev 
8434)
+++ code/gazebo/trunk/server/gui/StatusBar.cc   2009-11-22 20:49:26 UTC (rev 
8435)
@@ -106,26 +106,30 @@
 void StatusBar::Update()
 {
   //float percent = 0;
-  Time sim = 0;
-  Time real = 0;
+  double sim = 0;
+  double real = 0;
 
   if (Simulator::Instance()->GetRealTime() - this->lastUpdateTime > 
this->statusUpdatePeriod)
   {
-    if (Simulator::Instance()->GetRealTime() < this->statusUpdatePeriod )
+    Time simTime = Simulator::Instance()->GetSimTime();
+    Time realTime = Simulator::Instance()->GetRealTime();
+    
+    if (realTime < this->statusUpdatePeriod )
     {
-      this->percent = (Simulator::Instance()->GetSimTime() / 
Simulator::Instance()->GetRealTime());
+      this->percent = ( simTime / realTime);
       this->percentLastRealTime =0;
       this->percentLastSimTime = 0;
     }
     else
     {
-      this->percent = 
((Simulator::Instance()->GetSimTime()-this->percentLastSimTime) / 
(Simulator::Instance()->GetRealTime()-this->percentLastRealTime)).Double();
+      this->percent = ((simTime - this->percentLastSimTime) / 
+                       (realTime - this->percentLastRealTime)).Double();
 
-      this->percentLastRealTime = Simulator::Instance()->GetRealTime();
-      this->percentLastSimTime = Simulator::Instance()->GetSimTime();
+      this->percentLastRealTime = realTime;
+      this->percentLastSimTime = simTime;
     }
 
-    sim = Simulator::Instance()->GetSimTime();
+    sim = Simulator::Instance()->GetSimTime().Double();
     if (sim > 31536000)
     {
       sim /= (31536000);
@@ -147,7 +151,7 @@
       this->simTime->label("(min) Sim Time");
     }
 
-    real = Simulator::Instance()->GetRealTime();
+    real = Simulator::Instance()->GetRealTime().Double();
     if (sim > 31536000)
     {
       real /= (31536000);
@@ -171,8 +175,8 @@
 
     this->percentOutput->value(this->percent.Double());
 
-    this->realTime->value(real.Double());
-    this->simTime->value(sim.Double());
+    this->realTime->value(real);
+    this->simTime->value(sim);
     this->pauseTime->value(Simulator::Instance()->GetPauseTime().Double());
 
     this->lastUpdateTime = Simulator::Instance()->GetRealTime();


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to