Search in sources :

Example 1 with ActivateTimetableAction

use of jmri.jmrit.operations.automation.actions.ActivateTimetableAction 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 ActivateTimetableAction

use of jmri.jmrit.operations.automation.actions.ActivateTimetableAction in project JMRI by JMRI.

the class AutomationManagerTest method testCopyAutomation.

/**
     * Creates an automation with 5 items, and checks to see if all items
     * are copied correctly.
     */
public void testCopyAutomation() {
    AutomationManager manager = AutomationManager.instance();
    Assert.assertNotNull("test creation", manager);
    Automation automation = manager.newAutomation("TestAutomation");
    automation.setComment("test comment for automation");
    Assert.assertEquals(1, manager.getSize());
    AutomationItem item1 = automation.addItem();
    item1.setAction(new BuildTrainAction());
    item1.setTrain(new Train("trainId", "trainName1"));
    item1.setMessage("item1 OK message");
    item1.setMessageFail("item1 fail message");
    item1.setHaltFailureEnabled(false);
    AutomationItem item2 = automation.addItem();
    item2.setAction(new GotoAction());
    item2.setGotoAutomationItem(item1);
    AutomationItem item3 = automation.addItem();
    item3.setAction(new MoveTrainAction());
    item3.setTrain(new Train("trainId", "trainName2"));
    item3.setRouteLocation(new RouteLocation("id", new Location("id", "testLocationName")));
    AutomationItem item4 = automation.addItem();
    item4.setAction(new ActivateTimetableAction());
    TrainSchedule trainSchedule = TrainScheduleManager.instance().newSchedule("train schedule name");
    item4.setOther(trainSchedule);
    AutomationItem item5 = automation.addItem();
    item5.setAction(new RunAutomationAction());
    Automation automationToRun = manager.newAutomation("TestAutomation2");
    item5.setOther(automationToRun);
    item5.setMessage("item5 OK message");
    item5.setMessageFail("item5 fail message");
    item5.setHaltFailureEnabled(false);
    Automation copy = manager.copyAutomation(automation, "Copy");
    Assert.assertNotNull("test automation creation", copy);
    // There are now three automations
    Assert.assertEquals("The number of automations", 3, manager.getSize());
    Assert.assertEquals("The number of items", 5, copy.getSize());
    Assert.assertEquals(copy.getComment(), automation.getComment());
    AutomationItem copyItem1 = copy.getItemBySequenceId(1);
    Assert.assertEquals("1st item is build train", copyItem1.getActionName(), item1.getActionName());
    Assert.assertNotNull(copyItem1.getTrain());
    Assert.assertNull(copyItem1.getGotoAutomationItem());
    Assert.assertNull(copyItem1.getTrainSchedule());
    Assert.assertNull(copyItem1.getRouteLocation());
    Assert.assertEquals(copyItem1.getTrain(), item1.getTrain());
    Assert.assertEquals("item1 OK message", copyItem1.getMessage());
    Assert.assertEquals("item1 fail message", copyItem1.getMessageFail());
    Assert.assertNull(copyItem1.getAutomationToRun());
    Assert.assertFalse(copyItem1.isHaltFailureEnabled());
    AutomationItem copyItem2 = copy.getItemBySequenceId(2);
    Assert.assertEquals("2nd item is goto", copyItem2.getActionName(), item2.getActionName());
    Assert.assertNull(copyItem2.getTrain());
    Assert.assertNotNull(copyItem2.getGotoAutomationItem());
    Assert.assertNull(copyItem2.getTrainSchedule());
    Assert.assertNull(copyItem2.getRouteLocation());
    Assert.assertEquals(copyItem2.getGotoAutomationItem().getActionName(), item2.getGotoAutomationItem().getActionName());
    Assert.assertNull(copyItem2.getAutomationToRun());
    Assert.assertEquals("", copyItem2.getMessage());
    Assert.assertEquals("", copyItem2.getMessageFail());
    Assert.assertTrue(copyItem2.isHaltFailureEnabled());
    AutomationItem copyItem3 = copy.getItemBySequenceId(3);
    Assert.assertEquals("3rd item is move train", copyItem3.getActionName(), item3.getActionName());
    Assert.assertNotNull(copyItem3.getTrain());
    Assert.assertNull(copyItem3.getGotoAutomationItem());
    Assert.assertNull(copyItem3.getTrainSchedule());
    Assert.assertNotNull(copyItem3.getRouteLocation());
    Assert.assertEquals(copyItem3.getTrain(), item3.getTrain());
    Assert.assertEquals(copyItem3.getRouteLocation(), item3.getRouteLocation());
    Assert.assertNull(copyItem3.getAutomationToRun());
    Assert.assertEquals("", copyItem3.getMessage());
    Assert.assertEquals("", copyItem3.getMessageFail());
    Assert.assertTrue(copyItem3.isHaltFailureEnabled());
    AutomationItem copyItem4 = copy.getItemBySequenceId(4);
    Assert.assertEquals("4th item is activate train schedule", copyItem4.getActionName(), item4.getActionName());
    Assert.assertNull(copyItem4.getTrain());
    Assert.assertNull(copyItem4.getGotoAutomationItem());
    Assert.assertNull(copyItem4.getRouteLocation());
    Assert.assertNotNull(copyItem4.getTrainSchedule());
    Assert.assertEquals(trainSchedule, copyItem4.getTrainSchedule());
    Assert.assertNull(copyItem4.getAutomationToRun());
    Assert.assertEquals("", copyItem4.getMessage());
    Assert.assertEquals("", copyItem4.getMessageFail());
    Assert.assertTrue(copyItem4.isHaltFailureEnabled());
    AutomationItem copyItem5 = copy.getItemBySequenceId(5);
    Assert.assertEquals("5th item is run automation", copyItem5.getActionName(), item5.getActionName());
    Assert.assertNull(copyItem5.getTrain());
    Assert.assertNull(copyItem5.getGotoAutomationItem());
    Assert.assertNull(copyItem5.getRouteLocation());
    Assert.assertNull(copyItem5.getTrainSchedule());
    Assert.assertNotNull(copyItem5.getAutomationToRun());
    Assert.assertEquals(automationToRun, copyItem5.getAutomationToRun());
    Assert.assertEquals("item5 OK message", copyItem5.getMessage());
    Assert.assertEquals("item5 fail message", copyItem5.getMessageFail());
    Assert.assertFalse(copyItem5.isHaltFailureEnabled());
}
Also used : BuildTrainAction(jmri.jmrit.operations.automation.actions.BuildTrainAction) GotoAction(jmri.jmrit.operations.automation.actions.GotoAction) MoveTrainAction(jmri.jmrit.operations.automation.actions.MoveTrainAction) TrainSchedule(jmri.jmrit.operations.trains.timetable.TrainSchedule) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) Train(jmri.jmrit.operations.trains.Train) RunAutomationAction(jmri.jmrit.operations.automation.actions.RunAutomationAction) ActivateTimetableAction(jmri.jmrit.operations.automation.actions.ActivateTimetableAction) RouteLocation(jmri.jmrit.operations.routes.RouteLocation) Location(jmri.jmrit.operations.locations.Location)

