public RealSnapshot GetWIPSnapshot(DateTime time, int waferQtyThreshold) { if (time < StartDate || time > EndDate) { throw new Exception($"WIP snapshot cannot be generated for time {time}, it is is out of bounds of these LotTraces"); } else { List <RealLot> lots = new List <RealLot>(); foreach (LotTrace trace in All) { // Make sure that lot activities are ordered on track-in //trace.LotActivitiesRaw = trace.LotActivitiesRaw.OrderBy(x => x.TrackIn).ToList(); if (trace.LotActivities.Any() && time >= trace.StartDate && time < trace.EndDate) { // Find current LotActivity and RawActivity LotActivity activity = trace.GetLotActivityAt(time); LotActivityRaw raw = trace.GetLotActivityRawAt(time); if (activity != null && raw != null) { RealLot newLot; if (trace.HasStart && trace.HasEnd) { newLot = new RealLot(activity, raw, trace.StartDate, trace.EndDate, time); } else if (trace.HasStart && !trace.HasEnd) { newLot = new RealLot(activity, raw, trace.StartDate, null, time); } else if (!trace.HasStart && trace.HasEnd) { newLot = new RealLot(activity, raw, null, trace.EndDate, time); } else { newLot = new RealLot(activity, raw, null, null, time); } lots.Add(newLot); } } } RealSnapshot snapshot = new RealSnapshot(time, lots, waferQtyThreshold); return(snapshot); } }
private void ExtractLotActivities() { foreach (LotTrace trace in All) { List <LotActivityRaw> rawList = trace.LotActivitiesRaw; // Create activity LotActivity newActivity = new LotActivity(rawList[0]); string currentIRD = rawList[0].IRDGroup; // Set arrival time if first step if (trace.HasStart) { newActivity.Arrival = rawList[0].TrackIn; } // Loop over lot activities and stop if Workstation changed for (int i = 0; i < rawList.Count(); i++) { if (currentIRD != rawList[i].IRDGroup) { // Set time of event to Trackout previous step. If that is null, then to TrackIn of current step. DateTime?timeOfEvent = rawList[i - 1].TrackOut != null ? rawList[i - 1].TrackOut : timeOfEvent = rawList[i].TrackIn; newActivity.Departure = timeOfEvent; lotActivities.Add(newActivity); trace.LotActivities.Add(newActivity); newActivity = new LotActivity(rawList[i]); newActivity.Arrival = timeOfEvent; currentIRD = rawList[i].IRDGroup; } newActivity.AddLotActivityRaw(rawList[i]); } // Set departure time if last step on process plan if (trace.HasEnd) { newActivity.Departure = rawList.Last().TrackOut; } // Save if (trace.Status != "Terminated" && trace.Status != "Hold") { lotActivities.Add(newActivity); trace.LotActivities.Add(newActivity); } } }
public List <Tuple <DateTime, RealLot> > GetRealLotStarts() { List <Tuple <DateTime, RealLot> > lotStarts = new List <Tuple <DateTime, RealLot> >(); foreach (LotTrace trace in All.Where(x => x.HasStart && x.LotActivities.Any() && x.LotActivitiesRaw.Any())) { LotActivity activity = trace.LotActivities.First(); LotActivityRaw raw = trace.LotActivitiesRaw.First(); RealLot newLot = new RealLot(activity, raw, trace.StartDate, trace.EndDate); lotStarts.Add(new Tuple <DateTime, RealLot>(trace.StartDate, newLot)); } return(lotStarts); }