Пример #1
0
        private static void AddDataFromJobDB(JobDB jobDB, JobPlan jobFromMazak)
        {
            var jobFromDb = jobDB.LoadJob(jobFromMazak.UniqueStr);

            if (jobFromDb == null)
            {
                return;
            }

            jobFromMazak.RouteStartingTimeUTC = jobFromDb.RouteStartingTimeUTC;
            jobFromMazak.RouteEndingTimeUTC   = jobFromDb.RouteEndingTimeUTC;
            jobFromMazak.ScheduleId           = jobFromDb.ScheduleId;
            jobFromMazak.AddInspections(jobFromDb.GetInspections());
            jobFromMazak.HoldEntireJob = jobFromDb.HoldEntireJob;
            foreach (var b in jobFromDb.ScheduledBookingIds)
            {
                jobFromMazak.ScheduledBookingIds.Add(b);
            }
            for (int proc = 1; proc <= jobFromMazak.NumProcesses; proc++)
            {
                for (int path = 1; path <= jobFromMazak.GetNumPaths(proc); path++)
                {
                    if (proc > jobFromDb.NumProcesses || path > jobFromDb.GetNumPaths(proc))
                    {
                        continue;
                    }

                    jobFromMazak.SetSimulatedStartingTimeUTC(proc, path,
                                                             jobFromDb.GetSimulatedStartingTimeUTC(proc, path));
                    jobFromMazak.SetSimulatedAverageFlowTime(proc, path,
                                                             jobFromDb.GetSimulatedAverageFlowTime(proc, path));
                    jobFromMazak.SetSimulatedProduction(proc, path,
                                                        jobFromDb.GetSimulatedProduction(proc, path));
                    jobFromMazak.SetExpectedLoadTime(proc, path,
                                                     jobFromDb.GetExpectedLoadTime(proc, path));
                    jobFromMazak.SetExpectedUnloadTime(proc, path,
                                                       jobFromDb.GetExpectedUnloadTime(proc, path));
                    jobFromMazak.SetInputQueue(proc, path,
                                               jobFromDb.GetInputQueue(proc, path));
                    jobFromMazak.SetOutputQueue(proc, path,
                                                jobFromDb.GetOutputQueue(proc, path));

                    var mazakStops = jobFromMazak.GetMachiningStop(proc, path).ToList();
                    var dbStops    = jobFromDb.GetMachiningStop(proc, path).ToList();
                    for (int i = 0; i < Math.Min(mazakStops.Count, dbStops.Count); i++)
                    {
                        mazakStops[i].StationGroup      = dbStops[i].StationGroup;
                        mazakStops[i].ExpectedCycleTime = dbStops[i].ExpectedCycleTime;
                    }
                }
            }
        }
Пример #2
0
 public static void OffsetJob(JobPlan j, TimeSpan offset)
 {
     j.RouteStartingTimeUTC = j.RouteStartingTimeUTC.Add(offset);
     j.RouteEndingTimeUTC   = j.RouteEndingTimeUTC.Add(offset);
     for (int proc = 1; proc <= j.NumProcesses; proc++)
     {
         for (int path = 1; path <= j.GetNumPaths(proc); path++)
         {
             j.SetSimulatedStartingTimeUTC(proc, path,
                                           j.GetSimulatedStartingTimeUTC(proc, path).Add(offset)
                                           );
             var prod = new List <JobPlan.SimulatedProduction>();
             foreach (var p in j.GetSimulatedProduction(proc, path))
             {
                 prod.Add(new JobPlan.SimulatedProduction()
                 {
                     TimeUTC  = p.TimeUTC.Add(offset),
                     Quantity = p.Quantity,
                 });
             }
         }
     }
     // not converted: hold patterns
 }
