Java longs are only supported as a "pseudotype" at this time; the only
thing you can really do with them is pass them to Java functions. What
I would do in your case is to write a small library of functions for
dealing with dates, probably in Java, and then work with those
functions. For instance, the whole (limit) deffunction might be
rewritten as a Userfunction instead, or you might just write
(longdiff) and (longsum) functions, and rewrite (limit) to use them.
Note that there's no performance penalty whatsoever for mixing Java
and Jess code.
Another topic: why do you have
(or (> ?diff ?limit) (= ?diff ?limit))
instead of
(>= ?diff ?limit)
?
I think John Hossack wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hello,
>
> I am slowly building up an alarm processor using JESS and I am having a problem! Can
>anyone help?
>
> I am trying to calculate the time period elapsed between two alarms. This period is
>then checked against a time limit to see if the alarms have occured within or outside
>a specified time limit. To enable easy comparison between alarm times I have used the
>Date class to return the number of ms since 1970 for each alarm (this is returned as
>a long). This value only takes account of the day, month, year, hour, minute and
>seconds of the alarm - the alarm also contains a millisecond field that must be added
>to the calculated ms since 1970 to get the correct value.
>
> This functionality has been encapsulated in a deffunction that is called by a test
>function on the LHS of a rule. The function is as follows:
>
> (deffunction limit (?x_ms1970 ?x_ms ?y_ms1970 ?y_ms ?limit)
> (bind ?x_time (+ ?x_ms1970 ?x_ms)) ; add
>alarm millisecond to alarm millisecond since 1970
> (bind ?y_time (+ ?y_ms1970 ?y_ms))
> (bind ?diff (- ?x_time ?y_time)) ;
>calculate the difference in millisecond between alarms
> (if (or (> ?diff ?limit) (= ?diff ?limit)) then
>; if difference >= limit then return TRUE.
> (return TRUE)
> else
> (return FALSE)))
>
>
> When the function is called JESS Exceptions are created. I believe the problem is
>related to me trying to perform mathematical operations on variables of type long.
>Does anybody know of a way around this problem?
>
>
> Thanks in advance,
>
> John Hossack
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------