Example 3 with ActivateTimetableAction

use of jmri.jmrit.operations.automation.actions.ActivateTimetableAction in project JMRI by JMRI.

the class AutomationItemTest method testTrainSchedule.

public void testTrainSchedule() {
    AutomationItem automationItem = new AutomationItem("TestId");
    Assert.assertNotNull("test creation", automationItem);
    Assert.assertEquals("test id", "TestId", automationItem.getId());
    TrainSchedule trainSchedule = TrainScheduleManager.instance().newSchedule("TestScheduleName");
    automationItem.setTrainSchedule(trainSchedule);
    Assert.assertEquals("Do nothing action can't have a train schedule assignment", null, automationItem.getTrainSchedule());
    automationItem.setAction(new ActivateTimetableAction());
    Assert.assertEquals(trainSchedule, automationItem.getTrainSchedule());
    automationItem.setTrainSchedule(null);
    Assert.assertEquals(null, automationItem.getTrainSchedule());
    automationItem.setOther(trainSchedule);
    Assert.assertEquals(trainSchedule, automationItem.getTrainSchedule());
}
Also used : TrainSchedule(jmri.jmrit.operations.trains.timetable.TrainSchedule) ActivateTimetableAction(jmri.jmrit.operations.automation.actions.ActivateTimetableAction)

Aggregations

ActivateTimetableAction (jmri.jmrit.operations.automation.actions.ActivateTimetableAction)3 BuildTrainAction (jmri.jmrit.operations.automation.actions.BuildTrainAction)2 GotoAction (jmri.jmrit.operations.automation.actions.GotoAction)2 MoveTrainAction (jmri.jmrit.operations.automation.actions.MoveTrainAction)2 RunAutomationAction (jmri.jmrit.operations.automation.actions.RunAutomationAction)2 TrainSchedule (jmri.jmrit.operations.trains.timetable.TrainSchedule)2 ArrayList (java.util.ArrayList)1 Action (jmri.jmrit.operations.automation.actions.Action)1 ApplyTimetableAction (jmri.jmrit.operations.automation.actions.ApplyTimetableAction)1 BuildTrainIfSelectedAction (jmri.jmrit.operations.automation.actions.BuildTrainIfSelectedAction)1 DeselectTrainAction (jmri.jmrit.operations.automation.actions.DeselectTrainAction)1 GotoFailureAction (jmri.jmrit.operations.automation.actions.GotoFailureAction)1 GotoSuccessAction (jmri.jmrit.operations.automation.actions.GotoSuccessAction)1 HaltAction (jmri.jmrit.operations.automation.actions.HaltAction)1 IsTrainEnRouteAction (jmri.jmrit.operations.automation.actions.IsTrainEnRouteAction)1 MessageYesNoAction (jmri.jmrit.operations.automation.actions.MessageYesNoAction)1 NoAction (jmri.jmrit.operations.automation.actions.NoAction)1 PrintSwitchListAction (jmri.jmrit.operations.automation.actions.PrintSwitchListAction)1 PrintTrainManifestAction (jmri.jmrit.operations.automation.actions.PrintTrainManifestAction)1 PrintTrainManifestIfSelectedAction (jmri.jmrit.operations.automation.actions.PrintTrainManifestIfSelectedAction)1