Scale scale3 = new Scale(ctsub, "Scale3");
Scale scale4 = new Scale(ctsub, "Scale4");
scale4.factor.setExpression("feedbackGain");
TimedPlotter ctPlot = new TimedPlotter(ctsub, "CTPlot");
ctPlot.plot = new Plot();
ctPlot.plot.setGrid(true);
ctPlot.plot.setXRange(0.0, stopT);
ctPlot.plot.setYRange(-1.0, 1.0);
ctPlot.plot.setSize(500, 180);
ctPlot.plot.addLegend(0, "Position");
ctPlot.plot.addLegend(1, "Input");
ctPlot.plot.addLegend(2, "Control");
CTPeriodicSampler ctSampler = new CTPeriodicSampler(ctsub,
"PeriodicSampler");
ctSampler.samplePeriod.setExpression("samplePeriod");
// CT Connections
ctsub.connect(time.output, scale3.input);
ctsub.connect(scale3.output, trigFunction.input);
Relation cr0 = ctsub.connect(trigFunction.output, scale0.input, "CR0");
ctsub.connect(scale0.output, add1.plus, "CR1");
ctsub.connect(add1.output, intgl1.input, "CR2");
Relation cr3 = ctsub.connect(intgl1.output, intgl2.input, "CR3");
Relation cr4 = ctsub.connect(intgl2.output, ctPlot.input, "CR4");
scale1.input.link(cr3);
scale2.input.link(cr4);
ctSampler.input.link(cr4);
TypedIORelation cr5 = new TypedIORelation(ctsub, "CR5");
ctSampler.output.link(cr5);
subout.link(cr5);
ctsub.connect(scale1.output, add1.plus, "CR6");
ctsub.connect(scale2.output, add1.plus, "CR7");
ctsub.connect(scale4.output, add1.plus, "CR8");
TypedIORelation cr9 = new TypedIORelation(ctsub, "CR9");
hold.input.link(cr9);
subin.link(cr9);
Relation cr10 = ctsub.connect(hold.output, scale4.input, "CR10");
ctPlot.input.link(cr0);
ctPlot.input.link(cr10);
// DE System
ptolemy.domains.de.lib.TimedDelay delay = new ptolemy.domains.de.lib.TimedDelay(
this, "delay");
delay.delay.setToken(new DoubleToken(0.02));
FIR fir = new FIR(this, "fir");
fir.taps.setExpression("{0.7, 0.3}");
Quantizer quan = new Quantizer(this, "Quantizer");
Average accumulator = new Average(this, "accumulator");
Sampler sampler = new Sampler(this, "sampler");
Clock clk = new Clock(this, "ADClock");
clk.offsets.setExpression("{0.0}");
clk.period.setToken(new DoubleToken(1.0));
clk.values.setExpression("{true}");
TimedPlotter dePlot = new TimedPlotter(this, "DEPlot");
Plot newPlot = new Plot();
dePlot.plot = newPlot;
newPlot.setGrid(true);
newPlot.setXRange(0.0, stopT);
newPlot.setYRange(-1.0, 1.0);
newPlot.setSize(500, 180);
newPlot.setConnected(false);
newPlot.setImpulses(true);
newPlot.setMarksStyle("dots");
newPlot.addLegend(0, "Accum");
newPlot.addLegend(1, "Quantize");
FIR mav = new FIR(this, "MAV");
mav.taps.setExpression("{0.1, 0.1, 0.1, 0.1, 0.1, 0.05, 0.05, 0.05, "
+ "0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05}");