Ok.<br>That&#39;s my code:<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">/************************************** Payment Complete **************************************/<br>
rule &quot;Pay complete&quot;<br>    salience 10<br>    no-loop true<br>when<br>    event : PaywayEvent(id == PaywayEventType.OPERATION_IN)<br>    paymentData : PaymentData(credit &gt;= saleImport)    <br>    transaction : CurrentTransaction (state == TransactionState.CHARGE_PRODUCT)    <br>
    eval (!paywayManager.isStopped())<br>then<br>    retract(event);<br>    <br>    updateDebt(languageManager, hmiManager,paymentData.getDebt());<br>    <a href="http://log.info">log.info</a>(&quot;Machine.drl&quot;,&quot;Charge complete. Stopping devices!. Debt is &quot;+paymentData.getDebt());<br>
    for(Enumeration&lt;String&gt; e = paywayManager.getPaywayNames(); e.hasMoreElements(); ){<br>        String payway = e.nextElement();<br>        if(paywayManager.getPayway(payway).isLoaded()<br>            &amp;&amp; !paywayManager.getPayway(payway).getPaywayApi().isStopped()) {<br>
            PaywayEvent paywayEvent = new PaywayEvent(PaywayEventType.STOP_PAYMENT_DEVICES);<br>            paywayEvent.setDevice(payway); <br>            insert(paywayEvent);<br>        }<br>    }        <br>end<br><br><br>
This is the stop rule of the device<br><br>/******************************************STOP PAYMENT DEVICES ****************************/<br>rule &quot;Stop EmTicket Device&quot;<br>    salience 10<br>    no-loop true<br>when<br>
    event : PaywayEvent(id == PaywayEventType.STOP_PAYMENT_DEVICES &amp;&amp; device == &quot;discountticket&quot;)<br>    transaction : CurrentTransaction (state == TransactionState.CHARGE_PRODUCT)    <br>    eval (!emTicket.isStopped())<br>
then<br>    retract(event);<br>    if (emTicket.stop()){<br>        electromechanical.disableTakeTicket();<br>        electromechanical.blinkingLedOff();<br>        emTicket.setState(EmTicketState.OUT_OF_SERVICE);<br>    }<br>
    else{<br>        <a href="http://log.info">log.info</a>(&quot;EmTicket&quot;,&quot;EmTicket cannot be stoped!&quot;);<br>    }<br>    <br>    insert (new PaywayEvent(PaywayEventType.OPERATION_IN));<br>end<br></blockquote>
<br><br>So, there are bidirectional calls between STOP_PAYMENT_DEVICES and OPERATION_IN (because emTicket can&#39;t be stopped, so an event should be fired soon)<br><br>While this 2 rules are firing the other, the hardware sends an DISCOUNT_TICKET_ACCEPTED, that updates the debt, and the state of EmTicket, so the in next STOP_PAYMENT_DEVICES emTicket will be stopped.<br>
<br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">rule &quot;Discount Ticket discarded when accepted&quot;<br>    salience 1000<br>    no-loop true<br>
when<br>    event : ElectromechanicalEvent (eventType == ElectromechanicalEventType.CONSUM_EVENT<br>    &amp;&amp; description == &quot;articleDiscarded&quot;)<br>    transaction : CurrentTransaction(state == TransactionState.CHARGE_PRODUCT)<br>
    eval (emTicket.getState() == EmTicketState.ARTICLE_TAKEN)<br>    paymentData : PaymentData()<br>then    <br>  lot of code here..<br>end<br></blockquote><br><br>The problem I&#39;m facing is that  rule &quot;Discount Ticket discarded when accepted&quot; is never fired (and has a lot more of salience than the other two)! The other two rules are in a constant bucle. The event of the discarded is sent via enginer.insertEvent() &amp;&amp; fireAllRules. Maybe insert command in drl files has more priority than facts invoked from java classes?<br>
 Thanks in advance!<br><br><br><br><br><br><br><br><br><br><br><div class="gmail_quote">2011/7/7 Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Sorry, but I become more confused with every re-read. I think the original code is required.<br><br>I think that this is nothing but a FSM. Generally, this sort of problem should be doable without resorting to salience (except for one or two low priority ones acting as the &quot;safety net&quot;).<br>
<font color="#888888">
<br>-W</font><div><div></div><div class="h5"><br><br><br><br><div class="gmail_quote">On 7 July 2011 16:35, jmolly <span dir="ltr">&lt;<a href="mailto:jmolly@gmail.com" target="_blank">jmolly@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello.<br>
I&#39;m facing some problems in drools with salience. (maybe I don&#39;t understand<br>
how it works)<br>
<br>
We have a rule that check if an import has been satisfied by the client. But<br>
we have a lot of pay methods so, when the import has been satisfied, we have<br>
to stop all the payment devices. If a payment device is in use, we can&#39;t<br>
stop it, so we send stop commands until device can stop.<br>
The problem is that if a device is making a pay process, and consumes an<br>
event, that event is never fired.<br>
<br>
Maybe I can explain better with code:<br>
<br>
<br>
rule &quot;Pay device stop&quot;<br>
Salience 10<br>
Try to stop the device and sends an OPERATION_IN event if can&#39;t stop<br>
(because there is a ticket inside)<br>
<br>
Machine rule<br>
rule &quot;Operation in received witch devices not stopped&quot;<br>
salience 10<br>
   Sent stop events to all devices<br>
<br>
Machine rule<br>
rule &quot;Operation in received with devices stopped&quot;<br>
salience 10<br>
    All ok. Finish operation<br>
<br>
<br>
rule &quot;Ticket data read&quot;<br>
salience 1000<br>
  updates the debt for the user and sends an OPERATION_IN<br>
<br>
The pay hardware, when is reading a ticket, sent a TICKET_DATA_READ<br>
this rule has salience 100 and should be fired inmediatly but Drools is<br>
entering all time in a bucle from Operation in received and Pay stop device.<br>
<br>
<br>
Can someone give a clue about what are we doing wrong?<br>
<br>
<br>
Sorry for the english. I can post the original code if needed.<br>
Thanks in advance<br>
<font color="#888888"><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Problem-with-salience-tp3148382p3148382.html" target="_blank">http://drools.46999.n3.nabble.com/Problem-with-salience-tp3148382p3148382.html</a><br>


Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>
</div></div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>