[rules-users] Accumulate function

Wolfgang Laun wolfgang.laun at gmail.com
Tue May 22 09:20:01 EDT 2012


You could us a query to obtain a compact pattern for all matching
RFIDObservations. And I don't think you need a custom function;
collectSet should give you unique values.

Untested!

query uncrowdedObservations( SensorFixed $rdr, RFIDObservation $obs )
    $obs: RFIDObservation( sensor == $rdr ) over window:time( 60s )
    not CrowdInAreaEvent( sensor == $rdr, this meets[ 5s ] $obs )
end

rule "CrowdInAreaEvent-event"
no-loop
when
    $rdr: SensorFixed(type == Sensor.SENSOR_TYPE_RFID, $coverageArea :
areaOfInterest )
    accumulate( uncrowdedObservation( $rdr, $obs ), $set:
accumulateSet( $obs.getTagid() ) )
    eval( $set.getSize() > 10 )
then
   insert( ... );
end

-W

On 22/05/2012, Matteo Cusmai <cusmaimatteo at gmail.com> wrote:
> Hi Vincent,
> i have an rfid reader and i am collecting tagid from that sensor.
> I would like to raise an event when the number of different tags in a time
> interval is greater than 20 (for example).
>
>
>
> On Tue, May 22, 2012 at 2:33 PM, Vincent LEGENDRE <
> vincent.legendre at eurodecision.com> wrote:
>
>> No.
>> You can't use $obs before you bind it (2nd pattern)
>> The binding done for accumulate pattern must be used in some accumulate
>> fonction in order to be seen outside.
>>
>> Instead of trying to fix your rule, may be you can describe (with simple
>> phrases) what you are trying to do ?
>>
>> ------------------------------
>> *De: *"Matteo Cusmai" <cusmaimatteo at gmail.com>
>> *À: *"Rules Users List" <rules-users at lists.jboss.org>
>> *Envoyé: *Mardi 22 Mai 2012 12:33:16
>> *Objet: *[rules-users] Accumulate function
>>
>>
>> Hi all,
>> i am going to use a custom accumulate function like that:
>>
>> rule "CrowdInAreaEvent-event"
>>     no-loop
>>     when
>>         $RFIDReader : SensorFixed(type == Sensor.SENSOR_TYPE_RFID,
>> $coverageArea : areaOfInterest )
>>         not CrowdInAreaEvent( sensor == $RFIDReader, this meets[ 5s ]
>> $obs
>> )
>>         $count : Integer( intValue > 10 )
>>             from accumulate( $obs : RFIDObservation( $tagid : tagid,
>> sensor == $RFIDReader )
>>             over window:time( 60s ) from entry-point
>> lowLevelSensorStream,
>> countDistinct( $tagid ) );
>>     then
>>         insert( SituationManager.createCrowdInAreaEvent( "Crowd, number
>> people: " + $count, Event.THREAT_LOW, $coverageArea, $RFIDReader, $count,
>> 60, 10 ) );
>> end
>>
>> I need to refer $obs object in order to compare timing of new observation
>> with last event. Is it possible to do that?
>>
>> Thanks a lot,
>> Matteo.
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>



More information about the rules-users mailing list