@Override protected Sensor createNewSensor(String systemName,String userName){
  if (log.isDebugEnabled()) {
    log.debug("createNewSensor " + systemName + " "+ userName);
  }
  Sensor s;
  String sName=SerialAddress.normalizeSystemName(systemName);
  if (sName.equals("")) {
    log.error("Invalid Sensor system name - " + systemName);
    return null;
  }
  s=getBySystemName(sName);
  if (s != null) {
    log.error("Sensor with this name already exists - " + systemName);
    return null;
  }
  String altName=SerialAddress.convertSystemNameToAlternate(sName);
  s=getBySystemName(altName);
  if (s != null) {
    log.error("Sensor with name '" + systemName + "' already exists as '"+ altName+ "'");
    return null;
  }
  int bit=SerialAddress.getBitFromSystemName(sName);
  if ((bit <= 0) || (bit >= SENSORSPERNODE)) {
    log.error("Sensor bit number, " + Integer.toString(bit) + ", is outside the supported range, 1-"+ Integer.toString(SENSORSPERNODE - 1));
    return null;
  }
  if (userName == null) {
    s=new SerialSensor(sName);
  }
 else {
    s=new SerialSensor(sName,userName);
  }
  SerialNode node=SerialAddress.getNodeFromSystemName(sName);
  if (node == null) {
    log.warn("Sensor " + sName + " refers to an undefined Serial Node.");
    return s;
  }
  node.registerSensor(s,bit);
  if (log.isDebugEnabled()) {
    log.debug("register " + s.getSystemName() + " in node "+ node);
  }
  return s;
}

@ Override protected Sensor createNewSensor ( String systemName , String userName ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "createNewSensor " + systemName + " " + userName ) ; } Sensor s ; String sName = SerialAddress . normalizeSystemName ( systemName ) ; if ( sName . equals ( "" ) ) { log . error ( "Invalid Sensor system name - " + systemName ) ; return null ; } s = getBySystemName ( sName ) ; if ( s != null ) { log . error ( "Sensor with this name already exists - " + systemName ) ; return null ; } String altName = SerialAddress . convertSystemNameToAlternate ( sName ) ; s = getBySystemName ( altName ) ; if ( s != null ) { log . error ( "Sensor with name '" + systemName + "' already exists as '" + altName + "'" ) ; return null ; } int bit = SerialAddress . getBitFromSystemName ( sName ) ; if ( ( bit <= 0 ) || ( bit >= SENSORSPERNODE ) ) { log . error ( "Sensor bit number, " + Integer . toString ( bit ) + ", is outside the supported range, 1-" + Integer . toString ( SENSORSPERNODE - 1 ) ) ; return null ; } if ( userName == null ) { s = new SerialSensor ( sName ) ; } else { s = new SerialSensor ( sName , userName ) ; } SerialNode node = SerialAddress . getNodeFromSystemName ( sName ) ; if ( node == null ) { log . warn ( "Sensor " + sName + " refers to an undefined Serial Node." ) ; return s ; } node . registerSensor ( s , bit ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "register " + s . getSystemName ( ) + " in node " + node ) ; } return s ; }
create a new sensor if all checks are passed system name is normalized to ensure uniqueness .
