Esempio n. 1
0
 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;
 }
Esempio n. 2
0
        public SelBoxCaseSolution(Document document, BoxCaseAnalysis analysis, BoxCaseSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            Name = sol.Title;
        }
 public FormNewAnalysisBundleCase(Document document, BoxCaseAnalysis analysis)
     : base(document, analysis)
 {
     InitializeComponent();
     // units
     UnitsManager.AdaptUnitLabels(this);
     // analysis
     _analysis = analysis;
 }
Esempio n. 4
0
        public SelBoxCaseSolution(Document document, BoxCaseAnalysis analysis, BoxCaseSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            Name      = sol.Title;
        }
        public void ProcessAnalysis(BoxCaseAnalysis analysis)
        {
            _bProperties = analysis.BProperties;
            _caseProperties = analysis.CaseProperties;
            _constraintSet = analysis.ConstraintSet;

            if (!_constraintSet.IsValid)
                throw new EngineException("Constraint set is invalid!");

            analysis.Solutions = GenerateSolutions();
        }
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Analysis</param>
 public FormNewBoxCaseAnalysis(Document document, BoxCaseAnalysis analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
 }
        public DockContentBoxCaseAnalysis(IDocument document, BoxCaseAnalysis analysis)
        {
            _document = document;
            _analysis = analysis;
            _analysis.AddListener(this);

            _analysis.SolutionSelected += new BoxCaseAnalysis.SelectSolution(onSolutionSelectionChanged);
            _analysis.SolutionSelectionRemoved += new BoxCaseAnalysis.SelectSolution(onSolutionSelectionChanged);

            InitializeComponent();
        }
Esempio n. 8
0
 public void SaveBoxCaseAnalysis(BoxCaseAnalysis analysis, XmlElement parentElement, XmlDocument xmlDoc)
 {
     // create analysis element
     XmlElement xmlAnalysisElt = xmlDoc.CreateElement("AnalysisBoxCase");
     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.BProperties.Guid);
     xmlAnalysisElt.Attributes.Append(boxIdAttribute);
     // PalletId
     XmlAttribute palletIdAttribute = xmlDoc.CreateAttribute("CaseId");
     palletIdAttribute.Value = string.Format("{0}", analysis.CaseProperties.Guid);
     xmlAnalysisElt.Attributes.Append(palletIdAttribute);
     // Constraint set
     SaveBoxCaseConstraintSet(analysis.ConstraintSet, xmlAnalysisElt, xmlDoc);
     // Solutions
     int solIndex = 0;
     XmlElement solutionsElt = xmlDoc.CreateElement("Solutions");
     xmlAnalysisElt.AppendChild(solutionsElt);
     if (null != analysis.Solutions)
         foreach (BoxCaseSolution sol in analysis.Solutions)
         {
             SaveBoxCaseSolution(
                 analysis
                 , sol
                 , analysis.GetSelSolutionBySolutionIndex(solIndex) // null if not selected
                 , solutionsElt
                 , xmlDoc);
             ++solIndex;
         }
 }
Esempio n. 9
0
        public void SaveBoxCaseSolution(BoxCaseAnalysis analysis, BoxCaseSolution sol, SelBoxCaseSolution selSolution, XmlElement solutionsElt, XmlDocument xmlDoc)
        {
            // Solution
            XmlElement solutionElt = xmlDoc.CreateElement("Solution");
            solutionsElt.AppendChild(solutionElt);
            // Pattern name
            XmlAttribute patternNameAttribute = xmlDoc.CreateAttribute("Pattern");
            patternNameAttribute.Value = sol.PatternName;
            solutionElt.Attributes.Append(patternNameAttribute);
            // ortho axis
            XmlAttribute orthoAxisAttribute = xmlDoc.CreateAttribute("OrthoAxis");
            orthoAxisAttribute.Value = HalfAxis.ToString(sol.OrthoAxis);
            solutionElt.Attributes.Append(orthoAxisAttribute);
            // limit
            XmlAttribute limitReached = xmlDoc.CreateAttribute("LimitReached");
            limitReached.Value = string.Format("{0}", (int)sol.LimitReached);
            solutionElt.Attributes.Append(limitReached);
            // layers
            XmlElement layersElt = xmlDoc.CreateElement("Layers");
            solutionElt.AppendChild(layersElt);

            foreach (BoxLayer boxLayer in sol)
                Save(boxLayer, layersElt, xmlDoc);

            // Is selected ?
            if (null != selSolution)
            {
                // selected attribute
                XmlAttribute selAttribute = xmlDoc.CreateAttribute("Selected");
                selAttribute.Value = "true";
                solutionElt.Attributes.Append(selAttribute);
            }
        }
