Beispiel #1
0
        private void DrawWorkspace(object sender, RoutedEventArgs e)
        {
            WorkspaceDrawer drawer = new WorkspaceDrawer(400, 400, Color.White)
            {
                WorkspaceSize = new SizeF(1000, 1000),
                FrameColor    = Color.Gray,
                ColorTable    = testTable
            };

            SizeF palletSize    = new SizeF(250, 125);
            SizeF cartridgeSize = new SizeF(70, 50);

            WorkingSpace workingSpace = new WorkingSpace(new Robot(), palletSize, cartridgeSize, 10.0f);

            for (int i = 0; i < 8; ++i)
            {
                workingSpace.GetPalletSlot(i).Pallet = RandPallet(5, 5, 20, 5);
            }

            for (int i = 0; i < workingSpace.CartridgesSlotsCount; ++i)
            {
                workingSpace.GetCartridgeSlot(i).Cartridge = new ColorCartridge(NextColor(), 10);
            }

            workingSpace.GetCartridgeSlot(3).Cartridge = new ColorCartridge(NextColor(), 0);

            drawer.Draw(workingSpace, new PointF(200, 200));

            UpdateImage(drawer.Drawing);
        }
Beispiel #2
0
        private IAssemblingAction GetNextBlock(Robot robot, WorkingSpace workingSpace)
        {
            // First non-empty cartridge
            for (int i = 0; i < workingSpace.CartridgesSlotsCount; ++i)
            {
                var slot = workingSpace.GetCartridgeSlot(i);
                if (slot.Cartridge != null && slot.Cartridge.CurrentCount > 0)
                {
                    return(new GetBlockAction(robot, slot));
                }
            }

            return(null);
        }
Beispiel #3
0
        private void AssemblyMozaic(object sender, RoutedEventArgs e)
        {
            SizeF palletSize    = new SizeF(125, 125);
            SizeF cartridgeSize = new SizeF(70, 50);

            Robot robot = new Robot()
            {
                CatchBlockTime = TimeSpan.FromSeconds(1),
                PutBlockTime   = TimeSpan.FromSeconds(1.5),
                MovementSpeed  = 5.0f
            };

            WorkingSpace workingSpace = new WorkingSpace(robot, palletSize, cartridgeSize, 10.0f);

            for (int i = 0; i < 8; ++i)
            {
                workingSpace.GetPalletSlot(i).Pallet = new Pallet(5, 5, 20, 5);
            }

            for (int i = 0; i < workingSpace.CartridgesSlotsCount; ++i)
            {
                workingSpace.GetCartridgeSlot(i).Cartridge = new ColorCartridge(NextColor(), 10);
            }

            testSequence = new AssemblingSequence()
            {
                WorkingSpace = workingSpace,
                Actions      = new List <IAssemblingAction>()
            };


            WorkspaceDrawer drawer = new WorkspaceDrawer(400, 400, Color.White)
            {
                WorkspaceSize = new SizeF(1000, 1000),
                FrameColor    = Color.Gray,
                ColorTable    = testTable
            };

            drawer.Draw(testSequence.WorkingSpace, new PointF(200, 200));

            UpdateImage(drawer.Drawing);
        }
Beispiel #4
0
        private IAssemblingAction PutNextBlock(Robot robot, WorkingSpace workingSpace)
        {
            // First non-empty block
            for (int i = 0; i < 8; ++i)
            {
                var slot = workingSpace.GetPalletSlot(i);
                if (slot.Pallet != null)
                {
                    for (int r = 0; r < slot.Pallet.BlocksColors.Rows(); ++r)
                    {
                        for (int c = 0; c < slot.Pallet.BlocksColors.Cols(); ++c)
                        {
                            if (slot.Pallet.BlocksColors[r, c] < 0)
                            {
                                return(new PutBlockAction(robot, slot, new System.Drawing.Point(c, r)));
                            }
                        }
                    }
                }
            }

            return(null);
        }