[Fiware-tech-help] CEP question

Tali Yatzkar-Haham TALI at il.ibm.com
Thu Apr 16 09:07:10 CEST 2015


Dear Denis,

I am glad to hear you are using the CEP in your product!

When you want to aggregate several events, you can use the Aggregate type 
EPA. Below I copied the relevant parts from the User guide that describes 
this EPA operator.
In the Aggregate EPA you can define computed variables. In your case you 
would like to define a variable of type count, let's call it 
countSimpleEvents and for each input event type, the value used for 
computing this variable will be 1.
Then, in the condition of the EPA you will write countSimpleEvents >=10 
(or any other threshold value). If you want the EPA to report only once, 
then you can specify its definition.
Since you want the EPA to count separately for each 'SequenceID', you need 
to define a Segmentation Context, lets call it SequenceIDSegContext and 
add to its participant events the 'Simple Event' and as its expression 
SimpleEvent.SequenceID. You need to add this context to the EPA 
definition. This way the CEP will create a separate processing context for 
each  SequenceID value, and group together events of the same SequenceID. 
If you want the initiator/terminator of the temporal processing context to 
be group to the EPA events according to the SequenceID, then you need to 
create composite context, and add the SequenceIDSegContext and your 
temporal context to this segmentation context, and add this new composite 
context to the EPA definition.

Derived event - you need to define an event that will be used as derived 
event and add it an attribute of type integer and dimension 1, this 
defines the attribute type to be an  array of integers. Let call this 
attribute SequenceIDArr
When you specify the derive event of the EPA, you should set the 
expression of the SequenceIDArr attribute to SimpleEvent.SequenceID 
Since in an aggregation operator, if you refer to an input event 
attribute, you get an array containing the values of all the instances of 
the same input event type. 

(please note that the definition names and attribute names can not include 
spaces)


------------------------------

Relevant parts from the user guide:

Operand Properties for Aggregation Operands:
In an aggregation operator, the user can declare computed variables. These 
variables are computed during runtime and can be used in the EPA condition 
and in the expressions assigned to derived events' attributes.
Each computed variable has the following parameters:
§       Name ? a unique (within this EPA) variable name. 
§       Aggregation Type ? the type of aggregation to compute, which be 
set to one of the following: 
o       Count ? counts the number of participant events.
o       Sum ? summarizes the expression value for all the participant 
events.
o       Max ? maximum function over the expression value for all the 
participant events.
o       Min ? minimum function over the expression value for all the 
participant events.
o       Average ? average across the expression value for all the 
participant events.
§       Expression for every participant event ? The expression value is 
used to calculate the computed variable according to the aggregation type.


Derived Events: 
Note: In the aggregation operator, if we refer to an operand attribute, we 
get an array containing the values of all the instances of the same 
operand. There is no option to refer to a specific instance. Hence, the 
type of such attribute must be an array. 

-----------------

Hoped that helped, 

Best regards,
Tali

Tali Yatzkar Haham
Event-based Middleware & Solutions
IBM Haifa Research Lab, Israel
tali at il.ibm.com 972-4-8296320
 



From:   Denis Ermacora <ermacora at datamind.biz>
To:     Tali Yatzkar-Haham/Haifa/IBM at IBMIL
Date:   15/04/2015 11:50 AM
Subject:        CEP question



Dear Tali,
I'm writing you to ask some questions about the CEP Generic Enabler you 
developed in the last years as a module of the FI.WARE project.
My team and I are developing a product for Ultrasound image enhancement 
that internally makes use of the CEP component as a tomcat service to 
dispatch and route events coming from different sources and applying 
complex roles. The integration of CEP with the other components of the 
system is pretty stable and works well, anyway , due to time contraints in 
the development milestones , we defined some events and roles in an 
awkward and probabily too complicated way. The main problem is that , both 
in the documentation ( Install, User and Programmer Guides ) and in the 
example projects in the CEP package ( DoSAttack and LiveDemo) we cannot 
find a clear reference that explains how to handle events with members of 
array type, and how to combine different instances of simple events into 
one derived event.
More in detail which is the best way to represent a situation  like the 
following:

Defined an event 'Simple Event' with a string member 'Sample String' and 
an int member 'Sequence ID', the system accepts a number of these events.
When a given condition is fulfilled, for example a predefined  number of 
Simple Events with the same Sequence ID are present in the system, we want 
to derive from them a single event that embeds all the 'Sample String' 
values of the collected simple events in a 'Sample Strings' member of type 
array of strings.

Thanks for the answer and kind regards.
-- 
Denis Ermacora

Research and Development
DataMind S.r.l.
Parco Scientifico e Tecnologico
Via J. Linussio 51,
33100 Udine - Italy

Tel: 0432-629778
Fax: 0432-603887
ermacora at datamind.biz

C.F. & P.I. 02438900306 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fiware.org/private/fiware-tech-help/attachments/20150416/15adab3d/attachment.html>


More information about the Fiware-tech-help mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy