using WCS.Core;
using WCS.Entity.Protocol.BCR;
using WCS.Entity.Protocol.SRM;
using WCS.Entity.Protocol.Station;
using WCS.WorkEngineering.Extensions;
using WCS.WorkEngineering.Worlds;

namespace WCS.WorkEngineering.Systems
{
    /// <summary>
    ///  设备信息写入接口
    /// </summary>
    [BelongTo(typeof(MainWorld))]
    public class GetDeviceSystem : ServiceSystem<string, object>
    {
        /// <summary>
        /// 所有的站台
        /// </summary>
        private List<Station> Convs;

        private List<SRM> Srms;

        private List<BCR> Bcrs;

        private List<Device<IStation523>> Device91;

        /// <summary>
        ///  构造函数
        /// </summary>
        public GetDeviceSystem()
        {
            Convs = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Station(v, this.World)).ToList();
            Srms = Device.All.Where(v => v.HasProtocol<ISRM520>()).Select(v => new SRM(v, this.World)).ToList();
            Bcrs = Device.All.Where(v => v.HasProtocol<IBCR81>()).Select(v => new BCR(v, this.World)).ToList();
            Device91 = Device.All.Where(v => v.HasProtocol<IStation523>()).Select(v => new Device<IStation523>(v, this.World)).ToList();
        }

        protected override object Do(string info)
        {
            switch (info)
            {
                case "堆垛机":
                    return Srms;

                case "输送机":
                    return Convs;

                case "读码器":
                    return Bcrs;

                case "外检":
                    return Device91;

                default: return "未知设备类型";
            }
        }
    }
}
