Пример #1
0
 public void AddModel(FurnaceModel m)
 {
     if (this.FurnaceCollection != null)
     {
         this.FurnaceCollection.Add(m);
     }
 }
Пример #2
0
        void TestFactory3()
        {
            //构造间隔回路
            SwitchController sc = ControllerFactory.Create <SwitchController>();

            sc.GetInstance(3);

            SwitchModel sm1 = new SwitchModel(50, 40, 10, 2);
            SwitchModel sm2 = new SwitchModel(50, 45, 10, 2);
            SwitchModel sm3 = new SwitchModel(50, 52, 10, 2);
            SwitchModel sm4 = new SwitchModel(50, 61, 10, 2);
            SwitchModel sm5 = new SwitchModel(50, 56, 10, 2);

            sc.AddModel(sm1);
            sc.AddModel(sm2);
            sc.AddModel(sm3);
            sc.AddModel(sm4);
            sc.AddModel(sm5);


            //构造加热炉回路
            FurnaceController  fc      = ControllerFactory.Create <FurnaceController>(100);
            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);
            FurnaceManage manage = new FurnaceManage(20, 5);

            fc.GetInstance(pidcs2, manage, 1);

            FurnaceModel fm1 = new FurnaceModel(50, 51, 52, 53, 1);
            FurnaceModel fm2 = new FurnaceModel(50, 52, 52, 55, 1);
            FurnaceModel fm3 = new FurnaceModel(50, 50.5, 52, 54, 1);
            FurnaceModel fm4 = new FurnaceModel(50, 50, 52, 52, 1);
            FurnaceModel fm5 = new FurnaceModel(50, 51.2, 52, 53, 1);
            FurnaceModel fm6 = new FurnaceModel(50, 53, 52, 56, 1);
            FurnaceModel fm7 = new FurnaceModel(50, 52.2, 52, 54, 1);
            FurnaceModel fm8 = new FurnaceModel(50, 51.6, 52, 55, 1);

            fc.AddModel(fm1);
            fc.AddModel(fm2);
            fc.AddModel(fm3);
            fc.AddModel(fm4);
            fc.AddModel(fm5);
            fc.AddModel(fm6);
            fc.AddModel(fm7);
            fc.AddModel(fm8);
        }
Пример #3
0
        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);
        }