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