use of jmri.jmrit.operations.automation.actions.GotoAction 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.GotoAction 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());
}
use of jmri.jmrit.operations.automation.actions.GotoAction in project JMRI by JMRI.
the class AutomationItemTest method testGotoAutomationItem.
public void testGotoAutomationItem() {
AutomationManager manager = AutomationManager.instance();
Automation automation = manager.newAutomation("testAutomationGoto");
AutomationItem item1 = automation.addItem();
AutomationItem item2 = automation.addItem();
item1.setGotoAutomationItem(item2);
Assert.assertEquals("Do nothing action can't have a goto item", null, item1.getGotoAutomationItem());
item1.setAction(new GotoAction());
Assert.assertEquals(item2, item1.getGotoAutomationItem());
item1.setGotoAutomationItem(null);
Assert.assertEquals(null, item1.getGotoAutomationItem());
item1.setOther(item2);
Assert.assertEquals(item2, item1.getGotoAutomationItem());
}
Aggregations