use of jmri.jmrit.operations.automation.actions.Action in project JMRI by JMRI.
the class AutomationItem method getActionList.
/**
* Gets a list of all known automation actions
*
* @return list of automation actions
*/
public List<Action> getActionList() {
List<Action> list = new ArrayList<Action>();
list.add(new NoAction());
list.add(new BuildTrainAction());
list.add(new BuildTrainIfSelectedAction());
list.add(new PrintTrainManifestAction());
list.add(new PrintTrainManifestIfSelectedAction());
list.add(new RunTrainAction());
list.add(new MoveTrainAction());
list.add(new TerminateTrainAction());
list.add(new ResetTrainAction());
list.add(new IsTrainEnRouteAction());
list.add(new WaitTrainAction());
list.add(new WaitTrainTerminatedAction());
list.add(new ActivateTimetableAction());
list.add(new ApplyTimetableAction());
list.add(new SelectTrainAction());
list.add(new DeselectTrainAction());
list.add(new PrintSwitchListAction());
// list.add(new PrintSwitchListChangesAction()); // see UpdateSwitchListAction
list.add(new UpdateSwitchListAction());
list.add(new WaitSwitchListAction());
list.add(new RunSwitchListAction());
list.add(new RunSwitchListChangesAction());
list.add(new RunAutomationAction());
list.add(new ResumeAutomationAction());
list.add(new StopAutomationAction());
list.add(new MessageYesNoAction());
list.add(new GotoAction());
list.add(new GotoSuccessAction());
list.add(new GotoFailureAction());
list.add(new HaltAction());
return list;
}
use of jmri.jmrit.operations.automation.actions.Action in project JMRI by JMRI.
the class AutomationItem method setAction.
public void setAction(Action action) {
Action old = _action;
_action = action;
if (old != null) {
old.cancelAction();
}
if (action != null) {
// associate action with this item
action.setAutomationItem(this);
}
if (old != action) {
// NOI18N
setDirtyAndFirePropertyChange("AutomationItemActionChange", old, action);
}
}
use of jmri.jmrit.operations.automation.actions.Action in project JMRI by JMRI.
the class Automation method CheckForActionPropertyChange.
@SuppressFBWarnings(value = { "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP" }, justification = "Need to plause for user action")
private void CheckForActionPropertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(Action.ACTION_COMPLETE_CHANGED_PROPERTY) || evt.getPropertyName().equals(Action.ACTION_HALT_CHANGED_PROPERTY)) {
Action action = (Action) evt.getSource();
action.removePropertyChangeListener(this);
}
// the following code causes multiple wait actions to run concurrently
if (evt.getPropertyName().equals(Action.ACTION_RUNNING_CHANGED_PROPERTY)) {
firePropertyChange(evt.getPropertyName(), evt.getOldValue(), evt.getNewValue());
// when new value is true the action is running
if ((boolean) evt.getNewValue()) {
Action action = (Action) evt.getSource();
log.debug("Action ({}) is running", action.getActionString());
if (action.isConcurrentAction()) {
AutomationItem item = action.getAutomationItem();
AutomationItem nextItem = getNextAutomationItem(item);
if (nextItem != null && nextItem.getAction().isConcurrentAction()) {
// start this wait action
performAction(nextItem);
}
}
}
}
if (getCurrentAutomationItem() != null && getCurrentAutomationItem().getAction() == evt.getSource()) {
if (evt.getPropertyName().equals(Action.ACTION_COMPLETE_CHANGED_PROPERTY) || evt.getPropertyName().equals(Action.ACTION_HALT_CHANGED_PROPERTY)) {
getCurrentAutomationItem().getAction().cancelAction();
if (evt.getPropertyName().equals(Action.ACTION_COMPLETE_CHANGED_PROPERTY)) {
setNextAutomationItem();
if (isRunning()) {
// continue running by doing the next action
step();
}
} else if (evt.getPropertyName().equals(Action.ACTION_HALT_CHANGED_PROPERTY)) {
if ((boolean) evt.getNewValue() == true) {
log.debug("User halted successful action");
setNextAutomationItem();
}
stop();
}
}
if (evt.getPropertyName().equals(Action.ACTION_GOTO_CHANGED_PROPERTY)) {
// if old = false, branch if failure
if (evt.getOldValue() == null || (boolean) evt.getOldValue() == isLastActionSuccessful()) {
_gotoAutomationItem = (AutomationItem) evt.getNewValue();
// this gives the user a chance to "Stop" the automation
synchronized (this) {
try {
wait(250);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
}
}
Aggregations