#pragma once

#include <array>
#include <string>

enum class eLotInfoCode
{
    // Lot info types for comm.
    COMM_LOT_NUMBER   = 1,
    COMM_LOT_SIZE     = 2,
    COMM_PACKAGE_TYPE = 3,
    COMM_OPERATOR_ID  = 4,
    COMM_MACHINE_NAME = 5,
    COMM_GROSS_UPH    = 6,
    COMM_NET_UPH      = 7,
    COMM_SHIFT        = 8,
    COMM_DEVICE_ID    = 9
};

enum class eClientCode
{
    // Info requested by handler
    APPLICATION_NAME        = 51,
    CURRENT_PACKAGE_TYPE    = 52,
    REQUEST_PACKAGE_TYPE    = 53,
    REQUEST_PACKAGE_ID      = 54,
    REQUEST_SYSTEM_SETTINGS = 55,
    REQUEST_LOT_OPEN_STATUS = 56,
    ENABLE_DISABLE_STATION  = 57,

    // RTR Info requested by handler
    REQUEST_RTR_SYSTEM_INFO  = 60,
    REQUEST_RTR_RECIPE_MODE  = 61,
    RECEIVE_RTR_HANDLER_INFO = 62,

    // Special commands from handler
    RESET_STATISTIC           = 88,
    WRITE_RECIPE              = 89,
    READ_RECIPE               = 90,
    REMOTE_MODE               = 91,
    PARAMETER_ACCESS_CONTROL  = 92,
    SHOW_MULTIPLE_DISPLAY_WND = 93,
    WAFER_ID                  = 94,
    SELECT_APPLICATION        = 95,
    NEW_LOT_PKG_NAME          = 96,
    REEL_NUMBER               = 97,
    PRINT_SUMMARY             = 98,
    NEW_LOT_PKG_ID            = 99,


};

enum class eVisionCode
{
    // Command from Vision to handler
    LOT_PARAM_READY   = 98,
    LOT_PARAM_CHANGED = 99
};

enum class eRequestInfo
{
    CURRENT_POSITION = 1
};

enum class eStatusCmd
{
    MODULE_STATUS = 1,
    TEACH_STATUS  = 2,
    OTF_STATUS    = 3
};

class CMeyeVisionProtocol
{
public:
    CMeyeVisionProtocol();

    int GetAppId(char chApp);

    bool IsTrailer(char chTrailer);
    bool IsSyncBlock(const std::string& strSyncBlock);

    char GetAppSOT(int nAppId);
    char GetAppSOS(int nAppId);
    char GetAppEOS(int nAppId);

    std::string Ack();
    std::string Nack();
    std::string Nack2();

    std::string RunMode();
    std::string StopMode();

    std::string Command(const std::string& strApp);

    std::string SOTAck(int nAppId);
    std::string SOSAck(int nAppId);
    std::string EOSAck(int nAppId);

    std::string PictureTaken(int nAppId, bool bLongProcess);
    std::string LotOpenStatus(const std::string& strLotNumber);

    std::string FrameMsg(const std::string& strMsg);

    std::string LotParamReady(const std::string& strFile);
    std::string ParamChange(int nParamChangeCount);

    std::string RequestInfo(int nVAppId, eRequestInfo eInfoType);
    std::string ReplySpecialInfo(eClientCode eInfoCode, const std::string& strParam);

    std::string OperationDone(int nVAppId, int nState);

    std::string RTRSysInfo(int nInfo, const std::string& strSysInfo);
    std::string RTRRecipeMode(int nMode);

    std::string ModuleGrrResult(int nVAppId, int nModuleID, const std::string& strResult);

    std::string LoadRejectImageProgress(int nVAppId, bool bInProgress);

    std::string RequestStatus(int nVAppId, eStatusCmd eCode, int nID1, int nID2, int nStatus);

    [[deprecated("Old Protocol. Use RequestStatus() instead")]] 
    std::string RequestStatusOld(int nVAppId, int nID1, int nID2, int nStatus);

    std::string RequestParam(int nVAppId, int nModuleID, int nSetID, int nParamID, const std::string& strValue);

    std::string RequestOcrParam(int nVAppId, int nModuleID, int nSetID, int nParamID, const std::string& strValue);

private:
    std::array<std::string, 3> m_arrSOIList;
};
