public Sensor createNewSensor(String systemName,String userName){
  Sensor s;
  String sName=AcelaAddress.normalizeSystemName(systemName);
  if (sName.equals("")) {
    log.error("Invalid Acela 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=AcelaAddress.convertSystemNameToAlternate(sName);
  s=getBySystemName(altName);
  if (s != null) {
    log.error("Sensor with name: '" + systemName + "' already exists as: '"+ altName+ "'");
    return null;
  }
  int bit=AcelaAddress.getBitFromSystemName(sName);
  if ((bit < 0) || (bit >= 1023)) {
    log.error("Sensor bit number: " + Integer.toString(bit) + ", is outside the supported range, 1-1024");
    return null;
  }
  if (userName == null) {
    s=new AcelaSensor(sName);
  }
 else {
    s=new AcelaSensor(sName,userName);
  }
  AcelaNode node=AcelaAddress.getNodeFromSystemName(sName,_memo);
  if (node == null) {
    log.warn("Sensor: " + sName + ", refers to an undefined Acela Node.");
    return s;
  }
  if (!node.hasActiveSensors) {
    int newnodeaddress;
    newnodeaddress=node.getNodeAddress();
    log.warn("We got the wrong node: " + newnodeaddress);
    return s;
  }
  node.registerSensor(s,bit);
  return s;
}

public Sensor createNewSensor ( String systemName , String userName ) { Sensor s ; String sName = AcelaAddress . normalizeSystemName ( systemName ) ; if ( sName . equals ( "" ) ) { log . error ( "Invalid Acela 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 = AcelaAddress . convertSystemNameToAlternate ( sName ) ; s = getBySystemName ( altName ) ; if ( s != null ) { log . error ( "Sensor with name: '" + systemName + "' already exists as: '" + altName + "'" ) ; return null ; } int bit = AcelaAddress . getBitFromSystemName ( sName ) ; if ( ( bit < 0 ) || ( bit >= 1023 ) ) { log . error ( "Sensor bit number: " + Integer . toString ( bit ) + ", is outside the supported range, 1-1024" ) ; return null ; } if ( userName == null ) { s = new AcelaSensor ( sName ) ; } else { s = new AcelaSensor ( sName , userName ) ; } AcelaNode node = AcelaAddress . getNodeFromSystemName ( sName , _memo ) ; if ( node == null ) { log . warn ( "Sensor: " + sName + ", refers to an undefined Acela Node." ) ; return s ; } if ( ! node . hasActiveSensors ) { int newnodeaddress ; newnodeaddress = node . getNodeAddress ( ) ; log . warn ( "We got the wrong node: " + newnodeaddress ) ; return s ; } node . registerSensor ( s , bit ) ; return s ; }
create a new sensor if all checks are passed system name is normalized to ensure uniqueness .
