コード例 #1
0
 def test_hand_to_recieving_facing_away(self):
     with (self.assertRaises(NoUnitAtLocationError)):
         sys = UnitSystem()
         c1 = sys.create_conveyor((0, 0))
         c2 = sys.create_conveyor((1, 0))
         c1.direction = Direction.North
         c2.direction = Direction.North
         c1.sheet = Sheet()
         c1.put()
コード例 #2
0
 def test_hand_to_giving_facing_away(self):
     with (self.assertRaises(ConveyorFacingAwayError)):
         sys = UnitSystem()
         c1 = sys.create_conveyor((0, 0))
         c2 = sys.create_conveyor((1, 0))
         c1.direction = Direction.East
         c2.direction = Direction.North
         c1.sheet = Sheet()
         c1.put()
コード例 #3
0
    def test_hand_to_directions(self):
        sys = UnitSystem()
        c_north = sys.create_conveyor((1, 0))
        c_east = sys.create_conveyor((2, 1))
        c_south = sys.create_conveyor((1, 2))
        c_west = sys.create_conveyor((0, 1))
        c_center = sys.create_conveyor((1, 1))

        c_north.direction = Direction.South
        c_east.direction = Direction.West
        c_south.direction = Direction.North
        c_west.direction = Direction.East
        c_center.direction = Direction.North
        for _ in [c_north, c_east, c_south, c_west]:
            c_center.sheet = Sheet()
            c_center.put()
            c_center.turn_clockwise()
            while c_center.is_turning():
                pass
コード例 #4
0
def create_functional_units_and_actors(sys: UnitSystem) -> List[FunctionalUnit]:
    return [
        InputActor.start(sys.create_input_paper_stack((0, 1))),
        OutputActor.start(sys.create_output_paper_stack((3, 1))),
        ConveyorActor.start(sys.create_conveyor((1, 1))),
        ConveyorActor.start(sys.create_conveyor((2, 1))),
        PlotterActor.start(sys.create_plotter((1, 0), color=Color.Red)),
        PlotterActor.start(sys.create_plotter((2, 0), color=Color.Green)),
        PlotterActor.start(sys.create_plotter((1, 2), color=Color.Yellow)),
        PlotterActor.start(sys.create_plotter((2, 2), color=Color.Blue))]
コード例 #5
0
 def test_setup_1(self):  # check nothing crashes
     sys = UnitSystem()
     supervisor = SupervisorActor.start()
     InputActor.start(sys.create_input_paper_stack((0, 1))),
     OutputActor.start(sys.create_output_paper_stack((3, 1))),
     ConveyorActor.start(sys.create_conveyor((1, 1))),
     ConveyorActor.start(sys.create_conveyor((2, 1))),
     PlotterActor.start(sys.create_plotter((1, 0), color=Color.Red)),
     PlotterActor.start(sys.create_plotter((2, 0), color=Color.Green)),
     PlotterActor.start(sys.create_plotter((1, 3), color=Color.Yellow)),
     PlotterActor.start(sys.create_plotter((2, 3), color=Color.Blue))
     time.sleep(10)
     ActorRegistry().stop_all(block=True)
コード例 #6
0
 def test_unit_creation(self):
     sys = UnitSystem()
     ips = sys.create_input_paper_stack((0, 0))
     self.assertIsNotNone(ips)
     self.assertEqual(sys, ips.unit_sytem)
     ops = sys.create_output_paper_stack((0, 0))
     self.assertIsNotNone(ops)
     self.assertEqual(sys, ops.unit_sytem)
     plt = sys.create_plotter((0, 0), Color.Red)
     self.assertIsNotNone(plt)
     self.assertEqual(sys, plt.unit_sytem)
     con = sys.create_conveyor((0, 0))
     self.assertIsNotNone(con)
コード例 #7
0
 def test_setup_2(self):  # smaller setup
     sys = UnitSystem()
     supervisor = SupervisorActor.start()
     InputActor.start(sys.create_input_paper_stack((0, 1))),
     ops = sys.create_output_paper_stack((2, 1))
     OutputActor.start(ops),
     ConveyorActor.start(sys.create_conveyor((1, 1))),
     PlotterActor.start(sys.create_plotter((1, 0), color=Color.Red)),
     PlotterActor.start(sys.create_plotter((1, 2), color=Color.Blue)),
     sheet_orders = [SheetOrder({Color.Red: 1})]
     for order in sheet_orders:
         supervisor.tell(SheetOrderMessage(order))
     SleepyActor.start(20).stop(True)
     for order in sheet_orders:
         self.assertIn(order, ops.received_sheets)
     ActorRegistry().stop_all(block=True)