您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

readthread.h 788B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef READTHREAD_H
  2. #define READTHREAD_H
  3. #include <QThread>
  4. #include <sys/time.h>
  5. #include "inputmanager.h"
  6. typedef QList<QPair<QVariant, QVariant>> InputValues;
  7. class ReadThread : public QThread
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit ReadThread(InputManager* input, const QList<QVariant> &channels, quint64 interval, QObject *parent = 0);
  12. inline __suseconds_t getTime() const;
  13. protected:
  14. void run();
  15. signals:
  16. void newValues(InputValues values, quint64 timestamp);
  17. private:
  18. InputManager* m_input;
  19. QList<QVariant> m_channels;
  20. quint64 m_interval;
  21. };
  22. __suseconds_t ReadThread::getTime() const
  23. {
  24. struct timeval time;
  25. gettimeofday(&time, NULL);
  26. return 1000000 * time.tv_sec + time.tv_usec;
  27. }
  28. Q_DECLARE_METATYPE(InputValues)
  29. #endif // READTHREAD_H