using Aitex.Core.RT.Device;
using Aitex.Sorter.Common;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.Fsm;
using MECF.Framework.Common.Schedulers;
using MECF.Framework.Common.SubstrateTrackings;
using MECF.Framework.RT.EquipmentLibrary.LogicUnits;

namespace SicModules.EFEMs
{
    public abstract class EFEMModuleBase : ModuleFsmDevice, ITransferTarget, IModuleDevice
    {
        private int _slot = 1;

        public EFEMModuleBase(int slot)
        {
            _slot = slot;
        }

        public override bool Initialize()
        {
            WaferManager.Instance.SubscribeLocation(Module, _slot);

            return base.Initialize();
        }

        public abstract bool IsIdle { get; }

        //IModuleDevice
        public abstract bool IsReady { get; }
        public abstract bool IsError { get; }
        public abstract bool IsInit { get; }
        public abstract bool Home(out string reason);

        //ITransferTarget
        public abstract bool PrepareTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
        public abstract bool TransferHandoff(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
        public abstract bool PostTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
        public abstract bool CheckReadyForTransfer(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType, out string reason);
        public abstract void NoteTransferStart(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType);
        public abstract void NoteTransferStop(ModuleName robot, Hand blade, int targetSlot, EnumTransferType transferType);
        public abstract bool CheckReadyForMap(ModuleName robot, Hand blade, out string reason);
        public abstract bool CheckAcked(int entityTaskToken);

        public abstract bool MapWafer(ModuleName target );
        public abstract bool PickWafer(ModuleName target, Hand blade, int targetSlot);
        public abstract bool PlaceWafer(ModuleName target, Hand blade, int targetSlot);
        public abstract bool GotoWafer(ModuleName target, Hand blade, int targetSlot);
        public abstract bool MapTray(ModuleName target );
        public abstract bool PickTray(ModuleName target, Hand blade, int targetSlot);
        public abstract bool PlaceTray(ModuleName target, Hand blade, int targetSlot);
        public abstract bool GotoTray(ModuleName target, Hand blade, int targetSlot);
    }
}