Esempio n. 10
0
 public ReportData(BoxCaseAnalysis boxCaseAnalysis, SelBoxCaseSolution selBoxCaseSolution)
 {
     _boxCaseAnalysis = boxCaseAnalysis;
     _selBoxCaseSolution = selBoxCaseSolution;
 }
Esempio n. 11
0
 /// <summary>
 /// creates new box/case analysis view
 /// </summary>
 public DockContentBoxCaseAnalysis CreateNewBoxCaseAnalysisView(BoxCaseAnalysis analysis)
 {
     DockContentBoxCaseAnalysis form = new DockContentBoxCaseAnalysis(this, analysis);
     AddView(form);
     return form;
 }
        protected void Compute()
        {
            try
            {
                const double thickness = 4.0;
                _doc = new Document(_name, "", "", DateTime.Now, null);
                // colors
                Color[] colors = new Color[6];
                for (int i = 0; i < 6; ++i) colors[i] = Color.Chocolate;
                // bundle
                BundleProperties bundleProperties = _doc.CreateNewBundle(_name, _name, BundleLength, BundleWidth, FlatThickness, FlatWeight, Color.Beige, NoFlats);
                // case
                BoxProperties caseProperties = _doc.CreateNewCase(_name, _name
                    , CaseInsideLength + 2.0 * thickness, CaseInsideWidth + 2.0 * thickness, CaseInsideHeight + 2.0 * thickness
                    , CaseInsideLength, CaseInsideWidth, CaseInsideHeight
                    , CaseWeight, colors);
                // constraint set
                BundleCaseConstraintSet constraintSet = new BundleCaseConstraintSet();
                // maximum case weight
                constraintSet.UseMaximumCaseWeight = false;
                constraintSet.MaximumCaseWeight = 0.0;
                // maximum number of items
                constraintSet.UseMaximumNumberOfBoxes = false;
                constraintSet.MaximumNumberOfBoxes = 0;

                _analysis = _doc.CreateNewBoxCaseAnalysis(
                    _name, _name
                    , bundleProperties, caseProperties
                    , constraintSet
                    , new BoxCaseSolver());
                // fill grid
                FillGrid();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
 private void onBoxCaseAnalysisSolutionSelectionRemoved(BoxCaseAnalysis analysis, SelBoxCaseSolution selSolution)
 {
     // retrieve parent document
     Document doc = analysis.ParentDocument;
     // get node
     TreeNode selSolutionNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSISSOLUTION, doc, analysis, 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);
 }
 void onSolutionSelectionChanged(BoxCaseAnalysis analysis, SelBoxCaseSolution selSolution)
 {
     UpdateSelectButtonText();
     UpdateGridCheckBoxes();
 }
Esempio n. 15
0
 public BoxCaseAnalysis CreateNewBoxCaseAnalysis(
     string name, string description
     , BProperties boxProperties, BoxProperties caseProperties
     , BCaseConstraintSet constraintSet
     , IBoxCaseAnalysisSolver solver)
 {
     BoxCaseAnalysis analysis = new BoxCaseAnalysis(boxProperties, caseProperties, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _boxCaseAnalyses.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
             _boxCaseAnalyses.Remove(analysis);
             return null;
         }
     }
     // notify listeners
     NotifyOnNewBoxCaseAnalysis(analysis);
     Modify();
     return analysis;
 }
 public NodeTag(NodeType type, Document doc, BoxCaseAnalysis boxCaseAnalysis)
 {
     _type = type;
     _document = doc;
     _boxCaseAnalysis = boxCaseAnalysis;
 }
