Main Page
Related Pages
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Enumerations
a
b
c
d
e
g
i
l
m
o
p
r
s
t
v
+
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
+
Classes
Class List
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
_
a
b
c
d
e
f
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Enumerations
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
w
+
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Properties
a
b
c
d
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Related Functions
:
a
b
c
d
e
f
g
i
m
o
q
r
s
v
w
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
p
q
r
s
t
u
v
w
x
z
+
Enumerations
a
b
c
d
e
f
h
i
k
l
n
o
r
t
u
v
x
+
Enumerator
b
c
d
e
f
h
i
k
l
m
n
o
p
r
t
u
v
w
x
+
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
3rdparty
qwt
src
qwt_sampling_thread.cpp
Go to the documentation of this file.
1
/******************************************************************************
2
* Qwt Widget Library
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the Qwt License, Version 1.0
8
*****************************************************************************/
9
10
#include "
qwt_sampling_thread.h
"
11
#include <qelapsedtimer.h>
12
13
class
QwtSamplingThread::PrivateData
14
{
15
public
:
16
QElapsedTimer
timer
;
17
double
msecsInterval
;
18
};
19
21
QwtSamplingThread::QwtSamplingThread
( QObject* parent )
22
: QThread( parent )
23
{
24
m_data
=
new
PrivateData
;
25
m_data
->
msecsInterval
= 1e3;
// 1 second
26
}
27
29
QwtSamplingThread::~QwtSamplingThread
()
30
{
31
delete
m_data
;
32
}
33
41
void
QwtSamplingThread::setInterval
(
double
msecs )
42
{
43
if
( msecs < 0.0 )
44
msecs = 0.0;
45
46
m_data
->
msecsInterval
= msecs;
47
}
48
53
double
QwtSamplingThread::interval
()
const
54
{
55
return
m_data
->
msecsInterval
;
56
}
57
62
double
QwtSamplingThread::elapsed
()
const
63
{
64
if
(
m_data
->
timer
.isValid() )
65
return
m_data
->
timer
.nsecsElapsed() / 1e6;
66
67
return
0.0;
68
}
69
74
void
QwtSamplingThread::stop
()
75
{
76
m_data
->
timer
.invalidate();
77
}
78
83
void
QwtSamplingThread::run
()
84
{
85
m_data
->
timer
.start();
86
87
/*
88
We should have all values in nsecs/qint64, but
89
this would break existing code. TODO ...
90
Anyway - for QThread::usleep we even need microseconds( usecs )
91
*/
92
while
(
m_data
->
timer
.isValid() )
93
{
94
const
qint64 timestamp =
m_data
->
timer
.nsecsElapsed();
95
sample
( timestamp / 1e9 );
// seconds
96
97
if
(
m_data
->
msecsInterval
> 0.0 )
98
{
99
const
double
interval
=
m_data
->
msecsInterval
* 1e3;
100
const
double
elapsed
= (
m_data
->
timer
.nsecsElapsed() - timestamp ) / 1e3;
101
102
const
double
usecs = interval -
elapsed
;
103
104
if
( usecs > 0.0 )
105
QThread::usleep( qRound( usecs ) );
106
}
107
}
108
}
109
110
#if QWT_MOC_INCLUDE
111
#include "moc_qwt_sampling_thread.cpp"
112
#endif
QwtSamplingThread::PrivateData::msecsInterval
double msecsInterval
Definition:
qwt_sampling_thread.cpp:17
QwtSamplingThread::sample
virtual void sample(double elapsed)=0
QwtSamplingThread::stop
void stop()
Definition:
qwt_sampling_thread.cpp:74
QwtSamplingThread::elapsed
double elapsed() const
Definition:
qwt_sampling_thread.cpp:62
QwtSamplingThread::~QwtSamplingThread
virtual ~QwtSamplingThread()
Destructor.
Definition:
qwt_sampling_thread.cpp:29
QwtSamplingThread::PrivateData
Definition:
qwt_sampling_thread.cpp:13
QwtSamplingThread::m_data
PrivateData * m_data
Definition:
qwt_sampling_thread.h:58
QwtSamplingThread::PrivateData::timer
QElapsedTimer timer
Definition:
qwt_sampling_thread.cpp:16
QwtSamplingThread::run
virtual void run() QWT_OVERRIDE
Definition:
qwt_sampling_thread.cpp:83
qwt_sampling_thread.h
QwtSamplingThread::QwtSamplingThread
QwtSamplingThread(QObject *parent=NULL)
Constructor.
Definition:
qwt_sampling_thread.cpp:21
QwtSamplingThread::setInterval
void setInterval(double interval)
Definition:
qwt_sampling_thread.cpp:41
QwtSamplingThread::interval
double interval() const
Definition:
qwt_sampling_thread.cpp:53
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Jun 19 2023 03:01:39