overhauled brake time processor
This commit is contained in:
@@ -93,6 +93,20 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
return true;
|
||||
}
|
||||
|
||||
public Integer getSpeed(Context context) {
|
||||
Integer speed = null;
|
||||
for (Action action : this) {
|
||||
if (action instanceof SetSpeed) {
|
||||
speed = ((SetSpeed)action).getSpeed();
|
||||
}
|
||||
if (action instanceof ActionList) {
|
||||
Integer listSpeed = ((ActionList)action).getSpeed(context);
|
||||
if (isSet(listSpeed)) speed = listSpeed;
|
||||
}
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Action> iterator() {
|
||||
return actions.iterator();
|
||||
|
||||
@@ -34,6 +34,14 @@ public class ConditionalAction extends ActionList {
|
||||
return super.fire(context.clone()); // actions, that happen within the conditional action list must not modify the global context.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getSpeed(Context context) {
|
||||
for (Condition condition : conditions) {
|
||||
if (!condition.fulfilledBy(context)) return null;
|
||||
}
|
||||
return super.getSpeed(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
JSONObject json = super.json();
|
||||
|
||||
@@ -51,6 +51,10 @@ public class SetSpeed extends Action{
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t("Set speed to {} {}",speed,speedUnit);
|
||||
|
||||
Reference in New Issue
Block a user