use of jmri.jmrix.cmri.serial.SerialNode in project JMRI by JMRI.
the class ConnectionConfigXml method extendElement.
/**
* Write out the SerialNode objects too
*
* @param e Element being extended
*/
@SuppressFBWarnings(value = "SBSC_USE_STRINGBUFFER_CONCATENATION")
// though it would be good to fix it if you're working in this area
@Override
protected void extendElement(Element e) {
SerialTrafficController tc = ((CMRISystemConnectionMemo) adapter.getSystemConnectionMemo()).getTrafficController();
SerialNode node = (SerialNode) tc.getNode(0);
int index = 1;
while (node != null) {
// add node as an element
Element n = new Element("node");
n.setAttribute("name", "" + node.getNodeAddress());
e.addContent(n);
// add parameters to the node as needed
n.addContent(makeParameter("nodetype", "" + node.getNodeType()));
n.addContent(makeParameter("bitspercard", "" + node.getNumBitsPerCard()));
n.addContent(makeParameter("transmissiondelay", "" + node.getTransmissionDelay()));
n.addContent(makeParameter("num2lsearchlights", "" + node.getNum2LSearchLights()));
n.addContent(makeParameter("pulsewidth", "" + node.getPulseWidth()));
String value = "";
for (int i = 0; i < node.getLocSearchLightBits().length; i++) {
value = value + Integer.toHexString(node.getLocSearchLightBits()[i] & 0xF);
}
n.addContent(makeParameter("locsearchlightbits", "" + value));
value = "";
for (int i = 0; i < node.getCardTypeLocation().length; i++) {
value = value + Integer.toHexString(node.getCardTypeLocation()[i] & 0xF);
}
n.addContent(makeParameter("cardtypelocation", "" + value));
// look for the next node
node = (SerialNode) tc.getNode(index);
index++;
}
}
use of jmri.jmrix.cmri.serial.SerialNode in project JMRI by JMRI.
the class NodeConfigFrame method addButtonActionPerformed.
/**
* Method to handle add button
*/
public void addButtonActionPerformed() {
// Check that a node with this address does not exist
int nodeAddress = readNodeAddress();
if (nodeAddress < 0) {
return;
}
// error if a SerialNode corresponding to this node address exists
if (_memo == null || _memo.getTrafficController() == null) {
// shouldn't happen
log.error("Not properly set up: _memo {}", _memo, new Exception("Traceback"));
}
curNode = (SerialNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress);
if (curNode != null) {
statusText1.setText(// NOI18N
rb.getString("Error1") + Integer.toString(nodeAddress) + // NOI18N
rb.getString("Error2"));
statusText1.setVisible(true);
errorInStatus1 = true;
resetNotes2();
return;
}
// get node information from window
if (!readReceiveDelay()) {
return;
}
if (!readPulseWidth()) {
return;
}
// check consistency of node information
if (!checkConsistency()) {
return;
}
// all ready, create the new node
curNode = new SerialNode(nodeAddress, nodeType, _memo.getTrafficController());
// configure the new node
setNodeParameters();
// register any orphan sensors that this node may have
if (_memo != null && _memo.getSensorManager() != null)
((SerialSensorManager) _memo.getSensorManager()).registerSensorsForNode(curNode);
// reset after succefully adding node
resetNotes();
changedNode = true;
// provide user feedback
statusText1.setText(// NOI18N
rb.getString("FeedBackAdd") + " " + Integer.toString(nodeAddress));
errorInStatus1 = true;
}
use of jmri.jmrix.cmri.serial.SerialNode in project JMRI by JMRI.
the class ListFrame method initializeNodes.
/**
* Method to initialize configured nodes and set up the node select combo
* box
*/
public void initializeNodes() {
String str = "";
// clear the arrays
for (int i = 0; i < 128; i++) {
configNodeAddresses[i] = -1;
configNodes[i] = null;
}
// get all configured nodes
SerialNode node = (SerialNode) _memo.getTrafficController().getNode(0);
int index = 1;
while (node != null) {
configNodes[numConfigNodes] = node;
configNodeAddresses[numConfigNodes] = node.getNodeAddress();
str = Integer.toString(configNodeAddresses[numConfigNodes]);
nodeSelBox.addItem(str);
if (index == 1) {
selNode = node;
selNodeNum = configNodeAddresses[numConfigNodes];
// to force first time initialization
selNodeID = "y";
}
numConfigNodes++;
// go to next node
node = (SerialNode) _memo.getTrafficController().getNode(index);
index++;
}
}
use of jmri.jmrix.cmri.serial.SerialNode 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"));
int type = Integer.parseInt(findParmValue(n, "nodetype"));
int bpc = Integer.parseInt(findParmValue(n, "bitspercard"));
int delay = Integer.parseInt(findParmValue(n, "transmissiondelay"));
int num2l = Integer.parseInt(findParmValue(n, "num2lsearchlights"));
int pulseWidth = 500;
if ((findParmValue(n, "pulsewidth")) != null) {
pulseWidth = Integer.parseInt(findParmValue(n, "pulsewidth"));
}
String slb = findParmValue(n, "locsearchlightbits");
String ctl = findParmValue(n, "cardtypelocation");
// create node (they register themselves)
SerialNode node = new SerialNode(addr, type, ((CMRISystemConnectionMemo) adapter.getSystemConnectionMemo()).getTrafficController());
node.setNumBitsPerCard(bpc);
node.setTransmissionDelay(delay);
node.setNum2LSearchLights(num2l);
node.setPulseWidth(pulseWidth);
for (int j = 0; j < slb.length(); j++) {
node.setLocSearchLightBits(j, (slb.charAt(j) - '0'));
}
for (int j = 0; j < ctl.length(); j++) {
node.setCardTypeLocation(j, (ctl.charAt(j) - '0'));
}
// Trigger initialization of this Node to reflect these parameters
((CMRISystemConnectionMemo) adapter.getSystemConnectionMemo()).getTrafficController().initializeSerialNode(node);
}
}
use of jmri.jmrix.cmri.serial.SerialNode in project JMRI by JMRI.
the class ConnectionConfigXml method extendElement.
/**
* Write out the SerialNode objects too
*
* @param e Element being extended
*/
@SuppressFBWarnings(value = "SBSC_USE_STRINGBUFFER_CONCATENATION")
// though it would be good to fix it if you're working in this area
@Override
protected void extendElement(Element e) {
SerialTrafficController tc = ((CMRISystemConnectionMemo) adapter.getSystemConnectionMemo()).getTrafficController();
SerialNode node = (SerialNode) tc.getNode(0);
int index = 1;
while (node != null) {
// add node as an element
Element n = new Element("node");
n.setAttribute("name", "" + node.getNodeAddress());
e.addContent(n);
// add parameters to the node as needed
n.addContent(makeParameter("nodetype", "" + node.getNodeType()));
n.addContent(makeParameter("bitspercard", "" + node.getNumBitsPerCard()));
n.addContent(makeParameter("transmissiondelay", "" + node.getTransmissionDelay()));
n.addContent(makeParameter("num2lsearchlights", "" + node.getNum2LSearchLights()));
n.addContent(makeParameter("pulsewidth", "" + node.getPulseWidth()));
String value = "";
for (int i = 0; i < node.getLocSearchLightBits().length; i++) {
value = value + Integer.toHexString(node.getLocSearchLightBits()[i] & 0xF);
}
n.addContent(makeParameter("locsearchlightbits", "" + value));
value = "";
for (int i = 0; i < node.getCardTypeLocation().length; i++) {
value = value + Integer.toHexString(node.getCardTypeLocation()[i] & 0xF);
}
n.addContent(makeParameter("cardtypelocation", "" + value));
// look for the next node
node = (SerialNode) tc.getNode(index);
index++;
}
}
Aggregations