#ifndef DEVICECONNECT_H #define DEVICECONNECT_H #include "cmb.h" #define UPS_SUCCESS 0 // command succeeded #define UPS_NOT_OPEN -1 // command succeeded #define UPS_HARDWARE_ERROR -2 // command failed because of hardware error #define UPS_TIMEOUT -3 // wait for user interaction timed out #define UPS_PARA_ERR -4 // class DeviceConnect { public: DeviceConnect(); ~DeviceConnect(); int Open(char* sPort, int iBaud); int Close(); // 是否连接 BOOL IsOpen(); // 获取UPS状态 int GetStatus(bool& bUps, bool& bLow); // 关闭UPS int ShutDown(int iMinite); // 重启UPS int ReStart(int iMinite); //获取版本信息 int GetVersion(char* strVersion); protected: SSerial* m_pSerial; BYTE CalBcc(BYTE* pData, BYTE iCount); int Execute(BYTE* pData, int iLength, BYTE* pOut, int* pOutLen, int iTimeOut); int Execute(BYTE* pData, int iLength, int iTimeOut); }; #endif // DEVICECONNECT_H