Search in sources :

Example 6 with SerialNode

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);
    }
}
Also used : SerialNode(jmri.jmrix.cmri.serial.SerialNode) Element(org.jdom2.Element)

Example 7 with SerialNode

use of jmri.jmrix.cmri.serial.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
        int type = selNode.getNodeType();
        if (type == SerialNode.SMINI) {
            nodeInfoText.setText("SMINI - 24 " + rb.getString("InputBitsAnd") + " 48 " + rb.getString("OutputBits"));
            numInputBits = 24;
            numOutputBits = 48;
        } else if (type == SerialNode.USIC_SUSIC) {
            int bitsPerCard = selNode.getNumBitsPerCard();
            int numInputCards = selNode.numInputCards();
            int numOutputCards = selNode.numOutputCards();
            numInputBits = bitsPerCard * numInputCards;
            numOutputBits = bitsPerCard * numOutputCards;
            nodeInfoText.setText("USIC_SUSIC - " + bitsPerCard + rb.getString("BitsPerCard") + ", " + numInputBits + " " + rb.getString("InputBitsAnd") + " " + numOutputBits + " " + rb.getString("OutputBits"));
        }
    // here insert code for new types of C/MRI nodes
    }
    // initialize for input or output assignments
    if (inputSelected) {
        numBits = numInputBits;
        assignmentPanel.setBorder(inputBorderTitled);
    } else {
        numBits = numOutputBits;
        assignmentPanel.setBorder(outputBorderTitled);
    }
    ((AssignmentTableModel) assignmentListModel).fireTableDataChanged();
}
Also used : SerialNode(jmri.jmrix.cmri.serial.SerialNode)

Aggregations

SerialNode (jmri.jmrix.cmri.serial.SerialNode)7 Element (org.jdom2.Element)4 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 CMRISystemConnectionMemo (jmri.jmrix.cmri.CMRISystemConnectionMemo)2 SerialTrafficController (jmri.jmrix.cmri.serial.SerialTrafficController)2