#ifndef CPROCESS_LASERPOWERCALI_H
#define CPROCESS_LASERPOWERCALI_H

#include "cmprocess.h"
/*!
 * \brief The CProcess_LaserPowerCali class
 * 功率测试
 * TODO:需要重构，传入不同的功率计id
 * 只需要一个类处理即可
 */
#include "export_laser_power_cali.h"
#include "macro_def.h"
class LASER_POWER_CALI_EXPORT CProcess_LaserPowerCali : public CMProcess {
public:
    enum msg_id {
        PROCESS_LaserPowerCali_MSG_ID = MAX_PROCESS_MSG_ID,
        MOVECALIPOS,        //移动到功率测量位置
        CALIPOWER_BEFORE,
        CALIPOWER,          //单步的测量
        CALIPOWER_AFTER,
        CHECKPOWER,
        CHECKFULLPOWER,
        CALIPCHANGEANGLE_BEFORE,
        CALIPCHANGEANGLE,
        CALIPCHANGEANGLE_AFTER,
        CALIMAXPOWERANGLE_BEFORE,
        CALIMAXPOWERANGLE,  //找最大功率位置
        CALIMAXPOWERANGLE_AFTER,
        OPEN_LENS_BLOW,
        CALIPOWER_BEAM_BEFORE,
        CALIPOWER_BEAM,
        CALIPOWER_BEAM_AFTER,
        MAX_PROCESS_LaserPowerCali_MSG_ID,
    };
    CProcess_LaserPowerCali(const QString& name, int32_t id
                            , int32_t iLaserPathID);
    int32_t m_iLaserPathID;
public:
    virtual void do_msg(int iID, QVariantList& vlInput, V_MsgOutput* pvlOutput);
public:
    int MoveCaliPos();
public:
    int WaitMeasStable();
    void WaitPowermeterReady(double dPower);
public:
    int m_iCurFreq;
    int m_iCurEpulse;
    double m_dCurWidth;
    int    m_iCurMsgID;
    double m_dLastPower;
public:
    int m_curMaxPower;
    double m_lastCaliPower;
    bool m_bCaliMaxPowerUp;
    bool m_findMaxPower;
    int m_iLastCheckPowerWafer;

public:
    /**
     * \brief 测量功率前操作.
     *
     * \param iFreq
     * \param dWidth
     */
    virtual void before_cali_power(int iFreq, int iEpulse, double dBeamWidth);
    /**
     * \brief 测量功率.
     *
     * \param iFreq
     * \param dWidth
     * \param iStep
     */
	virtual void cali_power(int iFreq, int iEpulse, double dBeamWidth, int iStep);
    /**
     * \brief 测量功率后操作.
     *
     * \param iFreq
     * \param dWidth
     */
	virtual void after_cali_power(int iFreq, int iEpulse, double dBeamWidth);

    /**
     * \brief 检查功率偏差.
     *
     * \param iFreq
     * \param dWidth
     * \param dRealPower
     * \param report
     */
	virtual void check_power_diff(int iFreq, int iEpulse, double dWidth, double dRealPower, bool report);

	virtual void OpenLensOutBlow(bool bOpen);

#if 0
    void before_cali_PChange(int iFreq, double dWidth);
    void cali_PChange(int iFreq, double dWidth, int iStep);
    void after_cali_PChange(int iFreq, double dWidth);
#endif
    /**
     * \brief 找最大功率-前置操作.
     *
     * \param iFreq
     * \param dWidth
     */
	virtual void before_cali_MaxPower(int iFreq, double dWidth);
	virtual void cali_MaxPower(int iFreq, double dWidth, int iStep);
	virtual void after_cali_MaxPower(int iFreq, double dWidth);


    void check_full_power(int iFreq, double dWidth);

    
#ifdef __USE_LASER_BAEM__POWER__
	/**
	* \brief 测量功率前操作.
	*
	* \param iFreq
	* \param dWidth
	*/
	virtual void before_cali_power_rate(int iFreq, int iEpulse, double dWidth, double dAngle);
	/**
	* \brief 测量功率.
	*
	* \param iFreq
	* \param dWidth
	* \param iStep
	*/
	virtual void calibeam_power_rate(int iFreq, int iEpulse, double dWidth, int iStep, double dAngle);
	/**
	* \brief 测量功率后操作.
	*
	* \param iFreq
	* \param dWidth
	*/
	virtual void after_cali_power_rate(int iFreq, int iEpulse, double dWidth, double dAngle);
#endif
};

#endif // CPROCESS_LASERPOWERCALI_H
