userlock.h 783 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef USERLOCK_H
  2. #define USERLOCK_H
  3. #include <QObject>
  4. #include <QThread>
  5. #include <QDebug>
  6. #include <QSerialPort>
  7. #include <QSerialPortInfo>
  8. enum class lockWorkStat {
  9. init,
  10. readstat,
  11. open,
  12. close,
  13. check,
  14. };
  15. class userlock : public QThread
  16. {
  17. Q_OBJECT
  18. public:
  19. explicit userlock(QSerialPort *serial, QObject *parent = nullptr);
  20. private:
  21. bool threadstatus = true;
  22. QSerialPort *devserial;
  23. bool openPort = false;
  24. lockWorkStat workstat = lockWorkStat::init;
  25. quint16 Modbus_Crc(QByteArray &data, quint8 count);
  26. void sendData(QByteArray &sendData);
  27. bool readData(QByteArray *data, quint16 timeout);
  28. bool readLockStat(void);
  29. bool openLock(void);
  30. bool closeLock(void);
  31. bool checkLock(void);
  32. };
  33. #endif // USERLOCK_H