Beispiel #1
0
        public async Task ImportWorkLoad(JobPlan job)
        {
            var wlId = "INSGT-" + job.PartName.ToUpper() + "-" + DateTime.Now.ToString("yyMMddHHmm");
            var file = AllocateFilename("work", "wkl");

            var st  = job.GetSimulatedStartingTimeUTC(1, 1).ToLocalTime();
            var end = job.RouteEndingTimeUTC.ToLocalTime();


            await WriteFile(file, string.Join("\n", new[] {
                wlId,
                st.ToString(DateFormat),
                end.ToString(DateFormat),
                job.Priority.ToString(),
                "R-" + job.PartName,
                job.UniqueStr,
                "FMS-INSIGHT",
                "/",
                job.PartName,
                "0",
                job.GetPlannedCyclesOnFirstProcess(1).ToString(),
                "/"
            }));

            await _plantHost.Send("imwrkl -w " + wlId + " -s -c -W " + file.CellPath);
        }
Beispiel #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
 }
Beispiel #3
0
        /// Count up how many JobPaths have an earlier simulation start time and also share a fixture/face with the current job
        private static int CountEarlierConflicts(JobPlan jobToCheck, int proc1path, IEnumerable <JobPlan> jobs)
        {
            var startT = jobToCheck.GetSimulatedStartingTimeUTC(process: 1, path: proc1path);

            if (startT == DateTime.MinValue)
            {
                return(0);
            }

            // first, calculate the fixtures and faces used by the job to check
            var group            = jobToCheck.GetPathGroup(process: 1, path: proc1path);
            var usedFixtureFaces = new HashSet <ValueTuple <string, string> >();

            for (int proc = 1; proc <= jobToCheck.NumProcesses; proc++)
            {
                for (int path = 1; path <= jobToCheck.GetNumPaths(proc); path++)
                {
                    if (jobToCheck.GetPathGroup(proc, path) != group)
                    {
                        continue;
                    }
                    var(plannedFix, plannedFace) = jobToCheck.PlannedFixture(proc, path);
                    if (string.IsNullOrEmpty(plannedFix))
                    {
                        continue;
                    }
                    usedFixtureFaces.Add((plannedFix, plannedFace.ToString()));
                }
            }

            int earlierConflicts = 0;

            // go through each other job and process 1 path
            foreach (var otherJob in jobs)
            {
                for (var otherProc1Path = 1; otherProc1Path <= otherJob.GetNumPaths(process: 1); otherProc1Path++)
                {
                    if (otherJob.UniqueStr == jobToCheck.UniqueStr && proc1path == otherProc1Path)
                    {
                        continue;
                    }

                    // see if the process 1 starting time is later and if so skip the remaining checks
                    var otherStart = otherJob.GetSimulatedStartingTimeUTC(process: 1, path: otherProc1Path);
                    if (otherStart == DateTime.MinValue)
                    {
                        goto checkNextPath;
                    }
                    if (otherStart >= startT)
                    {
                        goto checkNextPath;
                    }
                    var otherGroup = otherJob.GetPathGroup(process: 1, path: otherProc1Path);

                    //the job-path combo starts earlier than the job-path to check, but need to see if it conflicts.

                    // go through all processes matching the path group and if a fixture face matches,
                    // count it as a conflict.
                    for (var otherProc = 1; otherProc <= otherJob.NumProcesses; otherProc++)
                    {
                        for (var otherPath = 1; otherPath <= otherJob.GetNumPaths(otherProc); otherPath++)
                        {
                            if (otherJob.GetPathGroup(otherProc, otherPath) != otherGroup)
                            {
                                continue;
                            }
                            var(otherFix, otherFace) = otherJob.PlannedFixture(otherProc, otherPath);
                            if (usedFixtureFaces.Contains((otherFix, otherFace.ToString())))
                            {
                                earlierConflicts += 1;
                                goto checkNextPath;
                            }
                        }
                    }

                    checkNextPath :;
                }
            }

            return(earlierConflicts);
        }
Beispiel #4
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);
        }