Пример #1
0
        public void DeleteCompletedAndDecrementSchedules()
        {
            var schedules = new MazakSchedules()
            {
                Schedules = new[] {
                    new MazakScheduleRow()
                    {
                        Id               = 1,
                        PartName         = "part1:1:1",
                        Comment          = MazakPart.CreateComment("uniq1", new [] { 1 }, false),
                        PlanQuantity     = 15,
                        CompleteQuantity = 15,
                        Priority         = 50,
                        Processes        =
                        {
                            new MazakScheduleProcessRow()
                            {
                                MazakScheduleRowId = 1,
                                FixedMachineFlag   = 1,
                                ProcessNumber      = 1
                            }
                        }
                    },
                    new MazakScheduleRow()
                    {
                        Id               = 2,
                        PartName         = "part2:1:1",
                        Comment          = MazakPart.CreateComment("uniq2", new [] { 1 }, false),
                        PlanQuantity     = 15,
                        CompleteQuantity = 10,
                        Priority         = 50,
                        Processes        =
                        {
                            new MazakScheduleProcessRow()
                            {
                                MazakScheduleRowId      = 1,
                                FixedMachineFlag        = 1,
                                ProcessNumber           = 1,
                                ProcessMaterialQuantity = 3,
                                ProcessExecuteQuantity  = 2
                            }
                        }
                    }
                }
            };

            var(actions, tokeep) = BuildMazakSchedules.RemoveCompletedAndDecrementSchedules(schedules, DecrementPriorityOnDownload: true);

            schedules.Schedules.First().Command = MazakWriteCommand.Delete;
            schedules.Schedules.Skip(1).First().Command  = MazakWriteCommand.ScheduleSafeEdit;
            schedules.Schedules.Skip(1).First().Priority = 40;
            schedules.Schedules.Skip(1).First().Processes.Clear();

            actions.Schedules.Should().BeEquivalentTo(schedules.Schedules);
            actions.Parts.Should().BeEmpty();
            actions.Fixtures.Should().BeEmpty();
            actions.Pallets.Should().BeEmpty();

            tokeep.Should().BeEquivalentTo(new[] { "part2:1:1" });
        }
