/** * Method to create a new Light based on the system name Returns null if the system name is not in * a valid format or if the system name does not correspond to a configured C/MRI digital output * bit Assumes calling method has checked that a Light with this system name does not already * exist */ public Light createNewLight(String systemName, String userName) { Light lgt = null; // Validate the systemName if (SerialAddress.validSystemNameFormat(systemName, 'L')) { lgt = new SerialLight(systemName, userName); if (!SerialAddress.validSystemNameConfig(systemName, 'L')) { log.warn("Light system Name does not refer to configured hardware: " + systemName); } } else { log.error("Invalid Light system Name format: " + systemName); } return lgt; }
/** * Public method to set a SECSI Output bit Note: systemName is of format CNnnnBxxxx where "nnn" is * the serial node number (0 - 127) "xxxx' is the bit number within that node (1 thru number of * defined bits) state is 'true' for 0, 'false' for 1 The bit is transmitted to the hardware * immediately before the next poll packet is sent. */ public void setSerialOutput(String systemName, boolean state) { // get the node and bit numbers SerialNode node = SerialAddress.getNodeFromSystemName(systemName); if (node == null) { log.error("bad SerialNode specification in SerialOutput system name:" + systemName); return; } int bit = SerialAddress.getBitFromSystemName(systemName); if (bit == 0) { log.error("bad output bit specification in SerialOutput system name:" + systemName); return; } // set the bit node.setOutputBit(bit, state); }
/** * Set the current state of this Light This routine requests the hardware to change. If this is * really a change in state of this bit (tested in SerialNode), a Transmit packet will be sent * before this Node is next polled. */ protected void doNewState(int oldState, int newState) { SerialNode mNode = SerialAddress.getNodeFromSystemName(getSystemName()); if (mNode != null) { if (newState == ON) { mNode.setOutputBit(mBit, false); } else if (newState == OFF) { mNode.setOutputBit(mBit, true); } else { log.warn("illegal state requested for Light: " + getSystemName()); } } }
/** * Public method to convert system name to its alternate format * * <p>Returns a normalized system name if system name is valid and has a valid alternate * representation, else return "". */ public String convertSystemNameToAlternate(String systemName) { return (SerialAddress.convertSystemNameToAlternate(systemName)); }
/** * Public method to normalize a system name * * <p>Returns a normalized system name if system name has a valid format, else returns "". */ public String normalizeSystemName(String systemName) { return (SerialAddress.normalizeSystemName(systemName)); }
/** * Public method to validate system name for configuration returns 'true' if system name has a * valid meaning in current configuration, else returns 'false' */ public boolean validSystemNameConfig(String systemName) { return (SerialAddress.validSystemNameConfig(systemName, 'L')); }
/** * Public method to validate system name format returns 'true' if system name has a valid format, * else returns 'false' */ public boolean validSystemNameFormat(String systemName) { return (SerialAddress.validSystemNameFormat(systemName, 'L')); }
/** * Sets up system dependent instance variables and sets system independent instance variables to * default values Note: most instance variables are in AbstractLight.java */ private void initializeLight(String systemName) { // Extract the Bit from the name mBit = SerialAddress.getBitFromSystemName(systemName); // Set initial state setState(OFF); }