public void Visit(MachineComposite mc) { foreach (MachineComponent child in mc.Children) { child.Accept(this); } }
public static void Main() { MachineComposite dublin = ExampleMachine.Dublin(); Term sp = new Constant((Machine)dublin.Find("StarPress:1401")); Term ub = new Constant((Machine)dublin.Find("UnloadBuffer:1501")); WhileCommand wc = new WhileCommand( new HasMaterial(sp), new CarryCommand(sp, ub)); wc.Execute(); }
public static void Main() { MachineComposite dublin = ExampleMachine.Dublin(); //Machine starPress = (Machine) dublin.Find("StarPress:1401"); // uncomment to add bins //starPress.Load(new Bin(42));// and see it work //starPress.Load(new Bin(84));// Term sp = new Constant((Machine)dublin.Find("StarPress:1401")); Term ub = new Constant((Machine)dublin.Find("UnloadBuffer:1501")); WhileCommand wc = new WhileCommand( new HasMaterial(sp), new CarryCommand(sp, ub)); wc.Execute(); }
private void Execute(MachineComponent mc) { Machine m = mc as Machine; if (m != null) { _variable.Assign(new Constant(m)); _body.Execute(); return; } MachineComposite comp = mc as MachineComposite; foreach (MachineComponent child in comp.Children) { Execute(child); } }