Hi,<div><br></div><div>Trying to build net mgmt system but having problem with basic cause/effect (mostly not understanding the engine).</div><div><br></div><div>I have a a Port object that contains a Card object. They both have separate states (up or down). I want to have a Port go to down state if the containing Card goes to down state - very basic now until i get the feel of it.</div>
<div><br></div>
<div>The state of the Card changes if a Notification is injected into the session (at least this is my understanding)</div><div><br></div><div><div>Here are my rules:</div><div><br></div><div>rule &quot;card going down&quot;</div>
<div>
    when</div><div>    <span style="white-space:pre-wrap">        </span>$card : Card($name : name , state == State.UP)</div><div>       <span style="white-space:pre-wrap">        </span>$notif : Notification( id == $name, type == NotificationType.CARD , state == State.DOWN )</div>

<div>    then</div><div>    <span style="white-space:pre-wrap">        </span>System.out.println(&quot;  got notification for card down &quot; + $card );</div><div>    <span style="white-space:pre-wrap">        </span>modify($card) {</div>

<div>    <span style="white-space:pre-wrap">                </span>setState(State.DOWN);</div><div>    <span style="white-space:pre-wrap">        </span>}</div><div>    <span style="white-space:pre-wrap">        </span>retract($notif);</div>
<div>end</div><div><br></div><div>// is the following rule correct??</div><div><br></div><div>rule &quot;port going down&quot;</div><div><span style="white-space:pre-wrap">        </span></div><div>    when</div><div>    <span style="white-space:pre-wrap">        </span>$port : Port($name : name , state == State.UP, $card : card)</div>

<div>       <span style="white-space:pre-wrap">        </span>Card ( state == State.DOWN) from $card</div><div>    then</div><div>    <span style="white-space:pre-wrap">        </span>System.out.println(&quot;  port down because card is down  port: &quot; + $port + &quot; card: &quot; + $card );</div>

<div>    <span style="white-space:pre-wrap">        </span>modify($port) { </div><div>    <span style="white-space:pre-wrap">                </span>setState(State.DOWN);</div><div>    <span style="white-space:pre-wrap">        </span>}</div>
<div>    <span style="white-space:pre-wrap">        </span></div><div>end</div></div><div><br></div><div><div>Here is the test case in a nutshell:</div></div><div><br></div><div><div><span style="white-space:pre-wrap">        </span></div>

<div><span style="white-space:pre-wrap">                        </span>Port port1 = new Port();</div><div><span style="white-space:pre-wrap">                        </span>Port port2 = new Port();</div></div><div><div>                        port1.setName(&quot;port1&quot;);</div>

<div><span style="white-space:pre-wrap">                        </span>port2.setName(&quot;port2&quot;);</div></div><div><br></div><div><div>                        Card card1 = new Card();</div><div><span style="white-space:pre-wrap">                        </span>card1.setName(&quot;port1 card1&quot;)</div>

<div>                        port1.setCard(card1);</div><div>                       // stateful session </div><div><div>                        ksession.insert(port1);</div><div><span style="white-space:pre-wrap">                        </span>ksession.insert(port2);</div>
<div><span style="white-space:pre-wrap">                        </span>ksession.insert(card1);</div><div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>System.out.println(&quot;  firing rules&quot;);</div><div>
<span class="Apple-tab-span" style="white-space:pre">                        </span>new Thread(new Runnable() {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>public void run() {</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>ksession.fireUntilHalt();</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>}</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>}).start();</div></div><div><br></div></div><div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>System.out.println(&quot;*** injecting notification down&quot;);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>Notification notif = new Notification();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>notif.setType(NotificationType.CARD);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>notif.setState(State.DOWN);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>notif.setId(&quot;port1 card1&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>FactHandle notifHandle = ksession.insert(notif);</div>
</div><div><br></div><div><br></div></div><div><div>                        ksession.halt();</div><div>                        ksession.dispose()</div><div><br></div></div><div><br></div><div>I would expect the card down notification to cause the port to do down by the second rule above but it does not fire.</div>
<div><br></div><div>Here is output</div><div><br></div><div><div>  card1: Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b]</div><div>OBJECT ASSERTED value:Port [state=UP, name=port1, card=Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b]] factId: 1</div>
<div>OBJECT ASSERTED value:Port [state=UP, name=port2, card=Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b]] factId: 3</div><div>OBJECT ASSERTED value:Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b] factId: 5</div>
<div>  firing rules</div><div>3</div><div>*** injecting notification down</div><div>ACTIVATION CREATED rule:card going down activationId:card going down [6, 5] declarations: $name=port1 card1(5); $notif=org.plugtree.examples.model.Notification@4a9a7d(6); $card=Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b](5)</div>
<div>OBJECT ASSERTED value:org.plugtree.examples.model.Notification@4a9a7d factId: 6</div><div>BEFORE ACTIVATION FIRED rule:card going down activationId:card going down [6, 5] declarations: $name=port1 card1(5); $notif=org.plugtree.examples.model.Notification@4a9a7d(6); $card=Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b](5)</div>
<div>  got notification for card down Card [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b]</div><div>OBJECT MODIFIED value:Card [state=DOWN, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b] factId: 5</div>
<div>OBJECT RETRACTED value:org.plugtree.examples.model.Notification@4a9a7d factId: 6</div><div>AFTER ACTIVATION FIRED rule:card going down activationId:card going down [-1, 5] declarations: $name=port1 card1(5); $card=Card [state=DOWN, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b](5)</div>
<div><br></div></div><div><br></div><div><br></div><div>Is the second rule written incorrectly? or do i have a gap in my expectations of how the engine should work (or both)</div><div><br></div><div>Thanks in advance,</div>
<div><br></div><div>Joe.</div><div><br></div>