From: Ken C. <ke...@us...> - 2009-07-30 12:19:52
|
Update of /cvsroot/jmri/jmri/jmrix/powerline/cm11 In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26394/src/jmri/jmrix/powerline/cm11 Modified Files: SpecificSensorManager.java Log Message: Added sensor support for the 'all on/off' commands. Index: SpecificSensorManager.java =================================================================== RCS file: /cvsroot/jmri/jmri/jmrix/powerline/cm11/SpecificSensorManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SpecificSensorManager.java 27 Jul 2009 00:58:57 -0000 1.3 --- SpecificSensorManager.java 30 Jul 2009 12:19:43 -0000 1.4 *************** *** 6,10 **** --- 6,12 ---- import jmri.jmrix.powerline.X10Sequence; import jmri.jmrix.powerline.SerialReply; + import jmri.jmrix.powerline.SerialAddress; import jmri.jmrix.powerline.cm11.Constants; + import java.util.List; /** *************** *** 46,72 **** int dat = l.getElement(i) & 0xFF; if ((bits & 0x01) != 0) { newCmdCode = dat & 0x0f; ! if (newCmdCode != -1 && newHouseCode != null && newAddrCode > 0) { ! String sysName = systemLetter() + "S" + newHouseCode + newAddrCode; ! sensor = provideSensor(sysName); ! // see if sensor exists, comment out for production, I'm using it for testing ! // if (sensor == null) { ! // sensor = newSensor(sysName.toUpperCase(), null); ! // } ! if (sensor != null) { ! if (newCmdCode == X10Sequence.FUNCTION_ON) { ! try { ! sensor.setKnownState(Sensor.ACTIVE); ! } catch (jmri.JmriException e) { ! log.warn("Exception setting " + sysName + " sensor ACTIVE: " + e); ! } ! } ! if (newCmdCode == X10Sequence.FUNCTION_OFF) { ! try { ! sensor.setKnownState(Sensor.INACTIVE); ! } catch (jmri.JmriException e) { ! log.warn("Exception setting " + sysName + " sensor INACTIVE: " + e); ! } ! } } } --- 48,101 ---- int dat = l.getElement(i) & 0xFF; if ((bits & 0x01) != 0) { + newHouseCode = X10Sequence.houseValueToText(X10Sequence.decode((dat >> 4) & 0x0F)); newCmdCode = dat & 0x0f; ! if (newHouseCode != null && (newCmdCode == X10Sequence.FUNCTION_ALL_LIGHTS_OFF || newCmdCode == X10Sequence.FUNCTION_ALL_UNITS_OFF || newCmdCode == X10Sequence.FUNCTION_ALL_LIGHTS_ON)) { ! // some sort of 'global' command, process for all matching the house code ! List<String> sensors = getSystemNameList(); ! for (int ii = 0; ii < sensors.size(); ii++) { ! String sName = sensors.get(ii); ! if (newHouseCode.compareTo(SerialAddress.houseCodeFromSystemName(sName)) == 0) { ! sensor = provideSensor(sName); ! if (sensor != null) { ! try { ! if (newCmdCode == X10Sequence.FUNCTION_ALL_LIGHTS_OFF || newCmdCode == X10Sequence.FUNCTION_ALL_UNITS_OFF) { ! sensor.setKnownState(Sensor.INACTIVE); ! } else { ! sensor.setKnownState(Sensor.ACTIVE); ! } ! } catch (jmri.JmriException e) { ! if (newCmdCode == X10Sequence.FUNCTION_ALL_LIGHTS_OFF || newCmdCode == X10Sequence.FUNCTION_ALL_UNITS_OFF) { ! log.error("Exception setting " + sName + " sensor INACTIVE: " + e); ! } else { ! log.error("Exception setting " + sName + " sensor ACTIVE: " + e); ! } ! } ! } ! } ! } ! } else { ! if (newCmdCode != -1 && newHouseCode != null && newAddrCode > 0) { ! String sysName = systemLetter() + "S" + newHouseCode + newAddrCode; ! sensor = provideSensor(sysName); ! // see if sensor exists, comment out for production, I'm using it for testing ! // if (sensor == null) { ! // sensor = newSensor(sysName.toUpperCase(), null); ! // } ! if (sensor != null) { ! if (newCmdCode == X10Sequence.FUNCTION_ON || newCmdCode == X10Sequence.FUNCTION_BRIGHT || newCmdCode == X10Sequence.FUNCTION_STATUS_ON) { ! try { ! sensor.setKnownState(Sensor.ACTIVE); ! } catch (jmri.JmriException e) { ! log.error("Exception setting " + sysName + " sensor ACTIVE: " + e); ! } ! } ! if (newCmdCode == X10Sequence.FUNCTION_OFF || newCmdCode == X10Sequence.FUNCTION_DIM || newCmdCode == X10Sequence.FUNCTION_STATUS_OFF) { ! try { ! sensor.setKnownState(Sensor.INACTIVE); ! } catch (jmri.JmriException e) { ! log.error("Exception setting " + sysName + " sensor INACTIVE: " + e); ! } ! } ! } } } |