removed unused "cause" parameter in actions
This commit is contained in:
@@ -328,7 +328,7 @@ public class Route extends BaseClass {
|
||||
ActionList actions = triggeredActions.get(contact.trigger());
|
||||
LOG.debug("Contact has id {} / trigger {} and is assigned with {}",contact.id(),contact.trigger(),isNull(actions)?t("nothing"):actions);
|
||||
if (isNull(actions)) return context;
|
||||
actions.fire(context,"Route.Contact("+contact.addr()+")");
|
||||
actions.fire(context);
|
||||
Context previousContext = context;
|
||||
if (isSet(context) && context.invalidated()) context = null; // route has been freed in between.
|
||||
return previousContext;
|
||||
@@ -689,7 +689,7 @@ public class Route extends BaseClass {
|
||||
LOG.debug("{}.prepareAndLock()",this);
|
||||
Train train = context.train();
|
||||
ActionList setupActions = triggeredActions.get(ROUTE_SETUP);
|
||||
if (isSet(setupActions) && !setupActions.fire(context.route(this),this+".prepare()")) {
|
||||
if (isSet(setupActions) && !setupActions.fire(context.route(this))) {
|
||||
LOG.debug("Was not able to prepare route for {}.",train);
|
||||
return false;
|
||||
}
|
||||
@@ -894,8 +894,7 @@ public class Route extends BaseClass {
|
||||
|
||||
if (isSet(startActions)) {
|
||||
context.route(this);
|
||||
String cause = this+".start("+train.name()+")";
|
||||
if (!startActions.fire(context,cause)) {
|
||||
if (!startActions.fire(context)) {
|
||||
LOG.debug("Failed to execute {}",startActions);
|
||||
return false; // start actions failed
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public abstract class Action extends BaseClass {
|
||||
return this.toString().equals(other.toString());
|
||||
}
|
||||
|
||||
public abstract boolean fire(Context context,Object cause);
|
||||
public abstract boolean fire(Context context);
|
||||
|
||||
public static Action get(Id actionId) {
|
||||
return actions.get(actionId);
|
||||
|
||||
@@ -80,10 +80,10 @@ public class ActionList extends Action implements Iterable<Action>{
|
||||
return actions.remove(action);
|
||||
}
|
||||
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
for (Action action : actions) {
|
||||
LOG.debug("firing \"{}\"",action);
|
||||
if (!action.fire(context,cause)) {
|
||||
if (!action.fire(context)) {
|
||||
LOG.warn("{} failed",action);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AddRemoveDestination extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
Train train = context.train();
|
||||
if (isNull(train)) return false;
|
||||
if (isNull(destination)) { // clear destinations!
|
||||
|
||||
@@ -24,7 +24,7 @@ public class AddRemoveTag extends Action{
|
||||
private boolean remove = false;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
if (remove) {
|
||||
context.train().removeTag(tag);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class AlterDirection extends Action{
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
Train train = context.train();
|
||||
if (isNull(train)) return false;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public class BrakeStart extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
context.train().startBrake();
|
||||
return true;
|
||||
|
||||
@@ -33,11 +33,11 @@ public class ConditionalAction extends ActionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
for (Condition condition : conditions) {
|
||||
if (!condition.fulfilledBy(context)) return elseActions.fire(context, cause);
|
||||
if (!condition.fulfilledBy(context)) return elseActions.fire(context);
|
||||
}
|
||||
return super.fire(context.clone(),cause); // actions, that happen within the conditional action list must not modify the global context.
|
||||
return super.fire(context.clone()); // actions, that happen within the conditional action list must not modify the global context.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CoupleTrain extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
Train train = context.train();
|
||||
if (isNull(train)) return false;
|
||||
Block block = train.currentBlock();
|
||||
|
||||
@@ -30,16 +30,16 @@ public class DelayedAction extends ActionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
int delay = min_delay + (min_delay < max_delay ? random.nextInt(max_delay - min_delay) : 0);
|
||||
|
||||
new DelayedExecution(delay,cause) {
|
||||
new DelayedExecution(delay) {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
LOG.debug("{} ms passed by, firing actions:",delay);
|
||||
if (context.invalidated()) return;
|
||||
DelayedAction.super.fire(context,cause);
|
||||
DelayedAction.super.fire(context);
|
||||
plan.alter();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ public class DetermineTrainInBlock extends Action {
|
||||
private Block block = null;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(block)) return false;
|
||||
Train train = parked ? (block.trains().isEmpty() ? null : block.trains().firstElement()) : block.occupyingTrain();
|
||||
context.train(train);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class DisableEnableBlock extends Action {
|
||||
private boolean disable = true;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(block)) block = context.block();
|
||||
if (isNull(block)) return false;
|
||||
block.setEnabled(!disable);
|
||||
|
||||
@@ -24,7 +24,7 @@ public class EngageDecoupler extends Action {
|
||||
private Decoupler decoupler = null;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context, Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(decoupler)) return false;
|
||||
decoupler.engage();
|
||||
return true;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class FinishRoute extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
Route route = context.route();
|
||||
Train train = context.train();
|
||||
if (isNull(train)) return false;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Loop extends ActionList {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(object)) return false;
|
||||
List<? extends BaseClass> elements = null;
|
||||
switch (object) {
|
||||
@@ -53,7 +53,7 @@ public class Loop extends ActionList {
|
||||
break;
|
||||
}
|
||||
if (elements == null) return false;
|
||||
for (BaseClass element : elements) super.fire(context.setMain(element),cause);
|
||||
for (BaseClass element : elements) super.fire(context.setMain(element));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class PreserveRoute extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (context.invalidated()) return false;
|
||||
Train train = context.train();
|
||||
Route route = context.route();
|
||||
|
||||
@@ -9,7 +9,7 @@ public class ReactivateContact extends Action{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.contact())) return false;
|
||||
if (isNull(context.route())) return false;
|
||||
return context.route().reactivate(context.contact());
|
||||
|
||||
@@ -11,7 +11,7 @@ public class SavePlan extends Action{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
try {
|
||||
plan.stream(plan.save());
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public class SendCommand extends Action{
|
||||
private Target target = Target.SRCP;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
switch (target) {
|
||||
case SRCP:
|
||||
plan.queue(new Command(command) {
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SetContextTrain extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
context.train(train);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class SetDisplayText extends TextAction{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
plan.place(display.text(fill(text, context)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SetPower extends Action{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
ControlUnit cu = plan.controlUnit();
|
||||
switch (pc) {
|
||||
case ON:
|
||||
|
||||
@@ -28,7 +28,7 @@ public class SetRelayOrSwitch extends Action {
|
||||
private boolean state = false;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(relayOrSwitch)) return false;
|
||||
if (relayOrSwitch instanceof Relay) ((Relay)relayOrSwitch).state(state);
|
||||
if (relayOrSwitch instanceof Switch) ((Switch)relayOrSwitch).state(state);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SetSignal extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (context.invalidated()) return false;
|
||||
if (isNull(signal)) return false;
|
||||
return signal.state(state);
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SetSpeed extends Action{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (context.invalidated()) return false;
|
||||
if (isNull(context.train())) return false;
|
||||
context.train().setSpeed(speed);
|
||||
|
||||
@@ -25,7 +25,7 @@ public class SetTurnout extends Action {
|
||||
private Turnout.State state = State.STRAIGHT;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (context.invalidated()) return false;
|
||||
if (isNull(turnout)) return false;
|
||||
if (!turnout.state(state,false).succeeded()) return false;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ShowText extends TextAction{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
plan.stream(fill(text,context));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class SplitTrain extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
Train train = context.train();
|
||||
if (isNull(train)) return false;
|
||||
return train.splitAfter(position);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class StartStopAuto extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
if (inverted) {
|
||||
context.train().start(true);
|
||||
|
||||
@@ -9,7 +9,7 @@ public class StopTrain extends Action{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context.train())) return false;
|
||||
LOG.debug("{}.fire() called, context = {}",this,context);
|
||||
context.train().stopNow();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SwitchFunction extends Action {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isNull(context) || isNull(context.train())) return false;
|
||||
switch (effect) {
|
||||
case TOGGLE:
|
||||
|
||||
@@ -20,7 +20,7 @@ public class TriggerContact extends Action {
|
||||
private Contact contact = null;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
if (isSet(contact)) return contact.trigger(200);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class WaitForContact extends ActionList {
|
||||
private int timeout = 10000;
|
||||
|
||||
@Override
|
||||
public boolean fire(Context context,Object cause) {
|
||||
public boolean fire(Context context) {
|
||||
LOG.debug("{}.fire(...) called, waiting for {}.",this,contact);
|
||||
if (isNull(contact)) return false;
|
||||
fired = false;
|
||||
@@ -41,17 +41,17 @@ public class WaitForContact extends ActionList {
|
||||
LOG.debug("{} triggered, firing {}",contact,actions);
|
||||
fired = true;
|
||||
contact.removeListener(this);
|
||||
WaitForContact.super.fire(context,cause);
|
||||
WaitForContact.super.fire(context);
|
||||
}
|
||||
};
|
||||
contact.addListener(listener);
|
||||
new DelayedExecution(timeout,cause) {
|
||||
new DelayedExecution(timeout) {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
contact.removeListener(listener);
|
||||
LOG.debug("{} timed out, firing {}",this,timeoutActions);
|
||||
if (!fired) timeoutActions.fire(context,cause);
|
||||
if (!fired) timeoutActions.fire(context);
|
||||
}
|
||||
};
|
||||
return true;
|
||||
|
||||
@@ -82,7 +82,7 @@ public class Contact extends Tile{
|
||||
if (isSet(timer)) timer.abort();
|
||||
Train train = lockingTrain();
|
||||
Context context = isSet(train) ? train.contact(this) : new Context(this);
|
||||
actions.fire(context,"Contact("+addr+")");
|
||||
actions.fire(context);
|
||||
|
||||
for (EventListener listener : listeners) listener.fire();
|
||||
|
||||
|
||||
@@ -170,8 +170,8 @@ public class Switch extends Tile{
|
||||
public void run() {
|
||||
Context context = new Context(Switch.this);
|
||||
if (state) {
|
||||
actionsOn.fire(context,Switch.this);
|
||||
} else actionsOff.fire(context,Switch.this);
|
||||
actionsOn.fire(context);
|
||||
} else actionsOff.fire(context);
|
||||
}
|
||||
}.start();
|
||||
stream();
|
||||
|
||||
Reference in New Issue
Block a user