Search in sources :

Example 1 with Action

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;
}
Also used : PrintTrainManifestAction(jmri.jmrit.operations.automation.actions.PrintTrainManifestAction) GotoSuccessAction(jmri.jmrit.operations.automation.actions.GotoSuccessAction) RunAutomationAction(jmri.jmrit.operations.automation.actions.RunAutomationAction) StopAutomationAction(jmri.jmrit.operations.automation.actions.StopAutomationAction) IsTrainEnRouteAction(jmri.jmrit.operations.automation.actions.IsTrainEnRouteAction) GotoAction(jmri.jmrit.operations.automation.actions.GotoAction) DeselectTrainAction(jmri.jmrit.operations.automation.actions.DeselectTrainAction) PrintTrainManifestIfSelectedAction(jmri.jmrit.operations.automation.actions.PrintTrainManifestIfSelectedAction) RunSwitchListChangesAction(jmri.jmrit.operations.automation.actions.RunSwitchListChangesAction) RunTrainAction(jmri.jmrit.operations.automation.actions.RunTrainAction) WaitSwitchListAction(jmri.jmrit.operations.automation.actions.WaitSwitchListAction) BuildTrainAction(jmri.jmrit.operations.automation.actions.BuildTrainAction) SelectTrainAction(jmri.jmrit.operations.automation.actions.SelectTrainAction) WaitTrainAction(jmri.jmrit.operations.automation.actions.WaitTrainAction) ApplyTimetableAction(jmri.jmrit.operations.automation.actions.ApplyTimetableAction) Action(jmri.jmrit.operations.automation.actions.Action) ResumeAutomationAction(jmri.jmrit.operations.automation.actions.ResumeAutomationAction) WaitTrainTerminatedAction(jmri.jmrit.operations.automation.actions.WaitTrainTerminatedAction) RunSwitchListAction(jmri.jmrit.operations.automation.actions.RunSwitchListAction) HaltAction(jmri.jmrit.operations.automation.actions.HaltAction) MessageYesNoAction(jmri.jmrit.operations.automation.actions.MessageYesNoAction) NoAction(jmri.jmrit.operations.automation.actions.NoAction) GotoFailureAction(jmri.jmrit.operations.automation.actions.GotoFailureAction) MoveTrainAction(jmri.jmrit.operations.automation.actions.MoveTrainAction) PrintTrainManifestAction(jmri.jmrit.operations.automation.actions.PrintTrainManifestAction) ActivateTimetableAction(jmri.jmrit.operations.automation.actions.ActivateTimetableAction) BuildTrainIfSelectedAction(jmri.jmrit.operations.automation.actions.BuildTrainIfSelectedAction) PrintSwitchListAction(jmri.jmrit.operations.automation.actions.PrintSwitchListAction) UpdateSwitchListAction(jmri.jmrit.operations.automation.actions.UpdateSwitchListAction) ResetTrainAction(jmri.jmrit.operations.automation.actions.ResetTrainAction) TerminateTrainAction(jmri.jmrit.operations.automation.actions.TerminateTrainAction) MoveTrainAction(jmri.jmrit.operations.automation.actions.MoveTrainAction) IsTrainEnRouteAction(jmri.jmrit.operations.automation.actions.IsTrainEnRouteAction) SelectTrainAction(jmri.jmrit.operations.automation.actions.SelectTrainAction) ArrayList(java.util.ArrayList) StopAutomationAction(jmri.jmrit.operations.automation.actions.StopAutomationAction) GotoFailureAction(jmri.jmrit.operations.automation.actions.GotoFailureAction) ResetTrainAction(jmri.jmrit.operations.automation.actions.ResetTrainAction) GotoSuccessAction(jmri.jmrit.operations.automation.actions.GotoSuccessAction) HaltAction(jmri.jmrit.operations.automation.actions.HaltAction) ResumeAutomationAction(jmri.jmrit.operations.automation.actions.ResumeAutomationAction) TerminateTrainAction(jmri.jmrit.operations.automation.actions.TerminateTrainAction) RunAutomationAction(jmri.jmrit.operations.automation.actions.RunAutomationAction) ActivateTimetableAction(jmri.jmrit.operations.automation.actions.ActivateTimetableAction) BuildTrainAction(jmri.jmrit.operations.automation.actions.BuildTrainAction) GotoAction(jmri.jmrit.operations.automation.actions.GotoAction) PrintSwitchListAction(jmri.jmrit.operations.automation.actions.PrintSwitchListAction) MessageYesNoAction(jmri.jmrit.operations.automation.actions.MessageYesNoAction) WaitTrainAction(jmri.jmrit.operations.automation.actions.WaitTrainAction) RunSwitchListChangesAction(jmri.jmrit.operations.automation.actions.RunSwitchListChangesAction) WaitTrainTerminatedAction(jmri.jmrit.operations.automation.actions.WaitTrainTerminatedAction) DeselectTrainAction(jmri.jmrit.operations.automation.actions.DeselectTrainAction) UpdateSwitchListAction(jmri.jmrit.operations.automation.actions.UpdateSwitchListAction) BuildTrainIfSelectedAction(jmri.jmrit.operations.automation.actions.BuildTrainIfSelectedAction) MessageYesNoAction(jmri.jmrit.operations.automation.actions.MessageYesNoAction) NoAction(jmri.jmrit.operations.automation.actions.NoAction) RunSwitchListAction(jmri.jmrit.operations.automation.actions.RunSwitchListAction) PrintTrainManifestIfSelectedAction(jmri.jmrit.operations.automation.actions.PrintTrainManifestIfSelectedAction) RunTrainAction(jmri.jmrit.operations.automation.actions.RunTrainAction) WaitSwitchListAction(jmri.jmrit.operations.automation.actions.WaitSwitchListAction) ApplyTimetableAction(jmri.jmrit.operations.automation.actions.ApplyTimetableAction)

