在修改其中的内容后,剪辑规则将对象进入无限循环

问题描述 投票:0回答:1

我在RHS上用剪辑对象中的某个数字递增变量。

规则正在运行,但进入无限循环。

我尝试在不修改对象内部变量的情况下运行它,它进入RHS一次,但是经过修改后它将进入循环。

(defrule modify
        "modify"
        (step 0)
        ?EA <- (object (is-a ALERT)
                (ID                      ?RID&:(or(eq ?ID "R") (eq ?RID "Q")))
                (TIME                     ?T)
        )
        =>
        (bind ?time (send ?EA get-TIME))
        (bind ?newTime (+ 86399 ?time))
        (send ?EA put-TIME ?newTime)
        (log_info (str-cat "old time is " ?time ", new time is " ?newTime "event time is " (send ?EA get-TIME)))
)

我希望即使修改了对象内的内容,也会打印一次日志。

谢谢。

clips
1个回答
0
投票

删除我们在RHS上递增的LHS上的Slot修复此问题。

(defrule modify
        "modify"
        (step 0)
        ?EA <- (object (is-a ALERT)
                (ID                      ?RID&:(or(eq ?ID "R") (eq ?RID "Q")))                
        )
        =>
        (bind ?time (send ?EA get-TIME))
        (bind ?newTime (+ 86399 ?time))
        (send ?EA put-TIME ?newTime)
        (log_info (str-cat "old time is " ?time ", new time is " ?newTime "event time is " (send ?EA get-TIME)))
)

如果我们在LHS中保留插槽TIME,则在更改/增量之后规则将被重新触发,并且它将进入循环。

© www.soinside.com 2019 - 2024. All rights reserved.