logserialport.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef LOGSERIALPORT_H
  2. #define LOGSERIALPORT_H
  3. #include <QObject>
  4. #include <QWidget>
  5. #include <QSerialPort>
  6. #include <QQueue>
  7. #include "utils/rtuhelper.h"
  8. #include <QPair>
  9. #include <QDateTime>
  10. #include <QFile>
  11. #include <QTimer>
  12. #include "QDebug"
  13. #include "globalinfo.h"
  14. #ifdef _MSC_VER
  15. #pragma execution_character_set("utf-8")
  16. #endif
  17. class LogSerialPort : public QObject,public UtilsFun::RTUHelper
  18. {
  19. Q_OBJECT
  20. public:
  21. explicit LogSerialPort(QObject *parent = nullptr);
  22. // inline bool isStart() const {return started;}
  23. // inline bool isOpened() const {return opened;}
  24. float toFloat(const QByteArray & ray);
  25. signals:
  26. // void refValue();
  27. // void newValue(int id,qint64 tm, double v);
  28. public slots:
  29. // void open(const QString & name, int bandwith);
  30. // void close();
  31. // void checkBuchang(double buchang, double max, double min);
  32. private slots:
  33. // void doTimerOut();
  34. // void readData();
  35. void doHandle(const QByteArray & data);
  36. // void save(int, const QDateTime &tm, double v);
  37. private:
  38. QSerialPort * _port;
  39. QTimer * _timer;
  40. QQueue<QByteArray> _sendQueue;
  41. bool started;
  42. bool needReply;
  43. bool opened;
  44. QPair<QDateTime,QFile * > _save;
  45. QByteArray _getData;
  46. QByteArray _resetData;
  47. scaledata scaledata;
  48. double buchang;
  49. double max;
  50. double min;
  51. };
  52. #endif // LOGSERIALPORT_H