Last change
on this file since 27 was
22,
checked in by rings, 14 years ago
|
|
-
Property svn:executable set to
*
|
File size:
1.4 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file GenericCapture.cpp |
---|
3 | * @author Tomas Urban |
---|
4 | * @version 0.3 |
---|
5 | * @date 23/07/2009 |
---|
6 | */ |
---|
7 | #include "GenericCapture.h" |
---|
8 | #include "Logger/Logger.h" |
---|
9 | |
---|
10 | GenericCapture::GenericCapture() : |
---|
11 | m_pDispatch(0) |
---|
12 | { |
---|
13 | m_startPoint.tv_sec = 0; |
---|
14 | m_startPoint.tv_usec = 0; |
---|
15 | m_offset.tv_sec = 0; |
---|
16 | m_offset.tv_usec = 0; |
---|
17 | m_timestamp.tv_sec = 0; |
---|
18 | m_timestamp.tv_usec = 0; |
---|
19 | } |
---|
20 | |
---|
21 | GenericCapture::~GenericCapture(void) |
---|
22 | { |
---|
23 | |
---|
24 | } |
---|
25 | |
---|
26 | void GenericCapture::UpdateTimestamp() |
---|
27 | { |
---|
28 | m_timestamp.tv_sec = m_startPoint.tv_sec + m_offset.tv_sec; |
---|
29 | m_timestamp.tv_usec = m_startPoint.tv_usec + m_offset.tv_usec; |
---|
30 | int nSec = m_timestamp.tv_usec / 1000000; |
---|
31 | if (nSec > 0) |
---|
32 | { |
---|
33 | m_timestamp.tv_sec += nSec; |
---|
34 | m_timestamp.tv_usec -= nSec * 1000000; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | void GenericCapture::SetStartPoint(struct timeval timestamp) |
---|
39 | { |
---|
40 | m_startPoint = timestamp; |
---|
41 | UpdateTimestamp(); |
---|
42 | } |
---|
43 | |
---|
44 | void GenericCapture::SetStartOffset(struct timeval offset) |
---|
45 | { |
---|
46 | m_offset = offset; |
---|
47 | UpdateTimestamp(); |
---|
48 | } |
---|
49 | |
---|
50 | void GenericCapture::ProcessCapturedData(CapturedData * pData) |
---|
51 | { |
---|
52 | if (!m_pDispatch) |
---|
53 | return; |
---|
54 | timeval msgTime = pData->GetTimestamp(); |
---|
55 | if (msgTime.tv_sec > m_timestamp.tv_sec || |
---|
56 | msgTime.tv_sec == m_timestamp.tv_sec && msgTime.tv_usec >= m_timestamp.tv_usec) |
---|
57 | { |
---|
58 | pData->SetCaptureType(GetCaptureType()); |
---|
59 | m_pDispatch->DispatchData(pData); |
---|
60 | } |
---|
61 | else |
---|
62 | Logger::Instance().LogDebug("Captured message discarded (older than start point)"); |
---|
63 | } |
---|
64 | |
---|
65 | bool GenericCapture::SetCaptureFile(const std::string sFile) |
---|
66 | { |
---|
67 | return sFile.length() == 0; |
---|
68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.