using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.SubstrateTrackings;
using OpenSEMI.ClientBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ACC = Aitex.Core.Common;

namespace CyberX8_MainPages.Unity
{
    public class WaferStatusImp
    {
        public WaferStatusImp(IQueryDataService dataService)
        {
            DataService = dataService;
        }

        public List<WaferInfo> GetWaferStatus(string moduleID)
        {
            List<WaferInfo> result = new List<WaferInfo>();
            string param = moduleID + ".ModuleWaferList";
            ACC.WaferInfo[] wafers = QueryDataClient.Instance.Service.GetData(param) as ACC.WaferInfo[];
            if (wafers != null)
            {
                for (int i = 0; i < wafers.Length; i++)
                {
                    result.Add(WaferInfoConverter(wafers[i], moduleID, i));
                }
            }
            return result;
        }

        private WaferInfo WaferInfoConverter(ACC.WaferInfo awafer, string modid, int slotid)
        {
            WaferInfo wafer = new WaferInfo();
            wafer.ModuleID = modid;
            wafer.SlotID = slotid;
            wafer.SlotIndex = slotid + 1;
            wafer.WaferID = awafer.WaferID;
            wafer.SourceName = awafer.WaferOrigin;
            wafer.WaferStatus = WaferManager.Instance.WaferStatusConverter(awafer);
            if (!string.IsNullOrEmpty(awafer.SequenceName))
            {
                wafer.SequenceName = awafer.SequenceName;
            }
            return wafer;
        }

        //0: trans?
        //1:goden
        //2:blue
        //3:cyan
        //4:green
        //5:error
        

        private IQueryDataService DataService;
    }
}