Пример #2
0
        public void AddsSchedules()
        {
            //basic job
            var job1 = new JobPlan("uniq1", 2, new int[] { 2, 2 });

            job1.PartName = "part1";
            job1.SetPathGroup(1, 1, 1);
            job1.SetPathGroup(1, 2, 2);
            job1.SetPathGroup(2, 1, 1);
            job1.SetPathGroup(2, 2, 2);
            job1.SetSimulatedStartingTimeUTC(1, 1, new DateTime(2018, 1, 9, 8, 7, 6, DateTimeKind.Local).ToUniversalTime());
            job1.SetSimulatedStartingTimeUTC(1, 2, new DateTime(2018, 1, 2, 3, 4, 5, DateTimeKind.Local).ToUniversalTime());
            job1.SetPlannedCyclesOnFirstProcess(1, 51);
            job1.SetPlannedCyclesOnFirstProcess(2, 41);
            job1.SetFixtureFace(1, 1, "fixA", 1);
            job1.SetFixtureFace(1, 2, "fixA", 1);
            job1.SetFixtureFace(2, 1, "fixA", 2);
            job1.SetFixtureFace(2, 2, "fixA", 2);

            //one with an input queue
            var job2 = new JobPlan("uniq2", 2, new int[] { 2, 2 });

            job2.PartName = "part2";
            job2.SetPathGroup(1, 1, 1);
            job2.SetPathGroup(1, 2, 2);
            job2.SetPathGroup(2, 1, 1);
            job2.SetPathGroup(2, 2, 2);
            job2.SetSimulatedStartingTimeUTC(1, 1, new DateTime(2018, 2, 9, 8, 7, 6, DateTimeKind.Local).ToUniversalTime());
            job2.SetSimulatedStartingTimeUTC(1, 2, new DateTime(2018, 2, 2, 3, 4, 5, DateTimeKind.Local).ToUniversalTime());
            job2.SetPlannedCyclesOnFirstProcess(1, 12);
            job2.SetPlannedCyclesOnFirstProcess(2, 42);
            job2.SetInputQueue(1, 1, "aaa");
            job2.SetInputQueue(1, 2, "bbb");
            job2.SetFixtureFace(1, 1, "fixA", 2); // conflicts with both job1 paths
            job2.SetFixtureFace(2, 2, "fixB", 2); // no conflicts

            //a schedule which already exists
            var job3 = new JobPlan("uniq3", 2, new int[] { 1, 1 });

            job3.PartName = "part3";
            job3.SetSimulatedStartingTimeUTC(1, 1, new DateTime(2018, 3, 9, 8, 7, 6, DateTimeKind.Local).ToUniversalTime());
            job3.SetPlannedCyclesOnFirstProcess(1, 23);

            // all the parts, plus a schedule for uniq3
            var curData = new MazakSchedulesPartsPallets()
            {
                Parts = new[] {
                    new MazakPartRow()
                    {
                        PartName = "part1:6:1",
                        Comment  = MazakPart.CreateComment("uniq1", new[] { 1, 1 }, false)
                    },
                    new MazakPartRow()
                    {
                        PartName = "part1:6:2",
                        Comment  = MazakPart.CreateComment("uniq1", new[] { 2, 2 }, false)
                    },
                    new MazakPartRow()
                    {
                        PartName = "part2:6:1",
                        Comment  = MazakPart.CreateComment("uniq2", new[] { 1, 1 }, false)
                    },
                    new MazakPartRow()
                    {
                        PartName = "part2:6:2",
                        Comment  = MazakPart.CreateComment("uniq2", new[] { 2, 2 }, false)
                    },
                    new MazakPartRow()
                    {
                        PartName = "part3:6:1",
                        Comment  = MazakPart.CreateComment("uniq3", new[] { 1, 1 }, false)
                    }
                },
                Schedules = new[] {
                    new MazakScheduleRow()
                    {
                        Id       = 1,
                        PartName = "part3:6:1",
                        Comment  = MazakPart.CreateComment("uniq3", new[] { 1, 1 }, false)
                    }
                }
            };

            var actions = BuildMazakSchedules.AddSchedules(curData, new[] { job1, job2, job3 }, true);

            actions.Parts.Should().BeEmpty();
            actions.Fixtures.Should().BeEmpty();
            actions.Pallets.Should().BeEmpty();

            actions.Schedules.Should().BeEquivalentTo(new[]
            {
                //uniq1
                new MazakScheduleRow()
                {
                    Command      = MazakWriteCommand.Add,
                    Id           = 2,
                    PartName     = "part1:6:1",
                    Comment      = MazakPart.CreateComment("uniq1", new[] { 1, 1 }, false),
                    PlanQuantity = 51,
                    Priority     = 91 + 1, // one earlier conflict
                    DueDate      = new DateTime(2018, 1, 9, 0, 0, 0, DateTimeKind.Local),
                    Processes    =
                    {
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 2,
                            ProcessNumber           = 1,
                            ProcessMaterialQuantity = 51
                        },
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 2,
                            ProcessNumber           = 2,
                            ProcessMaterialQuantity = 0
                        },
                    }
                },
                new MazakScheduleRow()
                {
                    Command      = MazakWriteCommand.Add,
                    Id           = 3,
                    PartName     = "part1:6:2",
                    Comment      = MazakPart.CreateComment("uniq1", new[] { 2, 2 }, false),
                    PlanQuantity = 41,
                    Priority     = 91,
                    DueDate      = new DateTime(2018, 1, 2, 0, 0, 0, DateTimeKind.Local),
                    Processes    =
                    {
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 3,
                            ProcessNumber           = 1,
                            ProcessMaterialQuantity = 41
                        },
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 3,
                            ProcessNumber           = 2,
                            ProcessMaterialQuantity = 0
                        },
                    }
                },

                //uniq2
                new MazakScheduleRow()
                {
                    Command      = MazakWriteCommand.Add,
                    Id           = 4,
                    PartName     = "part2:6:1",
                    Comment      = MazakPart.CreateComment("uniq2", new[] { 1, 1 }, false),
                    PlanQuantity = 12,
                    Priority     = 91 + 2, // conflicts with 2 earlier
                    DueDate      = new DateTime(2018, 2, 9, 0, 0, 0, DateTimeKind.Local),
                    Processes    =
                    {
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 4,
                            ProcessNumber           = 1,
                            ProcessMaterialQuantity = 0 // no material, input queue
                        },
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 4,
                            ProcessNumber           = 2,
                            ProcessMaterialQuantity = 0
                        },
                    }
                },
                new MazakScheduleRow()
                {
                    Command      = MazakWriteCommand.Add,
                    Id           = 5,
                    PartName     = "part2:6:2",
                    Comment      = MazakPart.CreateComment("uniq2", new[] { 2, 2 }, false),
                    PlanQuantity = 42,
                    Priority     = 91,
                    DueDate      = new DateTime(2018, 2, 2, 0, 0, 0, DateTimeKind.Local),
                    Processes    =
                    {
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 5,
                            ProcessNumber           = 1,
                            ProcessMaterialQuantity = 0 //no material, input queue
                        },
                        new MazakScheduleProcessRow()
                        {
                            MazakScheduleRowId      = 5,
                            ProcessNumber           = 2,
                            ProcessMaterialQuantity = 0
                        },
                    }
                }
            });
        }