#pragma once
#include "cpowermeterdriver.h"
#include "CMSerialPort.h"
#include "export_power_meter_driver.h"
#include <QDateTime>
class POWER_METER_DRIVER_EXPORT CPowerMeterDriver_lp : public CPowerMeterDriver
{
public:
    enum command_length
    {
        COMM_LEN=64,
        RESPONSE_LEN=64
    };
	enum msg_id
	{
		ZERO_POWERMETER=MAX_POWERMETERDRIVER_MSG_ID,
		GET_TEMPERATURE,
        kPowerMeterCheck,
        kReportCheckResult,
		MAX_POWERMETERDRIVER_MSG_ID_LP
	};
    CPowerMeterDriver_lp(const QString& name,int32_t id);
    virtual ~CPowerMeterDriver_lp(void);


	virtual void do_msg(int iID,QVariantList& vlInput,V_MsgOutput* pvlOutput);

	// CBase interface
public:
    virtual QDomElement WriteConfig(QDomDocument &doc, QDomElement &root) override;
    virtual int ReadConfig(QDomElement &root) override;

    // CPowerMeterDriver interface
public:
    virtual int32_t freshresult(int32_t chid) override;

    virtual int32_t SetZero(int32_t chid);

	virtual int32_t GetTemperature(int32_t chid);
    // CDriverCard interface
public:
    virtual int32_t init_driver() override;
    virtual int32_t exit_driver() override;
    virtual void SendCommand(const char *pCommand, char *pResponse) override;
    void MakeSendCheckComm(const char *pSendData, char *pResponse);

    void CheckResponse(char *pResponse);

    /**
 * \brief 检查功率计必要时重置.
 *
 */
    virtual void check_and_reset_powermeter();

    /**
     * \brief 报告检查结果.
     *
     */
    virtual void report_check_reslt(bool bReport);
    
public:
    QDateTime m_lastUsePowermeterTime;
	QString m_sCheckPowerResult;
    QString m_sCurCheckInfo;
private:
    CMSerialPort* m_pSerialPort;
};

