Esempio n. 1
0
        public List <Model.LoopModel> CreateLoops <T>(int loopsAmount, int deviceAmount, Model.ControllerModel controller, IDeviceService <T> deviceService)
        {
            string strMachineNumber = controller.MachineNumber;
            ControllerOperationCommon controllerBase = new ControllerOperationCommon();
            int loopID = controllerBase.GetMaxLoopID();

            string strLoopLengthFormat = "#";

            for (int i = 0; i < controller.LoopAddressLength; i++)
            {
                strLoopLengthFormat += "0";
            }
            List <Model.LoopModel> lstLoopModel = new List <LoopModel>();

            for (int i = 0; i < loopsAmount; i++) //创建回路
            {
                LoopModel loop = new LoopModel();
                loop.Controller   = controller;
                loop.ID           = loopID++;
                loop.Code         = strMachineNumber + i.ToString(strLoopLengthFormat);
                loop.Name         = strMachineNumber + i.ToString(strLoopLengthFormat);
                loop.DeviceAmount = deviceAmount;
                loop.SetDevices <T>(deviceService.InitializeDevices(deviceAmount));
                lstLoopModel.Add(loop);
                loop.IsLoopDataDirty = true;
                //  SetDataDirty();
            }
            return(lstLoopModel);
        }
Esempio n. 2
0
        /// <summary>
        /// 根据器件数量初始化器件信息
        /// </summary>
        /// <param name="cType">控制器类型</param>
        /// <param name="loop">回路对象</param>
        private void  InitializeDevicesToLoop(ControllerType cType, LoopModel loop)
        {
            switch (cType)
            {
            case ControllerType.FT8000:
            {
                DeviceService8000 deviceService = new DeviceService8000();
                deviceService.TheLoop = loop;
                List <DeviceInfo8000> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8000>(lstDeviceInfo);
                break;
            }

            case ControllerType.FT8003:
            {
                DeviceService8003 deviceService = new DeviceService8003();
                deviceService.TheLoop = loop;
                List <DeviceInfo8003> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8003>(lstDeviceInfo);
                break;
            }

            case ControllerType.NT8001:
            {
                DeviceService8001 deviceService = new DeviceService8001();
                deviceService.TheLoop = loop;
                List <DeviceInfo8001> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8001>(lstDeviceInfo);
                break;
            }

            case ControllerType.NT8007:
            {
                DeviceService8007 deviceService = new DeviceService8007();
                deviceService.TheLoop = loop;
                List <DeviceInfo8007> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8007>(lstDeviceInfo);
                break;
            }

            case ControllerType.NT8021:
            {
                DeviceService8021 deviceService = new DeviceService8021();
                deviceService.TheLoop = loop;
                List <DeviceInfo8021> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8021>(lstDeviceInfo);
                break;
            }

            case ControllerType.NT8036:
            {
                DeviceService8036 deviceService = new DeviceService8036();
                deviceService.TheLoop = loop;
                List <DeviceInfo8036> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8036>(lstDeviceInfo);
                break;
            }

            case ControllerType.NT8053:
            {
                DeviceService8053 deviceService = new DeviceService8053();
                deviceService.TheLoop = loop;
                List <DeviceInfo8053> lstDeviceInfo = deviceService.Create(loop.DeviceAmount);
                loop.SetDevices <DeviceInfo8053>(lstDeviceInfo);
                break;
            }
            }
        }