SimulationTime.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
20 package com.generalrobotix.ui.view.graph;
21 public class SimulationTime {
22  protected Time totalTime_;
23  protected Time currentTime_;
24  protected Time startTime_;
25  protected Time timeStep_;
26  protected Time viewUpdateStep_;
27 
34  public SimulationTime() {
35  totalTime_ = new Time();
36  timeStep_ = new Time();
37  viewUpdateStep_ = new Time();
38  currentTime_ = new Time();
39  startTime_ = new Time();
40  }
41 
43  Time totalTime, // [msec]
44  Time timeStep, // [usec]
45  Time viewUpdateStep // [usec]
46  ) {
47  totalTime_ = new Time(totalTime.getDouble());
48  timeStep_ = new Time(timeStep.getDouble());
49  viewUpdateStep_ = new Time(viewUpdateStep.getDouble());
50  currentTime_ = new Time(0,0);
51  startTime_ = new Time(0,0);
52  }
53 
55  double totalTime, // [msec]
56  double timeStep, // [usec]
57  double viewUpdateStep // [usec]
58  ) {
59  totalTime_ = new Time(totalTime);
60  timeStep_ = new Time(timeStep);
61  viewUpdateStep_ = new Time(viewUpdateStep);
62  currentTime_ = new Time(0,0);
63  startTime_ = new Time(0,0);
64  }
65 
66  public void set(SimulationTime time) {
67  totalTime_.set(time.totalTime_);
68  timeStep_.set(time.timeStep_);
69  viewUpdateStep_.set(time.viewUpdateStep_);
70  currentTime_.set(time.currentTime_);
71  startTime_.set(time.startTime_);
72  }
73 
78  public boolean inc() {
79  currentTime_.add(timeStep_);
80  if (currentTime_.msec_ > totalTime_.msec_) {
81  currentTime_.set(totalTime_);
82  return false;
83  } else if (currentTime_.msec_ == totalTime_.msec_) {
84  if (currentTime_.usec_ > totalTime_.usec_) {
85  currentTime_.set(totalTime_);
86  return false;
87  }
88  }
89 
90  return true;
91  }
92 
97  public void setStartTime(double time) {
98  startTime_.set(time);
99  }
100 
101  public void setCurrentTime(double time) {
102  currentTime_.set(time);
103  }
104 
105  public void setTotalTime(double time) {
106  totalTime_.set(time);
107  }
108 
109  public void setTimeStep(double time) {
110  timeStep_.set(time);
111  }
112 
113  public void setViewUpdateStep(double time) {
114  viewUpdateStep_.set(time);
115  }
116 
117 
122  public double getStartTime() {
123  return startTime_.getDouble();
124  }
125 
130  public double getCurrentTime() {
131  return currentTime_.getDouble();
132  }
133 
138  public double getTotalTime() {
139  return totalTime_.getDouble();
140  }
141 
142  public double getTimeStep() {
143  return timeStep_.getDouble();
144  }
145 
146  public double getViewUpdateStep() {
147  return viewUpdateStep_.getDouble();
148  }
149 }
150 
SimulationTime(double totalTime, double timeStep, double viewUpdateStep)
SimulationTime(Time totalTime, Time timeStep, Time viewUpdateStep)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05