#pragma once
#include <string>
#include "TypeDef.h"
//#include "McGlobal.h"

#include "ILamp.h"
/*
	������࣬��������
*/

using namespace JVision;
#pragma comment(lib,"JVisionLib.lib")

enum MATERIAL_TYPE
{
    MATERIAL_NULL, //��
    MATERIAL_WAFER,//��Բ
    MATERIAL_WAFFLE,//�����
    MATERIAL_BOX,//�Ϻ�
    MATERIAL_BOND  //�ؾ�����
};

typedef struct
{
    int iCameraId;          // ���Id
    string name;            // �������
    MATERIAL_TYPE eType;    //��������
}CameraInfo;

typedef long (*CallVideoBack) (int iCameraId,ImageInfo image);

#ifdef CAMERA_BASE_EXPORTS
#define CAMERA_BASE_DLL_API __declspec(dllexport)
#else
#define CAMERA_BASE_DLL_API //__declspec(dllimport)
#endif

class __declspec(dllexport) CCameraBase
{
public:
	CCameraBase(int id, string sDescribe,bool bEnable);
	~CCameraBase(){}

    virtual long Open() = 0;
    virtual void Close() = 0;
    virtual long VideoStart() = 0;
    virtual long VideoStop() = 0;
    virtual long GrabImage(ImageInfo& image) = 0;
    virtual long SetExposure(double exposure) = 0;
    virtual double GetExposure() = 0;
    virtual long SetGain(double gain) = 0;
    virtual double GetGain() = 0;

    int GetCameraID() { return m_iCameraId; };
    string GetCameraDescribe() { return m_sDescribe; };
    bool IsEnable() { return m_bEnable; };
    UINT GetImageWidthCenter();
    UINT GetImageHeightCenter();
    LONG SaveImage2File(ImageInfo image, const char* fileName);//����ͼ���ļ�
    //���ù�Դ���Ʋ���
    LONG SetLightChannelIndex(int type,
        string red_addr, int red_channel, string green_addr, int green_channel, string blue_addr, int blue_channel,
        string point_addr, int point_channel);
    //���ú��
    LONG SetRedLight(int LightValue);
    //�����̹�
    LONG SetGreenLight(int LightValue);
    //��������
    LONG SetBlueLight(int LightValue);
    //���õ��Դ
    LONG SetPointLight(int LightValue);

    //���õƹ�
    LONG SetLight(int redLightValue, int greenLightValue, int blueLightValue);

    //��ȡ�ƹ�
    LONG GetLight(int &redLightValue, int &greenLightValue, int &blueLightValue,int &pointLightValue);

    void SetVideoCallBackFunc(CallVideoBack func) { m_funVideoCallBack = func; };

protected:
    int m_iCameraId;
    string m_sName;
    string m_sDescribe;

    UINT	m_iWidthMax = 2248;                //ˮƽ��������������
    UINT	m_iHeightMax = 2048;			    //��ֱ��������Ǵ�����

    bool    m_bEnable = false;                      //�����ֹ/����

    double m_dExposure;
    double m_dGain;

    ILamp* m_pRedLamp = nullptr;              //�ƹ������(���)
    ILamp* m_pGreenLamp = nullptr;            //�ƹ������(�̹�)
    ILamp* m_pBlueLamp = nullptr;             //�ƹ������(����)
    ILamp* m_pPointLamp = nullptr;            //�ƹ������(���)
    INT m_iRedLightChannel;		    //���ͨ���ţ�-1 ��ʾ���ø��ֹ⣩
    INT m_iGreenLightChannel;		//�̹�ͨ���ţ�-1 ��ʾ���ø��ֹ⣩
    INT m_iBlueLightChannel;		//����ͨ���ţ�-1 ��ʾ���ø��ֹ⣩
    INT m_iPointLightChannel;		//���Դͨ���ţ�-1 ��ʾ���ø��ֹ⣩

    CallVideoBack m_funVideoCallBack = nullptr;
};