PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
vtkPlusTimestampedCircularBuffer Class Reference

This class stores an fixed number of timestamped items. It provides element retrieval based on timestamp, temporal filtering and interpolation, etc. More...

#include <src/PlusDataCollection/vtkPlusTimestampedCircularBuffer.h>

Inheritance diagram for vtkPlusTimestampedCircularBuffer:
Inheritance graph
[legend]
Collaboration diagram for vtkPlusTimestampedCircularBuffer:
Collaboration graph
[legend]

Public Member Functions

void AddToTimeStampReport (unsigned long itemIndex, double unfilteredTimestamp, double filteredTimestamp)
 
virtual void Clear ()
 
virtual PlusStatus CreateFilteredTimeStampForItem (unsigned long itemIndex, double inUnfilteredTimestamp, double &outFilteredTimestamp, bool &filteredTimestampProbablyValid)
 
virtual void DeepCopy (vtkPlusTimestampedCircularBuffer *buffer)
 
virtual int GetAveragedItemsForFiltering ()
 
virtual ItemStatus GetBufferIndexFromTime (const double time, int &bufferIndex)
 
virtual StreamBufferItemGetBufferItemPointerFromBufferIndex (const int bufferIndex)
 
virtual ItemStatus GetBufferItemPointerFromUid (const BufferItemUidType uid, StreamBufferItem *&itemPtr)
 
virtual int GetBufferSize ()
 
virtual ItemStatus GetFilteredTimeStamp (const BufferItemUidType uid, double &filteredTimestamp)
 
virtual double GetFrameRate (bool ideal=false, double *framePeriodStdevSecPtr=NULL)
 
virtual ItemStatus GetIndex (const BufferItemUidType uid, unsigned long &index)
 
virtual ItemStatus GetItemUidFromTime (const double time, BufferItemUidType &uid)
 
virtual bool GetLatestItemHasValidFieldData ()
 
virtual bool GetLatestItemHasValidTransformData ()
 
virtual bool GetLatestItemHasValidVideoData ()
 
virtual BufferItemUidType GetLatestItemUidInBuffer ()
 
virtual ItemStatus GetLatestTimeStamp (double &timestamp)
 
virtual double GetLocalTimeOffsetSec ()
 
virtual int GetNumberOfItems ()
 
virtual BufferItemUidType GetOldestItemUidInBuffer ()
 
virtual ItemStatus GetOldestTimeStamp (double &timestamp)
 
virtual double GetStartTime ()
 
virtual ItemStatus GetTimeStamp (const BufferItemUidType uid, double &timestamp)
 
virtual bool GetTimeStampLogging ()
 
virtual bool GetTimeStampReporting ()
 
PlusStatus GetTimeStampReportTable (vtkTable *timeStampReportTable)
 
virtual ItemStatus GetUnfilteredTimeStamp (const BufferItemUidType uid, double &unfilteredTimestamp)
 
void Lock ()
 
virtual PlusStatus PrepareForNewItem (const double timestamp, BufferItemUidType &newFrameUid, int &bufferIndex)
 
void PrintSelf (ostream &os, vtkIndent indent)
 
virtual void SetAveragedItemsForFiltering (unsigned int)
 
virtual PlusStatus SetBufferSize (int n)
 
virtual void SetLocalTimeOffsetSec (double)
 
virtual void SetStartTime (double)
 
virtual void SetTimeStampLogging (bool)
 
virtual void SetTimeStampReporting (bool)
 
virtual void TimeStampLoggingOff ()
 
virtual void TimeStampLoggingOn ()
 
virtual void TimeStampReportingOff ()
 
virtual void TimeStampReportingOn ()
 
void Unlock ()
 

Static Public Member Functions

static vtkPlusTimestampedCircularBufferNew ()
 

Protected Member Functions

 vtkPlusTimestampedCircularBuffer ()
 
 ~vtkPlusTimestampedCircularBuffer ()
 

Protected Attributes

unsigned int AveragedItemsForFiltering
 
std::deque< StreamBufferItemBufferItemContainer
 
double CurrentTimeStamp
 
vnl_vector< double > FilterContainerIndexVector
 
unsigned int FilterContainersNumberOfValidElements
 
unsigned int FilterContainersOldestIndex
 
vnl_vector< double > FilterContainerTimestampVector
 
BufferItemUidType LatestItemUid
 
