Пример #1
0
        void TestFactory()
        {
            //构造单回路
            SingleController   sc    = ControllerFactory.Create <SingleController>(5);
            List <PIDConstant> pidcs = new List <PIDConstant>();

            pidcs.Add(new PIDConstant(1, 1, 1, PIDControlAlgorithm.IPD));

            sc.GetInstance(pidcs, 1);

            PIDModel m1 = new PIDModel(50, 49);
            PIDModel m2 = new PIDModel(50, 49.5);
            PIDModel m3 = new PIDModel(50, 50.5);
            PIDModel m4 = new PIDModel(50, 50.8);

            sc.AddModel(m1);
            sc.AddModel(m2);
            sc.AddModel(m3);
            sc.AddModel(m4);

            //构造串级
            CascadeController  cc      = ControllerFactory.Create <CascadeController>(5);
            List <PIDConstant> pidcs2  = new List <PIDConstant>();
            PIDConstant        pidcIn  = new PIDConstant(120, 200, 30, PIDControlAlgorithm.IPD);
            PIDConstant        pidcOut = new PIDConstant(300, 30, 0, PIDControlAlgorithm.PID);

            pidcs2.Add(pidcIn);
            pidcs2.Add(pidcOut);
            cc.GetInstance(pidcs2, 1);

            CascadePIDModel cm1 = new CascadePIDModel(50, 52, 2000, 1950);

            cc.AddModel(cm1);


            //构造复杂串级
            MultiCascadeController mcc      = ControllerFactory.Create <MultiCascadeController>(5);
            List <PIDConstant>     pidcs3   = new List <PIDConstant>();
            PIDConstant            pidcIn2  = new PIDConstant(120, 200, 30, PIDControlAlgorithm.IPD);
            PIDConstant            pidcOut2 = new PIDConstant(300, 30, 0, PIDControlAlgorithm.PID);
            PIDConstant            pidcAu1  = new PIDConstant(100, 150, 20, PIDControlAlgorithm.IPD);//附加PID
            PIDConstant            pidcAu2  = new PIDConstant(100, 150, 20, PIDControlAlgorithm.IPD);

            pidcs3.Add(pidcIn2);
            pidcs3.Add(pidcOut2);
            pidcs3.Add(pidcAu1);
            pidcs3.Add(pidcAu2);

            mcc.GetInstance(pidcs3, 1);

            MultiCascadeModel mcm1 = new MultiCascadeModel(50, 52, 2000, 1950, 1);
            PIDModel          aum1 = new PIDModel(20, 19, 1);//附加回路模型
            PIDModel          aum2 = new PIDModel(20, 19.8, 1);

            mcm1.AddAuxiliaryModel(aum1);
            mcm1.AddAuxiliaryModel(aum2);

            mcc.AddModel(mcm1);
        }
Пример #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);
        }