public void ProcessAnalysis(BoxCasePalletAnalysis analysis) { _boxProperties = analysis.BoxProperties; _interlayerProperties = analysis.InterlayerProperties; _palletSolutionList = analysis.PalletSolutionsList; _constraintSet = analysis.ConstraintSet; analysis.Solutions = GenerateSolutions(); }
/// <summary> /// Creates a new case analysis /// </summary> /// <returns>created case analysis</returns> public BoxCasePalletAnalysis CreateNewBoxCasePalletOptimizationUI() { FormNewCaseAnalysis form = new FormNewCaseAnalysis(this) { Boxes = Boxes.ToArray() }; if (DialogResult.OK == form.ShowDialog()) { BoxCasePalletConstraintSet constraintSet = new BoxCasePalletConstraintSet() { // aligned / alternate layers AllowAlignedLayers = form.AllowAlignedLayers, AllowAlternateLayers = form.AllowAlternateLayers }; // patterns foreach (string patternName in form.AllowedPatterns) { constraintSet.SetAllowedPattern(patternName); } // allowed axes constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ); // use maximum case weight constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight; constraintSet.MaximumCaseWeight = form.MaximumCaseWeight; // use maximum number of boxes constraintSet.UseMaximumNumberOfItems = form.UseMaximumNumberOfItems; constraintSet.MaximumNumberOfItems = form.MaximumNumberOfItems; // minimum number of items constraintSet.MinimumNumberOfItems = form.MinimumNumberOfItems; constraintSet.UseMinimumNumberOfItems = form.UseMinimumNumberOfItems; // number of solutions kept constraintSet.NumberOfSolutionsKept = form.NumberOfSolutionsKept; if (!constraintSet.IsValid) { MessageBox.Show(string.Format(Properties.Resources.ID_CASEANALYSIS_INVALIDCONSTRAINTSET)); return(null); // invalid constraint set -> exit } return(CreateNewBoxCasePalletOptimization( form.CaseAnalysisName , form.CaseAnalysisDescription , form.SelectedBox , constraintSet , form.PalletSolutionList , new BoxCasePalletSolver())); } return(null); }
/// <summary> /// Edit given box/case/pallet analysis /// </summary> /// <param name="caseAnalysis"></param> public void EditCaseAnalysis(BoxCasePalletAnalysis caseAnalysis) { // do we need to recompute analysis bool recomputeRequired = false; FormNewCaseAnalysis form = new FormNewCaseAnalysis(caseAnalysis.ParentDocument, caseAnalysis); form.Boxes = Boxes.ToArray(); if (recomputeRequired = (DialogResult.OK == form.ShowDialog())) { // analysis name / description caseAnalysis.Name = form.CaseAnalysisName; caseAnalysis.Description = form.CaseAnalysisDescription; // selected box caseAnalysis.BoxProperties = form.SelectedBox; // pallet solutions caseAnalysis.PalletSolutionsList = form.PalletSolutionList; // constraint set BoxCasePalletConstraintSet constraintSet = caseAnalysis.ConstraintSet; // aligned / alternate layers constraintSet.AllowAlignedLayers = form.AllowAlignedLayers; constraintSet.AllowAlternateLayers = form.AllowAlternateLayers; // patterns constraintSet.AllowedPatternString = form.AllowedPatternsString; // allowed axes constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ); constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ); // use maximum case weight constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight; constraintSet.MaximumCaseWeight = form.MaximumCaseWeight; // use maximum number of boxes constraintSet.UseMaximumNumberOfItems = form.UseMaximumNumberOfItems; constraintSet.MaximumNumberOfItems = form.MaximumNumberOfItems; // minimum number of items constraintSet.MinimumNumberOfItems = form.MinimumNumberOfItems; constraintSet.UseMinimumNumberOfItems = form.UseMinimumNumberOfItems; // number of solutions kept constraintSet.NumberOfSolutionsKept = form.NumberOfSolutionsKept; } if (recomputeRequired) { caseAnalysis.OnEndUpdate(null); } }
private void FormNewCaseAnalysis_Load(object sender, EventArgs e) { try { // name / description if (null != _caseAnalysis) { tbName.Text = _caseAnalysis.Name; tbDescription.Text = _caseAnalysis.Description; } else { tbName.Text = _document.GetValidNewAnalysisName(Resources.ID_ANALYSIS); tbDescription.Text = tbName.Text; } // fill boxes combo foreach (BProperties box in _boxes) { cbBoxes.Items.Add(new BoxItem(box)); } // select box item if (cbBoxes.Items.Count > 0) { if (null == _caseAnalysis) { cbBoxes.SelectedIndex = 0; } else { for (int i = 0; i < cbBoxes.Items.Count; ++i) { BoxItem boxItem = cbBoxes.Items[i] as BoxItem; if (boxItem.Item == _caseAnalysis.BoxProperties) { cbBoxes.SelectedIndex = i; break; } } } } // Fill key combo FillKeyCombo(); // allowed position box + allowed patterns if (null == _caseAnalysis) { AllowAlignedLayers = Settings.Default.AllowAlignedLayer_CaseAnalysis; AllowAlternateLayers = Settings.Default.AllowAlternateLayer_CaseAnalysis; AllowVerticalX = Settings.Default.AllowVerticalX_CaseAnalysis; AllowVerticalY = Settings.Default.AllowVerticalY_CaseAnalysis; AllowVerticalZ = Settings.Default.AllowVerticalZ_CaseAnalysis; AllowedPatternsString = Settings.Default.AllowedPatterns_CaseAnalysis; } else { AllowAlignedLayers = _caseAnalysis.ConstraintSet.AllowAlignedLayers; AllowAlternateLayers = _caseAnalysis.ConstraintSet.AllowAlternateLayers; BoxCasePalletConstraintSet constraintSet = _caseAnalysis.ConstraintSet; AllowVerticalX = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_X_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_X_P); AllowVerticalY = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Y_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Y_P); AllowVerticalZ = constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Z_N) || constraintSet.AllowOrthoAxis(HalfAxis.HAxis.AXIS_Z_P); AllowedPatternsString = constraintSet.AllowedPatternString; } // update controls UpdateConditionStatus(this, null); UpdateButtonOkStatus(); // windows settings if (null != Settings.Default.FormNewCaseAnalysisPosition) { Settings.Default.FormNewCaseAnalysisPosition.Restore(this); } } catch (Exception ex) { _log.Error(ex.ToString()); } }