This is Unofficial EPICS BASE Doxygen Site
epics::pvData::PVTimeStamp Class Reference

Methods for accessing a timeStamp structure. More...

#include "pvTimeStamp.h"

Public Member Functions

 PVTimeStamp ()
 
bool attach (PVFieldPtr const &pvField)
 
void detach ()
 
bool isAttached ()
 
void get (TimeStamp &timeStamp) const
 
bool set (TimeStamp const &timeStamp)
 

Detailed Description

Methods for accessing a timeStamp structure.

A timeStamp structure has the following fields:

long secondsPastEpoch
int nanoseconds
int userTag

This class can be attached to a timeStamp structure field of any PVData object. The methods provide access to the fields in the attached structure, via an instance of class TimeStamp. This class should not be extended.

Definition at line 38 of file pvTimeStamp.h.

Constructor & Destructor Documentation

epics::pvData::PVTimeStamp::PVTimeStamp ( )
inline

Constructor

Definition at line 44 of file pvTimeStamp.h.

44 {}

Member Function Documentation

bool epics::pvData::PVTimeStamp::attach ( PVFieldPtr const &  pvField)

Definition at line 26 of file pvTimeStamp.cpp.

27 {
28  if(pvField->getField()->getType()!=structure) return false;
29  PVStructurePtr xxx = static_pointer_cast<PVStructure>(pvField);
30  PVStructure* pvStructure = xxx.get();
31  while(true) {
32  PVLongPtr pvLong = pvStructure->getSubField<PVLong>("secondsPastEpoch");
33  if(pvLong) {
34  pvSecs = pvLong;
35  pvNano = pvStructure->getSubField<PVInt>("nanoseconds");
36  pvUserTag = pvStructure->getSubField<PVInt>("userTag");
37  }
38  if(pvSecs
39  && pvNano
40  && pvUserTag) return true;
41  detach();
42  // look up the tree for a timeSyamp
43  pvStructure = pvStructure->getParent();
44  if(pvStructure==NULL) break;
45  }
46  return false;
47 }
PVScalarValue< int32 > PVInt
Definition: pvData.h:496
shared_ptr< T > static_pointer_cast(shared_ptr< U > const &r) BOOST_NOEXCEPT
Definition: shared_ptr.hpp:788
#define NULL
Definition: catime.c:38
std::tr1::shared_ptr< PVLong > PVLongPtr
Definition: pvData.h:508
PVScalarValue< int64 > PVLong
Definition: pvData.h:497
std::tr1::shared_ptr< PVStructure > PVStructurePtr
Definition: pvData.h:87
void epics::pvData::PVTimeStamp::detach ( )

Detach for pvField.

Definition at line 49 of file pvTimeStamp.cpp.

50 {
51  pvSecs.reset();
52  pvUserTag.reset();
53  pvNano.reset();
54 }
void epics::pvData::PVTimeStamp::get ( TimeStamp timeStamp) const

copy the timeStamp structure values to TimeStamp

Parameters
timeStampAn instance of class TimeStamp
Exceptions
Ifnot attached to a pvField.

Definition at line 61 of file pvTimeStamp.cpp.

62 {
63  if(pvSecs.get()==NULL) {
64  throw std::logic_error(notAttached);
65  }
66  timeStamp.put(pvSecs->get(),pvNano->get());
67  timeStamp.setUserTag(pvUserTag->get());
68 }
#define NULL
Definition: catime.c:38
bool epics::pvData::PVTimeStamp::isAttached ( )

Is the PVTimeStamp attached to a pvField?

Returns
(false,true) (is not,is) attached to a pvField.

Definition at line 56 of file pvTimeStamp.cpp.

56  {
57  if(pvSecs.get()==NULL) return false;
58  return true;
59 }
#define NULL
Definition: catime.c:38
bool epics::pvData::PVTimeStamp::set ( TimeStamp const &  timeStamp)

copy the values from TimeStamp to the timeStamp structure.

Parameters
timeStampAn instance of class TimeStamp
Returns
(false,true) if pvField (immutable, mutable)
Exceptions
Ifnot attached to a pvField.

Definition at line 70 of file pvTimeStamp.cpp.

71 {
72  if(pvSecs.get()==NULL) {
73  throw std::logic_error(notAttached);
74  }
75  if(pvSecs->isImmutable() || pvNano->isImmutable()) return false;
76  TimeStamp current;
77  get(current);
78  bool returnValue = false;
79  if(current.getSecondsPastEpoch()!=timeStamp.getSecondsPastEpoch())
80  {
81  pvSecs->put(timeStamp.getSecondsPastEpoch());
82  returnValue = true;
83  }
84  if(current.getNanoseconds()!=timeStamp.getNanoseconds())
85  {
86  pvNano->put(timeStamp.getNanoseconds());
87  returnValue = true;
88  }
89  if(current.getUserTag()!=timeStamp.getUserTag())
90  {
91  pvUserTag->put(timeStamp.getUserTag());
92  returnValue = true;
93  }
94  return returnValue;
95 }
#define NULL
Definition: catime.c:38

The documentation for this class was generated from the following files: