#ifndef BALLVALVE_H
#define BALLVALVE_H

#include "serialui.h"
#include <QString>


#define BALLVALVE_STATUS_OPENING (0xAA)
#define BALLVALVE_STATUS_CLOSING (0xBB)
#define BALLVALVE_STATUS_OPENEND (0xAC)
#define BALLVALVE_STATUS_CLOSEEND (0xBC)
#define BALLVALVE_STATUS_BREAK (0x00)
#define BALLVALVE_STATUS_FAULT (0xEA)

#define REGADDR_WORKSTATUS      (0X0001)
#define REGADDR_CONTROL         (0X0002)
#define REGADDR_POSITION        (0X0014)
#define REGADDR_STATUS_POSITION (0X0052)


class BallValve
{
public:
    BallValve(SerialUi* pSerial);
    bool SetPosition(unsigned short value);  //设置阀门的开度值 A (0--1000) 表示：(A/10)%
    bool GetWorkStatus(unsigned char& status);
    bool GetPosition(unsigned short& value);
    //bool Break();
    bool GetSP(unsigned char& status, unsigned short& value);

    void Dump_Statistics(QString file_path);

private:
    SerialUi* m_pSerial;
    bool check_crc(QByteArray data);

};

#endif // BALLVALVE_H
