Esempio n. 1
0
        /// <summary>
        /// 设置器件信息
        /// </summary>
        /// <param name="list">器件列表</param>
        /// <param name="type">控制器类型</param>
        /// <returns>是否成功</returns>
        public bool SetDeviceSetup(List <DeviceInfoBase> list, int deviceCount, ControllerType type)
        {
            bool isSuccess = false;

            try
            {
                if (!IsConnected)
                {
                    return(false);
                }
                List <NTP> ntpList = new List <NTP>();
                foreach (var item in list)
                {
                    NTP ntp = NTPBuildRequest.GetSetDeviceInfoRequest(item, deviceCount, type);
                    if (ntp != null)
                    {
                        ntpList.Add(ntp);
                    }
                }
                isSuccess = SerialClient.ExecuteSetTask(ntpList, type);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
            return(isSuccess);
        }
Esempio n. 2
0
        /// <summary>
        /// 设置手控盘信息
        /// </summary>
        /// <param name="list">手控盘列表</param>
        /// <param name="type">控制器类型</param>
        /// <returns>是否成功</returns>
        public bool SetManualBoardSetup(List <ManualControlBoard> list, ControllerType type)
        {
            if (!IsConnected)
            {
                return(false);
            }
            List <NTP> ntpList = new List <NTP>();

            foreach (var item in list)
            {
                NTP ntp = NTPBuildRequest.GetSetManualBoardRequest(item, type);
                if (ntp != null)
                {
                    ntpList.Add(ntp);
                }
            }
            return(SerialClient.ExecuteSetTask(ntpList, type));
        }
Esempio n. 3
0
        /// <summary>
        /// 设置控制器信息
        /// </summary>
        /// <param name="model">控制器信息</param>
        /// <param name="type">控制器类型</param>
        /// <returns>是否成功</returns>
        public bool SetMachineSetup(ControllerModel model, ControllerType type)
        {
            if (!IsConnected)
            {
                return(false);
            }
            List <NTP> ntpList = new List <NTP>();
            //器件
            int deviceCount = 0;

            foreach (var loop in model.Loops)
            {
                deviceCount = loop.DeviceAmount;
                List <DeviceInfo8053> list = loop.GetDevices <DeviceInfo8053>();
                foreach (var item in list)
                {
                    NTP ntp = NTPBuildRequest.GetSetDeviceInfoRequest(item, deviceCount, type);
                    if (ntp != null)
                    {
                        ntpList.Add(ntp);
                    }
                }
            }

            //标准组态
            foreach (var standard in model.StandardConfig)
            {
                NTP ntp = NTPBuildRequest.GetSetStandardConfigRequest(standard, type);
                if (ntp != null)
                {
                    ntpList.Add(ntp);
                }
            }

            //混合组态
            foreach (var mixed in model.MixedConfig)
            {
                NTP ntp = NTPBuildRequest.GetSetMixedConfigRequest(mixed, type);
                if (ntp != null)
                {
                    ntpList.Add(ntp);
                }
            }

            //通用组态
            foreach (var general in model.GeneralConfig)
            {
                NTP ntp = NTPBuildRequest.GetSetGeneralConfigRequest(general, type);
                if (ntp != null)
                {
                    ntpList.Add(ntp);
                }
            }

            //手控盘
            foreach (var manual in model.ControlBoard)
            {
                NTP ntp = NTPBuildRequest.GetSetManualBoardRequest(manual, type);
                if (ntp != null)
                {
                    ntpList.Add(ntp);
                }
            }

            return(SerialClient.ExecuteSetTask(ntpList, type));
        }