Search in sources :

Example 1 with SignalSystem

use of jmri.SignalSystem in project JMRI by JMRI.

the class AddSignalMastPanel method updateDCCMastPanel.

void updateDCCMastPanel() {
    if ((!Bundle.getMessage("DCCMast").equals(signalMastDriver.getSelectedItem())) && (!Bundle.getMessage("LNCPMast").equals(signalMastDriver.getSelectedItem()))) {
        return;
    }
    dccAspect = new HashMap<String, DCCAspectPanel>(10);
    java.util.List<jmri.CommandStation> connList = jmri.InstanceManager.getList(jmri.CommandStation.class);
    systemPrefixBox.removeAllItems();
    if (!connList.isEmpty()) {
        for (int x = 0; x < connList.size(); x++) {
            jmri.CommandStation station = connList.get(x);
            if (Bundle.getMessage("LNCPMast").equals(signalMastDriver.getSelectedItem())) {
                if (station instanceof jmri.jmrix.loconet.SlotManager) {
                    systemPrefixBox.addItem(station.getUserName());
                }
            } else {
                systemPrefixBox.addItem(station.getUserName());
            }
        }
    } else {
        systemPrefixBox.addItem("None");
    }
    String mastType = mastNames.get(mastBox.getSelectedIndex()).getName();
    mastType = mastType.substring(11, mastType.indexOf(".xml"));
    jmri.implementation.DefaultSignalAppearanceMap sigMap = jmri.implementation.DefaultSignalAppearanceMap.getMap(sigsysname, mastType);
    java.util.Enumeration<String> aspects = sigMap.getAspects();
    SignalSystem sigsys = InstanceManager.getDefault(jmri.SignalSystemManager.class).getSystem(sigsysname);
    while (aspects.hasMoreElements()) {
        String aspect = aspects.nextElement();
        DCCAspectPanel aPanel = new DCCAspectPanel(aspect);
        dccAspect.put(aspect, aPanel);
        aPanel.setAspectId((String) sigsys.getProperty(aspect, "dccAspect"));
    }
    dccMastPanel.removeAll();
    dccMastPanel.setLayout(new jmri.util.javaworld.GridLayout2(dccAspect.size() + 3, 2));
    dccMastPanel.add(systemPrefixBoxLabel);
    dccMastPanel.add(systemPrefixBox);
    dccMastPanel.add(dccAspectAddressLabel);
    dccMastPanel.add(dccAspectAddressField);
    if (dccAddressListener == null) {
        dccAddressListener = new FocusListener() {

            @Override
            public void focusLost(FocusEvent e) {
                if (dccAspectAddressField.getText().equals("")) {
                    return;
                }
                validateDCCAddress();
            }

            @Override
            public void focusGained(FocusEvent e) {
            }
        };
        dccAspectAddressField.addFocusListener(dccAddressListener);
    }
    if (mast == null) {
        systemPrefixBoxLabel.setEnabled(true);
        systemPrefixBox.setEnabled(true);
        dccAspectAddressLabel.setEnabled(true);
        dccAspectAddressField.setEnabled(true);
    }
    for (String aspect : dccAspect.keySet()) {
        // load aspect panels from hashmap
        dccMastPanel.add(dccAspect.get(aspect).getPanel());
    }
    if ((dccAspect.size() & 1) == 1) {
        // spacer
        dccMastPanel.add(new JLabel());
    }
    dccMastPanel.add(new JLabel(Bundle.getMessage("DCCMastCopyAspectId") + ":"));
    dccMastPanel.add(copyFromMastSelection());
}
Also used : JLabel(javax.swing.JLabel) FocusEvent(java.awt.event.FocusEvent) SignalSystemManager(jmri.SignalSystemManager) SignalSystem(jmri.SignalSystem) FocusListener(java.awt.event.FocusListener)

Example 2 with SignalSystem

use of jmri.SignalSystem in project JMRI by JMRI.

the class DefaultSignalSystemManager method load.

void load() {
    List<String> list = getListOfNames();
    for (int i = 0; i < list.size(); i++) {
        SignalSystem s = makeBean(list.get(i));
        register(s);
    }
}
Also used : DefaultSignalSystem(jmri.implementation.DefaultSignalSystem) SignalSystem(jmri.SignalSystem)

Example 3 with SignalSystem

use of jmri.SignalSystem in project JMRI by JMRI.

the class DefaultSignalSystemTest method testGetKeysOverlap.

@Test
public void testGetKeysOverlap() {
    SignalSystem t = new DefaultSignalSystem("sys", "user");
    t.setProperty("Stop", "A", 0);
    t.setProperty("Approach", "C", 5);
    t.setProperty("Approach", "A", 5);
    t.setProperty("Approach", "B", 5);
    t.setProperty("Clear", "B", 10);
    java.util.Enumeration<String> e = t.getKeys();
    Assert.assertEquals("A", e.nextElement());
    Assert.assertEquals("C", e.nextElement());
    Assert.assertEquals("B", e.nextElement());
    Assert.assertTrue(!e.hasMoreElements());
}
Also used : SignalSystem(jmri.SignalSystem) Test(org.junit.Test)

Example 4 with SignalSystem

use of jmri.SignalSystem in project JMRI by JMRI.

the class DefaultSignalSystemTest method testTwoAspectOneProperty.

@Test
public void testTwoAspectOneProperty() {
    SignalSystem t = new DefaultSignalSystem("sys", "user");
    t.setProperty("Stop", "Speed", 0);
    t.setProperty("Clear", "Speed", 10);
    Assert.assertEquals("Stop", 0, t.getProperty("Stop", "Speed"));
    Assert.assertEquals("Clear", 10, t.getProperty("Clear", "Speed"));
}
Also used : SignalSystem(jmri.SignalSystem) Test(org.junit.Test)

Example 5 with SignalSystem

use of jmri.SignalSystem in project JMRI by JMRI.

the class DefaultSignalSystemTest method testGetAspects.

@Test
public void testGetAspects() {
    SignalSystem t = new DefaultSignalSystem("sys", "user");
    t.setProperty("Stop", "Speed", 0);
    t.setProperty("Approach", "Speed", 5);
    t.setProperty("Clear", "Speed", 10);
    java.util.Enumeration<String> e = t.getAspects();
    Assert.assertEquals("Stop", e.nextElement());
    Assert.assertEquals("Approach", e.nextElement());
    Assert.assertEquals("Clear", e.nextElement());
    Assert.assertTrue(!e.hasMoreElements());
}
Also used : SignalSystem(jmri.SignalSystem) Test(org.junit.Test)

Aggregations

SignalSystem (jmri.SignalSystem)11 Test (org.junit.Test)9 FocusEvent (java.awt.event.FocusEvent)1 FocusListener (java.awt.event.FocusListener)1 JLabel (javax.swing.JLabel)1 SignalMast (jmri.SignalMast)1 SignalSystemManager (jmri.SignalSystemManager)1 DefaultSignalSystem (jmri.implementation.DefaultSignalSystem)1