#ifndef CPROCESS_COAT_H
#define CPROCESS_COAT_H

#include "cprocess_coatclean.h"
#include "cprecisetime.h"
#define PATH_CLEANTABLE_COAT  "cleantable-coat.dat"
#define PATH_CLEANTABLE_COATFLUID "cleantablefluid-coat.dat"
//涂敷操作
class CProcess_Coat : public CProcess_CoatClean {
public:
    enum msg_id {
        PROCESS_COATCLEAN_MSG_ID = MAX_PROCESS_COATCLEAN_MSG_ID,
        BUMP_TEST,  //吸胶测试
        SPARY_TEST, //唝胶测试
        REPLACE_COATFLUID, //更换液体
        MAX_PROCESS_COAT_MSG_ID,
    };

    CProcess_Coat(const QString& name, int32_t id);
    CPreciseTime m_COAT_M_TIME;
    QString GetActionName(int iActionID);
    void do_msg(int iID, QVariantList &vlInput, V_MsgOutput *pvlOutput) override;
    void all_action_before(int iActionType, int iStep);
    //dBumpNum 抽胶量 dPreSpyNum 预喷胶量
    void single_action_before(int iActionType, int32_t iType, double dTime, int iRPM, int iStep,
                              double dSpayNum, double dSpaySpd, double dCenterSpeed, double dEageSpeed, double dCenterWaitTime,
                              double dCoatPreSpyNum, int iCoatPreSpyWaitTime,
                              double dBumpNum, double dPreSpyNum);
    bool single_action_wait(int iActionType, int32_t iType, double dTime, int iRPM, int iStep);
    void single_action_after(int iActionType, int32_t iType, double dTime, int iRPM, int iStep);
    void all_action_after(int iActionType, int iStep);

    void Bump_Test(int iStep);
    void Spary_Test(int iStep);
    void ReplaceCoatFluid(int iStep);

    virtual void ReadWriteCleanTable(bool bWrite);
    void ReadWriteCleanCoatLiquid(bool bWrite);


    void Init_Pos() override;

public:
    void nozzeloperator_coat(int32_t iType);
    void CoatArmUp(bool bUp);
    void CleanArmUp(bool bUp);
    virtual void SpindleUp(bool bUp, bool bAfterChecked = false) override;
    void SpindleUpCheck(bool bUp);
    //bool  isSpindleUp();
    void MoveCleanWaitPos();
    void MoveCleanPreparePos();
    void MoveCleanEagePos();
    void MoveCleanCenterPos();
    void MoveCleanRingPos();
    void MoveCleanCyclic();
    void MoveCoatWaitPos();
    void MoveCoatPreparePos();
    void MoveCoatEagePos();
    void MoveCoatCenterPos(bool bOffset = false);
    void MoveCoatMultiSpd(bool bWait);
    void MoveCoatMultiSpd(bool bWait, double dCenterSpeed, double dEageSpeed);
    void MoveCleanProtectionBlockPos();//移动到保护块位置

    void Bump();
    void Bump(double dSpayNum, double& dActualBump, bool bZeroFirst = true);
    void BumpNoWait(double dSpayNum, double& dRetNum, double& dActualBump);
    void WaitBumpFinished(double dSpayNum, double dTargetNum);
    //void Bump(double )
    void Spray(bool bWaitFinished);
    void Spray(double dSpayVolume, bool bWaitFinished, double dSpaySpd);
    void Spray_prepare();
    void Spray_prepare(double dSpayVolume, double dSpaySpd, int iWaitMs);
    void SprayPrepareNoWait(double dPreSpayVolume);
    void WaitSparyPrepareFinished(double dPreSpayVolume);

    void SetdefaultSpeed(bool bSetSpindle = true);
    void SpindleSpin(double drpm);
    void SpindleStop();
    void MoveSpindleInitPos(bool bhome = true, bool bWait = true);

    void Wait_Spray_Finish();
    void CloseProtect(BOOL bClose, bool bWait = true);
    void CoatCenterWait();
    void CoatCenterWait(double dCenterWait);
    void Wait_CoatArm_finish();
    void Wait_CleanArm_finish();
    void Wait_Spindle_finish();

    void CheckVaccum();
    void CheckWater();

    void SetWaferHasWafer(bool bHas);
public:
    double m_dTotalBump; //ml
    double m_dVolumeActual;//ml
private:
    double m_BumpTargetVolume;
    double m_dReplaceFluidVolume;
    //sensor
    double m_dVolumeBefore;
    double m_dVolumeAfter;

    //bump
    double m_dSingleBump;


};

#endif // CPROCESS_COAT_H
