20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.GroupProcessor;
22 import ca.uqac.lif.cep.Pullable;
23 import ca.uqac.lif.cep.functions.Cumulate;
24 import ca.uqac.lif.cep.functions.CumulativeFunction;
25 import ca.uqac.lif.cep.tmf.QueueSource;
26 import ca.uqac.lif.cep.tmf.Stutter;
27 import ca.uqac.lif.cep.util.Numbers;
37 public static void main(String[] args)
40 QueueSource source1 =
new QueueSource().setEvents(3, 1, 4, 1, 5);
41 GroupProcessor gp1 =
new GroupProcessor(1, 1);
43 Stutter st =
new Stutter(2);
44 Cumulate sum =
new Cumulate(
45 new CumulativeFunction<Number>(Numbers.addition));
46 Connector.connect(st, sum);
47 gp1.addProcessors(st, sum);
48 gp1.associateInput(0, st, 0);
49 gp1.associateOutput(0, sum, 0);
51 Connector.connect(source1, gp1);
54 Pullable p_gp1 = gp1.getPullableOutput();
55 System.out.println(p_gp1.pull());
59 QueueSource source2 =
new QueueSource().setEvents(2, 7, 1, 8);
60 GroupProcessor gp2 = gp1.duplicate(
true);
61 Connector.connect(source2, gp2);
62 Pullable p_gp2 = gp2.getPullableOutput();
63 System.out.println(p_gp2.pull());
static void main(String[] args)
Duplicating processors without preserving their state.