}
buses = new Bus[1];
buses[0] = new EcBus(this, firstBusNumber);
// Generic locos
DefaultDeviceGroup dg = DefaultDeviceGroup
.newDescriptionDeviceGroup(buses[0]);
new DescriptionDevice(dg);
dg = DefaultDeviceGroup.newPowerGroup(buses[0]);
new EcPowerDevice(dg);
dg = DefaultDeviceGroup.newGenericLocoGroup
(buses[0], EcGenericLocoDevice.class);
for (LocData loco : locData) {
EcGenericLocoDevice locoDevice
= new EcGenericLocoDevice(loco.getAddress());
String proto = "P";
int version = 0;
if (loco.getFormat().equals("MM1")) {
proto = "M";
version = 1;
} else if (loco.getFormat().equals("MM2")) {
proto = "M";
version = 2;
} else if (loco.getFormat().equals("DCC")) {
proto = "N";
version = 1;
}
try {
locoDevice.init(dg, proto, version, loco.getSpeedSteps(), 5);
} catch (CommandExecutionException e) {
log.fine("Unexpected problem while initilizing loco: "
+ e.getMessage());
}
}
dg.setImplicitCreationAllowed(true);
// Generic Accessory
dg = DefaultDeviceGroup.newGenericAccessoryGroup
(buses[0], EcGenericAccessoryDevice.class);
dg.setImplicitCreationAllowed(true);
return buses;
}