#pragma once
#include "CMachineCalibration.h"
#include "CDataBaseOperate.h"
#include "dt.h"
#include <string>
#include <windows.h>
#include <mutex>
#include <vector>

using namespace std;

#ifdef MACHINE_SETUP_DLL
#define DLL_MACHINE_SETUP_API __declspec(dllexport)
#else
#define DLL_MACHINE_SETUP_API
#endif

namespace ns_db
{
#define MACHINE_SETUP_DATABASE_NAME			        ROOT_PATH##"\\db\\MachineSetup.db"
#define PRODUCT_LIST_TABLE_NAME                     "ProductList"
#define ALL_SUPPORT_STEP_LIST_TABLE_NAME            "AllSupportStepList"
#define ALL_SUPPORT_STEP_FUNCTION_TABLE_NAME        "AllSupportStepFunction"

    typedef struct _STEP_INFO : TABLE_INFO_BASE
    {
        UINT iId;
        string strName;
        string strDescribe;
    } STEP_INFO;

    typedef struct _PRODUCT_LIST_STRUCT : TABLE_INFO_BASE
    {
        INT         ID;
        string      ProductName;
        bool        IsUse;
        string      Version;
        string      User;
        string      Describe;
        string      Date;
        string      FilePath;
    } PRODUCT_LIST_STRUCT;


    class DLL_MACHINE_SETUP_API CMachineSetup : public CDataBaseOperate
    {
    public:
        CMachineSetup();
    private:
        LONG SaveDB() override;
        LONG LoadDB() override;

#pragma region ProductList表
    private:
        vector<PRODUCT_LIST_STRUCT>  m_vetProductList;
        LONG LoadProductList();
        LONG SaveProductList();
    public:
        LONG GetCurrentProductPath(string& strPath);
        vector<PRODUCT_LIST_STRUCT> GetProductList() { return m_vetProductList; };
        //设置ProductList。bAppend=ture时,将vecProduct里有,而m_vetProductList没有的项追加进m_vetProductList
        LONG SetProductList(vector<PRODUCT_LIST_STRUCT> vecProduct,bool bAppend = false);
#pragma endregion

#pragma region AllSupportStepList表
    private:
        //保存所有支持的Step对应关系
        vector<STEP_INFO>  m_vecAllSupportStep;
        //获取所有支持的Step列表
        LONG LoadAllSupportStepList();
    public:
        vector<STEP_INFO> GetAllSupportStepList() { return m_vecAllSupportStep; };
        LONG SetAllSupportStepList(vector<STEP_INFO> vecSupporStep, bool bAppend = false);
        LONG GetStepInfo(UINT iStepId, STEP_INFO& info);
#pragma endregion



    };


}