Skip to content
Permalink
Browse files

Repair StopRun call so SCWarrant does not change functions on abort

Remove clearStoppingBlock on abort
  • Loading branch information...
petecressman committed Sep 30, 2018
1 parent bf180db commit 4bdb525f10e6463a80f7da50de6c063a8695369e
Showing with 18 additions and 13 deletions.
  1. +18 −12 java/src/jmri/jmrit/logix/Engineer.java
  2. +0 −1 java/src/jmri/jmrit/logix/Warrant.java
@@ -441,9 +441,11 @@ private void rampDone(boolean stop, String type) {
_warrant.fireRunStatus("RampDone", _halt, type);
});
}
synchronized (this) {
notify();
log.debug("rampDone called notify");
if (!_atHalt && !_atClear) {
synchronized (this) {
notify();
log.debug("rampDone called notify");
}
}
}

@@ -646,10 +648,11 @@ public void stopRun(boolean abort, boolean turnOffFunctions) {
_throttle.setSpeedSetting(-1.0f);
setSpeed(0.0f); // prevent creep after EStop - according to Jim Betz
}
if (abort) {
if (abort && turnOffFunctions) {
_throttle.setF0(false);
_throttle.setF1(false);
_throttle.setF2(false);
_throttle.setF3(false);
}
_warrant.releaseThrottle(_throttle);
}
@@ -1101,20 +1104,22 @@ public void doRamp() {
float scriptDist = 0;
float scriptSpeed = 0;
for (int idx = _idxCurrentCommand; idx > 0; idx--) {
// backing down to find current script speed
ThrottleSetting ts = _commands.get(idx);
if ("SPEED".equals(ts.getCommand().toUpperCase())) {
scriptSpeed = Float.parseFloat(ts.getValue());
break;
}
}
float rampDist = _speedUtil.rampLengthForSpeedChange(speed, _endSpeed, _isForward);
int idxNextSpeedCmd = Math.max(_idxSkipToSpeedCommand, _idxCurrentCommand+1); // resume speed index
int idxSpeedCmd = Math.max(_idxSkipToSpeedCommand-1, _idxCurrentCommand); // resume speed index
int idxNextSpeedCmd = idxSpeedCmd + 1;
long scriptTime = 0;
boolean hasSpeed = (scriptSpeed > 0);
for (int idx = idxNextSpeedCmd; idx < _commands.size(); idx++) {
ThrottleSetting ts = _commands.get(idx);
while (idxNextSpeedCmd < _commands.size()) {
ThrottleSetting ts = _commands.get(idxSpeedCmd);
if (hasSpeed) {
scriptTime += ts.getTime(); // TODO fix -time at this scriptSpeed is next getTime()
scriptTime += ts.getTime();
String cmd = ts.getCommand().toUpperCase();
if ("SPEED".equals(cmd) || "NOOP".equals(cmd)) {
scriptDist += _speedUtil.getDistanceTraveled(scriptSpeed, _endSpeedType, scriptTime, _isForward);
@@ -1127,16 +1132,17 @@ public void doRamp() {
_endSpeed = _speedUtil.modifySpeed(scriptSpeed, _endSpeedType, _isForward);
rampDist = _speedUtil.rampLengthForSpeedChange(speed, _endSpeed, _isForward);
}
idxNextSpeedCmd = idx;
}
// log.debug("scriptDist= {}, rampDist= {} for _endSpeed= {} at index= {}",
// scriptDist, rampDist, _endSpeed, idx);
log.debug("scriptDist= {}, rampDist= {} for _endSpeed= {} at index= {}",
scriptDist, rampDist, _endSpeed, idxSpeedCmd);
if (scriptDist >= rampDist) {
advanceToCommandIndex(idxNextSpeedCmd); // don't let script set speeds up to here
advanceToCommandIndex(idxSpeedCmd); // don't let script set speeds up to here
break;
}
}
}
idxSpeedCmd++;
idxNextSpeedCmd++;
}
_normalSpeed = scriptSpeed;
if (log.isDebugEnabled())
@@ -701,7 +701,6 @@ synchronized public void stopWarrant(boolean abort, boolean turnOffFunctions) {
_protectSignal = null;
_idxProtectSignal = -1;
}
clearStoppingBlock();
if (_shareTOBlock != null) {
_shareTOBlock.removePropertyChangeListener(this);
_shareTOBlock = null;

0 comments on commit 4bdb525

Please sign in to comment.
You can’t perform that action at this time.