Exemple #1
0
 /// <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();
 }
Exemple #2
0
 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 CylinderPalletSolutionViewer(CylinderPalletSolution solution)
 {
     _analysis = null != solution ? solution.Analysis : null;
     _solution = solution;
 }
        private List <CylinderPalletSolution> GenerateSolutions()
        {
            List <CylinderPalletSolution> solutions = new List <CylinderPalletSolution>();

            // loop through all patterns
            foreach (CylinderLayerPattern pattern in _patterns)
            {
                for (int iDir = 0; iDir < (pattern.CanBeSwapped ? 2 : 1); ++iDir)
                {
                    // alternate pallet direction
                    LayerCyl layer = new LayerCyl(_cylProperties, _palletProperties, _constraintSet);

                    string title = string.Format("{0}-{1}", pattern.Name, iDir);
                    CylinderPalletSolution sol = new CylinderPalletSolution(null, title, true);

                    double actualLength = 0.0, actualWidth = 0.0;
                    pattern.Swapped = (iDir % 2 != 0);
                    pattern.GetLayerDimensions(layer, out actualLength, out actualWidth);
                    try
                    {
                        pattern.GenerateLayer(layer, actualLength, actualWidth);
                    }
                    catch (NotImplementedException ex)
                    {
                        _log.Debug(ex.Message);
                        continue;
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message);
                        continue;
                    }

                    // stop
                    double zLayer           = _palletProperties.Height;
                    bool   maxWeightReached = _constraintSet.UseMaximumPalletWeight && (_palletProperties.Weight + _cylProperties.Weight > _constraintSet.MaximumPalletWeight);
                    bool   maxHeightReached = _constraintSet.UseMaximumPalletHeight && (zLayer + _cylProperties.Height > _constraintSet.MaximumPalletHeight);
                    bool   maxNumberReached = false;

                    int iCount = 0;

                    // insert anti-slip interlayer
                    if (_constraintSet.HasInterlayerAntiSlip)
                    {
                        sol.CreateNewInterlayer(zLayer, 1);
                        zLayer += _interlayerPropertiesAntiSlip.Thickness;
                    }

                    while (!maxWeightReached && !maxHeightReached && !maxNumberReached)
                    {
                        // interlayer
                        if (_constraintSet.HasInterlayer && (sol.Count > 0))
                        {
                            sol.CreateNewInterlayer(zLayer, 0);
                            zLayer += _interlayerProperties.Thickness;
                        }
                        // select current layer type
                        CylinderLayer cylLayer = sol.CreateNewLayer(zLayer);
                        foreach (Vector2D layerPos in layer)
                        {
                            ++iCount;
                            maxWeightReached = _constraintSet.UseMaximumPalletWeight && ((iCount * _cylProperties.Weight + _palletProperties.Weight) > _constraintSet.MaximumPalletWeight);
                            maxNumberReached = _constraintSet.UseMaximumNumberOfItems && (iCount > _constraintSet.MaximumNumberOfItems);
                            if (!maxWeightReached && !maxNumberReached)
                            {
                                cylLayer.Add(
                                    new Vector3D(
                                        layerPos.X - 0.5 * _constraintSet.OverhangX,
                                        layerPos.Y - 0.5 * _constraintSet.OverhangY,
                                        zLayer));
                            }
                        }
                        // increment zLayer
                        zLayer += _cylProperties.Height;

                        maxHeightReached = _constraintSet.UseMaximumPalletHeight && (zLayer + _cylProperties.Height > _constraintSet.MaximumPalletHeight);
                    }
                    // limit reached
                    if (maxWeightReached)
                    {
                        sol.LimitReached = Limit.LIMIT_MAXWEIGHTREACHED;
                    }
                    else if (maxNumberReached)
                    {
                        sol.LimitReached = Limit.LIMIT_MAXNUMBERREACHED;
                    }
                    else if (maxHeightReached)
                    {
                        sol.LimitReached = Limit.LIMIT_MAXHEIGHTREACHED;
                    }
                    else
                    {
                        sol.LimitReached = Limit.LIMIT_UNKNOWN;
                    }

                    solutions.Add(sol);
                }
            }
            // sort solutions
            solutions.Sort();
            return(solutions);
        }
 private CylinderPalletSolution LoadCylinderPalletSolution(XmlElement eltSolution)
 {
     // title -> instantiation
     string stitle = eltSolution.Attributes["Title"].Value;
     CylinderPalletSolution sol = new CylinderPalletSolution(null, stitle, true);
     // layer
     if (eltSolution.HasAttribute("LimitReached"))
     {
         string sLimitReached = eltSolution.Attributes["LimitReached"].Value;
         sol.LimitReached = (Limit)(int.Parse(sLimitReached));
     }
     // layers
     XmlElement eltLayers = eltSolution.ChildNodes[0] as XmlElement;
     foreach (XmlNode nodeLayer in eltLayers.ChildNodes)
         sol.Add(LoadLayer(nodeLayer as XmlElement));
     return sol;
 }