Esempio n. 17
0
        /// <summary>
        /// edit box / case analysis
        /// </summary>
        public void EditBoxCaseAnalysis(BoxCaseAnalysis boxCaseAnalysis)
        {
            bool recomputeRequired = false;

            if (boxCaseAnalysis.IsBoxAnalysis)
            {
                FormNewBoxCaseAnalysis form = new FormNewBoxCaseAnalysis(boxCaseAnalysis.ParentDocument, boxCaseAnalysis);
                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    boxCaseAnalysis.Name = form.AnalysisName;
                    boxCaseAnalysis.Description = form.AnalysisDescription;
                    // selected box
                    boxCaseAnalysis.BProperties = form.SelectedBox;
                    boxCaseAnalysis.CaseProperties = form.SelectedCase;
                    // constraint set
                    BCaseConstraintSet constraintSet = boxCaseAnalysis.ConstraintSet;
                    BoxCaseConstraintSet boxCaseConstraintSet = constraintSet as BoxCaseConstraintSet;
                    if (null != boxCaseConstraintSet)
                    {
                        // allowed axes
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ);
                        boxCaseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ);
                    }
                    // use maximum case weight
                    constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight;
                    constraintSet.MaximumCaseWeight = form.MaximumCaseWeight;
                    // use maximum number of items
                    constraintSet.UseMaximumNumberOfBoxes = form.UseMaximumNumberOfBoxes;
                    constraintSet.MaximumNumberOfBoxes = form.MaximumNumberOfBoxes;
                }
            }
            else if (boxCaseAnalysis.IsBundleAnalysis)
            {
                FormNewAnalysisBundleCase form = new FormNewAnalysisBundleCase(boxCaseAnalysis.ParentDocument, boxCaseAnalysis);
                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    boxCaseAnalysis.Name = form.ItemName;
                    boxCaseAnalysis.Description = form.ItemDescription;
                    // selected bundle
                    boxCaseAnalysis.BProperties = form.SelectedBundle;
                    boxCaseAnalysis.CaseProperties = form.SelectedCase;
                    // constraint set
                    BCaseConstraintSet constraintSet = boxCaseAnalysis.ConstraintSet;
                    // use maximum case weight
                    constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight;
                    constraintSet.MaximumCaseWeight = form.MaximumCaseWeight;
                    // use maximum number of items
                    constraintSet.UseMaximumNumberOfBoxes = form.UseMaximumNumberOfBoxes;
                    constraintSet.MaximumNumberOfBoxes = form.MaximumNumberOfBoxes;
                }
            }
            if (recomputeRequired)
                boxCaseAnalysis.OnEndUpdate(null);
        }
 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;
     }
 }
 public void onBoxCaseAnalysisSolutionRemoved(Document doc, BoxCaseAnalysis boxCaseAnalysis, SelBoxCaseSolution selSolution)
 {
     // get node
     TreeNode selSolutionNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASESOLUTION, doc, boxCaseAnalysis, 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);
 }
 public void BoxCaseAnalysis_InsertSubNodes(Document doc, BoxCaseAnalysis analysis, TreeNode nodeAnalysis)
 {
     // sanity check
     if (null == nodeAnalysis) return;
     // remove existing sub nodes
     nodeAnalysis.Nodes.Clear();
     // insert sub box node
     int indexIcon = 3;
     TreeNode subBoxNode = new TreeNode(analysis.BProperties.Name, indexIcon, indexIcon);
     subBoxNode.Tag = new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSISBOX, doc, analysis.BProperties);
     nodeAnalysis.Nodes.Add(subBoxNode);
     // insert sub case node
     indexIcon = 4;
     TreeNode subCaseNode = new TreeNode(analysis.CaseProperties.Name, indexIcon, indexIcon);
     subCaseNode.Tag = new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSISCASE, doc, analysis.CaseProperties);
     nodeAnalysis.Nodes.Add(subCaseNode);
     nodeAnalysis.Expand();
 }
