Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SimTime Class Reference

#include <Util/SimTime.H>

List of all members.


Detailed Description

Encapsulated representation of simulation time.

Basic arithmetic operators are supported. The idea is to not rely on a particular representation, but currently we are using a 64-bit signed integer to represent the number of microseconds or nanoseconds.

With this representation, the possible range of values is -2^(-63)/10^9 seconds = -9.2e+9 seconds, to 2^(63)/10^9 seconds = 9.2e+9 seconds. So, roughly: 33 bits are used to represent the integer portion, 30 bits to represent the fractional portion, and 1 bit for the sign. That means that this representation has a somewhat larger range of values than does the standard 32+32 bit 'struct timeval' from <sys/time.h>, which uses 32 bits for the integral portion, and 32 bits for the fractional portion (of which 12 bits are wasted since the fractional portion represents microseconds and so only 20 bits are needed to get up to 10^6).

In order to avoid losing precision, you should avoid calling secs() or msecs() etc. and doing math on the results; instead, do math using SimTime's builtin operators, and only convert to secs() or msecs() when absolutely necessary (e.g., to display the time to the user).

Definition at line 72 of file SimTime.H.

Public Member Functions

 SimTime ()
 Default constructor; initialize to time=0.
std::string toString (bool with_suffix=false) const
 Convert to string.
double secs () const
 Return the number of seconds represented.
double msecs () const
 Return the number of milliseconds represented.
double usecs () const
 Return the number of microseconds represented.
int64 nsecs () const
 Return the number of nanoseconds represented.
double hertz () const
 Return the rate (inverse seconds) represented.
bool nonzero () const
 Return true if the time represented is non-zero.
SimTimeoperator+= (const SimTime &step)
 Plus-equals.
SimTime operator+ (const SimTime &that) const
 result=time1+time2
SimTime operator- (const SimTime &that) const
 result=time1-time2
SimTime operator * (const double x) const
 result=time*factor
SimTime operator * (const int x) const
 result=time*factor
SimTime operator * (const int64 x) const
 result=time*factor
bool operator< (const SimTime &that) const
 compare time1<time2
bool operator<= (const SimTime &that) const
 compare time1<=time2
bool operator> (const SimTime &that) const
 compare time1>time2
bool operator>= (const SimTime &that) const
 compare time1>=time2
bool operator== (const SimTime &that) const
 compare time1==time2
bool operator!= (const SimTime &that) const
 compare time1!=time2

Static Public Member Functions

static SimTime ZERO ()
 Pseudo-constructor; returns time=0.
static SimTime MAX ()
 Pseudo-constructor; builds the largest representable time.
static SimTime SECS (double s)
 Pseudo-constructor; returns time=s seconds.
static SimTime MSECS (double ms)
 Pseudo-constructor; returns time=ms milliseconds.
static SimTime USECS (double us)
 Pseudo-constructor; returns time=us microseconds.
static SimTime NSECS (int64 ns)
 Pseudo-constructor; returns time=ns nanoseconds.
static SimTime HERTZ (double hz)
 Pseudo-constructor; returns time=1/hz seconds.
static SimTime computeDeltaT (const SimTime &interval, const SimTime &timestep)
 Return a delta-t close to timestep for traversing the given interval.
static SimTime fromString (const std::string &s, const char *default_suffix=0)
 Convert from string.


Constructor & Destructor Documentation

SimTime::SimTime  )  [inline]
 

Default constructor; initialize to time=0.

Definition at line 76 of file SimTime.H.

Referenced by computeDeltaT(), MAX(), MSECS(), NSECS(), operator *(), operator+(), operator-(), SECS(), USECS(), and ZERO().


Member Function Documentation

static SimTime SimTime::computeDeltaT const SimTime interval,
const SimTime timestep
[inline, static]
 

Return a delta-t close to timestep for traversing the given interval.

Definition at line 100 of file SimTime.H.

References nseconds, and SimTime().

Referenced by FrictionSaccadeController::doEvolve(), StructureModule::evolve(), NeuralSimModule::evolve(), SimulationViewerStd::getTraj(), VirtualVoxelSalMap< T >::inputNewImage(), WinnerTakeAllStdOptim::integrate(), WinnerTakeAllTempNote::integrate(), WinnerTakeAllGreedy::integrate(), WinnerTakeAllStd::integrate(), LeakyIntFireAdp::integrate(), LeakyIntFire::integrate(), and LeakyIntegrator::integrate().

SimTime SimTime::fromString const std::string s,
const char *  default_suffix = 0
[static]
 

Convert from string.

If default_suffix=null, then a valid suffix must be present to indicate the units represented by the number. If default_suffix==non-null, then that suffix will be used if the string itself doesn't contain a units suffix.

Definition at line 57 of file SimTime.C.

References LFATAL, rutz::max(), MAX(), rutz::min(), and NSECS().

Referenced by convertFromString(), EyeTrace::EyeTrace(), FrameRange::fromString(), getMetadataFromAuxFiles(), main(), and ColorbarsInput::setConfigInfo().

double SimTime::hertz  )  const [inline]
 

Return the rate (inverse seconds) represented.

Definition at line 140 of file SimTime.H.

Referenced by EyeTrace::EyeTrace(), getMetadataFromAuxFiles(), UcbMpegOutputStream::makeEncoder(), Stimulus2D::peekFrameSpec(), BobDeinterlacer::start2(), and EyeSFile::start2().

static SimTime SimTime::HERTZ double  hz  )  [inline, static]
 

Pseudo-constructor; returns time=1/hz seconds.

Definition at line 97 of file SimTime.H.

References SECS().

Referenced by XCgrabberFlex::getNaturalFrameTime(), XCgrabber::getNaturalFrameTime(), RTSPGrabber::getNaturalFrameTime(), IEEE1394grabber::getNaturalFrameTime(), DC1394Grabber2::getNaturalFrameTime(), main(), V4Lgrabber::start1(), and submain().

static SimTime SimTime::MAX  )  [inline, static]
 

Pseudo-constructor; builds the largest representable time.

Definition at line 82 of file SimTime.H.

References rutz::max(), and SimTime().

Referenced by fromString().

double SimTime::msecs  )  const [inline]
 

Return the number of milliseconds represented.

Definition at line 128 of file SimTime.H.

Referenced by DirectFeedChannel::doInput(), SimulationViewerSurpCont::drawTime(), SimulationViewerStd::drawTime(), SimulationViewerNerdCam::drawTime(), SaccadeController::dumpQueues(), SimEventQueueDebug::evolve(), EyeTrace::EyeTrace(), SaccadeController::getDecision(), TigsInputFrameSeries::getFrame(), TigsInputFrame::getHash(), DirectFeedChannel::inputPyramid(), IZNeuronFunc::integrate(), DirectFeedChannel::outputAvailable(), SimEventQueueDebug::postHelper(), SimEventQueueDebug::prune(), PlotBuffer::push(), InputFrameSeries::Impl::readFrame(), SaccadeController::resetPos(), SimEventQueueDebug::resetTime(), SimulationViewerStats::save1(), SimulationViewerSurpCont::saveResults(), SimulationViewerNerdCam::saveResults(), SimEventClockTick::toString(), SimEventRetinaImage::toString(), FrameRange::toString(), OutputFrameSeries::update(), and InputFrameSeries::update().

static SimTime SimTime::MSECS double  ms  )  [inline, static]
 

Pseudo-constructor; returns time=ms milliseconds.

Definition at line 88 of file SimTime.H.

References SimTime().

Referenced by BiasImageForm::evolveBrain(), evolveBrain(), ObjRecSalBayes::evolveBrain(), FrameRange::fromString(), RawVisualCortex::getVCOutput(), ObjRecSPM::predict(), and ObjRecSPM::train().

bool SimTime::nonzero  )  const [inline]
 

Return true if the time represented is non-zero.

Definition at line 144 of file SimTime.H.

int64 SimTime::nsecs  )  const [inline]
 

Return the number of nanoseconds represented.

Definition at line 136 of file SimTime.H.

Referenced by tcl::aux_convert_from(), and TigsInputFrame::toGhostString().

static SimTime SimTime::NSECS int64  ns  )  [inline, static]
 

Pseudo-constructor; returns time=ns nanoseconds.

Definition at line 94 of file SimTime.H.

References SimTime().

Referenced by tcl::aux_convert_to(), TigsInputFrame::fromGhostString(), and fromString().

SimTime SimTime::operator * const int64  x  )  const [inline]
 

result=time*factor

Definition at line 169 of file SimTime.H.

References SimTime().

SimTime SimTime::operator * const int  x  )  const [inline]
 

result=time*factor

Definition at line 165 of file SimTime.H.

References SimTime().

SimTime SimTime::operator * const double  x  )  const [inline]
 

result=time*factor

Definition at line 161 of file SimTime.H.

References SimTime().

bool SimTime::operator!= const SimTime that  )  const [inline]
 

compare time1!=time2

Definition at line 194 of file SimTime.H.

References nseconds.

SimTime SimTime::operator+ const SimTime that  )  const [inline]
 

result=time1+time2

Definition at line 152 of file SimTime.H.

References nseconds, and SimTime().

SimTime& SimTime::operator+= const SimTime step  )  [inline]
 

Plus-equals.

Definition at line 148 of file SimTime.H.

References nseconds.

SimTime SimTime::operator- const SimTime that  )  const [inline]
 

result=time1-time2

