From: Pete C. <pet...@us...> - 2011-01-19 02:09:43
|
Update of /cvsroot/jmri/jmri/managers/configurexml In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv1793/src/jmri/managers/configurexml Modified Files: DefaultConditionalManagerXml.java Log Message: Implement trigger execution of action list on every state calculation in addition to current policy of execute only on change. Index: DefaultConditionalManagerXml.java =================================================================== RCS file: /cvsroot/jmri/jmri/managers/configurexml/DefaultConditionalManagerXml.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DefaultConditionalManagerXml.java 6 May 2010 00:44:08 -0000 1.8 --- DefaultConditionalManagerXml.java 19 Jan 2011 02:09:35 -0000 1.9 *************** *** 20,23 **** --- 20,24 ---- * * @author Dave Duchamp Copyright (c) 2007 + * @author Pete Cressman Copyright (C) 2009, 2011 * @version $Revision$ */ *************** *** 56,60 **** elem.setAttribute("antecedent", c.getAntecedentExpression()); elem.setAttribute("logicType", Integer.toString(c.getLogicType())); ! // save child state variables ArrayList <ConditionalVariable> variableList = c.getCopyOfStateVariables(); --- 57,67 ---- elem.setAttribute("antecedent", c.getAntecedentExpression()); elem.setAttribute("logicType", Integer.toString(c.getLogicType())); ! ! if (c.getTriggerOnChange()) { ! elem.setAttribute("triggerOnChange", "yes"); ! } else { ! elem.setAttribute("triggerOnChange", "no"); ! } ! // save child state variables ArrayList <ConditionalVariable> variableList = c.getCopyOfStateVariables(); *************** *** 305,308 **** --- 312,339 ---- } c.setAction(actionList); + + // 1/16/2011 - trigger for execution of the action list changed to execute each + // time state is computed. Formerly execution of the action list was done only + // when state changes. All conditionals are upgraded to this new policy. + // However, for conditionals with actions that toggle on change of state + // the old policy should be used. + boolean triggerOnChange = false; + if (conditionalList.get(i).getAttribute("triggerOnChange") != null) { + if ("yes".equals(conditionalList.get(i).getAttribute("triggerOnChange").getValue())) { + triggerOnChange = true; + } + } else { + /* Don't upgrade -Let old be as is + for (int k=0; k<actionList.size(); k++){ + ConditionalAction action = actionList.get(k); + if (action.getOption()==Conditional.ACTION_OPTION_ON_CHANGE){ + triggerOnChange = true; + break; + } + } + */ + triggerOnChange = true; + } + c.setTriggerOnChange(triggerOnChange); } else { log.error("createNewConditional failed for " + sysName + ", " +userName); |