ballvalve.h 905 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef BALLVALVE_H
  2. #define BALLVALVE_H
  3. #include "serialui.h"
  4. #define BALLVALVE_STATUS_OPENING (0xAA)
  5. #define BALLVALVE_STATUS_CLOSING (0xBB)
  6. #define BALLVALVE_STATUS_OPENEND (0xAC)
  7. #define BALLVALVE_STATUS_CLOSEEND (0xBC)
  8. #define BALLVALVE_STATUS_BREAK (0x00)
  9. #define BALLVALVE_STATUS_FAULT (0xEA)
  10. #define REGADDR_WORKSTATUS (0X0001)
  11. #define REGADDR_CONTROL (0X0002)
  12. #define REGADDR_POSITION (0X0014)
  13. #define REGADDR_STATUS_POSITION (0X0052)
  14. class BallValve
  15. {
  16. public:
  17. BallValve(SerialUi* pSerial);
  18. bool SetPosition(unsigned short value); //设置阀门的开度值 A (0--1000) 表示:(A/10)%
  19. bool GetWorkStatus(unsigned char& status);
  20. bool GetPosition(unsigned short& value);
  21. //bool Break();
  22. bool GetSP(unsigned char& status, unsigned short& value);
  23. private:
  24. SerialUi* m_pSerial;
  25. bool check_crc(QByteArray data);
  26. };
  27. #endif // BALLVALVE_H