Skip to content

Commit

Permalink
Add check for DCC address used in more than one running warrant
Browse files Browse the repository at this point in the history
  • Loading branch information
pete_ authored and pete_ committed Mar 26, 2019
1 parent 6304ec7 commit bd44c0a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
10 changes: 5 additions & 5 deletions java/src/jmri/jmrit/logix/Warrant.java
Expand Up @@ -432,7 +432,7 @@ public void setRunBlind(boolean runBlind) {
*/
@jmri.InvokeOnLayoutThread
protected void fireRunStatus(String property, Object old, Object status) {
// jmri.util.ThreadingUtil.runOnLayout(() -> { Will hang GUI!
// jmri.util.ThreadingUtil.runOnLayout(() -> { // Will hang GUI!
ThreadingUtil.runOnLayoutEventually(() -> { // OK but can be quite late in reporting speed changes
firePropertyChange(property, old, status);
});
Expand Down Expand Up @@ -967,9 +967,8 @@ public boolean controlRunTrain(int idx) {
}
break;
case DEBUG:
if (log.isDebugEnabled()) {
debugInfo();
}
ret = debugInfo();
fireRunStatus("SpeedChange", null, idx);
break;
default:
}
Expand Down Expand Up @@ -1067,7 +1066,8 @@ idx, CNTRL_CMDS[idx], getTrainName(), RUN_STATE[runState],
break;
case DEBUG:
ret = debugInfo();
break;
fireRunStatus("SpeedChange", null, idx);
return ret;
default:
}
}
Expand Down
9 changes: 7 additions & 2 deletions java/src/jmri/jmrit/logix/WarrantTableFrame.java
Expand Up @@ -33,6 +33,8 @@
import javax.swing.JTextField;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

import jmri.DccLocoAddress;
import jmri.InstanceManager;
import jmri.util.swing.XTableColumnModel;
import jmri.util.table.ButtonEditor;
Expand Down Expand Up @@ -451,7 +453,6 @@ public Component getTableCellEditorComponent(JTable table, Object value,
}
}


/**
* Return error message if warrant cannot be run.
*
Expand All @@ -460,12 +461,16 @@ public Component getTableCellEditorComponent(JTable table, Object value,
* @return null if warrant is started
*/
public String runTrain(Warrant w, int mode) {
w.deAllocate();
String msg = null;
if (w.getRunMode() != Warrant.MODE_NONE) {
msg = w.getRunModeMessage();
}
if (msg == null) {
w.deAllocate();
msg = _model.checkAddressInUse(w);
}

if (msg == null) {
msg = w.setRoute(false, null);
if (msg == null) {
msg = w.setRunMode(mode, null, null, null, w.getRunBlind());
Expand Down
15 changes: 8 additions & 7 deletions java/src/jmri/jmrit/logix/WarrantTableModel.java
Expand Up @@ -359,8 +359,9 @@ public int getPreferredWidth(int col) {

@Override
public Object getValueAt(int row, int col) {
// if (log.isDebugEnabled())
// log.debug("getValueAt: row= "+row+", column= "+col);
// if (log.isTraceEnabled()) {
// log.debug("getValueAt: row= "+row+", column= "+col);
// }
Warrant w = getWarrantAt(row);
// some error checking
if (w == null) {
Expand Down Expand Up @@ -442,7 +443,7 @@ public Object getValueAt(int row, int col) {
"off");
case CONTROL_COLUMN:
String msg = w.getRunningMessage();
log.debug("getValueAt: warrant= {}, getRunningMessage= \"{}\"", w.getDisplayName(), msg);
// log.debug("getValueAt: warrant= {}, getRunningMessage= \"{}\"", w.getDisplayName(), msg);
return msg;
case EDIT_COLUMN:
return Bundle.getMessage("ButtonEdit");
Expand All @@ -457,7 +458,7 @@ public Object getValueAt(int row, int col) {

@Override
public void setValueAt(Object value, int row, int col) {
// if (log.isDebugEnabled())
// if (log.isTraceEnabled())
// log.debug("setValueAt: row= " + row + ", column= " + col
// + ", value= " + (value==null ? value : (value.toString()==null ? value.getClass().getName() :value.toString())));
Warrant w = getWarrantAt(row);
Expand Down Expand Up @@ -539,7 +540,7 @@ public void setValueAt(Object value, int row, int col) {
// a warrant change. fireTableRows then causes getValueAt() which
// calls getRunningMessage()
int mode = w.getRunMode();
if (log.isDebugEnabled()) {
if (log.isTraceEnabled()) {
log.debug("setValueAt({}) for warrant {}", value, w.getDisplayName());
}
if (mode == Warrant.MODE_LEARN) {
Expand All @@ -560,7 +561,7 @@ public void setValueAt(Object value, int row, int col) {
s = Warrant.ABORT;
} else if (setting.equals(WarrantTableFrame.ramp)) {
s = Warrant.RAMP_HALT;
} else if (setting.equals("Debug")) {
} else /*if (setting.equals("Debug"))*/ {
s = Warrant.DEBUG;
}
w.controlRunTrain(s);
Expand Down Expand Up @@ -636,7 +637,7 @@ public void propertyChange(java.beans.PropertyChangeEvent e) {
} else if (e.getSource() instanceof Warrant) {
// a value changed. Find it, to avoid complete redraw
Warrant bean = (Warrant) e.getSource();
// log.debug("source is warrant "+bean.getDisplayName());
log.debug("source is warrant "+bean.getDisplayName());
for (int i = 0; i < _warList.size(); i++) {
if (bean.equals(_warList.get(i))) {

Expand Down

0 comments on commit bd44c0a

Please sign in to comment.