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; } } } }
private void AddBasicStopsWithProg(JobPlan job) { for (int proc = 1; proc <= job.NumProcesses; proc++) { for (int path = 1; path <= job.GetNumPaths(proc); path++) { job.AddLoadStation(proc, path, 1); job.AddUnloadStation(proc, path, 1); var stop = new JobMachiningStop("machine"); stop.Stations.Add(1); stop.ProgramName = "1234"; job.AddMachiningStop(proc, path, stop); } } }
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(); }
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 }
/// 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); }