use of jmri.jmrix.maple.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) SerialTrafficController.instance().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) SerialTrafficController.instance().getNode(index);
index++;
}
}
use of jmri.jmrix.maple.SerialNode in project JMRI by JMRI.
the class ConnectionConfigXml method extendElement.
/**
* Write out the SerialNode objects too
*
* @param e Element being extended
*/
@Override
protected void extendElement(Element e) {
SerialNode node = (SerialNode) SerialTrafficController.instance().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("transmissiondelay", "" + InputBits.getTimeoutTime()));
n.addContent(makeParameter("inputbits", "" + InputBits.getNumInputBits()));
n.addContent(makeParameter("senddelay", "" + OutputBits.getSendDelay()));
n.addContent(makeParameter("outputbits", "" + OutputBits.getNumOutputBits()));
// n.addContent(makeParameter("pulsewidth", ""+node.getPulseWidth()));
// look for the next node
node = (SerialNode) SerialTrafficController.instance().getNode(index);
index++;
}
}
use of jmri.jmrix.maple.SerialNode in project JMRI by JMRI.
the class ListFrame method displayNodeInfo.
/**
* Method to handle selection of a Node for info display
*/
public void displayNodeInfo(String nodeID) {
if (!nodeID.equals(selNodeID)) {
// The selected node is changing - initialize it
int nAdd = Integer.parseInt(nodeID);
SerialNode s = null;
for (int k = 0; k < numConfigNodes; k++) {
if (nAdd == configNodeAddresses[k]) {
s = configNodes[k];
}
}
if (s == null) {
// serious trouble, log error and ignore
log.error("Cannot find Node " + nodeID + " in list of configured Nodes.");
return;
}
// have node, initialize for new node
selNodeID = nodeID;
selNode = s;
selNodeNum = nAdd;
// prepare the information line
numInputBits = InputBits.getNumInputBits();
numOutputBits = OutputBits.getNumOutputBits();
nodeInfoText.setText(" - " + numInputBits + " " + rb.getString("InputBitsAnd") + " " + numOutputBits + " " + rb.getString("OutputBits"));
}
// initialize for input or output assignments
if (inputSelected) {
numBits = numInputBits;
assignmentPanel.setBorder(inputBorderTitled);
} else {
numBits = numOutputBits;
assignmentPanel.setBorder(outputBorderTitled);
}
((AssignmentTableModel) assignmentListModel).fireTableDataChanged();
}
use of jmri.jmrix.maple.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;
}
// get a SerialNode corresponding to this node address if one exists
curNode = (SerialNode) SerialTrafficController.instance().getNodeFromAddress(nodeAddress);
if (curNode != null) {
statusText1.setText(rb.getString("Error1") + Integer.toString(nodeAddress) + rb.getString("Error2"));
statusText1.setVisible(true);
errorInStatus1 = true;
resetNotes2();
return;
}
// get node information from window
if (!readPollTimeout()) {
return;
}
if (!readSendDelay()) {
return;
}
// if ( !readPulseWidth() ) return;
if (!readNumInputBits()) {
return;
}
if (!readNumOutputBits()) {
return;
}
// all ready, create the new node
curNode = new SerialNode(nodeAddress, 0);
// configure the new node
setNodeParameters();
// // register any orphan sensors that this node may have
// SerialSensorManager.instance().registerSensorsForNode(curNode);
// reset after succefully adding node
resetNotes();
changedNode = true;
// provide user feedback
statusText1.setText(rb.getString("FeedBackAdd") + " " + Integer.toString(nodeAddress));
errorInStatus1 = true;
}
use of jmri.jmrix.maple.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 delay = Integer.parseInt(findParmValue(n, "transmissiondelay"));
int senddelay = Integer.parseInt(findParmValue(n, "senddelay"));
int numinput = Integer.parseInt(findParmValue(n, "inputbits"));
int numoutput = Integer.parseInt(findParmValue(n, "outputbits"));
// int pulseWidth = 500;
// if ((findParmValue(n,"pulsewidth")) != null) {
// pulseWidth = Integer.parseInt(findParmValue(n,"pulsewidth"));
// }
// create node (they register themselves)
SerialNode node = new SerialNode(addr, 0);
InputBits.setTimeoutTime(delay);
InputBits.setNumInputBits(numinput);
OutputBits.setSendDelay(senddelay);
OutputBits.setNumOutputBits(numoutput);
// node.setPulseWidth(pulseWidth);
// Trigger initialization of this Node to reflect these parameters
SerialTrafficController.instance().initializeSerialNode(node);
}
}
Aggregations