private void readLotSteps(ToyFabSettings settings) { using (var reader = new StreamReader(Path.Combine(Directory, "LotSteps.csv"))) { int row = 1; while (!reader.EndOfStream) { string[] values = reader.ReadLine().Split(','); if (row != 1 && values[0] != "") { LotStep step = new LotStep(Convert.ToInt32(values[0]), values[1]); settings.LotSteps.Add(values[1], step); workStationLotStepMapping.Add(step, values[2]); int[] eligibilities = values.Skip(3).Select(x => Convert.ToInt32(x)).ToArray(); machineEligibilities.Add(step, eligibilities); } row++; } } }
public void readLotSteps(ToyFabSettings settings) { using (var reader = new StreamReader(Path.Combine(Directory, @"Old\LotSteps.csv"))) { int row = 1; while (!reader.EndOfStream) { string[] values = reader.ReadLine().Split(','); if (row != 1 && values[0] != "") { LotStep step = new LotStep(Convert.ToInt32(values[0]), values[1]); settings.LotSteps.Add(values[1], step); workStationLotStepMapping.Add(step, values[2]); List <int?> eligibilities = new List <int?>(); for (int i = 4; i < values.Length; i++) { eligibilities.Add((values[i] != "") ? Convert.ToInt32(values[i]) : (int?)null); } MachineEligibilities.Add(step, eligibilities); } row++; } } }
protected override void OnUpdate(ModelElementBase modelElement) { WorkCenter workCenter = (WorkCenter)modelElement; LotStep step = workCenter.LastArrivedLot.GetCurrentStep; queueLengths[step].UpdateValue(workCenter.Queues[step].Length); queueLengthsStatistic[step].Collect(queueLengths[step].PreviousValue, queueLengths[step].Weight); writeToFile(workCenter); }
public string GetWorkCenterNameForLotstep(LotStep lotstep) { foreach (var wc in LotStepsPerWorkStation) { if (wc.Value.Contains(lotstep)) { return(wc.Key); } } return("No workcenter found"); }
private void updateWeights() { int indexLotMaxWeight = 0; double maxWeight = double.MinValue; for (int i = 0; i < wc.Queue.Length; i++) { Lot lot = wc.Queue.PeekAt(i); double weight = 0.0; for (int relStep = -jStepBack; relStep <= 0; relStep++) { if (lot.HasRelativeStep(relStep)) { LotStep step = lot.GetRelativeStep(relStep); weight += lot.GetRelativeWorkCenter(relStep).Queues[step].LengthInWafers - WIPtargets[step]; } } for (int relStep = 1; relStep <= kStepAhead; relStep++) { if (lot.HasRelativeStep(relStep)) { LotStep step = lot.GetRelativeStep(relStep); weight += WIPtargets[step] - lot.GetRelativeWorkCenter(relStep).Queues[step].LengthInWafers; } } //Console.WriteLine($"{lot.Id}\t{lot.GetCurrentWorkCenter.Name}\t{lot.GetCurrentStep.Name}\t{(int)WIPtargets[lot.GetCurrentStep]}\t{lot.GetCurrentWorkCenter.Queues[lot.GetCurrentStep].Length}\t=" + // $"{lot.GetCurrentWorkCenter.Queues[lot.GetCurrentStep].Length - (int)WIPtargets[lot.GetCurrentStep]}"); // Only if weight is higher, replace lotToDispatch. If weight is equal, do FIFO, so keep old one. if (weight > maxWeight) { indexLotMaxWeight = i; maxWeight = weight; } } lotToDispatch = wc.Queue.PeekAt(indexLotMaxWeight); string chosenLotStep = lotToDispatch.GetCurrentStep.Name; //Console.WriteLine($"{lotToDispatch.Id} {lotToDispatch.GetCurrentStep.Name}"); }
protected override void OnUpdate(ModelElementBase modelElement) { WorkCenter workCenter = (WorkCenter)modelElement; try { LotStep step = new LotStep(); // Check whether this OnUpdate is triggered by Arrival or Departure event if (workCenter.IsArrivalFlag) { step = workCenter.LastArrivedLot.GetCurrentStep; //Console.WriteLine($"{GetTime} {this.Name} triggered by arrival of {step.Name} of lot {workCenter.LastArrivedLot.Id}."); } else { step = workCenter.LotStepInService; //Console.WriteLine($"{GetTime} {this.Name} triggered by departure of {step.Name} of lot {workCenter.Queues[step].PeekFirst().Id}"); } queueLengths[step].UpdateValue(workCenter.Queues[step].Length); queueLengthsStatistic[step].Collect(queueLengths[step].PreviousValue, queueLengths[step].Weight); writeToFile(workCenter); //writeToConsole(workCenter); } catch { if (workCenter.IsArrivalFlag) { Lot lot = workCenter.LastArrivedLot; throw new Exception($"{workCenter.Name} has lot {lot.ProductType} in {lot.GetCurrentStep.Name}, should be in {lot.GetCurrentWorkCenter.Name}"); } else { LotStep step = workCenter.LotStepInService; throw new Exception($"{workCenter.Name} has step {step.Name} in service, but this step belongs to workcenter {step.WorkCenter.Name}"); } } }
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); } }