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());
}
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);
}
}
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());
}
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"));
}
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());
}
Aggregations