// Cassette.h: interface for the CCassette class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CASSETTE_H__40D32EAF_CD08_423E_8533_3E3871B0E5FB__INCLUDED_)
#define AFX_CASSETTE_H__40D32EAF_CD08_423E_8533_3E3871B0E5FB__INCLUDED_

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

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

#define MAX_SLOT_PER_CASSETTE   25

struct stCassette
{
    int nSlotInfo[MAX_SLOT_PER_CASSETTE];
};

enum
{
    NO_WAFER,
    PRESENT,
    CROSS_SLOT,
    DOUBLE_WAFER,
    WAFER_PROCESSED,
    WAFER_PROCESSING,
    WAFER_REJECTED,
    MAX_SLOT_STATE,
    ALL_SLOTS_OK = NO_WAFER,
};

enum
{
    BOTTOM_UP,
    TOP_DOWN,
};

class MCCTRDLLCLASS CCassette
{
public:
    bool       IsAllSlotsFilled();
    int        GetNextEmptyWaferSlot(bool bDir = BOTTOM_UP);
    static int IsAnyCrossSlotorDoubleWafer(stCassette stCass, int nSlots);
    int        IsAnyCrossSlotOrDoubleWafer();
    bool       IsCassNeedProcessing();
    int        GetNextWaferSlot();
    bool       IsAllSlotsProcessed();
    stCassette GetCassetteInfo();
    int        GetSlotStatus(int nSlotNo);
    bool       Init(stCassette stCass, int nNoOfSlot = MAX_SLOT_PER_CASSETTE);
    CCassette();
    virtual ~CCassette();

    bool   Init(int iNumOfSlot);
    bool   SetNumOfSlot(int iNumOfSlot);
    bool   SetSlotPitch(double dSlotPitch);
    bool   SetSlotStatus(int iSlotNum, int iSlotStatus);
    bool   SetCurSlotNum(int iSlotNum);
    bool   SetCurSlotStatus(int iSlotStatus);
    int    GetNumOfSlot();
    double GetSlotPitch();
    int    GetCurrentSlot();
    int    GetNextSlotNum();
    int    GetNextSlot();
    bool   IndexToNextSlot();
    void   ResetSlotNum();

    int *m_iSlot;
    int  m_iCurSlot;

    double m_dSlotPitch;

    enum
    {
        NO_WAFER_PRESENT,
        WAFER_PRESENT,
        WAFER_REJECT,          // due to cannot pick wafer ???
        INVALID          = -1, // result not valid
        CURRENT_CASSETTE = 0,
        NEW_CASSETTE     = 1,
    };

private:
    bool CheckValidStatus(int nStatus);
    bool CheckSlotNoValid(int nSlotNo);
    stCassette m_stCassette;
    int        m_iNumOfSlot;
};

#endif // !defined(AFX_CASSETTE_H__40D32EAF_CD08_423E_8533_3E3871B0E5FB__INCLUDED_)
