logserialport.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef LOGSERIALPORT_H
  2. #define LOGSERIALPORT_H
  3. #include <QObject>
  4. #include <QWidget>
  5. #include <QSerialPort>
  6. #include <QQueue>
  7. #include "handle/utils/rtuhelper.h"
  8. #include <QPair>
  9. #include <QDateTime>
  10. #include <QFile>
  11. #include <QTimer>
  12. #include "QDebug"
  13. #include "globalinfo.h"
  14. #include "serialbasehandle.h"
  15. #ifdef _MSC_VER
  16. #pragma execution_character_set("utf-8")
  17. #endif
  18. class LogSerialPort : public UtilsFun::RTUHelper, public SerialBaseHandle
  19. {
  20. public:
  21. explicit LogSerialPort();
  22. ~LogSerialPort();
  23. // inline bool isStart() const {return started;}
  24. // inline bool isOpened() const {return opened;}
  25. float toFloat(const QByteArray & ray);
  26. bool needSend();
  27. QByteArray sendData();
  28. void handle(QByteArray & data);
  29. void doHandle(const QByteArray & data);
  30. // void save(int, const QDateTime &tm, double v);
  31. private:
  32. QSerialPort * _port;
  33. QTimer * _timer;
  34. QQueue<QByteArray> _sendQueue;
  35. bool started;
  36. bool needReply;
  37. bool opened;
  38. QPair<QDateTime,QFile * > _save;
  39. QByteArray _getData;
  40. QByteArray _resetData;
  41. scaledata _scaledata;
  42. QByteArray ret;
  43. double buchang;
  44. double max;
  45. double min;
  46. };
  47. #endif // LOGSERIALPORT_H