private void FuzzyAlgoFlat() { List<String> newBuyingFormats = new List<string>(); var pHint = new List<PrintingHint>(); var ppP = new ProductPartSingleSheetPrinting(); //Scorro i Dies e se rientrano nelle tolleranze!!!! var dies = new List<Die>(); ppP.CostDetail = this; ppP.Part = this.ProductPart; if (ProductPart.FormatType != -1) { foreach (var die in Dies.OfType<DieFlatRoll>()) { var side1 = ppP.Part.FormatOpened.GetSide1(); var side2 = ppP.Part.FormatOpened.GetSide2(); if (Math.Abs(die.Format.GetSide1() - side1) <= DieTollerance && Math.Abs(die.Format.GetSide2() - side2) <= DieTollerance) { ppP.PrintingFormat = die.PrintingFormat; ppP.MaxGain1 = die.MaxGain1 ?? 0; ppP.MaxGain2 = die.MaxGain2 ?? 0; ppP.AutoCutParameter = true; ppP.LateralMinDCut = true; ppP.Update(); //voglio aggiungere le fustelle valide!!!! var pHDie = new PrintingHint { Format = die.Format, FormatDesc = die.Format, //DCut1 = ppP.CalculatedDCut1, //DCut1 = die.DCut1, //DCut2 = die.DCut2, DCut1 = DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = ppP.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = die.PrintingFormat, PrintingFormat = die.PrintingFormat, Description = "h" + die.PrintingFormat.GetSide1() + " z" + (die.GetZFromCm(die.PrintingFormat.GetSide2())).ToString() + "*", FormatType = (die.FormatType ?? 0).ToString(), CalculatedGain = ppP.CalculatedGain, GainOnSide1 = die.MaxGain1 ?? 0, GainOnSide2 = die.MaxGain2 ?? 0, IsDie = true, DeltaDCut2 = 0 }; pHint.Add(pHDie); } } } var labelSide2 = this.ProductPart.FormatOpened.GetSide2(); var labelCut2 = this.ProductPart.DCut2 ?? 0; //calculate max Gain on Side2 based on TaskExecutor MaxFormat var steps = Math.Floor(TaskexEcutorSelected.FormatMax.GetSide2() / labelSide2 + labelCut2); foreach (var width in BuyingWidths) { for (int step = 1; step <= steps; step++) { ppP.AutoCutParameter = false; var buyingFormat = width + "x" + step * (labelCut2 + labelSide2); if (SheetCut.IsValid(TaskexEcutorSelected.FormatMax, TaskexEcutorSelected.FormatMin, buyingFormat)) { ppP.CostDetail = this; ppP.Part = this.ProductPart; ppP.PrintingFormat = buyingFormat; // ppP.AutoCutParameter = true; ppP.AutoCutParameter = false; ppP.LateralMinDCut = true; ppP.MaxGain1 = 0; ppP.MaxGain2 = 0; ppP.Update(); haveAlmostOne = (ppP.CalculatedGain > 0) || haveAlmostOne; var calc1Gain = ppP.CalculatedSide1Gain; var calc2Gain = ppP.CalculatedSide2Gain; for (int i = calc2Gain; i > 0; i--) { ppP.MaxGain2 = ppP.CalculatedSide2Gain - i; ppP.Update(); for (int k = calc1Gain; k > 0; k--) { //provo a togliere una posa in banda se l'interspazio di passo è > di quello della banda if (ppP.CalculatedDCut1 < ppP.CalculatedDCut2) { //tolgo una posa in banda ppP.MaxGain1 = k; ppP.Update(); } //mi calcolo l'interspazio più piccolo... mi servirà se non ho formati validi per ricavarne almeno uno if (ppP.CalculatedGain > 0) { smallestDeltaCalculatedDCut = ppP.CalculatedDCut2 < smallestDeltaCalculatedDCut ? ppP.CalculatedDCut2 : smallestDeltaCalculatedDCut; } var pH = new PrintingHint { Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = ppP.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = buyingFormat, PrintingFormat = buyingFormat, MaxGain2 = ppP.MaxGain2, MaxGain1 = ppP.MaxGain1, // Description = "h" + buyingFormat.GetSide1() + " z" + (buyingFormat.GetSide2() / 2.54 * 8).ToString(), CalculatedGain = ppP.CalculatedGain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - ppP.CalculatedDCut2) }; pH.Description = buyingFormat; if (!pHint.Contains(pH, new PrintingHintComparer())) { //il printing hint deve avere i formati stampabili, i suoi DCut, ma anche fustelle simili pHint.Add(pH); } if (ppP.CalculatedSide2Gain >= 1 && ppP.MaxGain2 == 0) { //provo ad aggiungere una nuova resa con interspazio negativo var lessZero = Math.Abs((ppP.Part.FormatOpened.GetSide2() - (ppP.CalculatedDCut2 * ppP.CalculatedSide2Gain))) / (ppP.CalculatedSide2Gain + 1); lessZero = Math.Truncate(lessZero * 1000 + 1) / 1000; smallerCalculatedDCutLessZero = lessZero < smallerCalculatedDCutLessZero ? lessZero : smallerCalculatedDCutLessZero; pH = new PrintingHint { Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = 0, // DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = lessZero * (-1), TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = buyingFormat, PrintingFormat = buyingFormat, MaxGain2 = ppP.MaxGain2 + 1, CalculatedGain = ppP.CalculatedGain + ppP.CalculatedSide1Gain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain + 1, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - lessZero * (-1)) }; pH.Description = buyingFormat; if (!pHint.Contains(pH, new PrintingHintComparer())) { //il printing hint deve avere i formati stampabili, i suoi DCut, ma anche fustelle simili pHint.Add(pH); } //ripristino l'autocut ppP.AutoCutParameter = true; ppP.LateralMinDCut = true; } } } }//End if } } ppP.MaxGain2 = 0; if (PrintingFormat != "" && PrintingFormat != null) { var pH = new PrintingHint { Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = ProductPartPrinting.CalculatedDCut1, DCut2 = ProductPartPrinting.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = PrintingFormat, PrintingFormat = PrintingFormat, MaxGain2 = ProductPartPrinting.MaxGain2, MaxGain1 = ProductPartPrinting.MaxGain1, // Description = "h" + PrintingFormat.GetSide1() + " z" + (PrintingFormat.GetSide2() / 2.54 * 8).ToString(), CalculatedGain = ProductPartPrinting.CalculatedGain, GainOnSide1 = ProductPartPrinting.CalculatedSide1Gain, GainOnSide2 = ProductPartPrinting.CalculatedSide2Gain, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - ProductPartPrinting.CalculatedDCut2) }; pH.Description = PrintingFormat; // se non ho trovato hint e ho almeno un PrintigFormat allora //inserisco il printing format negli hint if (!pHint.Contains(pH, new PrintingHintComparer())) { //ppP.PrintingFormat = PrintingFormat; //ppP.Update(); pHint.Add(pH); } } //qui inizio a togliere un po di pHint var pHint1 = ProductPart.SelectValidpHint(pHint, smallerCalculatedDCutLessZero, smallestDeltaCalculatedDCut); pHint = pHint1.ToList(); List<PrintingHint> widthValids = new List<PrintingHint>();// List<double>(); //scorro la lista ed estraggo solo gli z validi foreach (var item in pHint) { var z = item.BuyingFormat.GetSide2(); if (!widthValids.Select(x => x.BuyingFormat.GetSide2()).Contains(z)) { widthValids.Add(item); } } ppP.Part = (ProductPart)ppP.Part.Clone(); //bande di carta calcolate semplicemente con la resa, dati gli z validi e il maxWidth della macchina Flexo foreach (var item in widthValids) { double dCut1 = ppP.Part.DCut1 ?? 0; double dCut2 = ppP.Part.DCut2 ?? 0; var newBands = this.GetOptimizedWidthsFlat(item.PrintingFormat.GetSide2(), item.MaxGain2, ppP.Part.FormatOpened, ref dCut1, ref dCut2, 34); foreach (var nB in newBands) { ppP.PrintingFormat = nB.ToString() + "x" + item.PrintingFormat.GetSide2(); // item.Z.ToString(); ppP.MaxGain1 = 0; ppP.MaxGain2 = 0; ppP.AutoCutParameter = false; ppP.Part.DCut2 = dCut2; ppP.Part.DCut1 = dCut1; ppP.Update(); int i = 1; //non vale per le fascette gommate if (ProductPart.MinDCut != 0) { while (ppP.CalculatedDCut1 < ppP.CalculatedDCut2 && (ppP.CalculatedSide1Gain - i) > 0) { var maxGain1 = ppP.CalculatedSide1Gain - i; ppP.MaxGain1 = maxGain1; ppP.Update(); } } var pH = new PrintingHint { Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = dCut1,// DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = dCut2, //item.DCut2 ?? ppP.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = ppP.PrintingFormat, PrintingFormat = ppP.PrintingFormat, CalculatedGain = ppP.CalculatedGain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - (item.DCut2 ?? ppP.CalculatedDCut2)) }; pH.Description = ppP.PrintingFormat; //"h" + ppP.PrintingFormat.GetSide1() + " z" + (ppP.PrintingFormat.GetSide2() / 2.54 * 8).ToString(), if (!pHint.Contains(pH, new PrintingHintComparer())) { pHint.Add(pH); } } } PrintingHints = pHint; BuyingFormats = pHint.Select(x => x.BuyingFormat).ToList(); if (BuyingFormats.Count == 0) { //no format Error = 3; } }
//dovrei sapere all'interno della private void FuzzyAlgoFlexo() { List<String> newBuyingFormats = new List<string>(); var pHint = new List<PrintingHint>(); //ZMetric for Flexo bool zMetric = false; if (TaskexEcutorSelected.TypeOfExecutor == TaskExecutor.ExecutorType.Flexo) { zMetric = ((Flexo)TaskexEcutorSelected).ZMetric ?? false; } var ppP = new ProductPartSingleSheetPrinting(); //forcing lateral ppP.ForceLateral = this.ForceLateral ?? false; ppP.Lateral = this.Lateral ?? 0; //Scorro i Dies e se rientrano nelle tolleranze!!!! var dies = new List<Die>(); ppP.CostDetail = this; ppP.Part = this.ProductPart; if (ProductPart.FormatType != -1) { double side1, side2, side1B, side2B; side1 = side2 = side1B = side2B = 0; string originalFormat = ""; string originalFormatB = ""; if (ppP.Part.TypeOfProductPart == Models.ProductPart.ProductPartType.ProductPartDoubleLabelRoll) { ProductPartDoubleLabelRoll p; p = (ProductPartDoubleLabelRoll)ppP.Part; originalFormat = p.FormatA; originalFormatB = p.FormatB; } else { originalFormat = ppP.Part.Format; originalFormatB = ""; } foreach (var die in Dies.OfType<DieFlexo>()) { bool toInsert = false; if (ppP.Part.TypeOfProductPart == Models.ProductPart.ProductPartType.ProductPartDoubleLabelRoll) { ProductPartDoubleLabelRoll p; p = (ProductPartDoubleLabelRoll)ppP.Part; //--------------------------- p.FormatA = originalFormat; p.FormatB = originalFormatB; //--------------------------- side1 = p.FormatA.GetSide1(); side2 = p.FormatA.GetSide2(); side1B = p.FormatB.GetSide1(); side2B = p.FormatB.GetSide2(); toInsert = (Math.Abs(die.Format.GetSide1() - side1) <= DieTollerance && Math.Abs(die.Format.GetSide2() - side2) <= DieTollerance); toInsert = toInsert && (Math.Abs(die.FormatB.GetSide1() - side1B) <= DieTollerance && Math.Abs(die.FormatB.GetSide2() - side2B) <= DieTollerance); //--------------------------- p.FormatA = die.Format; p.FormatB = die.FormatB; //--------------------------- } else { ppP.Part.Format = originalFormat; ppP.Part.FormatOpened = originalFormat; side1 = ppP.Part.Format.GetSide1(); side2 = ppP.Part.Format.GetSide2(); toInsert = (Math.Abs(die.Format.GetSide1() - side1) <= DieTollerance && Math.Abs(die.Format.GetSide2() - side2) <= DieTollerance); ppP.Part.FormatOpened = die.Format; ppP.Part.Format = die.Format; } if (toInsert) { ppP.PrintingFormat = die.PrintingFormat; ppP.MaxGain1 = die.MaxGain1 ?? 0; ppP.MaxGain2 = die.MaxGain2 ?? 0; ppP.AutoCutParameter = true; ppP.LateralMinDCut = true; ppP.Update(); //voglio aggiungere le fustelle valide!!!! var pHDie = new PrintingHint { Format = die.Format, FormatDesc = die.FormatB != null ? die.Format + " + " + die.FormatB : die.Format, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, DCut1 = DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = ppP.CalculatedDCut2, BuyingFormat = die.PrintingFormat, PrintingFormat = die.PrintingFormat, Description = "h" + die.PrintingFormat.GetSide1() + " z" + (die.GetZFromCm(die.PrintingFormat.GetSide2())).ToString() + "*", FormatType = (die.FormatType ?? 0).ToString(), CalculatedGain = ppP.CalculatedGain, GainOnSide1 = die.MaxGain1 ?? 0, GainOnSide2 = die.MaxGain2 ?? 0, IsDie = true, DeltaDCut2 = 0 }; Console.WriteLine(ppP.CalculatedDCut2); pHint.Add(pHDie); //add in PHint new PrintingHint with each bands > die band var h = die.PrintingFormat.GetSide1(); foreach (var buyingWidths in BuyingWidths) { if (Convert.ToDouble(buyingWidths) > h) { //voglio aggiungere le fustelle valide!!!! pHDie = new PrintingHint { Format = die.Format, FormatDesc = die.FormatB != null ? die.Format + " + " + die.FormatB : die.Format, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, DCut1 = DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = ppP.CalculatedDCut2, BuyingFormat = die.PrintingFormat, PrintingFormat = die.PrintingFormat, Description = "h" + die.PrintingFormat.GetSide1() + " z" + (die.GetZFromCm(die.PrintingFormat.GetSide2())).ToString() + "*", FormatType = (die.FormatType ?? 0).ToString(), CalculatedGain = ppP.CalculatedGain, GainOnSide1 = die.MaxGain1 ?? 0, GainOnSide2 = die.MaxGain2 ?? 0, IsDie = true, DeltaDCut2 = 0 }; //override pHDie.BuyingFormat = buyingWidths.ToString() + "x" + die.PrintingFormat.GetSide2(); pHDie.PrintingFormat = pHDie.BuyingFormat; pHDie.Description = "h" + buyingWidths.ToString() + " z" + (die.GetZFromCm(die.PrintingFormat.GetSide2())).ToString() + "*"; pHint.Add(pHDie); } } } } //restore original format if (ppP.Part.TypeOfProductPart == Models.ProductPart.ProductPartType.ProductPartDoubleLabelRoll) { ProductPartDoubleLabelRoll p; p = (ProductPartDoubleLabelRoll)ppP.Part; p.FormatA = originalFormat; p.FormatB = originalFormatB; } else { ppP.Part.Format = originalFormat; ppP.Part.FormatOpened = originalFormat; } } foreach (var buyingFormat in BuyingFormats) { if (SheetCut.IsValid(TaskexEcutorSelected.FormatMax, TaskexEcutorSelected.FormatMin, buyingFormat)) { ppP.CostDetail = this; ppP.Part = this.ProductPart; ppP.PrintingFormat = buyingFormat; ppP.AutoCutParameter = true; ppP.LateralMinDCut = true; ppP.MaxGain1 = 0; ppP.MaxGain2 = 0; ppP.Update(); haveAlmostOne = (ppP.CalculatedGain > 0) || haveAlmostOne; var calc1Gain = ppP.CalculatedSide1Gain; var calc2Gain = ppP.CalculatedSide2Gain; if (true) { } for (int i = calc2Gain; i > 0; i--) { ppP.MaxGain2 = i; ppP.Update(); for (int k = calc1Gain; k > 0; k--) { //provo a togliere una posa in banda se l'interspazio di passo è > di quello della banda if (ppP.CalculatedDCut1 < ppP.CalculatedDCut2) { //tolgo una posa in banda ppP.MaxGain1 = k; ppP.Update(); } //mi calcolo l'interspazio più piccolo... mi servirà se non ho formati validi per ricavarne almeno uno if (ppP.CalculatedGain > 0) { smallestDeltaCalculatedDCut = ppP.CalculatedDCut2 < smallestDeltaCalculatedDCut ? ppP.CalculatedDCut2 : smallestDeltaCalculatedDCut; } var pH = new PrintingHint { ZMetric = zMetric, Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = ppP.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = buyingFormat, PrintingFormat = buyingFormat, MaxGain2 = ppP.MaxGain2, MaxGain1 = ppP.MaxGain1, // Description = "h" + buyingFormat.GetSide1() + " z" + (buyingFormat.GetSide2() / 2.54 * 8).ToString(), CalculatedGain = ppP.CalculatedGain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - ppP.CalculatedDCut2) }; pH.Description = "h" + buyingFormat.GetSide1() + " z" + pH.Z.ToString(); if (!pHint.Contains(pH, new PrintingHintComparer())) { //il printing hint deve avere i formati stampabili, i suoi DCut, ma anche fustelle simili pHint.Add(pH); } if (ppP.CalculatedSide2Gain >= 1 && ppP.MaxGain2 == 0) { //provo ad aggiungere una nuova resa con interspazio negativo var lessZero = Math.Abs((ppP.Part.FormatOpened.GetSide2() - (ppP.CalculatedDCut2 * ppP.CalculatedSide2Gain))) / (ppP.CalculatedSide2Gain + 1); lessZero = Math.Truncate(lessZero * 1000 + 1) / 1000; smallerCalculatedDCutLessZero = lessZero < smallerCalculatedDCutLessZero ? lessZero : smallerCalculatedDCutLessZero; pH = new PrintingHint { ZMetric = zMetric, Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = 0, // DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = lessZero * (-1), TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = buyingFormat, PrintingFormat = buyingFormat, MaxGain2 = ppP.MaxGain2 + 1, CalculatedGain = ppP.CalculatedGain + ppP.CalculatedSide1Gain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain + 1, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - lessZero * (-1)) }; pH.Description = "h" + buyingFormat.GetSide1() + " z" + pH.Z.ToString(); if (!pHint.Contains(pH, new PrintingHintComparer())) { //il printing hint deve avere i formati stampabili, i suoi DCut, ma anche fustelle simili pHint.Add(pH); } //ripristino l'autocut ppP.AutoCutParameter = true; ppP.LateralMinDCut = true; } } } }//End if } ppP.MaxGain2 = 0; if (PrintingFormat != "" && PrintingFormat != null) { var pH = new PrintingHint { ZMetric = zMetric, Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = ProductPartPrinting.CalculatedDCut1, DCut2 = ProductPartPrinting.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = PrintingFormat, PrintingFormat = PrintingFormat, MaxGain2 = ProductPartPrinting.MaxGain2, MaxGain1 = ProductPartPrinting.MaxGain1, // Description = "h" + PrintingFormat.GetSide1() + " z" + (PrintingFormat.GetSide2() / 2.54 * 8).ToString(), CalculatedGain = ProductPartPrinting.CalculatedGain, GainOnSide1 = ProductPartPrinting.CalculatedSide1Gain, GainOnSide2 = ProductPartPrinting.CalculatedSide2Gain, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - ProductPartPrinting.CalculatedDCut2) }; pH.Description = "h" + PrintingFormat.GetSide1() + " z" + pH.Z.ToString(); // se non ho trovato hint e ho almeno un PrintigFormat allora //inserisco il printing format negli hint if (!pHint.Contains(pH, new PrintingHintComparer())) { //ppP.PrintingFormat = PrintingFormat; //ppP.Update(); pHint.Add(pH); } } //qui inizio a togliere un po di pHint var pHint1 = ProductPart.SelectValidpHint(pHint, smallerCalculatedDCutLessZero, smallestDeltaCalculatedDCut); pHint = pHint1.ToList(); // List<string> aux = pHint.Select(z => z.BuyingFormat).ToList(); List<PrintingHint> zValids = new List<PrintingHint>();// List<double>(); //scorro la lista ed estraggo solo gli z validi foreach (var item in pHint) { var z = item.BuyingFormat.GetSide2(); if (!zValids.Select(x => x.BuyingFormat.GetSide2()).Contains(z)) { zValids.Add(item); } } ppP.Part = (ProductPart)ppP.Part.Clone(); //bande di carta calcolate semplicemente con la resa, dati gli z validi e il maxWidth della macchina Flexo foreach (var item in zValids) { double dCut1 = 0; double dCut2 = 0; var newBands = this.GetOptimizedWidths(item.PrintingFormat.GetSide2(), item.MaxGain2, ppP.Part.FormatOpened, ref dCut1, ref dCut2, 34, ProductPart.TypeOfDCut1 ?? 0, ProductPart.TypeOfDCut2 ?? 0); foreach (var nB in newBands) { ppP.PrintingFormat = nB.ToString() + "x" + item.PrintingFormat.GetSide2(); // item.Z.ToString(); ppP.MaxGain1 = 0; ppP.MaxGain2 = 0; ppP.AutoCutParameter = false; ppP.Part.DCut2 = item.DCut2;//dCut2; ppP.Part.DCut1 = dCut1; ppP.Update(); int i = 1; //non vale per le fascette gommate if (ProductPart.MinDCut != 0) { int maxGain1; maxGain1 = ppP.CalculatedSide1Gain; while (ppP.CalculatedDCut1 < ppP.CalculatedDCut2 && (ppP.CalculatedSide1Gain - i) > 1) { maxGain1 = ppP.CalculatedSide1Gain - i++; ppP.MaxGain1 = maxGain1; ppP.Update(); } } var pH = new PrintingHint { ZMetric = zMetric, Format = ppP.Part.FormatOpened, FormatDesc = ppP.Part.Format, DCut1 = DCut1OnDCut2AndPart(ppP.CalculatedDCut1, ppP.CalculatedDCut2, ppP.Part), DCut2 = item.DCut2 ?? ppP.CalculatedDCut2, TypeOfDCut2 = ppP.Part.TypeOfDCut2 ?? 0, BuyingFormat = ppP.PrintingFormat, PrintingFormat = ppP.PrintingFormat, Description = "h" + ppP.PrintingFormat.GetSide1() + " z" + (ppP.PrintingFormat.GetSide2() / 2.54 * 8).ToString(), CalculatedGain = ppP.CalculatedGain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain, DeltaDCut2 = Math.Abs((ProductPart.MaxDCut ?? 0) - (item.DCut2 ?? ppP.CalculatedDCut2)) }; pH.Description = "h" + ppP.PrintingFormat.GetSide1() + " z" + (pH.Z).ToString(); if (!pHint.Contains(pH, new PrintingHintComparer())) { pHint.Add(pH); } } } PrintingHints = pHint; BuyingFormats = pHint.Select(x => x.BuyingFormat).ToList(); if (BuyingFormats.Count == 0) { //no format Error = 3; } }
public void FuzzyAlgo() { List<String> newBuyingFormats = new List<string>(); var pHint = new List<PrintingHint>(); var ppP = new ProductPartSingleSheetPrinting(); //bande di carta calcolate semplicemente con la resa, dati gli z validi e il maxWidth della macchina Flexo foreach (var item in BuyingWidths) { ppP.CostDetail = this; ppP.Part = this.ProductPart; ppP.AutoCutParameter = true; ppP.PrintingFormat = item.ToString()+ "x" +ProductPart.Format.GetSide1(); ppP.Update(); if (ppP.CalculatedGain > 0) { pHint.Add(new PrintingHint { Format = ppP.Part.Format, DCut1 = ppP.CalculatedDCut1, DCut2 = ppP.CalculatedDCut2, BuyingFormat = ppP.PrintingFormat, PrintingFormat = ppP.PrintingFormat, Description = ppP.PrintingFormat, CalculatedGain = ppP.CalculatedGain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain }); } if (ProductPart.Format.GetSide1() != ProductPart.Format.GetSide2()) { ppP.CostDetail = this; ppP.Part = this.ProductPart; ppP.AutoCutParameter = true; ppP.PrintingFormat = item.ToString() + "x" + ProductPart.Format.GetSide2(); ppP.Update(); if (ppP.CalculatedGain > 0) { pHint.Add(new PrintingHint { Format = ppP.Part.Format, DCut1 = ppP.CalculatedDCut1, DCut2 = ppP.CalculatedDCut2, BuyingFormat = ppP.PrintingFormat, PrintingFormat = ppP.PrintingFormat, Description = ppP.PrintingFormat, CalculatedGain = ppP.CalculatedGain, GainOnSide1 = ppP.CalculatedSide1Gain, GainOnSide2 = ppP.CalculatedSide2Gain }); } } } PrintingHints = pHint; BuyingFormats = pHint.Select(x => x.BuyingFormat).ToList(); if (BuyingFormats.Count == 0) { //no format Error = 3; BuyingFormats.Add(ppP.Part.Format); } }