コード例 #1
0
ファイル: Tester.cs プロジェクト: QuarkSoftware/PIDSample
        void TestFactory2()
        {
            //构造进料回路
            FeedController fc = ControllerFactory.Create <FeedController>(10);

            List <PIDConstant> pidcs   = new List <PIDConstant>();
            PIDConstant        pidcIn  = new PIDConstant(120, 200, 30, PIDControlAlgorithm.IPD);
            PIDConstant        pidcOut = new PIDConstant(300, 30, 0, PIDControlAlgorithm.PID);

            pidcs.Add(pidcIn);
            pidcs.Add(pidcOut);

            double        interval = 1;
            DynamicObject dynObj   = new DynamicObject(20, 5, 3, 0.01, FetchType.Max);

            for (int i = 0; i < dynObj.Cycle; i++)
            {
                dynObj.UpdateDynamic(10 + r.NextDouble() * 2);
            }

            fc.GetInstance(pidcs, dynObj, interval, 100);

            //添加项
            for (int i = 0; i < 12; i++)
            {
                fc.UpdateDynamic(10 + r.NextDouble() * 2);
                FeedModel fm = new FeedModel(fc.DynamicList, 50, 52 + r.NextDouble(), 51, 0, 100, 1);
                fc.AddModel(fm);
            }
        }
コード例 #2
0
        public static T Create <T>(int maximun = 100) where T : ControllerBase, new()
        {
            ControllerBase controller = null;
            var            props      = new T().GetType().GetProperties();
            var            p          = props.Single(pro => pro.Name == "ControllerType");
            ControllerType ct         = (ControllerType)p.GetValue(new T(), null);

            if (ct == ControllerType.Single)
            {
                controller = new SingleController(maximun);
            }
            else if (ct == ControllerType.Cascade)
            {
                controller = new CascadeController(maximun);
            }
            else if (ct == ControllerType.MultiCascade)
            {
                controller = new MultiCascadeController(maximun);
            }
            else if (ct == ControllerType.Feed)
            {
                controller = new FeedController(maximun);
            }
            else if (ct == ControllerType.Radio)
            {
                controller = new RadioController(maximun);
            }
            else if (ct == ControllerType.ComplexRadio)
            {
                controller = new ComplexRadioController(maximun);
            }
            else if (ct == ControllerType.Switch)
            {
                controller = new SwitchController();
            }
            else if (ct == ControllerType.Furnace)
            {
                controller = new FurnaceController(maximun);
            }
            else if (ct == ControllerType.SplitRanging)
            {
                //controller = new ComplexRadioController();
            }
            return(controller as T);
        }