using WCS.Core;
using PLCType = WCS.Core.PLCType;

namespace WCS.Service.PLCAccessors
{
    /// <summary>
    ///  PLC访问器创建者
    /// </summary>
    public class PLCAccessorsCreater : IPLCAccessorCreater
    {
        /// <summary>
        ///  创建PLC访问器
        /// </summary>
        /// <param name="data">PLC信息</param>
        /// <returns></returns>
        /// <exception cref="Exception"> </exception>
        public IPLCAccessor Create(PLCInfo data)
        {
            switch (data.Type)
            {
                case PLCType.Siemens:
                    return new SiemensS7PLC(data.IP, data.Port, data.Rack, data.Slot);

                default:
                    return new VitrualRedisPLC(data, "127.0.0.1,database=1,prefix=Sorting:");
            }
        }
    }
}
