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

Reply via email to