20 import ca.uqac.lif.cep.Connector;
21 import ca.uqac.lif.cep.Pullable;
22 import ca.uqac.lif.cep.functions.ApplyFunction;
23 import ca.uqac.lif.cep.functions.FunctionTree;
24 import ca.uqac.lif.cep.functions.StreamVariable;
25 import ca.uqac.lif.cep.tmf.QueueSource;
26 import ca.uqac.lif.cep.util.Numbers;
40 public static void main (String[] args)
43 QueueSource source1 =
new QueueSource().setEvents(2, 7, 1, 8, 3);
44 QueueSource source2 =
new QueueSource().setEvents(3, 1, 4, 1, 6);
45 QueueSource source3 =
new QueueSource().setEvents(1, 1, 2, 3, 5);
46 FunctionTree tree =
new FunctionTree(Numbers.multiplication,
47 new FunctionTree(Numbers.addition,
48 StreamVariable.X, StreamVariable.Y),
50 ApplyFunction exp =
new ApplyFunction(tree);
51 Connector.connect(source1, 0, exp, 0);
52 Connector.connect(source2, 0, exp, 1);
53 Connector.connect(source3, 0, exp, 2);
55 Pullable p = exp.getPullableOutput();
56 for (
int i = 0; i < 5; i++)
58 float x = (Float) p.pull();
59 System.out.println(
"The event is: " + x);
Use a FunctionTree to create a complex function.