Ejemplo n.º 1
0
        private static PalletLocation FindPalletLocation(IMachineGroupName machName, MazakSchedulesPartsPallets mazakData, MazakDbType dbType, int palletNum)
        {
            foreach (var palLocRow in mazakData.PalletPositions)
            {
                if (palLocRow.PalletNumber == palletNum)
                {
                    if (dbType != MazakDbType.MazakVersionE)
                    {
                        return(ParseStatNameWeb(machName, palLocRow.PalletPosition));
                    }
                    else
                    {
                        return(ParseStatNameVerE(machName, palLocRow.PalletPosition));
                    }
                }
            }

            return(new PalletLocation(PalletLocationEnum.Buffer, "Buffer", 0));
        }
Ejemplo n.º 2
0
        private static void CalculateMaxProcAndPath(MazakSchedulesPartsPallets mazakData,
                                                    out Dictionary <string, int> uniqueToMaxProc1Path,
                                                    out Dictionary <string, int> uniqueToMaxProcess)
        {
            uniqueToMaxProc1Path = new Dictionary <string, int>();
            uniqueToMaxProcess   = new Dictionary <string, int>();
            foreach (var partRow in mazakData.Parts)
            {
                if (MazakPart.IsSailPart(partRow.PartName) && !string.IsNullOrEmpty(partRow.Comment))
                {
                    string jobUnique = "";
                    bool   manual    = false;
                    int    numProc   = partRow.Processes.Count;

                    MazakPart.ParseComment(partRow.Comment, out jobUnique, out var paths, out manual);

                    if (uniqueToMaxProc1Path.ContainsKey(jobUnique))
                    {
                        uniqueToMaxProc1Path[jobUnique] = Math.Max(uniqueToMaxProc1Path[jobUnique], paths.PathForProc(proc: 1));
                    }
                    else
                    {
                        uniqueToMaxProc1Path.Add(jobUnique, paths.PathForProc(proc: 1));
                    }

                    if (uniqueToMaxProcess.ContainsKey(jobUnique))
                    {
                        if (numProc != uniqueToMaxProcess[jobUnique])
                        {
                            Log.Warning("Paths for {uniq} have a different number of processes", jobUnique);
                        }
                    }
                    else
                    {
                        uniqueToMaxProcess.Add(jobUnique, numProc);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void AddRoutingToJob(MazakSchedulesPartsPallets mazakData, MazakPartRow partRow, JobPlan job, IMachineGroupName machineGroupName, MazakPart.IProcToPath procToPath, MazakDbType mazakTy)
        {
            //Add routing and pallets
            foreach (var partProcRow in partRow.Processes)
            {
                var path = procToPath.PathForProc(partProcRow.ProcessNumber);
                job.SetPartsPerPallet(partProcRow.ProcessNumber, path, partProcRow.FixQuantity);
                job.SetPathGroup(partProcRow.ProcessNumber, path, path);
                job.SetHoldMachining(partProcRow.ProcessNumber, path, job.HoldMachining(partProcRow.ProcessNumber, path));
                job.SetHoldLoadUnload(partProcRow.ProcessNumber, path, job.HoldLoadUnload(partProcRow.ProcessNumber, path));

                //Routing
                string fixStr    = partProcRow.FixLDS;
                string cutStr    = partProcRow.CutMc;
                string removeStr = partProcRow.RemoveLDS;

                if (mazakTy != MazakDbType.MazakVersionE)
                {
                    fixStr    = ConvertStatIntV2ToV1(Convert.ToInt32(fixStr));
                    cutStr    = ConvertStatIntV2ToV1(Convert.ToInt32(cutStr));
                    removeStr = ConvertStatIntV2ToV1(Convert.ToInt32(removeStr));
                }

                foreach (char c in fixStr)
                {
                    if (c != '0')
                    {
                        job.AddLoadStation(partProcRow.ProcessNumber, path, int.Parse(c.ToString()));
                    }
                }
                foreach (char c in removeStr)
                {
                    if (c != '0')
                    {
                        job.AddUnloadStation(partProcRow.ProcessNumber, path, int.Parse(c.ToString()));
                    }
                }

                JobMachiningStop routeStop = null;
                foreach (char c in cutStr)
                {
                    if (c != '0')
                    {
                        if (routeStop == null)
                        {
                            routeStop = new JobMachiningStop(machineGroupName.MachineGroupName);
                            job.AddMachiningStop(partProcRow.ProcessNumber, path, routeStop);
                        }
                        routeStop.Stations.Add(int.Parse(c.ToString()));
                    }
                }

                if (routeStop != null)
                {
                    routeStop.ProgramName = partProcRow.MainProgram;
                }

                //Planned Pallets
                foreach (var palRow in mazakData.Pallets)
                {
                    if (palRow.PalletNumber > 0 &&
                        palRow.Fixture == partProcRow.Fixture &&
                        !job.HasPallet(partProcRow.ProcessNumber, path, palRow.PalletNumber.ToString()))
                    {
                        job.AddProcessOnPallet(partProcRow.ProcessNumber, path, palRow.PalletNumber.ToString());
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static MazakWriteData AddSchedules(
            MazakSchedulesPartsPallets mazakData,
            IEnumerable <JobPlan> jobs,
            bool UseStartingOffsetForDueDate)
        {
            var transSet = new MazakWriteData();

            var usedScheduleIDs = new HashSet <int>();
            var scheduledParts  = new HashSet <string>();

            foreach (var schRow in mazakData.Schedules)
            {
                usedScheduleIDs.Add(schRow.Id);
                scheduledParts.Add(schRow.PartName);
            }

            //now add the new schedule
            foreach (JobPlan part in jobs)
            {
                for (int proc1path = 1; proc1path <= part.GetNumPaths(1); proc1path++)
                {
                    if (part.GetPlannedCyclesOnFirstProcess(proc1path) <= 0)
                    {
                        continue;
                    }

                    //check if part exists downloaded
                    int    downloadUid   = -1;
                    string mazakPartName = "";
                    string mazakComment  = "";
                    foreach (var partRow in mazakData.Parts)
                    {
                        if (MazakPart.IsSailPart(partRow.PartName))
                        {
                            MazakPart.ParseComment(partRow.Comment, out string u, out var ps, out bool m);
                            if (u == part.UniqueStr && ps.PathForProc(proc: 1) == proc1path)
                            {
                                downloadUid   = MazakPart.ParseUID(partRow.PartName);
                                mazakPartName = partRow.PartName;
                                mazakComment  = partRow.Comment;
                                break;
                            }
                        }
                    }
                    if (downloadUid < 0)
                    {
                        throw new BlackMaple.MachineFramework.BadRequestException(
                                  "Attempting to create schedule for " + part.UniqueStr + " but a part does not exist");
                    }

                    if (!scheduledParts.Contains(mazakPartName))
                    {
                        int schid            = FindNextScheduleId(usedScheduleIDs);
                        int earlierConflicts = CountEarlierConflicts(part, proc1path, jobs);
                        SchedulePart(transSet, schid, mazakPartName, mazakComment, part.NumProcesses, part, proc1path, earlierConflicts, UseStartingOffsetForDueDate);
                    }
                }
            }

            if (UseStartingOffsetForDueDate)
            {
                SortSchedulesByDate(transSet);
            }

            return(transSet);
        }
Ejemplo n.º 5
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
                        },
                    }
                }
            });
        }