double LocalTimeOffsetSec
 
double MaxAllowedFilteringTimeDifference
 
vtkIGSIORecursiveCriticalSection * Mutex
 
double NegligibleTimeDifferenceSec
 
int NumberOfItems
 
double StartTime
 
bool TimeStampLogging
 
bool TimeStampReporting
 
vtkTable * TimeStampReportTable
 
int WritePointer
 

Detailed Description

This class stores an fixed number of timestamped items. It provides element retrieval based on timestamp, temporal filtering and interpolation, etc.

Definition at line 37 of file vtkPlusTimestampedCircularBuffer.h.

Constructor & Destructor Documentation

◆ vtkPlusTimestampedCircularBuffer()

vtkPlusTimestampedCircularBuffer::vtkPlusTimestampedCircularBuffer ( )
protected

Definition at line 18 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ ~vtkPlusTimestampedCircularBuffer()

vtkPlusTimestampedCircularBuffer::~vtkPlusTimestampedCircularBuffer ( )
protected

Definition at line 41 of file vtkPlusTimestampedCircularBuffer.cxx.

Member Function Documentation

◆ AddToTimeStampReport()

void vtkPlusTimestampedCircularBuffer::AddToTimeStampReport ( unsigned long  itemIndex,
double  unfilteredTimestamp,
double  filteredTimestamp 
)

Add values to the timestamp report. If reporting is not enabled then no values will be added. This should only be called if an item is added without calling CreateFilteredTimeStampForItem.

Definition at line 654 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ Clear()

void vtkPlusTimestampedCircularBuffer::Clear ( )
virtual

Clear buffer (set the buffer pointer to the first element)

Definition at line 420 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ CreateFilteredTimeStampForItem()

PlusStatus vtkPlusTimestampedCircularBuffer::CreateFilteredTimeStampForItem ( unsigned long  itemIndex,
double  inUnfilteredTimestamp,
double &  outFilteredTimestamp,
bool &  filteredTimestampProbablyValid 
)
virtual

Create filtered and unfiltered timestamp for accurate timing of the buffer item. The timing may be inaccurate because the timestamp is attached to the item when Plus receives it and so the timestamp is affected by data transfer speed (which may slightly vary). A line is fitted to the index and timestamp of the last (AveragedItemsForFiltering) items. The filtered timestamp is the time value that corresponds to the frame index according to the fitted line. If the filtered timestamp is very different from the non-filtered timestamp then filteredTimestampProbablyValid will be false and it is recommended not to use that item, because its timestamp is probably incorrect.

Definition at line 529 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ DeepCopy()

void vtkPlusTimestampedCircularBuffer::DeepCopy ( vtkPlusTimestampedCircularBuffer buffer)
virtual

Make this buffer into a copy of another buffer. You should Lock both of the buffers before doing this.

Definition at line 398 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetAveragedItemsForFiltering()

virtual int vtkPlusTimestampedCircularBuffer::GetAveragedItemsForFiltering ( )
virtual

Get number of items used for timestamp filtering (with LSQR mimimizer)

◆ GetBufferIndexFromTime()

ItemStatus vtkPlusTimestampedCircularBuffer::GetBufferIndexFromTime ( const double  time,
int bufferIndex 
)
virtual

Given a timestamp, compute the nearest buffer index This assumes that the times motonically increase

Definition at line 291 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetBufferItemPointerFromBufferIndex()

StreamBufferItem * vtkPlusTimestampedCircularBuffer::GetBufferItemPointerFromBufferIndex ( const int  bufferIndex)
virtual

Get next writable buffer object INTERNAL USE ONLY! Need to lock buffer until we use the buffer index

Definition at line 196 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetBufferItemPointerFromUid()

ItemStatus vtkPlusTimestampedCircularBuffer::GetBufferItemPointerFromUid ( const BufferItemUidType  uid,
StreamBufferItem *&  itemPtr 
)
virtual

Get next writable buffer object INTERNAL USE ONLY! Need to lock buffer until we use the buffer index

Definition at line 170 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetBufferSize()

virtual int vtkPlusTimestampedCircularBuffer::GetBufferSize ( )
inlinevirtual

Definition at line 48 of file vtkPlusTimestampedCircularBuffer.h.

◆ GetFilteredTimeStamp()

ItemStatus vtkPlusTimestampedCircularBuffer::GetFilteredTimeStamp ( const BufferItemUidType  uid,
double &  filteredTimestamp 
)
virtual

