[rules-users] Finicky eval statements

Bagwell, Allen F afbagwe at sandia.gov
Wed Dec 10 13:24:46 EST 2008


That's probably it, but my mind is blanking on the definition of time-constant as it would apply here.

howOld() is doing a simple calculation of the difference between the current time and the timestamp value that was set in statusRequested however many x seconds ago. So based on your feedback, I'm assuming the inline eval isn't seeing proper timestamp value since its last change. But the top-leve eval can.

-A

________________________________
From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Wednesday, December 10, 2008 10:45 AM
To: Rules Users List
Subject: Re: [rules-users] Finicky eval statements


      Is your inline eval() time-constant? I would guess that "howOld()" is returning different values when executed at different times. Inline evals MUST be time-constant. Top level evals can deal with non-time-constant expressions.

      []s
      Edson

2008/12/10 Bagwell, Allen F <afbagwe at sandia.gov<mailto:afbagwe at sandia.gov>>

I'm puzzled over the proper use of in-line evals.  I've used them successfully in some places. But it seems that on occasion something doesn't work when I think it should.

First, this is a when clause that works properly using a separate eval statement. The rule activates and fires when expected:

$rt : RuleTimer(uniqueName == "Hardware Status Request", timedOut == true)
$hw : Hardware($activelyMonitored : activelyMonitored, command == null)
      AttrBoolean(this == $activelyMonitored, currentValue == true)
      eval($hw.getStatusRequested().howOld() > $hw.getStatusPeriod())


However, this re-write changing to an in-line eval never fires.

$rt : RuleTimer(uniqueName == "Hardware Status Request", timedOut == true)
$hw : Hardware($activelyMonitored : activelyMonitored, command == null, eval(statusRequested.howOld() > statusPeriod) )
      AttrBoolean(this == $activelyMonitored, currentValue == true)

Likewise, this re-write doesn't fire either where I sought to bind the more complex statusRequested object to a Drools variable before using it in the eval. The field statusPeriod just holds a primitive double.

$rt : RuleTimer(uniqueName == "Hardware Status Request", timedOut == true)
$hw : Hardware($activelyMonitored : activelyMonitored, $sr : statusRequested, command == null,
               eval($sr.howOld() > statusPeriod) )
      AttrBoolean(this == $activelyMonitored, currentValue == true)

I haven't been able to find anything in the manual that says these other two syntaxes are wrong. Furthermore, the Drools compiler has no issues with them.

Thanks!

Allen F. Bagwell
e-mail:  afbagwe at sandia.gov<mailto:afbagwe at sandia.gov>
phone:  505/284-4517
fax:  505/ 844-7886

Ask your doctor if medical advice from a TV commercial is right for you.




_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org<mailto:rules-users at lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com<http://www.jboss.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081210/9fd711d8/attachment.html 


More information about the rules-users mailing list