[rules-users] Getting Started with an simple sample

Stefan Schuster stefan.m.schuster at gmail.com
Fri Apr 26 06:22:12 EDT 2013


Hi Bojan,

thanks a lot for your fast response.

but how can I guarantee that there is only one textfile per detector
created, even if the detecor has a value above 5 for a longer time?
Obviously the method for textfile-creation could check if there already
exists a file on the filesystem, but that doesn't feel "drools-like" to me.

further ideas?

thanks
Stefan


2013/4/26 Bojan Janisch <bojan.janisch at scai.fraunhofer.de>

> Hi Stefan,
>
> after you know what in the knowledgesession shall be, you have to think
> how you could check the value that the detectors return. For this you could
> create a new class e.g. MeasureResult which contains the result of the
> detectors. So instead of inserting the value, you insert the object (that
> contains the value) into the session. Now your rule only have to check if
> there is a MeasureResult object and depending on the value, do something.
>
> For example:
>
> rule "Measure >= 5"
> when
>     MeasureResult(result >= 5)
> then
>     //insert textfile creation here
> end
>
> rule "Measure <= 3"
> when
>     MeasureResult(result <= 3)
> then
>     //insert textfile deletion here
> end
>
> Of course for these rules your MeasureResult class need a variable called
> result and getter-Methods for it.
>
> Greetings
> Bojan
>
>
>
> ----- Ursprüngliche Mail -----
> Von: "Stefan Schuster" <stefan.m.schuster at gmail.com>
> An: "Rules Users List" <rules-users at lists.jboss.org>
> Gesendet: Freitag, 26. April 2013 11:30:40
> Betreff: [rules-users] Getting Started with an simple sample
>
>
>
>
>
> Hello,
>
> I’m still in the phase of learning the basics with drools. Therefor I
> created a simplified problem that I try to realize it with drools:
>
> I have several detectors, each of them measures something and converts it
> into an integer value between 1 one 6. Every Minute a new measurement is
> performed.
>
> When a detector reaches a value of 5 or above, a textfile is created with
> the name of the detector as filename and a predefined text as content. When
> the detector reaches a value of 3 or less, the texfile is deleted.
>
> My problem is that I’m still “thinking in java” and not yet “thinking in
> drools”.
>
> I guess the measured values would be facts that I insert (like the
> key-pressed events in the pong-example) to the knowledgebase. But now I
> stumble, I have no idea how to continue. Could anyone give me a helping
> hand for the next steps?
>
> Thanks in advance
>
> Stefan
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130426/471d9f96/attachment-0001.html 


More information about the rules-users mailing list