Definition at line 210 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetFrameRate()

double vtkPlusTimestampedCircularBuffer::GetFrameRate ( bool  ideal = false,
double *  framePeriodStdevSecPtr = NULL 
)
virtual

Get the frame rate from the buffer based on the number of frames in the buffer and the elapsed time. Ideal frame rate shows the mean of the frame periods in the buffer based on the frame number difference (a.k.a. the device frame rate, a.k.a. the frame rate that would have been achieved if frames were not dropped). If framePeriodStdevSecPtr is not null, then the standard deviation of the frame period is computed as well (in seconds) and stored at the specified address.

Definition at line 431 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetIndex()

ItemStatus vtkPlusTimestampedCircularBuffer::GetIndex ( const BufferItemUidType  uid,
unsigned long &  index 
)
virtual

Get the index assigned by the data acuiqisition system (usually a counter) from the buffer by frame UID.

Definition at line 276 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetItemUidFromTime()

ItemStatus vtkPlusTimestampedCircularBuffer::GetItemUidFromTime ( const double  time,
BufferItemUidType uid 
)
virtual

Given a timestamp, compute the nearest frame UID This assumes that the times motonically increase

Definition at line 315 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetLatestItemHasValidFieldData()

bool vtkPlusTimestampedCircularBuffer::GetLatestItemHasValidFieldData ( )
virtual

Definition at line 264 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetLatestItemHasValidTransformData()

bool vtkPlusTimestampedCircularBuffer::GetLatestItemHasValidTransformData ( )
virtual

Definition at line 252 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetLatestItemHasValidVideoData()

bool vtkPlusTimestampedCircularBuffer::GetLatestItemHasValidVideoData ( )
virtual

Definition at line 240 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetLatestItemUidInBuffer()

virtual BufferItemUidType vtkPlusTimestampedCircularBuffer::GetLatestItemUidInBuffer ( )
inlinevirtual

Get the most recent frame UID that is already in the buffer

Definition at line 65 of file vtkPlusTimestampedCircularBuffer.h.

◆ GetLatestTimeStamp()

virtual ItemStatus vtkPlusTimestampedCircularBuffer::GetLatestTimeStamp ( double &  timestamp)
inlinevirtual

Get timestamp by frame UID associated with the buffer item

Definition at line 84 of file vtkPlusTimestampedCircularBuffer.h.

◆ GetLocalTimeOffsetSec()

virtual double vtkPlusTimestampedCircularBuffer::GetLocalTimeOffsetSec ( )
virtual

Get the local time offset in seconds (global = local + offset)

◆ GetNumberOfItems()

virtual int vtkPlusTimestampedCircularBuffer::GetNumberOfItems ( )
virtual

Get the number of items in the list (this is not the same as the buffer size, but is rather the number of transforms that have been added to the list). This will never be greater than the BufferSize.

◆ GetOldestItemUidInBuffer()

virtual BufferItemUidType vtkPlusTimestampedCircularBuffer::GetOldestItemUidInBuffer ( )
inlinevirtual

Get the oldest frame UID in the buffer

Definition at line 74 of file vtkPlusTimestampedCircularBuffer.h.

◆ GetOldestTimeStamp()

virtual ItemStatus vtkPlusTimestampedCircularBuffer::GetOldestTimeStamp ( double &  timestamp)
inlinevirtual

Definition at line 89 of file vtkPlusTimestampedCircularBuffer.h.

◆ GetStartTime()

virtual double vtkPlusTimestampedCircularBuffer::GetStartTime ( )
virtual

Get recording start time

◆ GetTimeStamp()

virtual ItemStatus vtkPlusTimestampedCircularBuffer::GetTimeStamp ( const BufferItemUidType  uid,
double &  timestamp 
)
inlinevirtual

Definition at line 101 of file vtkPlusTimestampedCircularBuffer.h.

◆ GetTimeStampLogging()

virtual bool vtkPlusTimestampedCircularBuffer::GetTimeStampLogging ( )
virtual

◆ GetTimeStampReporting()

virtual bool vtkPlusTimestampedCircularBuffer::GetTimeStampReporting ( )
virtual

◆ GetTimeStampReportTable()

PlusStatus vtkPlusTimestampedCircularBuffer::GetTimeStampReportTable ( vtkTable *  timeStampReportTable)

