Search in sources :

Example 6 with AcelaNode

use of jmri.jmrix.acela.AcelaNode in project JMRI by JMRI.

the class SignalHeadTableAction method okPressed.

// @TODO We could add a check to make sure that the user has entered a turnout into a turnout field if it has been presented.
// Done for: Acela
// For now only an error is recorded in the Console window
void okPressed(ActionEvent e) {
    if (!checkUserName(userName.getText())) {
        return;
    }
    SignalHead s;
    try {
        if (se8c4Aspect.equals(typeBox.getSelectedItem())) {
            handleSE8cOkPressed();
        } else if (acelaAspect.equals(typeBox.getSelectedItem())) {
            String inputusername = userName.getText();
            String inputsysname = ato1.getText().toUpperCase();
            int headnumber;
            if (inputsysname.length() == 0) {
                JOptionPane.showMessageDialog(addFrame, Bundle.getMessage("acelaWarning"));
                log.warn("must supply a signalhead number (i.e. AH23)");
                return;
            }
            if (inputsysname.length() > 2) {
                if (inputsysname.substring(0, 2).equals("AH")) {
                    headnumber = Integer.parseInt(inputsysname.substring(2, inputsysname.length()));
                } else if (checkIntegerOnly(inputsysname)) {
                    headnumber = Integer.parseInt(inputsysname);
                } else {
                    String msg = Bundle.getMessage("acelaSkippingCreation", new Object[] { ato1.getText() });
                    JOptionPane.showMessageDialog(addFrame, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
                    return;
                }
            } else {
                headnumber = Integer.parseInt(inputsysname);
            }
            if (checkBeforeCreating("AH" + headnumber)) {
                //if (jmri.jmrix.acela.status()) { // check for an active Acela connection status
                try {
                    if (inputusername.length() == 0) {
                        s = new jmri.jmrix.acela.AcelaSignalHead("AH" + headnumber, jmri.InstanceManager.getDefault(jmri.jmrix.acela.AcelaSystemConnectionMemo.class));
                    } else {
                        s = new jmri.jmrix.acela.AcelaSignalHead("AH" + headnumber, inputusername, jmri.InstanceManager.getDefault(jmri.jmrix.acela.AcelaSystemConnectionMemo.class));
                    }
                    InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
                } catch (java.lang.NullPointerException ex) {
                    JOptionPane.showMessageDialog(addFrame, Bundle.getMessage("SystemNotActiveWarning", "Acela"));
                    log.warn("No active Acela connection to create Signal Head");
                    return;
                }
            }
            int st = signalheadTypeFromBox(stBox);
            // This bit returns null I think, will need to check though
            AcelaNode sh = AcelaAddress.getNodeFromSystemName("AH" + headnumber, jmri.InstanceManager.getDefault(jmri.jmrix.acela.AcelaSystemConnectionMemo.class));
            switch(st) {
                case 1:
                    sh.setOutputSignalHeadType(headnumber, AcelaNode.DOUBLE);
                    break;
                case 2:
                    sh.setOutputSignalHeadType(headnumber, AcelaNode.TRIPLE);
                    break;
                case 3:
                    sh.setOutputSignalHeadType(headnumber, AcelaNode.BPOLAR);
                    break;
                case 4:
                    sh.setOutputSignalHeadType(headnumber, AcelaNode.WIGWAG);
                    break;
                default:
                    log.warn("Unexpected Acela Aspect type: " + st);
                    sh.setOutputSignalHeadType(headnumber, AcelaNode.UKNOWN);
                    // default to triple
                    break;
            }
        } else if (grapevine.equals(typeBox.getSelectedItem())) {
            // the turnout field must hold a GH system name
            if (systemName.getText().length() == 0) {
                // TODO Add user dialog
                log.warn("must supply a signalhead number (i.e. GH23)");
                return;
            }
            String inputsysname = systemName.getText().toUpperCase();
            if (!inputsysname.substring(0, 2).equals("GH")) {
                log.warn("skipping creation of signal, " + inputsysname + " does not start with GH");
                String msg = Bundle.getMessage("GrapevineSkippingCreation", new Object[] { inputsysname });
                JOptionPane.showMessageDialog(addFrame, msg, Bundle.getMessage("WarningTitle"), JOptionPane.ERROR_MESSAGE);
                return;
            }
            if (checkBeforeCreating(inputsysname)) {
                s = new jmri.jmrix.grapevine.SerialSignalHead(inputsysname, userName.getText());
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (quadOutput.equals(typeBox.getSelectedItem())) {
            if (checkBeforeCreating(systemName.getText())) {
                Turnout t1 = getTurnoutFromPanel(to1, "SignalHead:" + systemName.getText() + ":Green");
                Turnout t2 = getTurnoutFromPanel(to2, "SignalHead:" + systemName.getText() + ":Yellow");
                Turnout t3 = getTurnoutFromPanel(to3, "SignalHead:" + systemName.getText() + ":Red");
                Turnout t4 = getTurnoutFromPanel(to4, "SignalHead:" + systemName.getText() + ":Lunar");
                if (t1 == null) {
                    addTurnoutMessage(v1Border.getTitle(), to1.getDisplayName());
                }
                if (t2 == null) {
                    addTurnoutMessage(v2Border.getTitle(), to2.getDisplayName());
                }
                if (t3 == null) {
                    addTurnoutMessage(v3Border.getTitle(), to3.getDisplayName());
                }
                if (t4 == null) {
                    addTurnoutMessage(v4Border.getTitle(), to4.getDisplayName());
                }
                if (t4 == null || t3 == null || t2 == null || t1 == null) {
                    log.warn("skipping creation of signal " + systemName.getText() + " due to error");
                    return;
                }
                s = new jmri.implementation.QuadOutputSignalHead(systemName.getText(), userName.getText(), nbhm.getNamedBeanHandle(to1.getDisplayName(), t1), nbhm.getNamedBeanHandle(to2.getDisplayName(), t2), nbhm.getNamedBeanHandle(to3.getDisplayName(), t3), nbhm.getNamedBeanHandle(to4.getDisplayName(), t4));
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (tripleTurnout.equals(typeBox.getSelectedItem())) {
            if (checkBeforeCreating(systemName.getText())) {
                Turnout t1 = getTurnoutFromPanel(to1, "SignalHead:" + systemName.getText() + ":Green");
                Turnout t2 = getTurnoutFromPanel(to2, "SignalHead:" + systemName.getText() + ":Yellow");
                Turnout t3 = getTurnoutFromPanel(to3, "SignalHead:" + systemName.getText() + ":Red");
                if (t1 == null) {
                    addTurnoutMessage(v1Border.getTitle(), to1.getDisplayName());
                }
                if (t2 == null) {
                    addTurnoutMessage(v2Border.getTitle(), to2.getDisplayName());
                }
                if (t3 == null) {
                    addTurnoutMessage(v3Border.getTitle(), to3.getDisplayName());
                }
                if (t3 == null || t2 == null || t1 == null) {
                    log.warn("skipping creation of signal " + systemName.getText() + " due to error");
                    return;
                }
                s = new jmri.implementation.TripleTurnoutSignalHead(systemName.getText(), userName.getText(), nbhm.getNamedBeanHandle(to1.getDisplayName(), t1), nbhm.getNamedBeanHandle(to2.getDisplayName(), t2), nbhm.getNamedBeanHandle(to3.getDisplayName(), t3));
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (tripleOutput.equals(typeBox.getSelectedItem())) {
            if (checkBeforeCreating(systemName.getText())) {
                Turnout t1 = getTurnoutFromPanel(to1, "SignalHead:" + systemName.getText() + ":Green");
                Turnout t2 = getTurnoutFromPanel(to2, "SignalHead:" + systemName.getText() + ":Blue");
                Turnout t3 = getTurnoutFromPanel(to3, "SignalHead:" + systemName.getText() + ":Red");
                if (t1 == null) {
                    addTurnoutMessage(v1Border.getTitle(), to1.getDisplayName());
                }
                if (t2 == null) {
                    addTurnoutMessage(v2Border.getTitle(), to2.getDisplayName());
                }
                if (t3 == null) {
                    addTurnoutMessage(v3Border.getTitle(), to3.getDisplayName());
                }
                if (t3 == null || t2 == null || t1 == null) {
                    log.warn("skipping creation of signal " + systemName.getText() + " due to error");
                    return;
                }
                s = new jmri.implementation.TripleOutputSignalHead(systemName.getText(), userName.getText(), nbhm.getNamedBeanHandle(to1.getDisplayName(), t1), nbhm.getNamedBeanHandle(to2.getDisplayName(), t2), nbhm.getNamedBeanHandle(to3.getDisplayName(), t3));
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (doubleTurnout.equals(typeBox.getSelectedItem())) {
            if (checkBeforeCreating(systemName.getText())) {
                Turnout t1 = getTurnoutFromPanel(to1, "SignalHead:" + systemName.getText() + ":Green");
                Turnout t2 = getTurnoutFromPanel(to2, "SignalHead:" + systemName.getText() + ":Red");
                if (t1 == null) {
                    addTurnoutMessage(v1Border.getTitle(), to1.getDisplayName());
                }
                if (t2 == null) {
                    addTurnoutMessage(v2Border.getTitle(), to2.getDisplayName());
                }
                if (t2 == null || t1 == null) {
                    log.warn("skipping creation of signal " + systemName.getText() + " due to error");
                    return;
                }
                s = new jmri.implementation.DoubleTurnoutSignalHead(systemName.getText(), userName.getText(), nbhm.getNamedBeanHandle(to1.getDisplayName(), t1), nbhm.getNamedBeanHandle(to2.getDisplayName(), t2));
                s.setUserName(userName.getText());
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (singleTurnout.equals(typeBox.getSelectedItem())) {
            if (checkBeforeCreating(systemName.getText())) {
                Turnout t1 = getTurnoutFromPanel(to1, "SignalHead:" + systemName.getText() + ":" + (String) s2aBox.getSelectedItem() + ":" + (String) s3aBox.getSelectedItem());
                int on = signalStateFromBox(s2aBox);
                int off = signalStateFromBox(s3aBox);
                if (t1 == null) {
                    addTurnoutMessage(v1Border.getTitle(), to1.getDisplayName());
                }
                if (t1 == null) {
                    log.warn("skipping creation of signal " + systemName.getText() + " due to error");
                    return;
                }
                s = new jmri.implementation.SingleTurnoutSignalHead(systemName.getText(), userName.getText(), nbhm.getNamedBeanHandle(t1.getDisplayName(), t1), on, off);
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (virtualHead.equals(typeBox.getSelectedItem())) {
            if (checkBeforeCreating(systemName.getText())) {
                s = new jmri.implementation.VirtualSignalHead(systemName.getText(), userName.getText());
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (lsDec.equals(typeBox.getSelectedItem())) {
            // LDT LS-DEC
            if (checkBeforeCreating(systemName.getText())) {
                Turnout t1 = getTurnoutFromPanel(to1, "SignalHead:" + systemName.getText() + ":Green");
                Turnout t2 = getTurnoutFromPanel(to2, "SignalHead:" + systemName.getText() + ":Yellow");
                Turnout t3 = getTurnoutFromPanel(to3, "SignalHead:" + systemName.getText() + ":Red");
                Turnout t4 = getTurnoutFromPanel(to4, "SignalHead:" + systemName.getText() + ":FlashGreen");
                Turnout t5 = getTurnoutFromPanel(to5, "SignalHead:" + systemName.getText() + ":FlashYellow");
                Turnout t6 = getTurnoutFromPanel(to6, "SignalHead:" + systemName.getText() + ":FlashRed");
                Turnout t7 = getTurnoutFromPanel(to7, "SignalHead:" + systemName.getText() + ":Dark");
                int s1 = turnoutStateFromBox(s1Box);
                int s2 = turnoutStateFromBox(s2Box);
                int s3 = turnoutStateFromBox(s3Box);
                int s4 = turnoutStateFromBox(s4Box);
                int s5 = turnoutStateFromBox(s5Box);
                int s6 = turnoutStateFromBox(s6Box);
                int s7 = turnoutStateFromBox(s7Box);
                if (t1 == null) {
                    addTurnoutMessage(v1Border.getTitle(), to1.getDisplayName());
                }
                if (t2 == null) {
                    addTurnoutMessage(v2Border.getTitle(), to2.getDisplayName());
                }
                if (t3 == null) {
                    addTurnoutMessage(v3Border.getTitle(), to3.getDisplayName());
                }
                if (t4 == null) {
                    addTurnoutMessage(v4Border.getTitle(), to4.getDisplayName());
                }
                if (t5 == null) {
                    addTurnoutMessage(v5Border.getTitle(), to5.getDisplayName());
                }
                if (t6 == null) {
                    addTurnoutMessage(v6Border.getTitle(), to6.getDisplayName());
                }
                if (t7 == null) {
                    addTurnoutMessage(v7Border.getTitle(), to7.getDisplayName());
                }
                if (t7 == null || t6 == null || t5 == null || t4 == null || t3 == null || t2 == null || t1 == null) {
                    log.warn("skipping creation of signal " + systemName.getText() + " due to error");
                    return;
                }
                s = new jmri.implementation.LsDecSignalHead(systemName.getText(), nbhm.getNamedBeanHandle(t1.getDisplayName(), t1), s1, nbhm.getNamedBeanHandle(t2.getDisplayName(), t2), s2, nbhm.getNamedBeanHandle(t3.getDisplayName(), t3), s3, nbhm.getNamedBeanHandle(t4.getDisplayName(), t4), s4, nbhm.getNamedBeanHandle(t5.getDisplayName(), t5), s5, nbhm.getNamedBeanHandle(t6.getDisplayName(), t6), s6, nbhm.getNamedBeanHandle(t7.getDisplayName(), t7), s7);
                s.setUserName(userName.getText());
                InstanceManager.getDefault(jmri.SignalHeadManager.class).register(s);
            }
        } else if (dccSignalDecoder.equals(typeBox.getSelectedItem())) {
            handleDCCOkPressed();
        } else if (mergSignalDriver.equals(typeBox.getSelectedItem())) {
            handleMergSignalDriverOkPressed();
        } else {
            log.error("Unexpected type: " + typeBox.getSelectedItem());
        }
    } catch (NumberFormatException ex) {
        handleCreateException(ex, systemName.getText());
        // without creating
        return;
    }
}
Also used : TripleTurnoutSignalHead(jmri.implementation.TripleTurnoutSignalHead) QuadOutputSignalHead(jmri.implementation.QuadOutputSignalHead) DccSignalHead(jmri.implementation.DccSignalHead) DoubleTurnoutSignalHead(jmri.implementation.DoubleTurnoutSignalHead) TripleTurnoutSignalHead(jmri.implementation.TripleTurnoutSignalHead) SignalHead(jmri.SignalHead) SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) TripleOutputSignalHead(jmri.implementation.TripleOutputSignalHead) AcelaNode(jmri.jmrix.acela.AcelaNode) TripleOutputSignalHead(jmri.implementation.TripleOutputSignalHead) SingleTurnoutSignalHead(jmri.implementation.SingleTurnoutSignalHead) QuadOutputSignalHead(jmri.implementation.QuadOutputSignalHead) DoubleTurnoutSignalHead(jmri.implementation.DoubleTurnoutSignalHead) Turnout(jmri.Turnout)

Example 7 with AcelaNode

use of jmri.jmrix.acela.AcelaNode in project JMRI by JMRI.

the class NodeConfigFrame method cancelButtonActionPerformed.

/**
     * Method to handle cancel button
     */
@SuppressFBWarnings(value = "SBSC_USE_STRINGBUFFER_CONCATENATION")
public // though it would be good to fix it if you're working in this area
void cancelButtonActionPerformed() {
    // Reset 
    editMode = false;
    curNode = null;
    // lookup the nodes
    String nodesstring = "";
    int tempnumnodes = _memo.getTrafficController().getNumNodes();
    for (int i = 0; i < tempnumnodes; i++) {
        AcelaNode tempnode;
        tempnode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(i);
        nodesstring = nodesstring + " " + tempnode.getNodeTypeString();
    }
    thenodesStaticC.setText(nodesstring);
    // Find Acela Node address
    nodeAddress = readNodeAddress();
    if (nodeAddress < 0) {
        return;
    }
    // get the AcelaNode corresponding to this node address
    curNode = (AcelaNode) _memo.getTrafficController().getNodeFromAddress(nodeAddress);
    if (curNode == null) {
        statusText1.setText(rb.getString("Error4"));
        statusText1.setVisible(true);
        errorInStatus1 = true;
        resetNotes2();
        return;
    }
    // Set up static node address
    nodeAddrStatic.setText(Integer.toString(nodeAddress));
    nodeAddrBox.setVisible(true);
    nodeAddrField.setVisible(false);
    nodeAddrStatic.setVisible(false);
    // get information for this node and set up combo box
    nodeType = curNode.getNodeType();
    nodeTypeBox.setSelectedIndex(nodeType);
    nodeTypeBox.setVisible(false);
    nodeTypeStatic.setText(AcelaNode.getModuleNames()[nodeType]);
    nodeTypeStatic.setVisible(true);
    // get information for this node if it is an output node
    int numoutputbits = curNode.getNumOutputBitsPerCard();
    if (numoutputbits > 0) {
        // set up output types
        for (int o = 0; o < numoutputbits; o++) {
            if (curNode.getOutputInit(o) == 0) {
                initialState[o] = rb.getString("InitialStateOff");
            } else {
                // if (curNode.getOutputInit(o) == 1) {
                initialState[o] = rb.getString("InitialStateOn");
            }
            if (curNode.getOutputWired(o) == 0) {
                outputWired[o] = rb.getString("OutputWiredNO");
            } else {
                // if (curNode.getOutputWired(o) == 1) {
                outputWired[o] = rb.getString("OutputWiredNC");
            }
            if (curNode.getOutputType(o) == 0) {
                outputType[o] = rb.getString("OutputTypeONOFF");
            } else {
                if (curNode.getOutputType(o) == 1) {
                    outputType[o] = rb.getString("OutputTypePULSE");
                } else {
                    // if (curNode.getOutputType(o) == 2) {
                    outputType[o] = rb.getString("OutputTypeBLINK");
                }
            }
            outputLength[o] = String.valueOf(curNode.getOutputLength(o));
        }
    }
    // get information for this node if it is a sensor node
    int numsensorbits = curNode.getNumSensorBitsPerCard();
    if (numsensorbits > 0) {
        // set up sensor types
        for (int i = 0; i < numsensorbits; i++) {
            if (curNode.getSensorType(i) == 0) {
                filterType[i] = rb.getString("FilterTypeNoise");
            } else if (curNode.getSensorType(i) == 1) {
                filterType[i] = rb.getString("FilterTypeDebounce");
            } else if (curNode.getSensorType(i) == 2) {
                filterType[i] = rb.getString("FilterTypeCarGap");
            } else {
                filterType[i] = rb.getString("FilterTypeDirtyTrack");
            }
            if (curNode.getSensorPolarity(i) == 0) {
                filterPolarity[i] = rb.getString("FilterNormalPolarity");
            } else {
                filterPolarity[i] = rb.getString("FilterInversePolarity");
            }
            filterThreshold[i] = String.valueOf(curNode.getSensorThreshold(i));
        }
    }
    // Switch buttons
    editMode = false;
    addButton.setVisible(true);
    editButton.setVisible(true);
    deleteButton.setVisible(true);
    doneButton.setVisible(true);
    updateButton.setVisible(false);
    cancelButton.setVisible(false);
    // Switch to edit notes
    statusText1.setText(infoStatus1);
    statusText2.setText(infoStatus2);
    statusText3.setText(infoStatus3);
    d8outputConfigModel.setEditMode(false);
    swoutputConfigModel.setEditMode(false);
    ymoutputConfigModel.setEditMode(false);
    TBoutputConfigModel.setEditMode(false);
    TBsensorConfigModel.setEditMode(false);
    smoutputConfigModel.setEditMode(false);
    wmsensorConfigModel.setEditMode(false);
    sysensorConfigModel.setEditMode(false);
    contentPane.repaint();
}
Also used : AcelaNode(jmri.jmrix.acela.AcelaNode) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 8 with AcelaNode

use of jmri.jmrix.acela.AcelaNode 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) {
    AcelaNode node = (AcelaNode) AcelaTrafficController.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("nodetype", "" + node.getNodeTypeString()));
        if (node.getNodeType() == AcelaNode.TB) {
            for (int s = 0; s < 4; s++) {
                n.addContent(makeParameter("sensortype" + s, "" + node.getSensorTypeString(s)));
                n.addContent(makeParameter("sensorpolarity" + s, "" + node.getSensorPolarityString(s)));
                n.addContent(makeParameter("sensorthreshold" + s, "" + node.getSensorThreshold(s)));
            }
            for (int o = 0; o < 4; o++) {
                n.addContent(makeParameter("outputwired" + o, "" + node.getOutputWiredString(o)));
                n.addContent(makeParameter("outputinit" + o, "" + node.getOutputInitString(o)));
                n.addContent(makeParameter("outputtype" + o, "" + node.getOutputTypeString(o)));
                n.addContent(makeParameter("outputlength" + o, "" + node.getOutputLength(o)));
            }
        } else if (node.getNodeType() == AcelaNode.D8) {
            for (int o = 0; o < 8; o++) {
                n.addContent(makeParameter("outputwired" + o, "" + node.getOutputWiredString(o)));
                n.addContent(makeParameter("outputinit" + o, "" + node.getOutputInitString(o)));
                n.addContent(makeParameter("outputtype" + o, "" + node.getOutputTypeString(o)));
                n.addContent(makeParameter("outputlength" + o, "" + node.getOutputLength(o)));
            }
        } else if (node.getNodeType() == AcelaNode.WM) {
            for (int s = 0; s < 8; s++) {
                n.addContent(makeParameter("sensortype" + s, "" + node.getSensorTypeString(s)));
                n.addContent(makeParameter("sensorpolarity" + s, "" + node.getSensorPolarityString(s)));
                n.addContent(makeParameter("sensorthreshold" + s, "" + node.getSensorThreshold(s)));
            }
        } else if (node.getNodeType() == AcelaNode.SM) {
            for (int o = 0; o < 16; o++) {
                n.addContent(makeParameter("outputwired" + o, "" + node.getOutputWiredString(o)));
                n.addContent(makeParameter("outputinit" + o, "" + node.getOutputInitString(o)));
                n.addContent(makeParameter("outputtype" + o, "" + node.getOutputTypeString(o)));
                n.addContent(makeParameter("outputlength" + o, "" + node.getOutputLength(o)));
            }
        } else if (node.getNodeType() == AcelaNode.SW) {
            for (int o = 0; o < 16; o++) {
                n.addContent(makeParameter("outputwired" + o, "" + node.getOutputWiredString(o)));
                n.addContent(makeParameter("outputinit" + o, "" + node.getOutputInitString(o)));
                n.addContent(makeParameter("outputtype" + o, "" + node.getOutputTypeString(o)));
                n.addContent(makeParameter("outputlength" + o, "" + node.getOutputLength(o)));
            }
        } else if (node.getNodeType() == AcelaNode.YM) {
            for (int o = 0; o < 16; o++) {
                n.addContent(makeParameter("outputwired" + o, "" + node.getOutputWiredString(o)));
                n.addContent(makeParameter("outputinit" + o, "" + node.getOutputInitString(o)));
                n.addContent(makeParameter("outputtype" + o, "" + node.getOutputTypeString(o)));
                n.addContent(makeParameter("outputlength" + o, "" + node.getOutputLength(o)));
            }
        } else if (node.getNodeType() == AcelaNode.SY) {
            for (int s = 0; s < 16; s++) {
                n.addContent(makeParameter("sensortype" + s, "" + node.getSensorTypeString(s)));
                n.addContent(makeParameter("sensorpolarity" + s, "" + node.getSensorPolarityString(s)));
                n.addContent(makeParameter("sensorthreshold" + s, "" + node.getSensorThreshold(s)));
            }
        }
        // look for the next node
        node = (AcelaNode) ((jmri.jmrix.acela.serialdriver.SerialDriverAdapter) adapter).getSystemConnectionMemo().getTrafficController().getNode(index);
        index++;
    }
}
Also used : Element(org.jdom2.Element) SerialDriverAdapter(jmri.jmrix.acela.serialdriver.SerialDriverAdapter) AcelaNode(jmri.jmrix.acela.AcelaNode)

Example 9 with AcelaNode

use of jmri.jmrix.acela.AcelaNode in project JMRI by JMRI.

the class AcelaSignalHeadXml method store.

/**
     * Default implementation for storing the contents of a Acela
     * AcelaSignalHead
     *
     * @param o Object to store, of type AcelaSignalHead
     * @return Element containing the complete info
     */
@Override
public Element store(Object o) {
    AcelaSignalHead p = (AcelaSignalHead) o;
    Element element = new Element("signalhead");
    element.setAttribute("class", this.getClass().getName());
    // include contents
    element.setAttribute("systemName", p.getSystemName());
    String tu;
    tu = p.getUserName();
    if (tu != null) {
        element.setAttribute("userName", tu);
    }
    AcelaNode sh = AcelaAddress.getNodeFromSystemName(p.getSystemName(), _memo);
    int rawaddr = AcelaAddress.getBitFromSystemName(p.getSystemName());
    String shtype = sh.getOutputSignalHeadTypeString(rawaddr);
    element.setAttribute("signalheadType", shtype);
    storeCommon(p, element);
    return element;
}
Also used : AcelaSignalHead(jmri.jmrix.acela.AcelaSignalHead) Element(org.jdom2.Element) AcelaNode(jmri.jmrix.acela.AcelaNode)

Example 10 with AcelaNode

use of jmri.jmrix.acela.AcelaNode in project JMRI by JMRI.

the class AcelaSignalHeadXml method load.

@Override
public boolean load(Element shared, Element perNode) {
    String sys = shared.getAttribute("systemName").getValue();
    Attribute a = shared.getAttribute("userName");
    SignalHead h;
    if (a == null) {
        h = new AcelaSignalHead(sys, _memo);
    } else {
        h = new AcelaSignalHead(sys, a.getValue(), _memo);
    }
    Attribute t = shared.getAttribute("signalheadType");
    String shtype;
    if (t == null) {
        shtype = "UKNOWN";
    } else {
        shtype = t.getValue();
    }
    loadCommon(h, shared);
    InstanceManager.getDefault(jmri.SignalHeadManager.class).register(h);
    AcelaNode sh = AcelaAddress.getNodeFromSystemName(sys, _memo);
    int rawaddr = AcelaAddress.getBitFromSystemName(sys);
    sh.setOutputSignalHeadTypeString(rawaddr, shtype);
    return true;
}
Also used : Attribute(org.jdom2.Attribute) AcelaSignalHead(jmri.jmrix.acela.AcelaSignalHead) SignalHead(jmri.SignalHead) AcelaSignalHead(jmri.jmrix.acela.AcelaSignalHead) AcelaNode(jmri.jmrix.acela.AcelaNode)

Aggregations

AcelaNode (jmri.jmrix.acela.AcelaNode)10 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)4 QuadOutputSignalHead (jmri.implementation.QuadOutputSignalHead)3 SingleTurnoutSignalHead (jmri.implementation.SingleTurnoutSignalHead)3 TripleOutputSignalHead (jmri.implementation.TripleOutputSignalHead)3 Element (org.jdom2.Element)3 FlowLayout (java.awt.FlowLayout)2 BoxLayout (javax.swing.BoxLayout)2 JPanel (javax.swing.JPanel)2 JScrollPane (javax.swing.JScrollPane)2 SignalHead (jmri.SignalHead)2 Turnout (jmri.Turnout)2 DccSignalHead (jmri.implementation.DccSignalHead)2 TripleTurnoutSignalHead (jmri.implementation.TripleTurnoutSignalHead)2 AcelaSignalHead (jmri.jmrix.acela.AcelaSignalHead)2 SerialDriverAdapter (jmri.jmrix.acela.serialdriver.SerialDriverAdapter)2 BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1