Keeping track of external entities in Working Memory is possible but
you'll have to provide a safe restart mechanism.
Let's say you have events Reading( String detName, int value) and
Marker( String detName ), your rules would be
rule "above threshold"
when
Reading( $d: detName, $v: value > 5 )
not Marker( detName == $d )
then
// create file
insert new Marker( $d );
end
To be restart-safe, provide Java code checking for the existence of
files and insert Marker files accordingly.
-W
On 26/04/2013, Stefan Schuster <stefan.m.schuster(a)gmail.com> wrote:
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(a)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(a)gmail.com>
> An: "Rules Users List" <rules-users(a)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(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users