public override List <RealSnapshot> ReadRealSnapshots(DateTime from, DateTime until, TimeSpan interval, int waferQtyThreshold) { Console.Write("Reading RealSnaphots -"); if (LotTraces == null) { throw new Exception("LotTraces is still empty, first use ReadLotactivityHistories"); } RealSnapshots = new List <RealSnapshot>(); DateTime current = from; while (current <= until) { if (current >= LotTraces.StartDate && current <= LotTraces.EndDate) { RealSnapshots.Add(LotTraces.GetWIPSnapshot(current, waferQtyThreshold)); } current += interval; } Console.Write(" done.\n"); return(RealSnapshots); }
public WorkCenterLotActivities(LotTraces lotTraces, string workCenter) { WorkCenter = workCenter; startDate = lotTraces.StartDate; endDate = lotTraces.EndDate; WIPTrace = new List <Tuple <DateTime, int> >(); LotActivities = lotTraces.LotActivities.Where(x => x.WorkStation == workCenter).OrderBy(x => x.Arrival).ToList(); CalculateWIPTrace(startDate, endDate); EPTCalculator EPTCalculator = new EPTCalculator(); LotActivities = EPTCalculator.CalculateEPTs(LotActivities); AddWIPsToEPTstarts(); }
public void WriteLotActivitiesToCSV(string fileName) { LotTraces.WriteLotActivitiesToCSV(Path.Combine(DirectorySerializedFiles, fileName)); }
public List <Tuple <DateTime, RealLot> > GetLotStarts() { RealLotStarts = LotTraces.GetRealLotStarts(); return(RealLotStarts); }
public override List <WorkCenterLotActivities> ReadWorkCenterLotActivities(string fileName, bool onlyProductionLots) { Console.Write("Reading lot activities raw - "); WorkCenterLotActivities = new List <WorkCenterLotActivities>(); // Fill lot activites raw using (StreamReader reader = new StreamReader(Path.Combine(DirectoryInputCSVs, fileName))) { string headerLine = reader.ReadLine(); while (!reader.EndOfStream) { string dataLine = reader.ReadLine(); lotActivitiesRaw.Add(new LotActivityRaw(headerLine, dataLine)); } } Console.Write("done. \n"); // Filter only production lots, order by track-in time and group activities from same lot if (onlyProductionLots) { lotActivitiesRaw = lotActivitiesRaw.Where(x => x.LotId.StartsWith("M1")).OrderBy(x => x.TrackIn).OrderBy(x => x.LotId).ToList(); } // Map IRD groups on LotActivitiesRaw Dictionary <string, IRDMapping> irdDict = irdMappings.ToDictionary(x => $"{x.Techstage} {x.Subplan}", x => x); List <string> lotids = lotActivitiesRaw.Select(x => x.LotId).ToList(); foreach (LotActivityRaw lotActivity in lotActivitiesRaw) { if (irdDict.ContainsKey($"{lotActivity.Techstage} {lotActivity.Subplan}")) { lotActivity.IRDGroup = irdDict[$"{lotActivity.Techstage} {lotActivity.Subplan}"].IRDGroup; lotActivity.WorkStation = irdDict[$"{lotActivity.Techstage} {lotActivity.Subplan}"].WorkStation; } } Console.Write("Grouping lot activities per lot into lotraces - "); // Group lotactivities per Lot into LotTraces and map StepSequences on the LotActitiesRaw List <LotTrace> lotTraces = new List <LotTrace>(); string currentId = ""; LotTrace trace = new LotTrace(""); foreach (LotActivityRaw activity in lotActivitiesRaw) { if (activity.LotId != currentId) // Start new lot trace { if (currentId != "") { lotTraces.Add(trace); trace.MapPPStepSequencesOnActivites(processPlans); trace.CheckCompleteness(); trace.CalculateTimeInSteps(); } currentId = activity.LotId; trace = new LotTrace(activity.LotId); trace.ProductType = activity.ProductType; } trace.LotActivitiesRaw.Add(activity); } Console.Write("done. \n"); DateTime begin = lotActivitiesRaw.Select(x => x.TrackIn).Min(); DateTime end = lotActivitiesRaw.Select(x => x.TrackIn).Max(); LotTraces = new LotTraces(lotTraces, begin, end); int count = 1; Console.WriteLine($"Calculating EPTs for {irdMappings.Select(x => x.WorkStation).Distinct().Count()} workstations. Done for workstations:"); // Make LotActivitiesPerWorkCenter and calculate EPTs foreach (string workCenter in irdMappings.Select(x => x.WorkStation).Distinct()) { WorkCenterLotActivities.Add(new WorkCenterLotActivities(LotTraces, workCenter)); Console.Write($"{count++} "); } Console.Write("- done. \n"); return(WorkCenterLotActivities); }
static void Main(string[] args) { List <DateTime> DateTimes = ReadDateTimes(@"C:\CSSLWaferFab\Input\WIPBalanceWeights\DateTimes.csv"); int jStepBack = 0; int kStepAhead = 1; string inputDir = @"C:\CSSLWaferFab\Input\"; string eptParameterFile = @"FittedEPTParameters - 2019-06-01.csv"; // Get WaferFabSettings AutoDataReader reader = new AutoDataReader(inputDir + @"CSVs\", inputDir + @"SerializedFiles\"); WaferFabSettings waferFabSettings = reader.ReadWaferFabSettings(eptParameterFile, false, false, DispatcherBase.Type.MIVS); waferFabSettings.WIPTargets = reader.ReadWIPTargets(waferFabSettings.LotSteps, "WIPTargets.csv"); // Get all lots from snapshot LotTraces lotTraces = Deserializer.DeserializeLotTraces(inputDir + @"SerializedFiles\LotTraces_2019_2020_2021.dat"); foreach (DateTime time in DateTimes) { RealSnapshot realSnapshot = lotTraces.GetWIPSnapshot(time, 0); List <Lot> lots = realSnapshot.GetRealLots(0).Select(x => x.ConvertToLot(0, waferFabSettings.Sequences, false, time)).Where(x => x != null).ToList(); // Construct current WIP levels and WIP targets Dictionary <string, int> WIPlevels = realSnapshot.WIPlevelsInWafers; Dictionary <LotStep, double> WIPtargets = waferFabSettings.WIPTargets; // Construct weights per lot Dictionary <Lot, double> weights = new Dictionary <Lot, double>(); foreach (Lot lot in lots) { double weight = 0.0; for (int relStep = -jStepBack; relStep <= 0; relStep++) { if (lot.HasRelativeStep(relStep)) { LotStep step = lot.GetRelativeStep(relStep); if (WIPlevels.ContainsKey(step.Name)) { weight += WIPlevels[step.Name] - WIPtargets[step]; } else // WIP level of step is not know in snapshot, so it has to be 0 { weight -= WIPtargets[step]; } } } for (int relStep = 1; relStep <= kStepAhead; relStep++) { if (lot.HasRelativeStep(relStep)) { LotStep step = lot.GetRelativeStep(relStep); if (WIPlevels.ContainsKey(step.Name)) { weight += WIPtargets[step] - WIPlevels[step.Name]; } else // WIP level of step is not know in snapshot, so it has to be 0 { weight += WIPtargets[step]; } } } weights.Add(lot, weight); } WriteWeightsToCSV(weights, time); } }