public void AddModel(FeedModel m) { if (this.FeedCollection != null) { this.FeedCollection.Add(m); } }
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); } }
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); }