Get the table report of the timestamped buffer. To fill this table TimeStampReporting has to be enabled.

Definition at line 632 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ GetUnfilteredTimeStamp()

ItemStatus vtkPlusTimestampedCircularBuffer::GetUnfilteredTimeStamp ( const BufferItemUidType  uid,
double &  unfilteredTimestamp 
)
virtual

Definition at line 225 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ Lock()

void vtkPlusTimestampedCircularBuffer::Lock ( )
inline

Lock the buffer: this should be done before changing or accessing the data in the buffer if the buffer is being used from multiple threads.

Definition at line 149 of file vtkPlusTimestampedCircularBuffer.h.

◆ New()

static vtkPlusTimestampedCircularBuffer* vtkPlusTimestampedCircularBuffer::New ( )
static

◆ PrepareForNewItem()

PlusStatus vtkPlusTimestampedCircularBuffer::PrepareForNewItem ( const double  timestamp,
BufferItemUidType newFrameUid,
int bufferIndex 
)
virtual

Definition at line 73 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ PrintSelf()

void vtkPlusTimestampedCircularBuffer::PrintSelf ( ostream &  os,
vtkIndent  indent 
)

Definition at line 61 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ SetAveragedItemsForFiltering()

virtual void vtkPlusTimestampedCircularBuffer::SetAveragedItemsForFiltering ( unsigned int  )
virtual

Set number of items used for timestamp filtering (with LSQR mimimizer)

◆ SetBufferSize()

PlusStatus vtkPlusTimestampedCircularBuffer::SetBufferSize ( int  n)
virtual

Set/Get the size of the buffer, i.e. the maximum number of video frames that it will hold. The default is 30.

Definition at line 105 of file vtkPlusTimestampedCircularBuffer.cxx.

◆ SetLocalTimeOffsetSec()

virtual void vtkPlusTimestampedCircularBuffer::SetLocalTimeOffsetSec ( double  )
virtual

Set the local time offset in seconds (global = local + offset)

◆ SetStartTime()

virtual void vtkPlusTimestampedCircularBuffer::SetStartTime ( double  )
virtual

Set recording start time

◆ SetTimeStampLogging()

virtual void vtkPlusTimestampedCircularBuffer::SetTimeStampLogging ( bool  )
virtual

If TimeStampLogging is enabled then the timestamps and frame indexes that are used for filtering will be logged at TRACE level for diagnostic purposes.

◆ SetTimeStampReporting()

virtual void vtkPlusTimestampedCircularBuffer::SetTimeStampReporting ( bool  )
virtual

If TimeStampReporting is enabled then all filtered and unfiltered timestamp values will be saved in a table for diagnostic purposes.

◆ TimeStampLoggingOff()

virtual void vtkPlusTimestampedCircularBuffer::TimeStampLoggingOff ( )
virtual

◆ TimeStampLoggingOn()

virtual void vtkPlusTimestampedCircularBuffer::TimeStampLoggingOn ( )
virtual

◆ TimeStampReportingOff()

virtual void vtkPlusTimestampedCircularBuffer::TimeStampReportingOff ( )
virtual

◆ TimeStampReportingOn()

virtual void vtkPlusTimestampedCircularBuffer::TimeStampReportingOn ( )
virtual

◆ Unlock()

void vtkPlusTimestampedCircularBuffer::Unlock ( )
inline

Unlock the buffer: this should be done before changing or accessing the data in the buffer if the buffer is being used from multiple threads.

Definition at line 155 of file vtkPlusTimestampedCircularBuffer.h.

Member Data Documentation

◆ AveragedItemsForFiltering

unsigned int vtkPlusTimestampedCircularBuffer::AveragedItemsForFiltering
protected

Number of averaged items used for filtering - read from config files

Definition at line 247 of file vtkPlusTimestampedCircularBuffer.h.

◆ BufferItemContainer

std::deque<StreamBufferItem> vtkPlusTimestampedCircularBuffer::BufferItemContainer
protected

Definition at line 232 of file vtkPlusTimestampedCircularBuffer.h.

◆ CurrentTimeStamp

double vtkPlusTimestampedCircularBuffer::CurrentTimeStamp
protected

Definition at line 221 of file vtkPlusTimestampedCircularBuffer.h.

◆ FilterContainerIndexVector