Definition at line 156 of file SimTime.H.

References nseconds, and SimTime().

bool SimTime::operator< const SimTime that  )  const [inline]
 

compare time1<time2

Definition at line 174 of file SimTime.H.

References nseconds.

bool SimTime::operator<= const SimTime that  )  const [inline]
 

compare time1<=time2

Definition at line 178 of file SimTime.H.

References nseconds.

bool SimTime::operator== const SimTime that  )  const [inline]
 

compare time1==time2

Definition at line 190 of file SimTime.H.

References nseconds.

bool SimTime::operator> const SimTime that  )  const [inline]
 

compare time1>time2

Definition at line 182 of file SimTime.H.

References nseconds.

bool SimTime::operator>= const SimTime that  )  const [inline]
 

compare time1>=time2

Definition at line 186 of file SimTime.H.

References nseconds.

double SimTime::secs  )  const [inline]
 

Return the number of seconds represented.

Definition at line 124 of file SimTime.H.

Referenced by AlphaDecoder::AlphaDecoder(), SingleOpponentChannel::centerSurround(), FrictionSaccadeController::computeWhenNewDecision(), FrictionSaccadeController::computeWhenNewPercept(), FrictionSaccadeController::doEvolve(), FlickerChannel::doInput(), RectDecoder::getOutput(), HistDecoder::getOutput(), Stimulus2D::getTotalTime(), SimulationViewerStd::getTraj(), SingleChannelBeo::handleInput(), AttentionGuidanceMapSC::inputBU(), AttentionGuidanceMapSC::inputTD(), WinnerTakeAllStdOptim::integrate(), SaliencyMapFast::integrate(), LeakyIntFireAdp::integrate(), LeakyIntFire::integrate(), LeakyIntegrator::integrate(), Stimulus2D::next(), ColorbarsInput::readFrame(), Stimulus2D::setConfigInfo(), Stimulus2D::setFrameNumber(), EyeSFile::start2(), and submain().

static SimTime SimTime::SECS double  s  )  [inline, static]
 

Pseudo-constructor; returns time=s seconds.

Definition at line 85 of file SimTime.H.

References SimTime().

Referenced by AlphaDecoder::AlphaDecoder(), SingleChannelBeoServer::check(), Timer::getSimTime(), Stimulus2D::getTotalTime(), HERTZ(), DirectFeedChannel::killCaches(), main(), DirectFeedChannel::reset1(), Stimulus2D::setConfigInfo(), Stimulus2D::setFrameNumber(), and SingleChannelBeo::waitForOutput().

std::string SimTime::toString bool  with_suffix = false  )  const
 

Convert to string.

If with_suffix==true, then write a suffix after the number indicating the units (i.e., 's', 'ms', 'us'). If with_suffix==false, the no suffix is written and the number will represent the number of seconds.

Definition at line 48 of file SimTime.C.

References sformat().

Referenced by convertToString(), SimEventQueue::post(), and SimEventQueue::request().

double SimTime::usecs  )  const [inline]
 

Return the number of microseconds represented.

Definition at line 132 of file SimTime.H.

Referenced by BobDeinterlacer::readFrame(), and BobDeinterlacer::start2().

static SimTime SimTime::USECS double  us  )  [inline, static]
 

Pseudo-constructor; returns time=us microseconds.

Definition at line 91 of file SimTime.H.

References SimTime().

static SimTime SimTime::ZERO  )  [inline, static]
 

Pseudo-constructor; returns time=0.

Definition at line 79 of file SimTime.H.

References SimTime().

Referenced by AlphaDecoder::AlphaDecoder(), FrameRange::FrameRange(), FrameRange::fromString(), SaccadeController::getDecision(), FrameIstream::getNaturalFrameTime(), SaccadeController::getPreviousDecision(), RawVisualCortex::getVCOutput(), StructureModule::initialize(), NeuralSimModule::initialize(), WinnerTakeAllStdOptim::integrate(), main(), MonkeyEyeHeadController::MonkeyEyeHeadController(), MonkeySaccadeController::MonkeySaccadeController(), TigsJob::movieFrameLength(), WTAwinner::NONE(), processWholeImage(), SingleChannel::pyramidTime(), BobDeinterlacer::readFrame(), WinnerTakeAllStdOptim::reset1(), WinnerTakeAllTempNote::reset1(), WinnerTakeAllStd::reset1(), SimulationViewerStd::reset1(), SimulationViewerNerdCam::reset1(), SaliencyMapFast::reset1(), DirectFeedChannel::reset1(), ColorbarsInput::setConfigInfo(), V4Lgrabber::start1(), submain(), and VirtualVoxelSalMap< T >::VirtualVoxelSalMap().


The documentation for this class was generated from the following files:
Generated on Sun Nov 22 13:46:32 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4