// Wafer.h: interface for the CWafer class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_WAFER_H__9EF8D45E_528F_4C48_A7B0_B6B4E59969DA__INCLUDED_)
#define AFX_WAFER_H__9EF8D45E_528F_4C48_A7B0_B6B4E59969DA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#ifdef  BUILD_MCCTRDLL
#define     MCCTRDLLCLASS   __declspec(dllexport)
#else
#define     MCCTRDLLCLASS   __declspec(dllimport)
#endif

#include "Die.h"

const int MAP_DEGREE = -1;

class MCCTRDLLCLASS CWafer
{
public:
//  Default constructor
    CWafer();

//  Constructor to init wafer parameters
    CWafer(double dWaferDiameter, double dWaferEdgeClearance, int iNumOfDiePerWafer,
           int iRow, int iCol);

//  Default Destructor
    virtual ~CWafer();

//  Set number of die per wafer. Returns true if sucessful
    bool SetNumOfDiePerWafer(int iDiePerWafer);

//  allocate die array size. Returns true if sucessful
    bool SetDieArray();

//  set wafer diameter. Returns true if sucessful
    bool SetWaferDiameter(double dWaferDiameter);

//  set wafer edge clearance. Returns true if sucessful
    bool SetWaferEdgeClearance(double dWaferEdgeClearance);

//  set Die bin code. Returns true if sucessful
    bool SetDieBinCode(int iRow, int iCol, char cDieBinCode);

//  set num of row
    bool SetNumRow(int iRow);

//  set num of col
    bool SetNumCol(int iCol);

//  set die grap x in mm. Returns true if successful
    bool SetDieGrapX(double dGrapX);

//  set die grap y in mm. Returns true if successful
    bool SetDieGrapY(double dGrapY);

//  Set Die Size Y in mm. Return true if sucessful
    bool SetDieSizeY(double dDieSizeY);

//  Set Die Size X in mm. Return true if sucessful
    bool SetDieSizeX(double dDieSizeX);

//  get wafer diameter
    double GetWaferDiameter();

//  get wafer edge clearance
    double GetWaferEdgeClearance();

//  get wafer diameter - edge clearance
    double GetEffectiveWaferDiameter();

//  get die per wafer
    int GetDiePerWafer();

//  get die bin code
    char GetDieBinCode(int iRow, int iCol);

//  get die grap x in mm
    double GetDieGrapX();

//  get die grap y in mm
    double GetDieGrapY();

//  Get Die Size Y in mm
    double GetDieSizeY();

//  Get Die Size X in mm
    double GetDieSizeX();

//  get num of wafer col
    int GetNumCol();

//  get num of wafer row
    int GetNumRow();

//  get wafer x working area
    double GetXWorkingWaferDiameter();

//  get wafer y working area
    double GetYWorkingWaferDiameter();

//  initialised wafer diameter, Edge clearance, number of die per wafer and die bin code array
//  Return true if sucessful
    bool InitWaferPara(double dWaferDiameter, double dWaferEdgeClearance,
                       int iNumOfDiePerWafer, int iRow, int iCol);

//  rotate wafer map by 90 degree CW
    void RotateWafer90();

//  rotate wafer map by 180 degree CW
    void RotateWafer180();

//  rotate wafer map by 270 degree CW
    void RotateWafer270();

/// set the rotation angle of the wafer in CW
    bool SetDegreeRotated(int iDegree);

/// Get the rotation angle of the wafer in cw
    double GetDegreeRotated();

protected:
    char *m_cWafer; // store bin code info

    CCriticalSection m_CritSection;

private:
    int m_iDiePerWafer;           // number of die per wafer
    int m_iCol;                   // number of col
    int m_iRow;                   // number of row
    int m_iDegreeRotated;         // rotated degree in angle

    double m_dWaferDiameter;      // wafer diameter
    double m_dWaferEdgeClearance; // wafer edge clearance

    CDie m_Die;                   // store die info
};

#endif // !defined(AFX_WAFER_H__9EF8D45E_528F_4C48_A7B0_B6B4E59969DA__INCLUDED_)
