use of jmri.jmrix.acela.AcelaTrafficController in project JMRI by JMRI.
the class ConnectionConfigXml method unpackElement.
@Override
protected void unpackElement(Element shared, Element perNode) {
List<Element> l = shared.getChildren("node");
for (int i = 0; i < l.size(); i++) {
Element n = l.get(i);
int addr = Integer.parseInt(n.getAttributeValue("name"));
String nodetypestring = findParmValue(n, "nodetype");
int type = AcelaNode.moduleTypes.lastIndexOf(nodetypestring) / 2;
// create node (they register themselves)
AcelaNode node = new AcelaNode(addr, type, ((jmri.jmrix.acela.serialdriver.SerialDriverAdapter) adapter).getSystemConnectionMemo().getTrafficController());
log.info("Created a new Acela Node [" + addr + "] as a result of a configuration file of type: " + type);
if (type == AcelaNode.TB) {
for (int s = 0; s < 4; s++) {
String sensortype = findParmValue(n, "sensortype" + s);
String sensorpolarity = findParmValue(n, "sensorpolarity" + s);
int sensorthreshold = Integer.parseInt(findParmValue(n, "sensorthreshold" + s));
node.setSensorTypeString(s, sensortype);
node.setSensorPolarityString(s, sensorpolarity);
if (sensorthreshold < 0) {
sensorthreshold = 0;
}
if (sensorthreshold > 31) {
sensorthreshold = 31;
}
node.setSensorThreshold(s, sensorthreshold);
}
for (int o = 0; o < 4; o++) {
String outputwired = findParmValue(n, "outputwired" + o);
String outputinit = findParmValue(n, "outputinit" + o);
String outputtype = findParmValue(n, "outputtype" + o);
String outputlengths = findParmValue(n, "outputlength" + o);
// This can be removed in June 2010:
if (outputlengths == null) {
outputlengths = AcelaNode.outputLEN0;
}
int outputlength = Integer.parseInt(outputlengths);
node.setOutputWiredString(o, outputwired);
node.setOutputInitString(o, outputinit);
// This can be removed in June 2010:
if (outputtype == null) {
outputtype = AcelaNode.outputONOFF;
}
node.setOutputTypeString(o, outputtype);
if (outputlength < 0) {
outputlength = 0;
}
if (outputlength > 255) {
outputlength = 255;
}
node.setOutputLength(o, outputlength);
}
} else if (type == AcelaNode.D8) {
for (int o = 0; o < 8; o++) {
String outputwired = findParmValue(n, "outputwired" + o);
String outputinit = findParmValue(n, "outputinit" + o);
String outputtype = findParmValue(n, "outputtype" + o);
String outputlengths = findParmValue(n, "outputlength" + o);
// This can be removed in June 2010:
if (outputlengths == null) {
outputlengths = AcelaNode.outputLEN0;
}
int outputlength = Integer.parseInt(outputlengths);
node.setOutputWiredString(o, outputwired);
node.setOutputInitString(o, outputinit);
// This can be removed in June 2010:
if (outputtype == null) {
outputtype = AcelaNode.outputONOFF;
}
node.setOutputTypeString(o, outputtype);
if (outputlength < 0) {
outputlength = 0;
}
if (outputlength > 255) {
outputlength = 255;
}
node.setOutputLength(o, outputlength);
}
} else if (type == AcelaNode.WM) {
for (int s = 0; s < 8; s++) {
String sensortype = findParmValue(n, "sensortype" + s);
String sensorpolarity = findParmValue(n, "sensorpolarity" + s);
int sensorthreshold = Integer.parseInt(findParmValue(n, "sensorthreshold" + s));
node.setSensorTypeString(s, sensortype);
node.setSensorPolarityString(s, sensorpolarity);
if (sensorthreshold < 0) {
sensorthreshold = 0;
}
if (sensorthreshold > 31) {
sensorthreshold = 31;
}
node.setSensorThreshold(s, sensorthreshold);
}
} else if (type == AcelaNode.SM) {
for (int o = 0; o < 16; o++) {
String outputwired = findParmValue(n, "outputwired" + o);
// This can be removed in June 2010:
if (outputwired == null) {
outputwired = AcelaNode.outputNO;
}
String outputinit = findParmValue(n, "outputinit" + o);
String outputtype = findParmValue(n, "outputtype" + o);
String outputlengths = findParmValue(n, "outputlength" + o);
// This can be removed in June 2010:
if (outputlengths == null) {
outputlengths = AcelaNode.outputLEN0;
}
int outputlength = Integer.parseInt(outputlengths);
node.setOutputInitString(o, outputinit);
// This can be removed in June 2010:
if (outputtype == null) {
outputtype = AcelaNode.outputONOFF;
}
node.setOutputTypeString(o, outputtype);
if (outputlength < 0) {
outputlength = 0;
}
if (outputlength > 255) {
outputlength = 255;
}
node.setOutputLength(o, outputlength);
}
} else if (type == AcelaNode.SW) {
for (int o = 0; o < 16; o++) {
String outputwired = findParmValue(n, "outputwired" + o);
// This can be removed in June 2010:
if (outputwired == null) {
outputwired = AcelaNode.outputNO;
}
String outputinit = findParmValue(n, "outputinit" + o);
String outputtype = findParmValue(n, "outputtype" + o);
String outputlengths = findParmValue(n, "outputlength" + o);
// This can be removed in June 2010:
if (outputlengths == null) {
outputlengths = AcelaNode.outputLEN0;
}
int outputlength = Integer.parseInt(outputlengths);
node.setOutputInitString(o, outputinit);
// This can be removed in June 2010:
if (outputtype == null) {
outputtype = AcelaNode.outputONOFF;
}
node.setOutputTypeString(o, outputtype);
if (outputlength < 0) {
outputlength = 0;
}
if (outputlength > 255) {
outputlength = 255;
}
node.setOutputLength(o, outputlength);
}
} else if (type == AcelaNode.YM) {
for (int o = 0; o < 16; o++) {
String outputwired = findParmValue(n, "outputwired" + o);
// This can be removed in June 2010:
if (outputwired == null) {
outputwired = AcelaNode.outputNO;
}
String outputinit = findParmValue(n, "outputinit" + o);
String outputtype = findParmValue(n, "outputtype" + o);
String outputlengths = findParmValue(n, "outputlength" + o);
// This can be removed in June 2010:
if (outputlengths == null) {
outputlengths = AcelaNode.outputLEN0;
}
int outputlength = Integer.parseInt(outputlengths);
node.setOutputInitString(o, outputinit);
// This can be removed in June 2010:
if (outputtype == null) {
outputtype = AcelaNode.outputONOFF;
}
node.setOutputTypeString(o, outputtype);
if (outputlength < 0) {
outputlength = 0;
}
if (outputlength > 255) {
outputlength = 255;
}
node.setOutputLength(o, outputlength);
}
} else if (type == AcelaNode.SY) {
for (int s = 0; s < 16; s++) {
String sensortype = findParmValue(n, "sensortype" + s);
String sensorpolarity = findParmValue(n, "sensorpolarity" + s);
int sensorthreshold = Integer.parseInt(findParmValue(n, "sensorthreshold" + s));
node.setSensorTypeString(s, sensortype);
node.setSensorPolarityString(s, sensorpolarity);
if (sensorthreshold < 0) {
sensorthreshold = 0;
}
if (sensorthreshold > 31) {
sensorthreshold = 31;
}
node.setSensorThreshold(s, sensorthreshold);
}
}
// Do not poll for Acela network nodes
AcelaTrafficController.instance().setNeedToPollNodes(false);
// Trigger initialization of this Node to reflect these parameters
AcelaTrafficController.instance().initializeAcelaNode(node);
}
// Do not let the Acela network poll until we are really ready
((AcelaTrafficController) adapter).setReallyReadyToPoll(true);
}
use of jmri.jmrix.acela.AcelaTrafficController in project JMRI by JMRI.
the class SerialDriverAdapter method configure.
/**
* set up all of the other objects to operate with an serial command station
* connected to this port
*/
@Override
public void configure() {
// connect to the traffic controller
AcelaTrafficController control = new AcelaTrafficController();
control.connectPort(this);
this.getSystemConnectionMemo().setAcelaTrafficController(control);
this.getSystemConnectionMemo().configureManagers();
// connect to a packetizing traffic controller
// LnPacketizer packets = new LnPacketizer();
// packets.connectPort(this);
// do the common manager config
// configureManagers();
//now moved to the adapter memo
/*jmri.InstanceManager.setLightManager(new jmri.jmrix.acela.AcelaLightManager());
AcelaSensorManager s;
jmri.InstanceManager.setSensorManager(s = new jmri.jmrix.acela.AcelaSensorManager());
this.getSystemConnectionMemo().getTrafficController().setSensorManager(s);
AcelaTurnoutManager t;
jmri.InstanceManager.setTurnoutManager(t = new jmri.jmrix.acela.AcelaTurnoutManager());
this.getSystemConnectionMemo().getTrafficController().setTurnoutManager(t); */
// start operation
// packets.startThreads();
}
use of jmri.jmrix.acela.AcelaTrafficController in project JMRI by JMRI.
the class AcelaComponentFactoryTest method setUp.
// The minimal setup for log4J
@Before
public void setUp() {
apps.tests.Log4JFixture.setUp();
jmri.util.JUnitUtil.resetInstanceManager();
AcelaTrafficController tc = new AcelaTrafficControlScaffold();
memo = new AcelaSystemConnectionMemo(tc);
}
Aggregations