Exemple #6
0
 public CylinderPalletSolutionViewer(CylinderPalletSolution solution)
 {
     _analysis = null != solution ? solution.Analysis : null;
     _solution = solution;
 }
        public void SaveCylinderPalletSolution(
            CylinderPalletAnalysis analysis
            , CylinderPalletSolution sol
            , SelCylinderPalletSolution 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 layersElt = xmlDoc.CreateElement("Layers");
            solutionElt.AppendChild(layersElt);

            foreach (ILayer layer in sol)
            {
                CylinderLayer cylLayer = layer as CylinderLayer;
                if (null != cylLayer)
                    Save(cylLayer, layersElt, xmlDoc);

                InterlayerPos interlayerPos = layer as InterlayerPos;
                if (null != interlayerPos)
                {
                    // Interlayer
                    XmlElement interlayerElt = xmlDoc.CreateElement("Interlayer");
                    layersElt.AppendChild(interlayerElt);
                    // ZLow
                    XmlAttribute zlowAttribute = xmlDoc.CreateAttribute("ZLow");
                    zlowAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", interlayerPos.ZLow);
                    interlayerElt.Attributes.Append(zlowAttribute);
                }
            }
            if (null != selSolution)
            {
                // selected attribute
                XmlAttribute selAttribute = xmlDoc.CreateAttribute("Selected");
                selAttribute.Value = "true";
                solutionElt.Attributes.Append(selAttribute);
            }
        }
        public SelCylinderPalletSolution(Document document, CylinderPalletAnalysis analysis, CylinderPalletSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            Name = sol.Title;
        }
        private List<CylinderPalletSolution> GenerateSolutions()
        {
            List<CylinderPalletSolution> solutions = new List<CylinderPalletSolution>();

            // loop through all patterns
            foreach (CylinderLayerPattern pattern in _patterns)
            {
                for (int iDir = 0; iDir < (pattern.CanBeSwapped ? 2 : 1); ++iDir)
                {
                    // alternate pallet direction
                    LayerCyl layer = new LayerCyl(_cylProperties, _palletProperties, _constraintSet);

                    string title = string.Format("{0}-{1}", pattern.Name, iDir);
                    CylinderPalletSolution sol = new CylinderPalletSolution(null, title, true);
 
                    double actualLength = 0.0, actualWidth = 0.0;
                    pattern.Swapped = (iDir % 2 != 0);
                    pattern.GetLayerDimensions(layer, out actualLength, out actualWidth);
                    try
                    {
                        pattern.GenerateLayer(layer, actualLength, actualWidth);
                    }
                    catch (NotImplementedException ex)
                    {
                        _log.Debug(ex.Message);
                        continue;
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex.Message);
                        continue;
                    }

                    // stop
                    double zLayer = _palletProperties.Height;
                    bool maxWeightReached = _constraintSet.UseMaximumPalletWeight && (_palletProperties.Weight + _cylProperties.Weight > _constraintSet.MaximumPalletWeight);
                    bool maxHeightReached = _constraintSet.UseMaximumPalletHeight && (zLayer + _cylProperties.Height > _constraintSet.MaximumPalletHeight);
                    bool maxNumberReached = false;

                    int iCount = 0;

                    // insert anti-slip interlayer
                    if (_constraintSet.HasInterlayerAntiSlip)
                    {
                        sol.CreateNewInterlayer(zLayer, 1);
                        zLayer += _interlayerPropertiesAntiSlip.Thickness;
                    }

                    while (!maxWeightReached && !maxHeightReached && !maxNumberReached)
                    {
                        // interlayer
                        if (_constraintSet.HasInterlayer && (sol.Count > 0))
                        {
                            sol.CreateNewInterlayer(zLayer, 0);
                            zLayer += _interlayerProperties.Thickness;
                        }
                        // select current layer type
                        CylinderLayer cylLayer = sol.CreateNewLayer(zLayer);
                        foreach (Vector2D layerPos in layer)
                        {
                            ++iCount;
                            maxWeightReached = _constraintSet.UseMaximumPalletWeight && ((iCount * _cylProperties.Weight + _palletProperties.Weight) > _constraintSet.MaximumPalletWeight);
                            maxNumberReached = _constraintSet.UseMaximumNumberOfItems && (iCount > _constraintSet.MaximumNumberOfItems);
                            if (!maxWeightReached && !maxNumberReached)
                                cylLayer.Add(
                                    new Vector3D(
                                        layerPos.X - 0.5 * _constraintSet.OverhangX,
                                        layerPos.Y - 0.5 * _constraintSet.OverhangY,
                                        zLayer));
                        }
                        // increment zLayer
                        zLayer += _cylProperties.Height;

                        maxHeightReached = _constraintSet.UseMaximumPalletHeight && (zLayer + _cylProperties.Height > _constraintSet.MaximumPalletHeight);
                    }
                    // limit reached
                    if (maxWeightReached) sol.LimitReached = Limit.LIMIT_MAXWEIGHTREACHED;
                    else if (maxNumberReached) sol.LimitReached = Limit.LIMIT_MAXNUMBERREACHED;
                    else if (maxHeightReached) sol.LimitReached = Limit.LIMIT_MAXHEIGHTREACHED;
                    else sol.LimitReached = Limit.LIMIT_UNKNOWN;

                    solutions.Add(sol);
                }
            }
            // sort solutions
            solutions.Sort();
            return solutions;
        }
 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();
 }