SimulationTime.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00020 package com.generalrobotix.ui.view.graph;
00021 public class SimulationTime {
00022     protected Time totalTime_;
00023     protected Time currentTime_;
00024     protected Time startTime_;
00025     protected Time timeStep_;
00026     protected Time viewUpdateStep_;
00027 
00034     public SimulationTime() {
00035         totalTime_ = new Time();
00036         timeStep_ = new Time();
00037         viewUpdateStep_ = new Time();
00038         currentTime_ = new Time();
00039         startTime_ = new Time();
00040     }
00041 
00042     public SimulationTime(
00043         Time totalTime, // [msec]
00044         Time timeStep,   // [usec]
00045         Time viewUpdateStep   // [usec]
00046     ) {
00047         totalTime_ = new Time(totalTime.getDouble());
00048         timeStep_ = new Time(timeStep.getDouble());
00049         viewUpdateStep_ = new Time(viewUpdateStep.getDouble());
00050         currentTime_ = new Time(0,0);
00051         startTime_ = new Time(0,0);
00052     }
00053 
00054     public SimulationTime(
00055         double totalTime, // [msec]
00056         double timeStep,   // [usec]
00057         double viewUpdateStep   // [usec]
00058     ) {
00059         totalTime_ = new Time(totalTime);
00060         timeStep_ = new Time(timeStep);
00061         viewUpdateStep_ = new Time(viewUpdateStep);
00062         currentTime_ = new Time(0,0);
00063         startTime_ = new Time(0,0);
00064     }
00065 
00066     public void set(SimulationTime time) { 
00067         totalTime_.set(time.totalTime_);
00068         timeStep_.set(time.timeStep_);
00069         viewUpdateStep_.set(time.viewUpdateStep_);
00070         currentTime_.set(time.currentTime_);
00071         startTime_.set(time.startTime_);
00072     }
00073 
00078     public boolean inc() {
00079         currentTime_.add(timeStep_);
00080         if (currentTime_.msec_ > totalTime_.msec_) {
00081             currentTime_.set(totalTime_);
00082             return false;
00083         } else if (currentTime_.msec_ == totalTime_.msec_) {
00084             if (currentTime_.usec_ > totalTime_.usec_) {
00085                 currentTime_.set(totalTime_);
00086                 return false;
00087             }
00088         }
00089 
00090         return true;
00091     }
00092 
00097     public void setStartTime(double time) {
00098         startTime_.set(time);
00099     }
00100 
00101     public void setCurrentTime(double time) {
00102         currentTime_.set(time);
00103     }
00104 
00105     public void setTotalTime(double time) {
00106         totalTime_.set(time);
00107     }
00108 
00109     public void setTimeStep(double time) {
00110         timeStep_.set(time);
00111     }
00112 
00113     public void setViewUpdateStep(double time) {
00114         viewUpdateStep_.set(time);
00115     }
00116 
00117 
00122     public double getStartTime() {
00123         return startTime_.getDouble();
00124     }
00125 
00130     public double getCurrentTime() {
00131         return currentTime_.getDouble();
00132     }
00133 
00138     public double getTotalTime() {
00139         return totalTime_.getDouble();
00140     }
00141 
00142     public double getTimeStep() {
00143         return timeStep_.getDouble();
00144     }
00145 
00146     public double getViewUpdateStep() {
00147         return viewUpdateStep_.getDouble();
00148     }
00149 }
00150 


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:57