Пример #1
0
        /// <summary>
        /// 獲取PLC實現類的完整路徑
        /// </summary>
        /// <param name="plcBrand">PLC牌子</param>
        /// <returns></returns>
        public static string GetPLCAccessorFullName(EnmPLCBrand plcBrand)
        {
            string strAccessorFullName = string.Empty;

            switch (plcBrand)
            {
                case EnmPLCBrand.ZWorld:
                    strAccessorFullName = "PLCEquipment.DeviceImplement.ZWorld.PLC_ZWorld";
                    break;
                default:
                    break;
            }

            return strAccessorFullName;
        }
Пример #2
0
        public static AbstractPLCEquipment CreatePLC(EnmPLCBrand brand)
        {
            string accessorFullName = EquipmentGeneral.GetPLCAccessorFullName(brand);

            if (string.IsNullOrEmpty(accessorFullName))
            {
                return null;
            }

            try
            {
                Type accessorType = Type.GetType(accessorFullName, false);
                return (AbstractPLCEquipment)Activator.CreateInstance(accessorType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }