/// <summary>
 /// overrides IItemListener.Update
 /// </summary>
 /// <param name="item"></param>
 public void Update(ItemBase item)
 {
     // update grid
     FillGrid();
     // select first solution
     if (gridSolutions.RowsCount > 0)
     {
         gridSolutions.Selection.SelectRow(1, true);
     }
     if (_analysis.Solutions.Count > 0)
     {
         _sol = _analysis.Solutions[0];
     }
     // draw
     graphCtrlSolution.Invalidate();
 }
 private void onGridSolutionSelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
 {
     SourceGrid.RangeRegion region = gridSolutions.Selection.GetSelectionRegion();
     int[] indexes = region.GetRowsIndex();
     // no selection -> exit
     if (indexes.Length == 0)
     {
         return;
     }
     // get selected solution
     _sol = _analysis.Solutions[indexes[0] - 1];
     // update select/unselect button text
     UpdateSelectButtonText();
     // redraw
     graphCtrlSolution.Invalidate();
 }
 public HCylinderPalletSolutionViewer(HCylinderPalletSolution solution)
 {
     _analysis = null != solution ? solution.Analysis : null;
     _solution = solution;
 }
Esempio n. 4
0
 public HCylinderPalletSolutionViewer(HCylinderPalletSolution solution)
 {
     _analysis = null != solution ? solution.Analysis : null;
     _solution = solution;
 }
 private void onGridSolutionSelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
 {
     SourceGrid.RangeRegion region = gridSolutions.Selection.GetSelectionRegion();
     int[] indexes = region.GetRowsIndex();
     // no selection -> exit
     if (indexes.Length == 0) return;
     // get selected solution
     _sol = _analysis.Solutions[indexes[0] - 1];
     // update select/unselect button text
     UpdateSelectButtonText();
     // redraw
     graphCtrlSolution.Invalidate();
 }
 /// <summary>
 /// overrides IItemListener.Update
 /// </summary>
 /// <param name="item"></param>
 public void Update(ItemBase item)
 {
     // update grid
     FillGrid();
     // select first solution
     if (gridSolutions.RowsCount > 0)
         gridSolutions.Selection.SelectRow(1, true);
     if (_analysis.Solutions.Count > 0)
         _sol = _analysis.Solutions[0];
     // draw
     graphCtrlSolution.Invalidate();
 }
Esempio n. 7
0
 private HCylinderPalletSolution LoadHCylinderPalletSolution(XmlElement eltSolution)
 {
     // title -> instantiation
     string stitle = eltSolution.Attributes["Title"].Value;
     HCylinderPalletSolution sol = new HCylinderPalletSolution(null, stitle);
     // limit reached
     if (eltSolution.HasAttribute("LimitReached"))
     {
         string sLimitReached = eltSolution.Attributes["LimitReached"].Value;
         sol.LimitReached = (Limit)(int.Parse(sLimitReached));
     }
     // cyl positions
     XmlElement eltPositions = eltSolution.ChildNodes[0] as XmlElement;
     foreach (XmlNode nodeCylPos in eltPositions.ChildNodes)
         sol.Add(LoadCylPosition(nodeCylPos as XmlElement));
     return sol;
 }
Esempio n. 8
0
 public void SaveHCylinderPalletSolution(
     HCylinderPalletAnalysis analysis
     , HCylinderPalletSolution sol
     , SelHCylinderPalletSolution selSolution
     , XmlElement solutionsElt
     , XmlDocument xmlDoc)
 {
     // Solution
     XmlElement solutionElt = xmlDoc.CreateElement("Solution");
     solutionsElt.AppendChild(solutionElt);
     // title
     XmlAttribute titleAttribute = xmlDoc.CreateAttribute("Title");
     titleAttribute.Value = sol.Title;
     solutionElt.Attributes.Append(titleAttribute);
     // limit
     XmlAttribute limitReached = xmlDoc.CreateAttribute("LimitReached");
     limitReached.Value = string.Format("{0}", (int)sol.LimitReached);
     solutionElt.Attributes.Append(limitReached);
     // layers
     XmlElement positionsElt = xmlDoc.CreateElement("CylPositions");
     solutionElt.AppendChild(positionsElt);
     foreach (CylPosition cylPos in sol)
     {
         // CylPosition
         XmlElement positionElt = xmlDoc.CreateElement("CylPosition");
         positionsElt.AppendChild(positionElt);
         // XmlAttribute
         XmlAttribute attPosition = xmlDoc.CreateAttribute("Position");
         attPosition.Value = cylPos.XYZ.ToString();
         positionElt.Attributes.Append(attPosition);
         XmlAttribute attAxisDir = xmlDoc.CreateAttribute("AxisDir");
         attAxisDir.Value = HalfAxis.ToString(cylPos.Direction);
         positionElt.Attributes.Append(attAxisDir);
     }
     if (null != selSolution)
     {
         // selected attribute
         XmlAttribute selAttribute = xmlDoc.CreateAttribute("Selected");
         selAttribute.Value = "true";
         solutionElt.Attributes.Append(selAttribute);
     }
 }
Esempio n. 9
0
        public SelHCylinderPalletSolution(Document document, HCylinderPalletAnalysis analysis, HCylinderPalletSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            Name = sol.Title;
        }
Esempio n. 10
0
        private List <HCylinderPalletSolution> GenerateSolutions()
        {
            List <HCylinderPalletSolution> solutions = new List <HCylinderPalletSolution>();

            // loop through all patterns
            foreach (HCylinderLoadPattern pattern in _patterns)
            {
                if (!_constraintSet.AllowPattern(pattern.Name))
                {
                    continue;
                }
                // loop through directions
                for (int iDir = 0; iDir < (pattern.CanBeSwapped ? 2 : 1); ++iDir)
                {
                    string title = string.Format("{0}-{1}", pattern.Name, iDir);
                    HCylinderPalletSolution sol = new HCylinderPalletSolution(null, title);

                    double actualLength = 0.0, actualWidth = 0.0;
                    double maxHeight = _constraintSet.UseMaximumPalletHeight ? _constraintSet.MaximumPalletHeight : -1;

                    pattern.Swapped = (iDir % 2 != 0);

                    int maxCountNoItems = -1;
                    if (_constraintSet.UseMaximumNumberOfItems)
                    {
                        maxCountNoItems = _constraintSet.MaximumNumberOfItems;
                    }
                    int maxCountWeight = -1;
                    if (_constraintSet.UseMaximumPalletWeight)
                    {
                        maxCountWeight = (int)Math.Floor((_constraintSet.MaximumPalletWeight - _palletProperties.Weight) / _cylProperties.Weight);
                    }
                    int maxCount = -1;
                    if (-1 != maxCountNoItems && -1 == maxCountWeight)
                    {
                        maxCount = maxCountNoItems;
                    }
                    else if (-1 == maxCountNoItems && -1 != maxCountWeight)
                    {
                        maxCount = maxCountWeight;
                    }
                    else if (-1 != maxCountNoItems && -1 != maxCountWeight)
                    {
                        maxCount = Math.Min(maxCountWeight, maxCountNoItems);
                    }
                    try
                    {
                        CylLoad load = new CylLoad(_cylProperties, _palletProperties, _constraintSet);
                        pattern.GetDimensions(load, maxCount, out actualLength, out actualWidth);
                        pattern.Generate(load, maxCount, actualLength, actualWidth, maxHeight - _palletProperties.Height);

                        // Limit reached ?
                        sol.LimitReached = load.LimitReached;
                        // maxCount might actually max weight reached
                        if (load.LimitReached == Limit.LIMIT_MAXNUMBERREACHED && maxCount == maxCountWeight)
                        {
                            sol.LimitReached = Limit.LIMIT_MAXWEIGHTREACHED;
                        }

                        // copies all cylinder positions
                        foreach (CylPosition pos in load)
                        {
                            sol.Add(new CylPosition(
                                        pos.XYZ
                                        - 0.5 * _constraintSet.OverhangX * Vector3D.XAxis
                                        - 0.5 * _constraintSet.OverhangY * Vector3D.YAxis,
                                        pos.Direction
                                        ));
                        }
                    }
                    catch (NotImplementedException ex)
                    {
                        _log.Debug(ex.Message);
                        continue;
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message);
                        continue;
                    }
                    // add solution
                    if (sol.Count > 0)
                    {
                        solutions.Add(sol);
                    }
                } // loop on directions
            }     // loop through all patterns
            // sort solution
            solutions.Sort();
            return(solutions);
        }
Esempio n. 11
0
        private List<HCylinderPalletSolution> GenerateSolutions()
        {
            List<HCylinderPalletSolution> solutions = new List<HCylinderPalletSolution>();

            // loop through all patterns
            foreach (HCylinderLoadPattern pattern in _patterns)
            {
                if (!_constraintSet.AllowPattern(pattern.Name))
                    continue;
                // loop through directions
                for (int iDir = 0; iDir < (pattern.CanBeSwapped ? 2 : 1); ++iDir)
                {
                    string title = string.Format("{0}-{1}", pattern.Name, iDir);
                    HCylinderPalletSolution sol = new HCylinderPalletSolution(null, title);

                    double actualLength = 0.0, actualWidth = 0.0;
                    double maxHeight = _constraintSet.UseMaximumPalletHeight ? _constraintSet.MaximumPalletHeight : -1;

                    pattern.Swapped = (iDir % 2 != 0);

                    int maxCountNoItems = -1;
                    if (_constraintSet.UseMaximumNumberOfItems) maxCountNoItems = _constraintSet.MaximumNumberOfItems;
                    int maxCountWeight = -1;
                    if (_constraintSet.UseMaximumPalletWeight)
                        maxCountWeight = (int)Math.Floor((_constraintSet.MaximumPalletWeight - _palletProperties.Weight) / _cylProperties.Weight);
                    int maxCount = -1;
                    if (-1 != maxCountNoItems && -1 == maxCountWeight) maxCount = maxCountNoItems;
                    else if (-1 == maxCountNoItems && -1 != maxCountWeight) maxCount = maxCountWeight;
                    else if (-1 != maxCountNoItems && -1 != maxCountWeight) maxCount = Math.Min(maxCountWeight, maxCountNoItems);
                    try
                    {
                        CylLoad load = new CylLoad(_cylProperties, _palletProperties, _constraintSet);
                        pattern.GetDimensions(load, maxCount, out actualLength, out actualWidth);
                        pattern.Generate(load, maxCount, actualLength, actualWidth, maxHeight - _palletProperties.Height);

                        // Limit reached ?
                        sol.LimitReached = load.LimitReached;
                        // maxCount might actually max weight reached
                        if (load.LimitReached == Limit.LIMIT_MAXNUMBERREACHED && maxCount == maxCountWeight)
                            sol.LimitReached = Limit.LIMIT_MAXWEIGHTREACHED;

                        // copies all cylinder positions
                        foreach (CylPosition pos in load)
                        {
                            sol.Add(new CylPosition(
                                pos.XYZ
                                - 0.5 * _constraintSet.OverhangX * Vector3D.XAxis
                                - 0.5 * _constraintSet.OverhangY * Vector3D.YAxis,
                                pos.Direction
                                ));
                        }
                    }
                    catch (NotImplementedException ex)
                    {
                        _log.Debug(ex.Message);
                        continue;
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message);
                        continue;
                    }
                    // add solution
                    if (sol.Count > 0)
                        solutions.Add(sol);
                } // loop on directions
            } // loop through all patterns
            // sort solution
            solutions.Sort();
            return solutions;
        }