#ifndef CSYSTEMEXTERNAL_H
#define CSYSTEMEXTERNAL_H

#include "callsystem.h"
#include "export_system_external.h"
#include "cimagecontainer.h"
#include "logic_eap.h"
class CSystemExternal :
    public CAllsystem
{
public:
    std::map<int, QString> m_mapNameList;
    bool_t m_bNeedFreshUI;
    bool m_bDisableCutlineLaser;

    int32_t m_iCurChID; //当前通道 相机
    int32_t m_iCurSideID;//当前面 A面 B面
    int32_t m_iCurLayer;    //当前切割的第几层
    bool m_bEnbaleLaserOpen;
	bool m_bDisableHairlineOffsetAutoCompensation; //禁用偏移自动补偿
public:
    virtual bool CellExist(int IOOutput, int IOInput) = 0;
    virtual void SendLogMessage(const QString& info, int type) = 0;
    virtual void AddProductInfo(int processId, const QString& info, bool toLog = true) = 0;
    virtual QString MakeRecoverPath(const QString& file) = 0;
    virtual void SetCamParam(int iCamId, int exposureUs, int gain) = 0;
    virtual void SetCamLight(int32_t iCamID, int32_t light, bool bdirect,
                             bool bsetDefault) = 0;
    virtual void changeChannel_msg(int32_t idestCh, bool bmove, V_MsgQueue& msgqueue) = 0;
    virtual void changeChannel(int32_t idestCh, bool bmove) = 0;

    virtual void changeSide_msg(int32_t iside, bool bxymove, V_MsgQueue& msgqueue) = 0;
    virtual void abort_state(int iSMID, int iStateID, QVariantList& extraData, bool bOnnlyCurMachine = false) = 0;
    virtual void absmove_xy(double dx, double dy) = 0;
    virtual void absmove_msg(double dpos, int ichID, V_MsgQueue& msgqueue) = 0;

    virtual void absmove_xy_msg(double dx, double dy, V_MsgQueue& msgqueue) = 0;

    virtual void relmove_xy_msg(double dx, double dy, V_MsgQueue& msgqueue) = 0;

    virtual void relmove_msg(double ddis, int ichID, V_MsgQueue& msgqueue) = 0;
    virtual void start_test(int iSMID, const V_MsgQueue& msgqueue,
                            bool bReport = true) = 0;

    virtual bool start_manual(int iSMID, const V_MsgQueue& msgqueue,
                              bool bReport = true) = 0;
    virtual void  SetCutStreet(CImageContainer* pContainer, int iSideID, int iCamID, bool bSetBoth = false) = 0;

    virtual int CutPosX(double dStartPosX, double dEndPosX, double dPosY, double dPosZ,
                        int iDelayTime, int iLaserPathID, double dOffsetY,
                        double dspd, int iSide, int iSubIndex, bool bEnableLaser, double dAccSpeed = 0,
                        bool bSetIOStatus = true, bool bSetCutSpeed = true, bool bCloseLaserIO = true) = 0;

    virtual int CutPos(double dStartPos, double dEndPos, double dLocationPos, double dPosZ,
               double dOffsetPos, double dOverCut,
               int iLaserPathID, bool bXDirect,
               double dCutSpeed, double dAccSpeed, bool bEnableLaser) = 0;
    virtual bool IsSMAutoRun(int smID) = 0;

    virtual void AssertCheckWtVaccum() = 0;

    virtual bool SendEvent(_EventID eventID) = 0;

    virtual bool SetVariable(_SVID svid, const std::string newValue) = 0;

	std::function<void(int& iLight1, int &iLight2, int iCamIndex)> m_pfnGetLightData = nullptr;
	std::function<void(int& iExposure1, int& iExposure2, int iCamIndex)>m_pfnGetCamInfo = nullptr;
    std::function<void(int iLight1, int iLight2, int iCamIndex)> m_pfnSetLightData = nullptr;
    std::function<void(int iExposure1, int iExposure2, int iCamIndex)>m_pfnSetCamInfo = nullptr;
    std::function<void(bool bVisible)> m_pfnShowPowerMsg = nullptr;
};

class SYSTEM_EXTERNAL_EXPORT SystemExternalHelper
{
public:
    CSystemExternal& GetSysInstance();
    void SetInstance(CAllsystem* pInstance);
    static SystemExternalHelper& Instance();

private:
    CSystemExternal* m_pInstance = nullptr;
};


#define _SysExt_Instance SystemExternalHelper::Instance().GetSysInstance()
#endif // CSYSTEMEXTERNAL_H