Exemple #1
0
        private bool DoesNextProcessAndPathGroupMatch(JobPlan job, JobLogDB.QueuedMaterial qm, int proc, int pathGroup)
        {
            var matLog   = _log.GetLogForMaterial(qm.MaterialID);
            var lastProc =
                matLog
                .SelectMany(e => e.Material)
                .Where(m => m.MaterialID == qm.MaterialID)
                .Select(m => m.Process)
                .DefaultIfEmpty(0)
                .Max();

            if (lastProc != proc)
            {
                return(false);
            }

            //now try and calculate path.  Just check pallet.
            var lastPallet =
                matLog
                .SelectMany(e => e.Material.Select(m => new { log = e, mat = m }))
                .Where(x => x.mat.MaterialID == qm.MaterialID && x.mat.Process == proc)
                .Select(x => x.log.Pallet)
                .Where(x => !string.IsNullOrEmpty(x))
                .DefaultIfEmpty("")
                .First()
            ;

            if (string.IsNullOrEmpty(lastPallet))
            {
                throw new UnableToFindPathGroup();
            }

            Log.Debug("Calculated last pallet {pal} for {@qm} and proc {proc}", lastPallet, qm);

            for (int path = 1; path <= job.GetNumPaths(proc); path++)
            {
                if (job.HasPallet(proc, path, lastPallet))
                {
                    return(job.GetPathGroup(proc, path) == pathGroup);
                }
            }

            throw new UnableToFindPathGroup();
        }
Exemple #2
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());
                    }
                }
            }
        }