> Should the creation of the external file depend on the existence of > *any* MeasureResult (with the same detector)? No, because:
The rule doesn't depend on *any* MeasureResult, it depends on the detector which created the file. I've understood that each detector shall only create one file and thats exactly what the rule is doing. > - There always is one, otherwise the 1st pattern wouldn't be true. There isn't always a file, for example if you only get the Result 4 from each detector, then nothing happens. > - Apart from that: all existing MeasureResult's could be below 5, and > this should not block file creation. Why should a Result from below 5 block the file creation? Isn't the condition that a result is 5 or above needed for filecreation? So the detector has at least one time returned 5 or above. So I don't really get the point whats bothering you. Greetings Bojan ----- Ursprüngliche Mail ----- Von: Wolfgang Laun <[email protected]> An: Rules Users List <[email protected]> Gesendet: Fri, 26 Apr 2013 13:54:30 +0200 (CEST) Betreff: Re: [rules-users] Getting Started with an simple sample Hmm... On 26/04/2013, Bojan Janisch <[email protected]> wrote: > I didn't know that there is another condition to test for. > > So there has to be a second condition that checks if the detector that > returned the result has already created a file. > Just add a further field into the MeasureResult object, which now should > contain a value and a detector. > > Now you should change your rules to something like this: > > rule "Measure >= 5" > when > $mes:MeasureResult(result >= 5, mes_detector:detector) > not MeasureResult(mes_detector == detector) > then > //insert textfile creation here > end Should the creation of the external file depend on the existence of *any* MeasureResult (with the same detector)? No, because: - There always is one, otherwise the 1st pattern wouldn't be true. - Apart from that: all existing MeasureResult's could be below 5, and this should not block file creation. -W > > rule "Measure <= 3" > when > $mes:MeasureResult(result <= 3, mes_detector:detector) > not MeasureResult(mes_detector == detector) > then > //insert textfile deletion here > end > > The first condition again tests for the result and in addition it saves the > detector that created the result into the field mes_detector. > The second condition now says that there shall not be a MeasureResult which > has a detector that already created a result. > > Note that you have to retract the MeasureResult object from the Session when > you remove a file so that the detector can create a file again. > > Greetings > Bojan > > ----- Ursprüngliche Mail ----- > Von: Stefan Schuster <[email protected]> > An: Rules Users List <[email protected]> > Gesendet: Fri, 26 Apr 2013 12:22:12 +0200 (CEST) > Betreff: Re: [rules-users] Getting Started with an simple sample > > 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 <[email protected]> > >> 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" <[email protected]> >> An: "Rules Users List" <[email protected]> >> 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 >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> _______________________________________________ >> rules-users mailing list >> [email protected] >> https://lists.jboss.org/mailman/listinfo/rules-users > > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
