public synchronized void add(DccLocoAddress locoAddress,boolean directionNormal){
  if (!contains(locoAddress)) {
    if (ConsistList.size() == 0) {
      byte command=NceBinaryCommand.LOCO_CMD_FWD_CONSIST_LEAD;
      if (!directionNormal) {
        command=NceBinaryCommand.LOCO_CMD_REV_CONSIST_LEAD;
      }
      addLocoToConsist(locoAddress.getNumber(),locoAddress.isLongAddress(),command);
      ConsistPosition.put(locoAddress,DccConsist.POSITION_LEAD);
    }
 else     if (ConsistList.size() == 1) {
      byte command=NceBinaryCommand.LOCO_CMD_FWD_CONSIST_REAR;
      if (!directionNormal) {
        command=NceBinaryCommand.LOCO_CMD_REV_CONSIST_REAR;
      }
      addLocoToConsist(locoAddress.getNumber(),locoAddress.isLongAddress(),command);
      ConsistPosition.put(locoAddress,DccConsist.POSITION_TRAIL);
    }
 else {
      byte command=NceBinaryCommand.LOCO_CMD_FWD_CONSIST_MID;
      if (!directionNormal) {
        command=NceBinaryCommand.LOCO_CMD_REV_CONSIST_MID;
      }
      addLocoToConsist(locoAddress.getNumber(),locoAddress.isLongAddress(),command);
      ConsistPosition.put(locoAddress,ConsistPosition.size());
    }
    ConsistList.add(locoAddress);
    ConsistDir.put(locoAddress,Boolean.valueOf(directionNormal));
  }
 else {
    log.error("Loco " + locoAddress + " is already part of this consist "+ getConsistAddress());
  }
}

public synchronized void add ( DccLocoAddress locoAddress , boolean directionNormal ) { if ( ! contains ( locoAddress ) ) { if ( ConsistList . size ( ) == 0 ) { byte command = NceBinaryCommand . LOCO_CMD_FWD_CONSIST_LEAD ; if ( ! directionNormal ) { command = NceBinaryCommand . LOCO_CMD_REV_CONSIST_LEAD ; } addLocoToConsist ( locoAddress . getNumber ( ) , locoAddress . isLongAddress ( ) , command ) ; ConsistPosition . put ( locoAddress , DccConsist . POSITION_LEAD ) ; } else if ( ConsistList . size ( ) == 1 ) { byte command = NceBinaryCommand . LOCO_CMD_FWD_CONSIST_REAR ; if ( ! directionNormal ) { command = NceBinaryCommand . LOCO_CMD_REV_CONSIST_REAR ; } addLocoToConsist ( locoAddress . getNumber ( ) , locoAddress . isLongAddress ( ) , command ) ; ConsistPosition . put ( locoAddress , DccConsist . POSITION_TRAIL ) ; } else { byte command = NceBinaryCommand . LOCO_CMD_FWD_CONSIST_MID ; if ( ! directionNormal ) { command = NceBinaryCommand . LOCO_CMD_REV_CONSIST_MID ; } addLocoToConsist ( locoAddress . getNumber ( ) , locoAddress . isLongAddress ( ) , command ) ; ConsistPosition . put ( locoAddress , ConsistPosition . size ( ) ) ; } ConsistList . add ( locoAddress ) ; ConsistDir . put ( locoAddress , Boolean . valueOf ( directionNormal ) ) ; } else { log . error ( "Loco " + locoAddress + " is already part of this consist " + getConsistAddress ( ) ) ; } }
add a locomotive to a consist
