|
LRAUV
revA
|
Timespan class, represents a delta of time. More...
#include <Timestamp.h>


Public Member Functions | |
| Timespan (const double &seconds) | |
| Constructor, set time from double. More... | |
| Timespan (const struct timeval &timeval) | |
| Constructor, set time from struct timeval. More... | |
| Timespan (const Timespan ©Me=ZERO_TIMESPAN) | |
| Copy constructor. More... | |
| ~Timespan () | |
| Destructor. More... | |
| virtual double | asDouble () const |
| Accessor, convert to double. More... | |
| virtual double | asFloat () const |
| Accessor, convert to float. More... | |
| bool | setDuration (const char *duration) |
| Sets the timespan using an XML-like duration string. More... | |
| Timespan & | operator+= (const Timespan &rhs) |
| Addition with a Timespan. More... | |
| Timespan & | operator-= (const Timespan &rhs) |
| Subtraction of a Timespan. More... | |
| Timespan & | operator-= (const struct timeval &rhs) |
| Subtraction of a Timeval. More... | |
| void | sleepFor (void) const |
| Sleep for the timespan. More... | |
| const char * | toString (char *buf, int buflen, int precision=3) const |
| Writes the Timespan to a unsigned char buffer. More... | |
| const Str | toString (int precision=3) const |
| Writes the Timespan as a Str. More... | |
Public Member Functions inherited from Timestamp | |
| Timestamp (const double &seconds) | |
| Constructor, set time from double. More... | |
| Timestamp (const int seconds, const unsigned int microseconds) | |
| Constructor, set time from separate seconds and microseconds. More... | |
| Timestamp (const int year, const int month, const int day, const int hour, const int minute, const int second) | |
| Constructor, set time from separate date and time integers. More... | |
| Timestamp (const struct timeval &timeval) | |
| Constructor, set time from struct timeval. More... | |
| Timestamp (const char *timeString) | |
| Constructor, set time from simple y,m,d, h,m,s type formats including ISO9601. More... | |
| Timestamp (const Timestamp ©Me=NOT_SET_TIME) | |
| Copy constructor. More... | |
| void | addFromMicros (const long long µs) |
| add seconds << 20 + microseconds More... | |
| void | addFromMillis (const long long &millis) |
| add seconds << 10 + microseconds >> 10 More... | |
| void | round (int seconds) |
| virtual | ~Timestamp () |
| Destructor. More... | |
| Timespan | elapsed () const |
| Returns the time elapsed since this timestamp. More... | |
| long long | asMicros () const |
| Quickly returns the (seconds << 20) + microseconds (52 bits) More... | |
| long long | asMillis () const |
| Quickly returns the (seconds << 10) + (microseconds >> 10) (42 bits) More... | |
| time_t | asTimeT () const |
| *struct tm | asStructTm () const |
| Timestamp & | operator= (const Timestamp &rhs) |
| Copy operator. More... | |
| Timestamp & | operator= (const double &seconds) |
| Set from double. More... | |
| Timestamp & | operator= (const struct timeval &timeval) |
| Set from struct timeval. More... | |
| Timestamp & | operator+= (const Timespan &rhs) |
| Addition with a Timespan. More... | |
| Timestamp & | operator-= (const Timespan &rhs) |
| Subtraction of a Timespan. More... | |
| Timestamp | operator+ (const Timespan &rhs) const |
| Addition to Timespan. More... | |
| Timestamp | operator- (const Timespan &rhs) const |
| Subtraction from Timespan. More... | |
| Timespan | operator- (const struct timeval &rhs) const |
| Subtraction from struct timeval. More... | |
| Timespan | operator- (const Timestamp &rhs) const |
| Subtraction of two times yields a timespan. More... | |
| bool | operator== (const Timestamp &rhs) const |
| Equalities/inequalities. More... | |
| bool | operator!= (const Timestamp &rhs) const |
| Equalities/inequalities. More... | |
| bool | operator> (const Timestamp &rhs) const |
| Greater-than operator. More... | |
| bool | operator< (const Timestamp &rhs) const |
| Less-than operator. More... | |
| bool | operator<= (const Timestamp &rhs) const |
| Greater-than-equal operator. More... | |
| bool | operator>= (const Timestamp &rhs) const |
| Less-than-equal operator. More... | |
| Timestamp & | setToCurrentTime () |
| Set to the current time. More... | |
| Timestamp & | setToMonoTime () |
| Set to clock that represents monotonic time since some unspecified starting point. More... | |
| void | sleepTill () |
| Sleep until the given time. More... | |
| void | toTimespec (struct timespec *) const |
| Internal conversion function. More... | |
| void | fromTimespec (const struct timespec *in) |
| Internal conversion function. More... | |
| const struct timeval & | getTimeval () const |
| Get the internal storage. More... | |
| const char * | toString (char *buf, int buflen, int precision=3) const |
| Writes the Timestamp as to a unsigned char buffer. More... | |
| const Str | toString (int precision=3) const |
| Writes the Timestamp as a Str. More... | |
| const Str | toSmallString () const |
| Writes the Timestamp as a small Str (YYYYmmdd'T'HHMMSS). More... | |
| const Str | toSmallerString () const |
| Writes the Timestamp as a smaller Str (YYYYmmddHHMM). More... | |
| const Str | toDateHourString () const |
| Writes the Timestamp as a date-hour Str (YYYYmmddHH). More... | |
Static Public Member Functions | |
| static Timespan | FromMicros (const long long µs) |
| Named Constructor, set from seconds << 20 + microseconds,. More... | |
| static Timespan | FromMillis (const long long &millis) |
| Named Constructor, set from seconds << 10 + milliseconds >> 10. More... | |
| static Timespan | Milliseconds (float msec) |
| Static allows creation of Timespans denominated in milliseconds. More... | |
| static Timespan | Seconds (double sec) |
| Static allows creation of Timespans denominated in seconds (as a float) This function originally took an integer, but I think this syntax also makes sense. More... | |
| static Timespan | Minutes (int min) |
| Static allows creation of Timespans denominated in minutes. More... | |
| static Timespan | Hours (int hour) |
| Static allows creation of Timespans denominated in hours. More... | |
| static Timespan | Days (int day) |
| Static allows creation of Timespans denominated in days. More... | |
Static Public Member Functions inherited from Timestamp | |
| static Timestamp | FromMicros (const long long µs) |
| Named Constructor, set from seconds << 20 + microseconds,. More... | |
| static Timestamp | FromMillis (const long long &millis) |
| Named Constructor, set from seconds << 10 + milliseconds >> 10. More... | |
| static Timestamp | Now () |
| Static for current time for use on RHS. More... | |
Static Public Attributes | |
| static const Timespan | INVALID_TIMESPAN |
| Constant value to represent an invalid timespan. More... | |
| static const Timespan | ZERO_TIMESPAN |
| Constant value to represent instant of time. More... | |
Static Public Attributes inherited from Timestamp | |
| static const Timestamp | NOT_SET_TIME |
| Constant value to represent "no time". More... | |
| static const Timestamp | EPOCH_START_TIME |
| Constant value to represent beginning of (1970 Jan 1) epoch. More... | |
Additional Inherited Members | |
Public Attributes inherited from Timestamp | |
| *int | tm_min |
| Returns value as struct tm: int tm_sec; /* seconds. More... | |
| *int | tm_hour |
| *int | tm_mday |
| *int | tm_mon |
| *int | tm_year |
| *int | tm_wday |
| *int | tm_yday |
| *int | tm_isdst |
Protected Member Functions inherited from Timestamp | |
| struct timeval & | fromDouble (const double &seconds) |
| Set the internal storage to the specified value. More... | |
| struct timeval & | fromIntegers (const int seconds, const unsigned int microseconds) |
| Set the internal storage to the specified values. More... | |
| struct timeval & | fromIntegers (const int year, const int month, const int day, const int hour, const int minute, const int second) |
| Set the internal storage to the specified values. More... | |
| struct timeval & | fromString (const char *timeString) |
| Set the internal storage to the specified ISO9601 string value. More... | |
Static Protected Member Functions inherited from Timestamp | |
| static struct timeval | TimevalFromIntegers (const int seconds, const unsigned int microseconds) |
| Returns a struct timeval from the specified values. More... | |
| static struct timeval | TimevalFromMicros (const long long µs) |
| Returns a struct timeval from asMicros() result. More... | |
| static struct timeval | TimevalFromMillis (const long long &millis) |
| Returns a struct timeval from asMillis() result. More... | |
Protected Attributes inherited from Timestamp | |
| struct timeval | timeval_ |
| Internal storage for time. More... | |
Timespan class, represents a delta of time.
| Timespan::Timespan | ( | const double & | seconds | ) |
Constructor, set time from double.
Tests:
Create a new object w/o params.
Expect asDouble() == 0
Referenced by Days(), FromMicros(), FromMillis(), Hours(), Milliseconds(), Minutes(), and Seconds().
| Timespan::Timespan | ( | const struct timeval & | timeval | ) |
Constructor, set time from struct timeval.
| Timespan::Timespan | ( | const Timespan & | rhs = ZERO_TIMESPAN | ) |
Copy constructor.
Tests:
Create new object copied from another object.
asDouble == asDouble
|
inline |
Destructor.
|
virtual |
Accessor, convert to double.
Reimplemented from Timestamp.
References Timestamp::asDouble(), and INVALID_TIMESPAN.
Referenced by HFRCMVirtualSurfaceDrifter::advect(), CommandLine::commandIbitMcp3553(), HorizontalControl::controlHeading(), DeadReckonUsingCompactModelForecast::deadReckon(), DeadReckoner::deadReckon(), ValueClause::evalSide(), HorizontalControl::headingControl(), SBIT::initialize(), Navigator::readConfigs(), Navigator::readVehicleOrientation(), DeadReckonUsingMultipleVelocitySources::readVehicleVelocity(), DropWeight::run(), PitchServo::run(), YawRateCalculator::run(), PitchRateCalculator::run(), DepthRateCalculator::run(), InternalSim::run(), NavigationSim::run(), DepthServo::run(), Tracking::run(), DAT::runnable(), Component::setDurationOfLastRun(), HorizontalControl::setHeadingRate(), Rowe_600::stop(), Timespan_Test::testConstructorCopyArg(), Timespan_Test::testConstructorDoubleArg(), Timespan_Test::testConstructorNoArguments(), and Navigator::writeVehiclePosition().
|
virtual |
Accessor, convert to float.
Reimplemented from Timestamp.
References Timestamp::asFloat(), and INVALID_TIMESPAN.
Referenced by PeakDetectHorizontal::calcSatisfied(), VerticalControl::controlDepth(), VerticalControl::controlDepthRate(), DataOverHttps::dataRead(), VerticalControl::elevatorControl(), AcousticModem_Benthos_ATM900::gotNewQuery(), DAT::gotNewQuery(), VerticalControl::massAndElevatorControl(), VerticalControl::massControl(), UartStream::openAtBaudrate(), VerticalControl::overrideVertical(), Onboard::run(), DataOverHttps::run(), ExternalSim::run(), CTD_NeilBrown::runnable(), NAL9602::sendingTransmit(), VerticalControl::setPitchRate(), DataOverHttps::sslConnecting(), and DataOverHttps::tcpConnecting().
|
inlinestatic |
Static allows creation of Timespans denominated in days.
References Timespan().
|
static |
Named Constructor, set from seconds << 20 + microseconds,.
Named Constructor, set from seconds << 20 + microseconds.
References Timespan(), and Timestamp::TimevalFromMicros().
|
static |
Named Constructor, set from seconds << 10 + milliseconds >> 10.
References Timespan(), and Timestamp::TimevalFromMillis().
|
inlinestatic |
Static allows creation of Timespans denominated in hours.
References Timespan().
Referenced by HFRadarCompactModelForecaster::loadHistory(), AcousticModem_Benthos_ATM900::parseDebugRxMessage(), AcousticModem_Benthos_ATM900::parseDebugTxMessage(), and Timestamp_Test::testWholeUnits().
|
inlinestatic |
Static allows creation of Timespans denominated in milliseconds.
References Timespan().
Referenced by LPC3Reg::ActivateBurnwire(), LPC3Reg::DeactivateBurnwire(), LPC3Reg::DeactivateRadio(), NAL9602::fillBuffer(), AcousticModem_Benthos_ATM900::parseDebugRxMessage(), AcousticModem_Benthos_ATM900::parseDebugTxMessage(), LPC3Reg::PowerOffLoads(), LPC3Reg::PowerOnLoads(), LPC3Reg::SWReset(), Timespan_Test::testSleepFor(), Timestamp_Test::testSleepNow(), and Timestamp_Test::testWholeUnits().
|
inlinestatic |
Static allows creation of Timespans denominated in minutes.
References Timespan().
Referenced by AcousticModem_Benthos_ATM900::parseDebugRxMessage(), AcousticModem_Benthos_ATM900::parseDebugTxMessage(), and Timestamp_Test::testWholeUnits().
Addition with a Timespan.
Addition of a Timespan.
Tests:
References Timestamp::timeval_.
Subtraction of a Timespan.
Tests:
References Timestamp::timeval_.
| Timespan & Timespan::operator-= | ( | const struct timeval & | rhs | ) |
|
inlinestatic |
Static allows creation of Timespans denominated in seconds (as a float) This function originally took an integer, but I think this syntax also makes sense.
When called with an integer parameter, it does rely on the implicit conversion from ints to doubles
References Timespan().
Referenced by Batt_Ocean_Server::initialize(), ExternalSim::initialize(), AcousticModem_Benthos_ATM900::parseDebugRxMessage(), AcousticModem_Benthos_ATM900::parseDebugTxMessage(), SettingReader::read(), DataReader::read(), VerticalControl::readConfig(), SCPI::readConfig(), NAL9602::readConfig(), Supervisor::run(), MultiHandler::shutdown(), and Timestamp_Test::testWholeUnits().
| bool Timespan::setDuration | ( | const char * | durationCstr | ) |
Sets the timespan using an XML-like duration string.
format is "P(\d+D)?(\d+H)?(\d+M)?(\d+(.\d+)?S)?" returns true if parsed correctly, false otherwise
Referenced by MissionItem::initializeFromScript().
| void Timespan::sleepFor | ( | void | ) | const |
Sleep for the timespan.
Sleep for the specified period.
References Timestamp::toTimespec().
Referenced by LPC3Reg::ActivateBurnwire(), Supervisor::ClearRunningFile(), LPC3Reg::DeactivateBurnwire(), LPC3Reg::DeactivateRadio(), CommandLine::DoCommand(), NAL9602::fillBuffer(), UartStream::flush(), Batt_Ocean_Server::initialize(), CommandLine::kbGetc(), WetLabsBB2FL::paused(), Turbulence_NPS::paused(), CTD_NeilBrown::paused(), Rowe_600::paused(), LPC3Reg::PowerOffLoads(), LPC3Reg::PowerOnLoads(), UartStream::read(), AnalogToDigital::readCounts(), Turbulence_NPS::receive(), Rowe_600::resume(), Supervisor::run(), Handler::runBetween(), Radio_Surface::runnable(), WetLabsBB2FL::runnable(), CTD_NeilBrown::runnable(), Rowe_600LCM::runnable(), Rowe_600::runnable(), UartStream::serGetChar(), MultiHandler::shutdown(), Timestamp::sleepTill(), Radio_Surface::start(), Rowe_600LCM::start(), Rowe_600::start(), Radio_Surface::starting(), Rowe_600LCM::starting(), Rowe_600::starting(), Radio_Surface::stop(), WetLabsBB2FL::stop(), Turbulence_NPS::stop(), CTD_NeilBrown::stop(), Rowe_600LCM::stop(), Rowe_600::stop(), Radio_Surface::stopped(), WetLabsBB2FL::stopped(), Turbulence_NPS::stopped(), CTD_NeilBrown::stopped(), Rowe_600LCM::stopped(), Rowe_600::stopped(), Radio_Surface::stopping(), Rowe_600::stopping(), LPC3Reg::SWReset(), Timespan_Test::testSleepFor(), and UartStream::waitForBufferEmpty().
| const char * Timespan::toString | ( | char * | buf, |
| int | buflen, | ||
| int | precision = 3 |
||
| ) | const |
Writes the Timespan to a unsigned char buffer.
| buf | Buffer to write to |
| buflen | Maximum number of characters to write the buffer |
| precision | Number of decimals to include in seconds result (up to 6). |
References MAX, MIN, and Timestamp::timeval_.
Referenced by ESPClient::consumeResult(), ESPClient::handleException(), ESPComponent::starting(), Timespan_Test::testToString(), toString(), and ESPComponent::waitForESPConnection().
| const Str Timespan::toString | ( | int | precision = 3 | ) | const |
References toString().
|
static |
Constant value to represent an invalid timespan.
This can be represented exactly as a float.
Referenced by asDouble(), asFloat(), Wait::calcSatisfied(), Component::execute(), Behavior::executeIfUnsatisfied(), Aggregate::gotoNextItem(), Wait::initialize(), Aggregate::initialize(), ReadDataComponent::isSatisfied(), SyslogEntry::Read(), EventEntry::Read(), Unserialize::Run(), MissionItem::run(), Wait::runIfUnsatisfied(), MissionItem::runIfUnsatisfied(), MissionItem::satisfied(), UartStream::serGetChar(), and SplitFileLogWriter::write().
|
static |
Constant value to represent instant of time.
Referenced by UartStream::flush(), UartStream::flushCRLF(), main(), Reporter::ReportItem::needsReporting(), LogEngine::processQueue(), BinaryLogReader::read(), Unserialize::Run(), ValueDetect_Test::tearDown(), OffshoreEnvelope_Test::tearDown(), Timespan_Test::testConstructorNoArguments(), OffshoreEnvelope_Test::testRun(), and LogEngine::uninitialize().