Example 2 with Action

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);
    }
}
Also used : GotoSuccessAction(jmri.jmrit.operations.automation.actions.GotoSuccessAction) RunAutomationAction(jmri.jmrit.operations.automation.actions.RunAutomationAction) StopAutomationAction(jmri.jmrit.operations.automation.actions.StopAutomationAction) IsTrainEnRouteAction(jmri.jmrit.operations.automation.actions.IsTrainEnRouteAction) GotoAction(jmri.jmrit.operations.automation.actions.GotoAction) DeselectTrainAction(jmri.jmrit.operations.automation.actions.DeselectTrainAction) PrintTrainManifestIfSelectedAction(jmri.jmrit.operations.automation.actions.PrintTrainManifestIfSelectedAction) RunSwitchListChangesAction(jmri.jmrit.operations.automation.actions.RunSwitchListChangesAction) RunTrainAction(jmri.jmrit.operations.automation.actions.RunTrainAction) WaitSwitchListAction(jmri.jmrit.operations.automation.actions.WaitSwitchListAction) BuildTrainAction(jmri.jmrit.operations.automation.actions.BuildTrainAction) SelectTrainAction(jmri.jmrit.operations.automation.actions.SelectTrainAction) WaitTrainAction(jmri.jmrit.operations.automation.actions.WaitTrainAction) ApplyTimetableAction(jmri.jmrit.operations.automation.actions.ApplyTimetableAction) Action(jmri.jmrit.operations.automation.actions.Action) ResumeAutomationAction(jmri.jmrit.operations.automation.actions.ResumeAutomationAction) WaitTrainTerminatedAction(jmri.jmrit.operations.automation.actions.WaitTrainTerminatedAction) RunSwitchListAction(jmri.jmrit.operations.automation.actions.RunSwitchListAction) HaltAction(jmri.jmrit.operations.automation.actions.HaltAction) MessageYesNoAction(jmri.jmrit.operations.automation.actions.MessageYesNoAction) NoAction(jmri.jmrit.operations.automation.actions.NoAction) GotoFailureAction(jmri.jmrit.operations.automation.actions.GotoFailureAction) MoveTrainAction(jmri.jmrit.operations.automation.actions.MoveTrainAction) PrintTrainManifestAction(jmri.jmrit.operations.automation.actions.PrintTrainManifestAction) ActivateTimetableAction(jmri.jmrit.operations.automation.actions.ActivateTimetableAction) BuildTrainIfSelectedAction(jmri.jmrit.operations.automation.actions.BuildTrainIfSelectedAction) PrintSwitchListAction(jmri.jmrit.operations.automation.actions.PrintSwitchListAction) UpdateSwitchListAction(jmri.jmrit.operations.automation.actions.UpdateSwitchListAction) ResetTrainAction(jmri.jmrit.operations.automation.actions.ResetTrainAction) TerminateTrainAction(jmri.jmrit.operations.automation.actions.TerminateTrainAction)

Example 3 with 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();
                    }
                }
            }
        }
    }
}
Also used : Action(jmri.jmrit.operations.automation.actions.Action) HaltAction(jmri.jmrit.operations.automation.actions.HaltAction) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

Action (jmri.jmrit.operations.automation.actions.Action)3 HaltAction (jmri.jmrit.operations.automation.actions.HaltAction)3 ActivateTimetableAction (jmri.jmrit.operations.automation.actions.ActivateTimetableAction)2 ApplyTimetableAction (jmri.jmrit.operations.automation.actions.ApplyTimetableAction)2 BuildTrainAction (jmri.jmrit.operations.automation.actions.BuildTrainAction)2 BuildTrainIfSelectedAction (jmri.jmrit.operations.automation.actions.BuildTrainIfSelectedAction)2 DeselectTrainAction (jmri.jmrit.operations.automation.actions.DeselectTrainAction)2 GotoAction (jmri.jmrit.operations.automation.actions.GotoAction)2 GotoFailureAction (jmri.jmrit.operations.automation.actions.GotoFailureAction)2 GotoSuccessAction (jmri.jmrit.operations.automation.actions.GotoSuccessAction)2 IsTrainEnRouteAction (jmri.jmrit.operations.automation.actions.IsTrainEnRouteAction)2 MessageYesNoAction (jmri.jmrit.operations.automation.actions.MessageYesNoAction)2 MoveTrainAction (jmri.jmrit.operations.automation.actions.MoveTrainAction)2 NoAction (jmri.jmrit.operations.automation.actions.NoAction)2 PrintSwitchListAction (jmri.jmrit.operations.automation.actions.PrintSwitchListAction)2 PrintTrainManifestAction (jmri.jmrit.operations.automation.actions.PrintTrainManifestAction)2 PrintTrainManifestIfSelectedAction (jmri.jmrit.operations.automation.actions.PrintTrainManifestIfSelectedAction)2 ResetTrainAction (jmri.jmrit.operations.automation.actions.ResetTrainAction)2 ResumeAutomationAction (jmri.jmrit.operations.automation.actions.ResumeAutomationAction)2 RunAutomationAction (jmri.jmrit.operations.automation.actions.RunAutomationAction)2