コード例 #1
0
        private static void SchedulePart(
            MazakWriteData transSet, int SchID, string mazakPartName, string mazakComment, int numProcess,
            JobPlan part, int proc1path, int earlierConflicts, bool UseStartingOffsetForDueDate)
        {
            var newSchRow = new MazakScheduleRow();

            newSchRow.Command            = MazakWriteCommand.Add;
            newSchRow.Id                 = SchID;
            newSchRow.PartName           = mazakPartName;
            newSchRow.PlanQuantity       = part.GetPlannedCyclesOnFirstProcess(proc1path);
            newSchRow.CompleteQuantity   = 0;
            newSchRow.FixForMachine      = 0;
            newSchRow.MissingFixture     = 0;
            newSchRow.MissingProgram     = 0;
            newSchRow.MissingTool        = 0;
            newSchRow.MixScheduleID      = 0;
            newSchRow.ProcessingPriority = 0;
            newSchRow.Comment            = mazakComment;

            if (UseStartingOffsetForDueDate)
            {
                if (part.GetSimulatedStartingTimeUTC(1, proc1path) != DateTime.MinValue)
                {
                    var start = part.GetSimulatedStartingTimeUTC(1, proc1path);
                    newSchRow.DueDate  = start.ToLocalTime().Date;
                    newSchRow.Priority = 91 + Math.Min(earlierConflicts, 9);
                }
                else
                {
                    newSchRow.DueDate  = DateTime.Today;
                    newSchRow.Priority = 91;
                }
            }
            else
            {
                newSchRow.Priority = 75;
                newSchRow.DueDate  = DateTime.Parse("1/1/2008 12:00:00 AM");
            }

            bool entireHold = false;

            if (part.HoldEntireJob != null)
            {
                entireHold = part.HoldEntireJob.IsJobOnHold;
            }
            bool machiningHold = false;

            if (part.HoldMachining(1, proc1path) != null)
            {
                machiningHold = part.HoldMachining(1, proc1path).IsJobOnHold;
            }
            newSchRow.HoldMode = (int)HoldPattern.CalculateHoldMode(entireHold, machiningHold);

            int matQty = newSchRow.PlanQuantity;

            if (!string.IsNullOrEmpty(part.GetInputQueue(process: 1, path: proc1path)))
            {
                matQty = 0;
            }

            //need to add all the ScheduleProcess rows
            for (int i = 1; i <= numProcess; i++)
            {
                var newSchProcRow = new MazakScheduleProcessRow();
                newSchProcRow.MazakScheduleRowId = SchID;
                newSchProcRow.ProcessNumber      = i;
                if (i == 1)
                {
                    newSchProcRow.ProcessMaterialQuantity = matQty;
                }
                else
                {
                    newSchProcRow.ProcessMaterialQuantity = 0;
                }
                newSchProcRow.ProcessBadQuantity     = 0;
                newSchProcRow.ProcessExecuteQuantity = 0;
                newSchProcRow.ProcessMachine         = 0;

                newSchRow.Processes.Add(newSchProcRow);
            }

            transSet.Schedules.Add(newSchRow);
        }
コード例 #2
0
        private IEnumerable <ScheduleWithQueues> LoadSchedules(MazakSchedulesAndLoadActions mazakData)
        {
            var loadOpers    = mazakData.LoadActions;
            var schs         = new List <ScheduleWithQueues>();
            var pending      = _log.AllPendingLoads();
            var skippedParts = new HashSet <string>();

            foreach (var schRow in mazakData.Schedules.OrderBy(s => s.DueDate).ThenBy(s => s.Priority))
            {
                if (!MazakPart.IsSailPart(schRow.PartName))
                {
                    continue;
                }

                MazakPart.ParseComment(schRow.Comment, out string unique, out var procToPath, out bool manual);

                var job = _jobDB.LoadJob(unique);
                if (job == null)
                {
                    continue;
                }

                // only if no load or unload action is in process
                bool foundJobAtLoad = false;
                foreach (var action in loadOpers)
                {
                    if (action.Unique == job.UniqueStr && action.Path == procToPath.PathForProc(action.Process))
                    {
                        foundJobAtLoad = true;
                        skippedParts.Add(job.PartName);
                        log.Debug("Not editing queued material because {uniq} is in the process of being loaded or unload with action {@action}", job.UniqueStr, action);
                        break;
                    }
                }
                foreach (var pendingLoad in pending)
                {
                    var s = pendingLoad.Key.Split(',');
                    if (schRow.PartName == s[0])
                    {
                        skippedParts.Add(job.PartName);
                        foundJobAtLoad = true;
                        log.Debug("Not editing queued material because found a pending load {@pendingLoad}", pendingLoad);
                        break;
                    }
                }
                if (foundJobAtLoad)
                {
                    continue;
                }

                // start building the schedule
                var sch = new ScheduleWithQueues()
                {
                    SchRow = schRow,
                    Unique = unique,
                    Job    = job,
                    LowerPriorityScheduleMatchingPartSkipped = skippedParts.Contains(job.PartName),
                    Procs = new Dictionary <int, ScheduleWithQueuesProcess>(),
                };
                bool missingProc = false;
                for (int proc = 1; proc <= job.NumProcesses; proc++)
                {
                    MazakScheduleProcessRow schProcRow = null;
                    foreach (var row in schRow.Processes)
                    {
                        if (row.ProcessNumber == proc)
                        {
                            schProcRow = row;
                            break;
                        }
                    }
                    if (schProcRow == null)
                    {
                        log.Error("Unable to find process {proc} for job {uniq} and schedule {schid}", proc, job.UniqueStr, schRow.Id);
                        missingProc = true;
                        break;
                    }
                    var path = procToPath.PathForProc(proc);
                    sch.Procs.Add(proc, new ScheduleWithQueuesProcess()
                    {
                        SchProcRow = schProcRow,
                        PathGroup  = job.GetPathGroup(process: proc, path: path),
                        InputQueue = job.GetInputQueue(process: proc, path: path)
                    });
                }
                if (!missingProc)
                {
                    schs.Add(sch);
                }
            }
            return(schs);
        }