deviceconnect.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef DEVICECONNECT_H
  2. #define DEVICECONNECT_H
  3. #include "cmb.h"
  4. #define UPS_SUCCESS 0 // command succeeded
  5. #define UPS_NOT_OPEN -1 // command succeeded
  6. #define UPS_HARDWARE_ERROR -2 // command failed because of hardware error
  7. #define UPS_TIMEOUT -3 // wait for user interaction timed out
  8. #define UPS_PARA_ERR -4 //
  9. class DeviceConnect
  10. {
  11. public:
  12. DeviceConnect();
  13. ~DeviceConnect();
  14. int Open(char* sPort, int iBaud);
  15. int Close();
  16. // 是否连接
  17. BOOL IsOpen();
  18. // 获取UPS状态
  19. int GetStatus(bool& bUps, bool& bLow);
  20. // 关闭UPS
  21. int ShutDown(int iMinite);
  22. // 重启UPS
  23. int ReStart(int iMinite);
  24. //获取版本信息
  25. int GetVersion(char* strVersion);
  26. protected:
  27. SSerial* m_pSerial;
  28. BYTE CalBcc(BYTE* pData, BYTE iCount);
  29. int Execute(BYTE* pData, int iLength, BYTE* pOut, int* pOutLen, int iTimeOut = 200);
  30. int Execute(BYTE* pData, int iLength, int iTimeOut = 200);
  31. };
  32. #endif // DEVICECONNECT_H