From: Dave D. <djd...@us...> - 2004-05-29 01:39:41
|
Update of /cvsroot/jmri/jmri/jmrix/cmri/serial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32545 Modified Files: SerialNode.java Log Message: Added new routine to clear searchlight bits New routine to clear searchlight bits ---------------------------------------------------------------------- Index: SerialNode.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrix/cmri/serial/SerialNode.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** SerialNode.java 28 May 2004 02:30:44 -0000 1.15 --- SerialNode.java 29 May 2004 01:39:33 -0000 1.16 *************** *** 456,460 **** // validate that bits are not already set if ( (locSearchLightBits[bit] != 0) || (locSearchLightBits[bit+1] != 0) ) { ! log.warn("bit number for SMINI Searchlights bits already set: "+ Integer.toString(bit)); return; --- 456,460 ---- // validate that bits are not already set if ( (locSearchLightBits[bit] != 0) || (locSearchLightBits[bit+1] != 0) ) { ! log.error("bit number for SMINI Searchlights bits already set: "+ Integer.toString(bit)); return; *************** *** 466,469 **** --- 466,501 ---- } + /** + * Public Method to clear location of SearchLightBits (SMINI only) + * bit - bitNumber of the low bit of an oscillating search light bit pair + * Notes: Bits are numbered from 0 + * Two bits are cleared by each call - bit and bit + 1. + * If either bit is already clear, an error is logged and no + * bits are set. + */ + public void clear2LeadSearchLight(int bit) { + // check for SMINI + // if other types of CMRI nodes allow oscillating search lights, modify this method + if (nodeType!=SMINI) { + log.error("Invalid setting of Searchlights bits - not SMINI node"); + return; + } + // validate bit number range + if ( (bit<0) || (bit>46) ) { + log.error("Invalid bit number when setting SMINI Searchlights bits: "+ + Integer.toString(bit)); + return; + } + // validate that bits are not already clear + if ( (locSearchLightBits[bit] != 1) || (locSearchLightBits[bit+1] != 1) ) { + log.error("bit number for SMINI Searchlights bits already clear: "+ + Integer.toString(bit)); + return; + } + // set the bits + locSearchLightBits[bit] = 0; + locSearchLightBits[bit+1] = 0; + num2LSearchLights --; + } /** |