Beispiel #1
0
 public void AddModel(MultiCascadeModel m)
 {
     if (this.MultiCascadeCollection != null)
     {
         this.MultiCascadeCollection.Add(m);
     }
 }
Beispiel #2
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);
        }
        public PIDCollection InitCollection(PIDCollection c, PIDModel item, PIDConstant pidc, int maximum, ControllerType ct = ControllerType.Single, PIDAction action = PIDAction.None, double cumulativeErrRange = 0)
        {
            if (c == null)
            {
                c = new PIDCollection(pidc, item.Interval);
            }
            else
            {
                c.PIDConstants = pidc;
                c.Interval     = item.Interval;
            }
            c.CumulativeErrRange = cumulativeErrRange;
            c.Maximum            = maximum;
            c.E = i => c[i].Err;

            switch (ct)
            {
            case ControllerType.Single:
                PIDModel m = new PIDModel(item.SV, item.PV, item.Interval);
                c.Add(m);
                break;

            case ControllerType.Cascade:
                CascadePIDModel cm = item as CascadePIDModel;
                PIDModel        m2 = null;
                if (action == PIDAction.Input)
                {
                    m2 = new PIDModel(cm.InSV, cm.InPV, cm.Interval);
                }
                else if (action == PIDAction.Output)
                {
                    m2 = new PIDModel(cm.OutSV, cm.OutPV, cm.Minimum, cm.Maximum, cm.Interval);
                }
                c.Add(m2);
                break;

            case ControllerType.MultiCascade:
                MultiCascadeModel mcm = item as MultiCascadeModel;
                PIDModel          m3  = null;
                if (action == PIDAction.Input)
                {
                    m3 = new PIDModel(mcm.InSV, mcm.InPV, mcm.Interval);
                }
                else if (action == PIDAction.Output)
                {
                    m3 = new PIDModel(mcm.OutSV, mcm.OutPV, mcm.Minimum, mcm.Maximum, mcm.Interval);
                }
                c.Add(m3);
                break;

            case ControllerType.Feed:
                FeedModel fm = item as FeedModel;
                PIDModel  m4 = null;
                if (action == PIDAction.Input)
                {
                    m4 = new PIDModel(fm.InSV, fm.InPV, fm.Interval);
                }
                else if (action == PIDAction.Output)
                {
                    m4 = new PIDModel(fm.OutSV + fm.CorrectionValue, fm.OutPV, fm.Minimum, fm.Maximum, fm.Interval);
                }
                c.Add(m4);
                break;

            case ControllerType.Radio:
                RadioModel rm = item as RadioModel;
                PIDModel   m5 = new PIDModel(rm.SV + rm.CorrectionValue, rm.PV, rm.Interval);
                c.Add(m5);
                break;

            case ControllerType.ComplexRadio:
                ComplexRadioModel crm = item as ComplexRadioModel;
                PIDModel          m6  = null;
                if (action == PIDAction.Input)
                {
                    m6 = new PIDModel(crm.InSV, crm.InPV, crm.Interval);
                }
                else if (action == PIDAction.Output)
                {
                    m6 = new PIDModel(crm.OutSV + crm.CorrectionValue, crm.OutPV, crm.Minimum, crm.Maximum, crm.Interval);
                }
                c.Add(m6);
                break;

            case ControllerType.Furnace:
                FurnaceModel fum = item as FurnaceModel;
                PIDModel     m7  = null;
                if (action == PIDAction.Input)
                {
                    m7 = new PIDModel(fum.InSV, fum.InPV, fum.Interval);
                }
                else if (action == PIDAction.Output)
                {
                    m7 = new PIDModel(fum.OutSV, fum.OutPV, fum.Minimum, fum.Maximum, fum.Interval);
                }
                c.Add(m7);
                break;
            }
            return(c);
        }