public ReportData( CasePalletAnalysis palletAnalysis, SelCasePalletSolution selSolution , CylinderPalletAnalysis cylinderPalletAnalysis, SelCylinderPalletSolution selCylinderPalletSolution , HCylinderPalletAnalysis hCylinderPalletAnalysis, SelHCylinderPalletSolution selHCylinderPalletSolution , BoxCaseAnalysis boxCaseAnalysis, SelBoxCaseSolution selBoxCaseSolution , BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selCaseSolution , PackPalletAnalysis packPalletAnalysis, SelPackPalletSolution selPackPalletSolution ) { // case/pallet analysis _palletAnalysis = palletAnalysis; _selSolution = selSolution; // box/case/pallet analysis _caseAnalysis = caseAnalysis; _selCaseSolution = selCaseSolution; // Cylinder analysis _cylinderPalletAnalysis = cylinderPalletAnalysis; _selCylinderPalletSolution = selCylinderPalletSolution; // HCylinder analysis _hCylinderPalletAnalysis = hCylinderPalletAnalysis; _selHCylinderPalletSolution = selHCylinderPalletSolution; // Box case analysis _boxCaseAnalysis = boxCaseAnalysis; _selBoxCaseSolution = selBoxCaseSolution; // Pack pallet analysis _packPalletAnalysis = packPalletAnalysis; _selPackPalletSolution = selPackPalletSolution; }
public SelBoxCasePalletSolution(Document document, BoxCasePalletAnalysis analysis, BoxCasePalletSolution sol) : base(document) { _analysis = analysis; _solution = sol; Name = sol.Title; }
/// <summary> /// Constructor /// </summary> /// <param name="title"></param> /// <param name="caseAnalysis">Parent case analysis reference</param> public BoxCasePalletSolution(BoxCasePalletAnalysis caseAnalysis, string title, PalletSolutionDesc palletSolutionDesc, bool hasHomogeneousLayers) { _title = title; _parentCaseAnalysis = caseAnalysis; _palletSolutionDesc = palletSolutionDesc; _hasHomogeneousLayers = hasHomogeneousLayers; }
public void ProcessAnalysis(BoxCasePalletAnalysis analysis) { _boxProperties = analysis.BoxProperties; _interlayerProperties = analysis.InterlayerProperties; _palletSolutionList = analysis.PalletSolutionsList; _constraintSet = analysis.ConstraintSet; analysis.Solutions = GenerateSolutions(); }
/// <summary> /// Constructor used while browsing/editing case analysis /// </summary> /// <param name="document">Document</param> /// <param name="caseAnalysis">Case analysis</param> public FormNewCaseAnalysis(Document document, BoxCasePalletAnalysis caseAnalysis) { InitializeComponent(); // set unit labels UnitsManager.AdaptUnitLabels(this); // save document reference _document = document; _caseAnalysis = caseAnalysis; }
/// <summary> /// Constructor /// </summary> /// <param name="document">Document to which the case analysis begins</param> /// <param name="caseAnalysis">Case analysis browsed</param> public DockContentBoxCasePalletAnalysis(IDocument document, BoxCasePalletAnalysis caseAnalysis) { _document = document; _caseAnalysis = caseAnalysis; _caseAnalysis.AddListener(this); _caseAnalysis.SolutionSelected += new Basics.BoxCasePalletAnalysis.SelectSolution(SolutionSelectionChanged); _caseAnalysis.SolutionSelectionRemoved += new Basics.BoxCasePalletAnalysis.SelectSolution(SolutionSelectionChanged); InitializeComponent(); }
/// <summary> /// handles case solution unselected : actually removed selected solution node from case analysis node /// </summary> public void OnCaseAnalysisSolutionRemoved(Document doc, BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selSolution) { // get node TreeNode selSolutionNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASESOLUTION, doc, caseAnalysis, selSolution)); // test if (null == selSolutionNode) { _log.Error(string.Format("Failed to find a valid tree node for selSolution {0}", selSolution.Name)); return; } // remove node Nodes.Remove(selSolutionNode); }
private void onCaseAnalysisSolutionSelectionRemoved(BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selSolution) { // retrieve parent document Document doc = caseAnalysis.ParentDocument; // get node TreeNode caseAnalysisNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEPALLETANALYSIS, doc, caseAnalysis)); // test if (null == caseAnalysisNode) { _log.Warn(string.Format("Failed to find a valid tree node for caseAnalysis {0}", caseAnalysis.Name)); return; } // remove node Nodes.Remove(caseAnalysisNode); }
void SolutionSelectionChanged(BoxCasePalletAnalysis analysis, SelBoxCasePalletSolution selSolution) { UpdateSelectButtonText(); UpdateGridCheckBoxes(); }
/// <summary> /// handles new analysis created /// </summary> /// <param name="doc"></param> /// <param name="caseAnalysis"></param> public void OnNewBoxCasePalletAnalysisCreated(Document doc, BoxCasePalletAnalysis caseAnalysis) { // get parent node TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_LISTANALYSIS, doc)); // insert case analysis node TreeNode nodeAnalysis = new TreeNode(caseAnalysis.Name, 17, 17); nodeAnalysis.Tag = new NodeTag(NodeTag.NodeType.NT_BOXCASEPALLETANALYSIS, doc, caseAnalysis); parentNode.Nodes.Add(nodeAnalysis); parentNode.Expand(); // insert sub box node TreeNode subBoxNode = new TreeNode(caseAnalysis.BoxProperties.Name, 3, 3); subBoxNode.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISBOX, doc, caseAnalysis, caseAnalysis.BoxProperties); nodeAnalysis.Nodes.Add(subBoxNode); nodeAnalysis.Expand(); caseAnalysis.SolutionSelected += new Basics.BoxCasePalletAnalysis.SelectSolution(onCaseAnalysisSolutionSelected); caseAnalysis.SolutionSelectionRemoved += new Basics.BoxCasePalletAnalysis.SelectSolution(onCaseAnalysisSolutionSelectionRemoved); }
private void onCaseAnalysisSolutionSelected(BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selSolution) { // retrieve document Document doc = caseAnalysis.ParentDocument; // get parent node TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEPALLETANALYSIS, doc, caseAnalysis)); if (null == parentNode) throw new Exception("Failed to locate Analysis (NT_BOXCASEPALLETANALYSIS) node..."); // insert selected solution node TreeNode nodeSelSolution = new TreeNode(selSolution.Name, 15, 15); nodeSelSolution.Tag = new NodeTag(NodeTag.NodeType.NT_CASESOLUTION, doc, caseAnalysis, selSolution); parentNode.Nodes.Add(nodeSelSolution); // expand tree node parentNode.Expand(); }
public BoxCasePalletAnalysis CreateNewBoxCasePalletOptimization( string name, string description , BoxProperties bProperties , BoxCasePalletConstraintSet constraintSet , List<PalletSolutionDesc> palletSolutionList , IBoxCasePalletAnalysisSolver solver) { BoxCasePalletAnalysis analysis = new BoxCasePalletAnalysis(bProperties, palletSolutionList, constraintSet); analysis.Name = name; analysis.Description = description; // insert in list _boxCasePalletOptimizations.Add(analysis); // compute analysis if (null != solver) { solver.ProcessAnalysis(analysis); if (analysis.Solutions.Count < 1) { // remove analysis from list if it has no valid solution _boxCasePalletOptimizations.Remove(analysis); _log.InfoFormat("Failed to find any solution {0}", analysis.Name); return null; } } // notify listeners NotifyOnNewCaseAnalysisCreated(analysis); Modify(); return analysis; }
public void OnNewBoxCasePalletAnalysisCreated(Document doc, BoxCasePalletAnalysis caseAnalysis) { CreateOrActivateViewCaseAnalysis(caseAnalysis); }
private void NotifyOnNewCaseAnalysisCreated(BoxCasePalletAnalysis caseAnalysis) { foreach (IDocumentListener listener in _listeners) listener.OnNewBoxCasePalletAnalysisCreated(this, caseAnalysis); }
/// <summary> /// creates new case analysis view /// </summary> /// <param name="analysis"></param> /// <returns></returns> public DockContentBoxCasePalletAnalysis CreateCaseAnalysisView(BoxCasePalletAnalysis analysis) { // check if analysis has valid solutions if (!analysis.HasValidSolutions) { MessageBox.Show(string.Format(Properties.Resources.ID_ANALYSISHASNOVALIDSOLUTION, analysis.Name)); return null; } // show Box/Case/Pallet analysis view DockContentBoxCasePalletAnalysis form = new DockContentBoxCasePalletAnalysis(this, analysis); AddView(form); return form; }
private void AppendCaseConstraintSet(BoxCasePalletAnalysis caseAnalysis, XmlElement elemCaseAnalysis, XmlDocument xmlDoc) { string ns = xmlDoc.DocumentElement.NamespaceURI; BoxCasePalletConstraintSet cs = caseAnalysis.ConstraintSet; // caseConstraintSet element XmlElement elemCaseConstraintSet = CreateElement("caseConstraintSet", null, elemCaseAnalysis, xmlDoc, ns); // allowedPatterns CreateElement("allowedPatterns", cs.AllowedPatternString, elemCaseConstraintSet, xmlDoc, ns); // allowedOrthoAxis CreateElement("allowedOrthoAxis", cs.AllowOrthoAxisString, elemCaseConstraintSet, xmlDoc, ns); // allowAlignedLayers CreateElement("allowAlignedLayers", cs.AllowAlignedLayers ? "Y" : "N", elemCaseConstraintSet, xmlDoc, ns); // allowAlternateLayers CreateElement("allowAlternateLayers", cs.AllowAlternateLayers ? "Y" : "N", elemCaseConstraintSet, xmlDoc, ns); // maximumCaseWeightGroup if (cs.UseMaximumCaseWeight) { XmlElement maximumCaseWeightGroup = CreateElement("maximumCaseWeightGroup", null, elemCaseConstraintSet, xmlDoc, ns); AppendElementValue(xmlDoc, maximumCaseWeightGroup, "maximumCaseWeight", UnitsManager.UnitType.UT_MASS, cs.MaximumCaseWeight); } // minimumBoxPerCaseGroup if (cs.UseMinimumNumberOfItems) { XmlElement minimumBoxPerCaseGroup = CreateElement("minimumBoxPerCaseGroup", null, elemCaseConstraintSet, xmlDoc, ns); CreateElement("minimumBoxPerCase", cs.MinimumNumberOfItems, minimumBoxPerCaseGroup, xmlDoc, ns); } // maximumBoxPerCaseGroup if (cs.UseMaximumNumberOfItems) { XmlElement maximumBoxPerCaseGroup = CreateElement("minimumBoxPerCaseGroup", null, elemCaseConstraintSet, xmlDoc, ns); CreateElement("maximumBoxPerCase", cs.MinimumNumberOfItems, maximumBoxPerCaseGroup, xmlDoc, ns); } }
/// <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); }
public void OnNewBoxCasePalletAnalysisCreated(Document doc, BoxCasePalletAnalysis caseAnalysis) { _log.Info(string.Format("Loaded box/case/pallet analysis {0}", caseAnalysis.Name)); }
public ReportData(BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selCaseSolution) { _caseAnalysis = caseAnalysis; _selCaseSolution = selCaseSolution; }
public NodeTag(NodeType type, Document document, ItemBase itemProperties) { _type = type; _document = document; _itemProperties = itemProperties; if (_type == NodeType.NT_CASEPALLETANALYSIS && itemProperties is CasePalletAnalysis) { _casePalletAnalysis = itemProperties as CasePalletAnalysis; _itemProperties = null; } else if (_type == NodeType.NT_PACKPALLETANALYSIS && itemProperties is PackPalletAnalysis) { _packPalletAnalysis = itemProperties as PackPalletAnalysis; _itemProperties = null; } else if (_type == NodeType.NT_BOXCASEANALYSIS && itemProperties is BoxCaseAnalysis) { _boxCaseAnalysis = itemProperties as BoxCaseAnalysis; _itemProperties = null; } else if (_type == NodeType.NT_BOXCASEPALLETANALYSIS && itemProperties is BoxCasePalletAnalysis) { _boxCasePalletAnalysis = itemProperties as BoxCasePalletAnalysis; _itemProperties = null; } else if (_type == NodeType.NT_CYLINDERPALLETANALYSIS && itemProperties is CylinderPalletAnalysis) { _cylinderPalletAnalysis = itemProperties as CylinderPalletAnalysis; _itemProperties = null; } else if (_type == NodeType.NT_HCYLINDERPALLETANALYSIS && itemProperties is HCylinderPalletAnalysis) { _hCylinderPalletAnalysis = itemProperties as HCylinderPalletAnalysis; _itemProperties = null; } }
private BoxCasePalletSolution LoadBoxCasePalletSolution(XmlElement eltSolution, BoxCasePalletAnalysis analysis) { // title string stitle = eltSolution.Attributes["Title"].Value; // guid Guid guid = new Guid(eltSolution.Attributes["PalletSolutionId"].Value); // homogeneousLayers bool homogeneousLayers = string.Equals(eltSolution.Attributes["HomogeneousLayers"].Value, "true", StringComparison.CurrentCultureIgnoreCase); // instantiation BoxCasePalletSolution sol = new BoxCasePalletSolution(analysis, stitle, analysis.GetPalletSolutionDescByGuid(guid), homogeneousLayers); // layers XmlElement eltLayers = eltSolution.ChildNodes[0] as XmlElement; foreach (XmlNode nodeLayer in eltLayers.ChildNodes) sol.Add(LoadLayer(nodeLayer as XmlElement)); return sol; }
public NodeTag(NodeType type, Document doc, BoxCasePalletAnalysis caseAnalysis) { _type = type; _document = doc; _boxCasePalletAnalysis = caseAnalysis; }
private void SaveCaseAnalysis(BoxCasePalletAnalysis analysis, XmlElement parentElement, XmlDocument xmlDoc) { // create analysis element XmlElement xmlAnalysisElt = xmlDoc.CreateElement("AnalysisCase"); parentElement.AppendChild(xmlAnalysisElt); // Name XmlAttribute analysisNameAttribute = xmlDoc.CreateAttribute("Name"); analysisNameAttribute.Value = analysis.Name; xmlAnalysisElt.Attributes.Append(analysisNameAttribute); // Description XmlAttribute analysisDescriptionAttribute = xmlDoc.CreateAttribute("Description"); analysisDescriptionAttribute.Value = analysis.Description; xmlAnalysisElt.Attributes.Append(analysisDescriptionAttribute); // BoxId XmlAttribute boxIdAttribute = xmlDoc.CreateAttribute("BoxId"); boxIdAttribute.Value = string.Format("{0}", analysis.BoxProperties.Guid); xmlAnalysisElt.Attributes.Append(boxIdAttribute); // ConstraintSet : beg XmlElement constraintSetElement = xmlDoc.CreateElement("ConstraintSetCase"); xmlAnalysisElt.AppendChild(constraintSetElement); XmlAttribute alignedLayersAttribute = xmlDoc.CreateAttribute("AlignedLayersAllowed"); alignedLayersAttribute.Value = string.Format("{0}", analysis.ConstraintSet.AllowAlignedLayers); constraintSetElement.Attributes.Append(alignedLayersAttribute); XmlAttribute alternateLayersAttribute = xmlDoc.CreateAttribute("AlternateLayersAllowed"); alternateLayersAttribute.Value = string.Format("{0}", analysis.ConstraintSet.AllowAlternateLayers); constraintSetElement.Attributes.Append(alternateLayersAttribute); // allowed box positions XmlAttribute allowedAxisAttribute = xmlDoc.CreateAttribute("AllowedBoxPositions"); allowedAxisAttribute.Value = analysis.ConstraintSet.AllowOrthoAxisString; constraintSetElement.Attributes.Append(allowedAxisAttribute); // allowed layer patterns XmlAttribute allowedPatternAttribute = xmlDoc.CreateAttribute("AllowedPatterns"); allowedPatternAttribute.Value = analysis.ConstraintSet.AllowedPatternString; constraintSetElement.Attributes.Append(allowedPatternAttribute); // stop criterions if (analysis.ConstraintSet.UseMaximumCaseWeight) { XmlAttribute maximumWeightAttribute = xmlDoc.CreateAttribute("MaximumCaseWeight"); maximumWeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumCaseWeight); constraintSetElement.Attributes.Append(maximumWeightAttribute); } if (analysis.ConstraintSet.UseMaximumNumberOfItems) { XmlAttribute maximumNumberOfItems = xmlDoc.CreateAttribute("ManimumNumberOfItems"); maximumNumberOfItems.Value = string.Format("{0}", analysis.ConstraintSet.MaximumNumberOfItems); constraintSetElement.Attributes.Append(maximumNumberOfItems); } // solution filtering if (analysis.ConstraintSet.UseMinimumNumberOfItems) { XmlAttribute minimumNumberOfItems = xmlDoc.CreateAttribute("MinimumNumberOfItems"); minimumNumberOfItems.Value = string.Format("{0}", analysis.ConstraintSet.MinimumNumberOfItems); constraintSetElement.Attributes.Append(minimumNumberOfItems); } // number of solutions to keep if (analysis.ConstraintSet.UseNumberOfSolutionsKept) { XmlAttribute numberOfSolutionsKept = xmlDoc.CreateAttribute("NumberOfSolutions"); numberOfSolutionsKept.Value = string.Format("{0}", analysis.ConstraintSet.NumberOfSolutionsKept); constraintSetElement.Attributes.Append(numberOfSolutionsKept); } // ConstraintSet : end // Pallet solution descriptors XmlElement palletSolutionsElement = xmlDoc.CreateElement("PalletSolutionDescriptors"); xmlAnalysisElt.AppendChild(palletSolutionsElement); foreach (PalletSolutionDesc desc in analysis.PalletSolutionsList) SavePalletSolutionDescriptor(desc, palletSolutionsElement, xmlDoc); // Solutions XmlElement solutionsElt = xmlDoc.CreateElement("CaseSolutions"); xmlAnalysisElt.AppendChild(solutionsElt); int solIndex = 0; foreach (BoxCasePalletSolution caseSolution in analysis.Solutions) SaveCaseSolution(caseSolution, analysis.GetSelCaseSolutionBySolutionIndex(solIndex++), solutionsElt, xmlDoc); }
public NodeTag(NodeType type, Document doc, BoxCasePalletAnalysis caseAnalysis, ItemBase itemProperties) { _type = type; _document = doc; _boxCasePalletAnalysis = caseAnalysis; _itemProperties = itemProperties; _selSolution = null; }
public NodeTag(NodeType type, Document document, BoxCasePalletAnalysis caseAnalysis, SelBoxCasePalletSolution selBoxCasePalletSolution) { _type = type; _document = document; _boxCasePalletAnalysis = caseAnalysis; _selBoxCasePalletSolution = selBoxCasePalletSolution; }
/// <summary> /// Creates or activate a case analysis view /// </summary> public void CreateOrActivateViewCaseAnalysis(BoxCasePalletAnalysis caseAnalysis) { // search ammong existing views foreach (IDocument doc in Documents) foreach (IView view in doc.Views) { DockContentBoxCasePalletAnalysis form = view as DockContentBoxCasePalletAnalysis; if (null == form) continue; if (caseAnalysis == form.CaseAnalysis) { form.Activate(); return; } } // ---> not found // ---> create new form DocumentSB parentDocument = (DocumentSB)caseAnalysis.ParentDocument; DockContentBoxCasePalletAnalysis formCaseAnalysis = parentDocument.CreateCaseAnalysisView(caseAnalysis); formCaseAnalysis.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document); }