- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Interfaces/ElapsedTimeService.cpp

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #include "ElapsedTimeService.h"
    00015
    00016 #include "TimeService.h"
    00017
    00018 using namespace Mers::Interfaces;
    00019 using Mers::Utils::Lang::ReferencedObject;
    00020 using Mers::Utils::Lang::Time;
    00021
    00023
    00024 ElapsedTimeService::ElapsedTimeService(TimeService * tService)
    00025         : ReferencedObject(), mTimeService(tService)
    00026 {
    00027         mTimeService->addReference();
    00028         resetTime();
    00029 }
    00030
    00032
    00033 ElapsedTimeService::~ElapsedTimeService()
    00034 {
    00035         mTimeService->removeReference();
    00036 }
    00037
    00039
    00040 Time ElapsedTimeService::elapsedTime()
    00041 {
    00042         double eTime = elapsed();
    00043         // @HACK
    00044         // TimeService and ElapsedTimeService objects are in terms of seconds.
    00045         // John Stedl's Time is in milliseconds.
    00046         // This was hacked just for PlanRunner.
    00047         return Time((long) (eTime * 1000));
    00048 }
    00049
    00051
    00052 double ElapsedTimeService::elapsed()
    00053 {
    00054         return mTimeService->time() - mStartTime;
    00055 }
    00056
    00058
    00059 void ElapsedTimeService::resetTime()
    00060 {
    00061         mStartTime = mTimeService->time();
    00062 }
    00063
    00065
    00066
    00067