qwt_sampling_thread.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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 "qwt_system_clock.h"
12 
14 {
15 public:
17 
18  double interval;
19  bool isStopped;
20 };
21 
22 
25  QThread( parent )
26 {
27  d_data = new PrivateData;
28  d_data->interval = 1000; // 1 second
29  d_data->isStopped = true;
30 }
31 
34 {
35  delete d_data;
36 }
37 
46 {
47  if ( interval < 0.0 )
48  interval = 0.0;
49 
51 }
52 
58 {
59  return d_data->interval;
60 }
61 
67 {
68  if ( d_data->isStopped )
69  return 0.0;
70 
71  return d_data->clock.elapsed();
72 }
73 
79 {
80  d_data->isStopped = true;
81 }
82 
88 {
89  d_data->clock.start();
90  d_data->isStopped = false;
91 
92  while ( !d_data->isStopped )
93  {
94  const double elapsed = d_data->clock.elapsed();
95  sample( elapsed / 1000.0 );
96 
97  if ( d_data->interval > 0.0 )
98  {
99  const double msecs =
101 
102  if ( msecs > 0.0 )
103  usleep( qRound( 1000.0 * msecs ) );
104  }
105  }
106 }
virtual void sample(double elapsed)=0
double elapsed() const
virtual ~QwtSamplingThread()
Destructor.
QwtSamplingThread(QObject *parent=NULL)
Constructor.
double elapsed() const
double interval() const
void setInterval(double interval)
QwtSystemClock provides high resolution clock time functions.


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:17