vnl_vector<double> vtkPlusTimestampedCircularBuffer::FilterContainerIndexVector
protected

Matrix used for storing the last number of AveragedItemsForFiltering frame index

Definition at line 235 of file vtkPlusTimestampedCircularBuffer.h.

◆ FilterContainersNumberOfValidElements

unsigned int vtkPlusTimestampedCircularBuffer::FilterContainersNumberOfValidElements
protected

Number of valid elements in the frame index and timestamp containers (maximum can be equal to AveragedItemsForFiltering)

Definition at line 244 of file vtkPlusTimestampedCircularBuffer.h.

◆ FilterContainersOldestIndex

unsigned int vtkPlusTimestampedCircularBuffer::FilterContainersOldestIndex
protected

Pointer to the next item index to write in the containers (usually the oldest one)

Definition at line 241 of file vtkPlusTimestampedCircularBuffer.h.

◆ FilterContainerTimestampVector

vnl_vector<double> vtkPlusTimestampedCircularBuffer::FilterContainerTimestampVector
protected

Vector used for storing the last number of AveragedItemsForFiltering unfiltered timestamps

Definition at line 238 of file vtkPlusTimestampedCircularBuffer.h.

◆ LatestItemUid

BufferItemUidType vtkPlusTimestampedCircularBuffer::LatestItemUid
protected

This will be the UID of the next item that will be added. The UID is monotonously increasing for each new frame.

Definition at line 230 of file vtkPlusTimestampedCircularBuffer.h.

◆ LocalTimeOffsetSec

double vtkPlusTimestampedCircularBuffer::LocalTimeOffsetSec
protected

Time offset of the buffer in seconds

Definition at line 224 of file vtkPlusTimestampedCircularBuffer.h.

◆ MaxAllowedFilteringTimeDifference

double vtkPlusTimestampedCircularBuffer::MaxAllowedFilteringTimeDifference
protected

Maximum time difference that is allowed between filtered and the non-filtered timestamp (in seconds). If the filtered value differs too much from the non-filtered one, then it rejects the filtering result. This useful for making the timestamp filtering more robust (the LSQR fitting sometimes fails).

Definition at line 254 of file vtkPlusTimestampedCircularBuffer.h.

◆ Mutex

vtkIGSIORecursiveCriticalSection* vtkPlusTimestampedCircularBuffer::Mutex
protected

Definition at line 214 of file vtkPlusTimestampedCircularBuffer.h.

◆ NegligibleTimeDifferenceSec

double vtkPlusTimestampedCircularBuffer::NegligibleTimeDifferenceSec
protected

Due to numerical inaccuracies (e.g, saving a timestamp to a string and reading from it results in a slightly different value) it's better to use a tolerance value when making comparisons.

Definition at line 277 of file vtkPlusTimestampedCircularBuffer.h.

◆ NumberOfItems

int vtkPlusTimestampedCircularBuffer::NumberOfItems
protected

Definition at line 216 of file vtkPlusTimestampedCircularBuffer.h.

◆ StartTime

double vtkPlusTimestampedCircularBuffer::StartTime
protected

Acquisition start time

Definition at line 257 of file vtkPlusTimestampedCircularBuffer.h.

◆ TimeStampLogging

bool vtkPlusTimestampedCircularBuffer::TimeStampLogging
protected

If TimeStampReporting is enabled then all filtered and unfiltered timestamp values will be saved in a table for diagnostic purposes. It generates quite a lot of output in the logs, so it is recommended to use only for diagnostic purposes.

Definition at line 271 of file vtkPlusTimestampedCircularBuffer.h.

◆ TimeStampReporting

bool vtkPlusTimestampedCircularBuffer::TimeStampReporting
protected

If TimeStampReporting is enabled then all filtered and unfiltered timestamp values will be saved in a table. As the table is continuously growing it should be enabled only temporarily, for diagnostic purposes.

Definition at line 266 of file vtkPlusTimestampedCircularBuffer.h.

◆ TimeStampReportTable

vtkTable* vtkPlusTimestampedCircularBuffer::TimeStampReportTable
protected

Table used for storing timestamp filtering results

Definition at line 260 of file vtkPlusTimestampedCircularBuffer.h.

◆ WritePointer

int vtkPlusTimestampedCircularBuffer::WritePointer
protected

Next image will be written here

Definition at line 219 of file vtkPlusTimestampedCircularBuffer.h.


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