Namespaces | Classes | Enumerations | Functions
novadaq Namespace Reference

Namespaces

 cnv
 
 datalogger
 
 HexUtils
 
 messages
 
 timeutils
 

Classes

class  BackgroundProcess
 
class  Cache
 
class  CacheManager
 
class  CachePolicy
 
class  ConcurrentQueue
 
class  EnvVarCache
 
struct  FailIfFull
 
struct  KeepNewest
 
class  LocationUtils
 
class  PartitionNumber
 
class  ProcessUtils
 
struct  RejectNewest
 
class  Runnable
 
class  SHMConvention
 
class  Status
 
class  TimedCachePolicy
 
class  XMLDeserializationRegistry
 
class  XMLSerializable
 

Enumerations

enum  OFFLINE_FRAMEWORK { ART_FRAMEWORK = 1, FMWK_FRAMEWORK, LAST_FRAMEWORK }
 Enumeration of the Offline frameworks. More...
 

Functions

double convertTimevalToDouble (struct timeval const &inputUnixTime)
 
double getCurrentTime ()
 
std::string formatDateTime (time_t secondsSinceTheEpoch)
 

Detailed Description

A bunch of simple, static functions to return DAQ conventions

Author
Jonathan Paley
Version
Id
DAQConventions.h,v 1.12 2013/02/07 20:20:53 jpaley Exp

Enumeration Type Documentation

Enumeration of the Offline frameworks.

Enumerator
ART_FRAMEWORK 
FMWK_FRAMEWORK 
LAST_FRAMEWORK 

Definition at line 17 of file SHMConvention.h.

Function Documentation

double novadaq::convertTimevalToDouble ( struct timeval const &  inputUnixTime)

Free function to convert a timeval struct into a double.

Definition at line 10 of file TimeUtils.cpp.

Referenced by gov::fnal::cd::rms::provider::DDSConnection::dumpMessage(), getCurrentTime(), and GeneralTests::testTimeUtils().

11 {
12  return ((double) inputUnixTime.tv_sec) +
13  (((double) inputUnixTime.tv_usec) / 1000000.0);
14 }
std::string novadaq::formatDateTime ( time_t  secondsSinceTheEpoch)

Definition at line 28 of file TimeUtils.cpp.

References cet::replace_all().

29 {
30  boost::posix_time::ptime convertedTime =
31  boost::posix_time::from_time_t(secondsSinceTheEpoch);
32  std::string resultString =
33  boost::posix_time::to_iso_extended_string(convertedTime);
34 
35  // strip off any extra fractional seconds digits (more than three)
36  size_t dotPos = resultString.find_last_of(".");
37  if (dotPos != std::string::npos &&
38  resultString.length() > (dotPos + 4)) {
39  resultString = resultString.substr(0, (dotPos + 4));
40  }
41  dotPos = resultString.find_last_of(",");
42  if (dotPos != std::string::npos &&
43  resultString.length() > (dotPos + 4)) {
44  resultString = resultString.substr(0, (dotPos + 4));
45  }
46 
47  // replace the time separator with a space
48  boost::replace_all(resultString, "T", " ");
49 
50  return resultString;
51 }
bool replace_all(std::string &in, std::string const &from, std::string const &to)
Replace all occurrences of from in string with to.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
double novadaq::getCurrentTime ( )

Free function to fetch the current time as a double. (The resulting time is still the number of seconds since the UNIX time epoch, but it's represented as a double instead of a struct).

Definition at line 21 of file TimeUtils.cpp.

References convertTimevalToDouble().

22 {
23  struct timeval unixTime;
24  gettimeofday(&unixTime, 0);
25  return convertTimevalToDouble(unixTime);
26 }
double convertTimevalToDouble(struct timeval const &inputUnixTime)
Definition: TimeUtils.cpp:10