<div dir="ltr">Amazing!<div>thanks a lot Wolfgang!</div><div><br></div><div>Kind regards</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 12, 2014 at 10:27 AM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You can create a rule with a timer to update Current with the required<br>
frequency.<br>
<br>
rule "set current"<br>
timer (int: 1s 1s)<br>
no-loop<br>
when<br>
$c: Current()<br>
then<br>
modify( $c ){ setXYZ(whatever) }<br>
end<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 11/03/2014, Ioannis Christodoulou <<a href="mailto:io.christod@gmail.com">io.christod@gmail.com</a>> wrote:<br>
> Thanks a lot for the prompt reply and the detailed example!<br>
> It took me some time but I managed to convert it to a working xls decision<br>
> table.<br>
><br>
> Now, I wanted to figure out how to automatically update the Current object<br>
> regularly, in order to re-calculate the rules over time.<br>
> My application is a java ee one. Would creating a @schedule on a singleton<br>
> method be a good solution, or is there another better advice for it?<br>
><br>
> Thanks again!<br>
><br>
> Ευχαριστώ πολύ,<br>
> Ιωάννης Χριστοδούλου<br>
><br>
><br>
> On Tue, Mar 11, 2014 at 8:50 PM, Wolfgang Laun<br>
> <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>>wrote:<br>
><br>
>> As you have Level with a field date, you can access that point in time in<br>
>> milliseconds, using getTimeInMillis(). For the current time, you might<br>
>> insert an object of class Current with a member now of class Calendar.<br>
>><br>
>> rule closest<br>
>> when<br>
>> Current( $now: now )<br>
>> $level: Level( $value == 2, $date: date )<br>
>> not $x: Level( Math.abs( $x.getDate().getTimeInMillis() -<br>
>> $now.getTimeInMillis() ) < Math.abs( $date.getTimeInMillis() -<br>
>> $now.getTimeInMillis() ) )<br>
>> then<br>
>> // $level is the Level fact closest to Current with a level of 2<br>
>> end<br>
>><br>
>> Untested. If the long expression gives you trouble, try enclosing it in<br>
>> eval(...).<br>
>> -W<br>
>><br>
>><br>
>> On 11 March 2014 18:14, JChrist <<a href="mailto:io.christod@gmail.com">io.christod@gmail.com</a>> wrote:<br>
>><br>
>>> Hello everyone,<br>
>>> I was messing with drools v6.0.1.Final the past week and I have not been<br>
>>> able to completely understand how to integrate the rule engine to my<br>
>>> specification.<br>
>>><br>
>>> For the needs of my project, I want to regularly insert some data in the<br>
>>> engine, similar to the following:<br>
>>> class Level { double value;Calendar date; }<br>
>>> this class contains some values at specific time points (both in the<br>
>>> past<br>
>>> and in the future).<br>
>>><br>
>>> I would like to be able create a decision table based on the "current"<br>
>>> time<br>
>>> (plus or minus a variable offset) and the value of the closest Level to<br>
>>> that<br>
>>> time point.<br>
>>><br>
>>> For example, assuming it is '2014-11-03 19:10:00' and the level objects<br>
>>> in<br>
>>> the session currently are:<br>
>>> '1.0 2014-11-03 18:00:00' and '2.0 2014-11-03 19:00:00',<br>
>>><br>
>>> I would want a rule to say that if current level value is 2.0 then do<br>
>>> some<br>
>>> stuff and it would make a match.<br>
>>><br>
>>> I would really appreciate any help on how to overcome this issue, as<br>
>>> well<br>
>>> as<br>
>>> any good examples/tutorials regarding this.<br>
>>><br>
>>> Kind regards.<br>
>>><br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> View this message in context:<br>
>>> <a href="http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html" target="_blank">http://drools.46999.n3.nabble.com/Temporal-rules-in-decision-table-tp4028638.html</a><br>
>>> Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
>>> _______________________________________________<br>
>>> rules-users mailing list<br>
>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> rules-users mailing list<br>
>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><br>
><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a></div></div></blockquote></div><br></div></div>