Esempio n. 21
0
 public BoxCaseAnalysis CreateNewBoxCaseAnalysis(
     string name, string description
     , BProperties boxProperties, BoxProperties caseProperties
     , BCaseConstraintSet constraintSet
     , List<BoxCaseSolution> solutions)
 {
     BoxCaseAnalysis analysis = new BoxCaseAnalysis(boxProperties, caseProperties, constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _boxCaseAnalyses.Add(analysis);
     // set solutions
     analysis.Solutions = solutions;
     // notify listeners
     NotifyOnNewBoxCaseAnalysis(analysis);
     // set solution selected if it is unique
     if (solutions.Count == 1)
         analysis.SelectSolutionByIndex(0);
     return analysis;
 }
Esempio n. 22
0
 public void OnNewBoxCaseAnalysisCreated(Document doc, BoxCaseAnalysis boxCaseAnalysis)
 {
     CreateOrActivateViewBoxCaseAnalysis(boxCaseAnalysis);
 }
Esempio n. 23
0
 private void NotifyOnNewBoxCaseAnalysis(BoxCaseAnalysis analysis)
 {
     foreach (IDocumentListener listener in _listeners)
         listener.OnNewBoxCaseAnalysisCreated(this, analysis);
 }
 private void onBoxCaseAnalysisSolutionSelected(BoxCaseAnalysis analysis, SelBoxCaseSolution selSolution)
 {
     // retrieve parent document
     Document doc = analysis.ParentDocument;
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSIS, doc, analysis));
     // insert selected solution node
     TreeNode nodeSelSolution = new TreeNode(selSolution.Name, 15, 15);
     nodeSelSolution.Tag = new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSISSOLUTION, doc, analysis, selSolution);
     parentNode.Nodes.Add(nodeSelSolution);
     // expand tree nodes
     parentNode.Expand();
 }
 public NodeTag(NodeType type, Document doc, BoxCaseAnalysis boxCaseAnalysis, SelBoxCaseSolution selBoxCaseSolution)
 {
     _type = type;
     _document = doc;
     _boxCaseAnalysis = boxCaseAnalysis;
     _selBoxCaseSolution = selBoxCaseSolution;
 }
Esempio n. 26
0
 public void OnNewBoxCaseAnalysisCreated(Document doc, BoxCaseAnalysis analysis)
 {
     _log.Info(string.Format("Loaded box/case analysis {0}", analysis.Name));
 }
Esempio n. 27
0
 public BoxCaseSolution(BoxCaseAnalysis boxCaseAnalysis, HalfAxis.HAxis orthoAxis, string patternName)
 {
     _boxCaseAnalysis = boxCaseAnalysis;
     _orthoAxis       = orthoAxis;
     _patternName     = patternName;
 }
 /// <summary>
 /// handles new box case analysis creation
 /// </summary>
 /// <param name="doc">Document</param>
 /// <param name="analysis">Analysis</param>
 public void OnNewBoxCaseAnalysisCreated(Document doc, BoxCaseAnalysis analysis)
 {
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_LISTANALYSIS, doc));
     // get parent node
     int indexIconAnalysis = 17;
     TreeNode nodeAnalysis = new TreeNode(analysis.Name, indexIconAnalysis, indexIconAnalysis);
     nodeAnalysis.Tag = new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSIS, doc, analysis);
     parentNode.Nodes.Add(nodeAnalysis);
     parentNode.Expand();
     BoxCaseAnalysis_InsertSubNodes(doc, analysis, nodeAnalysis);
     // add event handlers for solution selection
     analysis.Modified += new Basics.BoxCaseAnalysis.ModifyAnalysis(onBoxCaseAnalysisModified);
     analysis.SolutionSelected += new BoxCaseAnalysis.SelectSolution(onBoxCaseAnalysisSolutionSelected);
     analysis.SolutionSelectionRemoved += new Basics.BoxCaseAnalysis.SelectSolution(onBoxCaseAnalysisSolutionSelectionRemoved);
 }
 private void onBoxCaseAnalysisModified(BoxCaseAnalysis analysis)
 {
     // retrieve parent document
     Document doc = analysis.ParentDocument;
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_BOXCASEANALYSIS, doc, analysis));
     // remove & insert sub nodes
     BoxCaseAnalysis_InsertSubNodes(doc, analysis, parentNode);
 }
Esempio n. 30
0
 public void CreateOrActivateViewBoxCaseAnalysis(BoxCaseAnalysis boxCaseAnalysis)
 {
     // search among existing views
     foreach (IDocument doc in Documents)
         foreach (IView view in doc.Views)
         {
             DockContentBoxCaseAnalysis form = view as DockContentBoxCaseAnalysis;
             if (null == form) continue;
             if (boxCaseAnalysis == form.Analysis)
             {
                 form.Activate();
                 return;
             }
         }
     // ---> not found
     // ---> create new form
     DocumentSB parentDocument = (DocumentSB)boxCaseAnalysis.ParentDocument;
     DockContentBoxCaseAnalysis formBoxCaseAnalysis = parentDocument.CreateNewBoxCaseAnalysisView(boxCaseAnalysis);
     formBoxCaseAnalysis.Show(dockPanel, WeifenLuo.WinFormsUI.Docking.DockState.Document);
 }