Пример #3
0
        private JobPlan CreateJob()
        {
            var job1 = new JobPlan("Unique1", 2, new int[] { 2, 3 });

            job1.PartName = "Job1";
            job1.SetPlannedCyclesOnFirstProcess(1, 125);
            job1.SetPlannedCyclesOnFirstProcess(2, 53);
            job1.RouteStartingTimeUTC                    = DateTime.Parse("2019-10-22 20:24 GMT").ToUniversalTime();
            job1.RouteEndingTimeUTC                      = job1.RouteStartingTimeUTC.AddHours(100);
            job1.Archived                                = false;
            job1.JobCopiedToSystem                       = true;
            job1.ScheduleId                              = "Job1tag1245";
            job1.HoldEntireJob.UserHold                  = true;
            job1.HoldEntireJob.ReasonForUserHold         = "test string";
            job1.HoldEntireJob.HoldUnholdPatternStartUTC = job1.RouteStartingTimeUTC;
            job1.HoldEntireJob.HoldUnholdPatternRepeats  = true;
            job1.HoldEntireJob.HoldUnholdPattern.Add(TimeSpan.FromMinutes(10));
            job1.HoldEntireJob.HoldUnholdPattern.Add(TimeSpan.FromMinutes(18));
            job1.HoldEntireJob.HoldUnholdPattern.Add(TimeSpan.FromMinutes(125));
            job1.Priority         = 164;
            job1.Comment          = "Hello there";
            job1.CreateMarkerData = true;
            job1.ScheduledBookingIds.Add("booking1");
            job1.ScheduledBookingIds.Add("booking2");
            job1.ScheduledBookingIds.Add("booking3");

            job1.SetPartsPerPallet(1, 1, 10);
            job1.SetPartsPerPallet(1, 2, 15);
            job1.SetPartsPerPallet(2, 1, 20);
            job1.SetPartsPerPallet(2, 2, 22);
            job1.SetPartsPerPallet(2, 3, 23);

            job1.SetPathGroup(1, 1, 64);
            job1.SetPathGroup(1, 2, 74);
            job1.SetPathGroup(2, 1, 12);
            job1.SetPathGroup(2, 2, 88);
            job1.SetPathGroup(2, 3, 5);

            job1.SetInputQueue(1, 1, "in11");
            job1.SetOutputQueue(1, 2, "out12");
            job1.SetInputQueue(2, 1, "in21");
            job1.SetOutputQueue(2, 3, "out23");

            job1.SetSimulatedStartingTimeUTC(1, 1, DateTime.Parse("1/5/2011 11:34 PM GMT").ToUniversalTime());
            job1.SetSimulatedStartingTimeUTC(1, 2, DateTime.Parse("2/10/2011 12:45 AM GMT").ToUniversalTime());
            job1.SetSimulatedStartingTimeUTC(2, 1, DateTime.Parse("3/14/2011 2:03 AM GMT").ToUniversalTime());
            job1.SetSimulatedStartingTimeUTC(2, 2, DateTime.Parse("4/20/2011 3:22 PM GMT").ToUniversalTime());
            job1.SetSimulatedStartingTimeUTC(2, 3, DateTime.Parse("5/22/2011 4:18 AM GMT").ToUniversalTime());

            job1.SetSimulatedAverageFlowTime(1, 1, TimeSpan.FromMinutes(0.5));
            job1.SetSimulatedAverageFlowTime(1, 2, TimeSpan.FromMinutes(1.5));
            job1.SetSimulatedAverageFlowTime(2, 1, TimeSpan.FromMinutes(2.5));
            job1.SetSimulatedAverageFlowTime(2, 2, TimeSpan.FromMinutes(3.5));
            job1.SetSimulatedAverageFlowTime(2, 3, TimeSpan.FromMinutes(4.5));

            job1.AddProcessOnPallet(1, 1, "Pal2");
            job1.AddProcessOnPallet(1, 1, "Pal5");
            job1.AddProcessOnPallet(1, 2, "Pal4");
            job1.AddProcessOnPallet(1, 2, "Pal35");
            job1.AddProcessOnPallet(2, 1, "Pal12");
            job1.AddProcessOnPallet(2, 1, "Pal64");
            job1.AddProcessOnPallet(2, 2, "Hi");
            job1.AddProcessOnPallet(2, 2, "Pal2");
            job1.AddProcessOnPallet(2, 3, "Pal5");
            job1.AddProcessOnPallet(2, 3, "OMG");

            job1.SetFixtureFace(1, 1, "Fix1", 1);
            job1.SetFixtureFace(1, 2, "ABC", 4);
            job1.SetFixtureFace(2, 1, "Fix123", 6);
            // 2, 2 has non-integer face, so should be ignored
            job1.SetFixtureFace(2, 3, "Fix17", 7);

            job1.AddLoadStation(1, 1, 35);
            job1.AddLoadStation(1, 1, 64);
            job1.AddLoadStation(1, 2, 785);
            job1.AddLoadStation(1, 2, 15);
            job1.AddLoadStation(2, 1, 647);
            job1.AddLoadStation(2, 1, 474);
            job1.AddLoadStation(2, 2, 785);
            job1.AddLoadStation(2, 2, 53);
            job1.AddLoadStation(2, 3, 15);

            job1.SetExpectedLoadTime(1, 1, TimeSpan.FromSeconds(100));
            job1.SetExpectedLoadTime(1, 2, TimeSpan.FromMinutes(53));
            job1.SetExpectedLoadTime(2, 1, TimeSpan.FromHours(52));
            job1.SetExpectedLoadTime(2, 2, TimeSpan.FromSeconds(98));
            job1.SetExpectedLoadTime(2, 3, TimeSpan.FromSeconds(35));

            job1.AddUnloadStation(1, 1, 75);
            job1.AddUnloadStation(1, 1, 234);
            job1.AddUnloadStation(1, 2, 53);
            job1.AddUnloadStation(2, 1, 563);
            job1.AddUnloadStation(2, 2, 2);
            job1.AddUnloadStation(2, 2, 12);
            job1.AddUnloadStation(2, 3, 32);

            job1.SetExpectedUnloadTime(1, 1, TimeSpan.FromSeconds(13));
            job1.SetExpectedUnloadTime(1, 2, TimeSpan.FromMinutes(12));
            job1.SetExpectedUnloadTime(2, 1, TimeSpan.FromHours(63));
            job1.SetExpectedUnloadTime(2, 2, TimeSpan.FromSeconds(73));
            job1.SetExpectedUnloadTime(2, 3, TimeSpan.FromSeconds(532));

            var route = new JobMachiningStop("Machine");

            route.Stations.Add(12);
            route.Stations.Add(23);
            route.ProgramName       = "Emily";
            route.ExpectedCycleTime = TimeSpan.FromHours(1.2);
            route.Tools["tool1"]    = TimeSpan.FromMinutes(30);
            route.Tools["tool2"]    = TimeSpan.FromMinutes(35);
            job1.AddMachiningStop(1, 1, route);

            route = new JobMachiningStop("Other Machine");
            route.Stations.Add(23);
            route.Stations.Add(12);
            route.ProgramName       = "awef";
            route.ExpectedCycleTime = TimeSpan.FromHours(2.8);
            route.Tools["tool1"]    = TimeSpan.FromMinutes(9);
            route.Tools["tool33"]   = TimeSpan.FromMinutes(42);
            job1.AddMachiningStop(1, 2, route);

            route = new JobMachiningStop("Test");
            route.Stations.Add(64);
            route.Stations.Add(323);
            route.ProgramName       = "Goodbye";
            route.ExpectedCycleTime = TimeSpan.FromHours(6.3);
            route.Tools["tool2"]    = TimeSpan.FromMinutes(12);
            route.Tools["tool44"]   = TimeSpan.FromMinutes(99);
            job1.AddMachiningStop(2, 1, route);

            route = new JobMachiningStop("Test");
            route.Stations.Add(32);
            route.Stations.Add(64);
            route.ProgramName = "wefq";
            job1.AddMachiningStop(2, 2, route);

            route = new JobMachiningStop("Test");
            route.Stations.Add(245);
            route.Stations.Add(36);
            route.ProgramName = "dduuude";
            job1.AddMachiningStop(2, 1, route);

            route = new JobMachiningStop("Test");
            route.Stations.Add(23);
            route.Stations.Add(53);
            route.ProgramName = "so cool";
            job1.AddMachiningStop(2, 2, route);

            job1.AddInspection(new JobInspectionData("Insp1", "counter1", 53, TimeSpan.FromMinutes(100), 12));
            job1.AddInspection(new JobInspectionData("Insp2", "counter1", 12, TimeSpan.FromMinutes(64)));
            job1.AddInspection(new JobInspectionData("Insp3", "abcdef", 175, TimeSpan.FromMinutes(121), 2));
            job1.AddInspection(new JobInspectionData("Insp4", "counter2", 16.12, TimeSpan.FromMinutes(33)));
            job1.AddInspection(new JobInspectionData("Insp5", "counter3", 0.544, TimeSpan.FromMinutes(44)));

            job1.HoldMachining(1, 1).UserHold                  = false;
            job1.HoldMachining(1, 1).ReasonForUserHold         = "reason for user hold";
            job1.HoldMachining(1, 1).HoldUnholdPatternRepeats  = false;
            job1.HoldMachining(1, 1).HoldUnholdPatternStartUTC = DateTime.Parse("2010/5/3 7:32 PM").ToUniversalTime();
            job1.HoldMachining(1, 1).HoldUnholdPattern.Add(TimeSpan.FromMinutes(5));
            job1.HoldMachining(1, 1).HoldUnholdPattern.Add(TimeSpan.FromMinutes(53));

            job1.HoldMachining(1, 2).UserHold                  = true;
            job1.HoldMachining(1, 2).ReasonForUserHold         = "another reason for user hold";
            job1.HoldMachining(1, 2).HoldUnholdPatternRepeats  = true;
            job1.HoldMachining(1, 2).HoldUnholdPatternStartUTC = DateTime.Parse("2010/5/12 6:12 PM").ToUniversalTime();
            job1.HoldMachining(1, 2).HoldUnholdPattern.Add(TimeSpan.FromMinutes(84));
            job1.HoldMachining(1, 2).HoldUnholdPattern.Add(TimeSpan.FromMinutes(1));

            job1.HoldMachining(2, 1).UserHold                  = false;
            job1.HoldMachining(2, 1).ReasonForUserHold         = "oh my reason for user hold";
            job1.HoldMachining(2, 1).HoldUnholdPatternRepeats  = true;
            job1.HoldMachining(2, 1).HoldUnholdPatternStartUTC = DateTime.Parse("2010/9/1 1:30 PM").ToUniversalTime();
            job1.HoldMachining(2, 1).HoldUnholdPattern.Add(TimeSpan.FromMinutes(532));
            job1.HoldMachining(2, 1).HoldUnholdPattern.Add(TimeSpan.FromMinutes(64));

            job1.HoldLoadUnload(1, 1).UserHold                  = true;
            job1.HoldLoadUnload(1, 1).ReasonForUserHold         = "abcdef";
            job1.HoldLoadUnload(1, 1).HoldUnholdPatternRepeats  = true;
            job1.HoldLoadUnload(1, 1).HoldUnholdPatternStartUTC = DateTime.Parse("2010/12/2 3:32 PM").ToUniversalTime();
            job1.HoldLoadUnload(1, 1).HoldUnholdPattern.Add(TimeSpan.FromMinutes(63));
            job1.HoldLoadUnload(1, 1).HoldUnholdPattern.Add(TimeSpan.FromMinutes(7));

            job1.HoldLoadUnload(1, 2).UserHold                  = false;
            job1.HoldLoadUnload(1, 2).ReasonForUserHold         = "agr";
            job1.HoldLoadUnload(1, 2).HoldUnholdPatternRepeats  = false;
            job1.HoldLoadUnload(1, 2).HoldUnholdPatternStartUTC = DateTime.Parse("2010/6/1 3:12 PM").ToUniversalTime();
            job1.HoldLoadUnload(1, 2).HoldUnholdPattern.Add(TimeSpan.FromMinutes(174));
            job1.HoldLoadUnload(1, 2).HoldUnholdPattern.Add(TimeSpan.FromMinutes(83));

            job1.HoldLoadUnload(2, 3).UserHold                  = true;
            job1.HoldLoadUnload(2, 3).ReasonForUserHold         = "erhagsad";
            job1.HoldLoadUnload(2, 3).HoldUnholdPatternRepeats  = false;
            job1.HoldLoadUnload(2, 3).HoldUnholdPatternStartUTC = DateTime.Parse("2010/11/5 9:30 AM").ToUniversalTime();
            job1.HoldLoadUnload(2, 3).HoldUnholdPattern.Add(TimeSpan.FromMinutes(32));
            job1.HoldLoadUnload(2, 3).HoldUnholdPattern.Add(TimeSpan.FromMinutes(64));

            return(job1);
        }
Пример #4
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
                        },
                    }
                }
            });
        }