示例#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;
 }
        public DockContentAnalysisCaseOfBoxes(IDocument document, CasePalletAnalysis analysis)
        {
            _document = document;
            _analysis = analysis;
            _analysis.AddListener(this);

            InitializeComponent();
        }
示例#3
0
        public SelCasePalletSolution(Document document, CasePalletAnalysis analysis, CasePalletSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            Name      = sol.Title;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="document">object implementing the IDocument interface</param>
        /// <param name="analysis">viewed analysis</param>
        public DockContentCasePalletAnalysis(IDocument document, CasePalletAnalysis analysis)
        {
            _document = document;

            _analysis = analysis;
            _analysis.AddListener(this);

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

            InitializeComponent();
        }
 public FormNewAnalysisBundle(Document document, CasePalletAnalysis analysis)
     : base(document, analysis)
 {
     InitializeComponent();
     // set unit labels
     UnitsManager.AdaptUnitLabels(this);
     // save document reference
     _document = document;
     _analysis = analysis;
     // set caption text
     if (null != _analysis)
         Text = string.Format(Properties.Resources.ID_EDIT, _analysis.Name);
 }
示例#6
0
 /// <summary>
 /// Truck analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Parent pallet analysis</param>
 /// <param name="selSolution">Parent selected solution</param>
 /// <param name="truckProperties">TruckProperties item</param>
 /// <param name="constraintSet">Constraint set</param>
 public TruckAnalysis(
     Document document
     , CasePalletAnalysis analysis
     , SelCasePalletSolution selSolution
     , TruckProperties truckProperties
     , TruckConstraintSet constraintSet)
     : base(document)
 {
     Name                 = truckProperties.Name;
     _analysis            = analysis;
     _selSolution         = selSolution;
     this.TruckProperties = truckProperties;
     _constraintSet       = constraintSet;
 }
 /// <summary>
 /// Truck analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Parent pallet analysis</param>
 /// <param name="selSolution">Parent selected solution</param>
 /// <param name="truckProperties">TruckProperties item</param>
 /// <param name="constraintSet">Constraint set</param>
 public TruckAnalysis(
     Document document
     , CasePalletAnalysis analysis
     , SelCasePalletSolution selSolution
     , TruckProperties truckProperties
     , TruckConstraintSet constraintSet)
     : base(document)
 {
     Name = truckProperties.Name;
     _analysis = analysis;
     _selSolution = selSolution;
     this.TruckProperties = truckProperties;
     _constraintSet = constraintSet;
 }
 /// <summary>
 /// Constructor used while browsing/editing existing analysis
 /// </summary>
 /// <param name="document">Parent document</param>
 /// <param name="analysis">Analysis</param>
 public FormNewAnalysis(Document document, CasePalletAnalysis 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);
     // update combo boxes
     onInterlayerChecked(this, null);
     onAntiSlipInterlayerChecked(this, null);
     onPalletCornersChecked(this, null);
     onPalletCapChecked(this, null);
     onPalletFilmChecked(this, null);
 }
示例#9
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ECTAnalysis(
     Document document
     , CasePalletAnalysis analysis
     , SelCasePalletSolution selSolution)
     : base(document)
 {
     _analysis    = analysis;
     _selSolution = selSolution;
     // get a cardboard quality
     foreach (string skey in McKeeFormula.CardboardQualityDictionary.Keys)
     {
         _qualityData = McKeeFormula.CardboardQualityDictionary[skey];
         break;
     }
     // get a _printSurface value
     foreach (string skey in McKeeFormula.PrintCoefDictionary.Keys)
     {
         _printSurface = skey;
         break;
     }
 }
示例#10
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ECTAnalysis(
     Document document
     , CasePalletAnalysis analysis
     , SelCasePalletSolution selSolution)
     : base(document)
 {
     _analysis = analysis;
     _selSolution = selSolution;
     // get a cardboard quality
     foreach (string skey in McKeeFormula.CardboardQualityDictionary.Keys)
     {
         _qualityData = McKeeFormula.CardboardQualityDictionary[skey];
         break;
     }
     // get a _printSurface value
     foreach (string skey in McKeeFormula.PrintCoefDictionary.Keys)
     {
         _printSurface = skey;
         break;
     }
 }
        /// <summary>
        /// Append new solution descriptor
        /// </summary>
        /// <param name="desc"></param>
        public void Append(SelCasePalletSolution selSolution, string name, bool keepSimilarSolutions)
        {
            Document           document = selSolution.Analysis.ParentDocument;
            CasePalletSolution sol      = selSolution.Solution;
            CasePalletAnalysis analysis = sol.Analysis;
            // instantiate new descriptor
            PalletSolutionDesc desc = new PalletSolutionDesc(this, sol, name);

            // remove similar solutions
            if (!keepSimilarSolutions)
            {
                RemoveByKeyAndCaseDimensions(desc);
            }
            // save solution as stb file
            document.WriteSolution(selSolution, desc.FullFilePath);
            _palletSolutionList.Add(desc);
            _palletSolutionList.Sort();
            if (null != SolutionAppended)
            {
                SolutionAppended(this, new PalletSolutionEventArgs(desc));
            }
            Save();
        }
示例#12
0
 /// <summary>
 /// Creates a new analysis without generating solutions
 /// </summary>
 /// <param name="name">Name of analysis</param>
 /// <param name="description">Description</param>
 /// <param name="box">Case</param>
 /// <param name="pallet">Pallet</param>
 /// <param name="interlayer">Interlayer</param>
 /// <param name="constraintSet">PalletConstraintSet</param>
 /// <param name="solutions">Solutions</param>
 /// <returns>CasePalletAnalysis generated using input parameters</returns>
 public CasePalletAnalysis CreateNewCasePalletAnalysis(
     string name, string description
     , BProperties box, PalletProperties pallet
     , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip
     , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm
     , PalletConstraintSet constraintSet
     , List<CasePalletSolution> solutions)
 {
     CasePalletAnalysis analysis = new CasePalletAnalysis(
         box, pallet,
         interlayer, interlayerAntiSlip,
         palletCorners, palletCap, palletFilm,
         constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _casePalletAnalyses.Add(analysis);
     // set solutions
     analysis.Solutions = solutions;
     // notify listeners
     NotifyOnNewCasePalletAnalysisCreated(analysis);
     // set solution selected if it is unique
     if (solutions.Count == 1)
         analysis.SelectSolutionByIndex(0);
     return analysis;
 }
示例#13
0
        private void SavePalletAnalysis(CasePalletAnalysis analysis, XmlElement parentElement, XmlDocument xmlDoc)
        {
            // create analysis element
            XmlElement xmlAnalysisElt = xmlDoc.CreateElement("AnalysisPallet");
            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("PalletId");
            palletIdAttribute.Value = string.Format("{0}", analysis.PalletProperties.Guid);
            xmlAnalysisElt.Attributes.Append(palletIdAttribute);
            // InterlayerId
            if (null != analysis.InterlayerProperties)
            {
                XmlAttribute interlayerIdAttribute = xmlDoc.CreateAttribute("InterlayerId");
                interlayerIdAttribute.Value = string.Format("{0}", analysis.InterlayerProperties.Guid);
                xmlAnalysisElt.Attributes.Append(interlayerIdAttribute);
            }
            // InterlayerAntiSlipId
            if (null != analysis.InterlayerPropertiesAntiSlip)
            {
                XmlAttribute interlayerIdAttribute = xmlDoc.CreateAttribute("InterlayerAntiSlipId");
                interlayerIdAttribute.Value = string.Format("{0}", analysis.InterlayerPropertiesAntiSlip.Guid);
                xmlAnalysisElt.Attributes.Append(interlayerIdAttribute);
            }
            // PalletCornerId
            if (null != analysis.PalletCornerProperties)
            {
                XmlAttribute palletCornerAttribute = xmlDoc.CreateAttribute("PalletCornerId");
                palletCornerAttribute.Value = string.Format("{0}", analysis.PalletCornerProperties.Guid);
                xmlAnalysisElt.Attributes.Append(palletCornerAttribute);
            }
            // PalletCapId
            if (null != analysis.PalletCapProperties)
            {
                XmlAttribute palletCapIdAttribute = xmlDoc.CreateAttribute("PalletCapId");
                palletCapIdAttribute.Value = string.Format("{0}", analysis.PalletCapProperties.Guid);
                xmlAnalysisElt.Attributes.Append(palletCapIdAttribute);
            }
            // PalletFilmId
            if (null != analysis.PalletFilmProperties)
            {
                XmlAttribute palletFilmIdAttribute = xmlDoc.CreateAttribute("PalletFilmId");
                palletFilmIdAttribute.Value = string.Format("{0}", analysis.PalletFilmProperties.Guid);
                xmlAnalysisElt.Attributes.Append(palletFilmIdAttribute);
            }
            // ###
            // ConstraintSet
            bool bundleAnalysis = (analysis.ConstraintSet.GetType() == typeof(BundlePalletConstraintSet));
            XmlElement constraintSetElement = xmlDoc.CreateElement(bundleAnalysis ? "ConstraintSetBundle":"ConstraintSetBox");
            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);
            if (!bundleAnalysis)
            {
                // allowed box positions
                XmlAttribute allowedAxisAttribute = xmlDoc.CreateAttribute("AllowedBoxPositions");
                HalfAxis.HAxis[] axes = { HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_Z_P };
                string allowedAxes = string.Empty;
                foreach (HalfAxis.HAxis axis in axes)
                    if (analysis.ConstraintSet.AllowOrthoAxis(axis))
                    {
                        if (!string.IsNullOrEmpty(allowedAxes))
                            allowedAxes += ",";
                        allowedAxes += HalfAxis.ToString(axis);
                    }
                allowedAxisAttribute.Value = allowedAxes;
                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.UseMaximumHeight)
            {
                XmlAttribute maximumHeightAttribute = xmlDoc.CreateAttribute("MaximumHeight");
                maximumHeightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumHeight);
                constraintSetElement.Attributes.Append(maximumHeightAttribute);
            }
            if (analysis.ConstraintSet.UseMaximumNumberOfCases)
            {
                XmlAttribute maximumNumberOfItems = xmlDoc.CreateAttribute("ManimumNumberOfItems");
                maximumNumberOfItems.Value = string.Format("{0}", analysis.ConstraintSet.MaximumNumberOfItems);
                constraintSetElement.Attributes.Append(maximumNumberOfItems);
            }
            if (analysis.ConstraintSet.UseMaximumPalletWeight)
            {
                XmlAttribute maximumPalletWeight = xmlDoc.CreateAttribute("MaximumPalletWeight");
                maximumPalletWeight.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumPalletWeight);
                constraintSetElement.Attributes.Append(maximumPalletWeight);
            }
            if (analysis.ConstraintSet.UseMaximumWeightOnBox)
            {
                XmlAttribute maximumWeightOnBox = xmlDoc.CreateAttribute("MaximumWeightOnBox");
                maximumWeightOnBox.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.MaximumWeightOnBox);
                constraintSetElement.Attributes.Append(maximumWeightOnBox);
            }
            // overhang / underhang
            XmlAttribute overhangX = xmlDoc.CreateAttribute("OverhangX");
            overhangX.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.OverhangX);
            constraintSetElement.Attributes.Append(overhangX);
            XmlAttribute overhangY = xmlDoc.CreateAttribute("OverhangY");
            overhangY.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", analysis.ConstraintSet.OverhangY);
            constraintSetElement.Attributes.Append(overhangY);
            // 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);
            }
            // pallet film turns
            if (analysis.HasPalletFilm)
            {
                XmlAttribute palletFilmTurns = xmlDoc.CreateAttribute("PalletFilmTurns");
                palletFilmTurns.Value = string.Format("{0}", analysis.ConstraintSet.PalletFilmTurns);
                constraintSetElement.Attributes.Append(palletFilmTurns);
            }
            xmlAnalysisElt.AppendChild(constraintSetElement);

            // Solutions
            int solIndex = 0;
            XmlElement solutionsElt = xmlDoc.CreateElement("Solutions");
            xmlAnalysisElt.AppendChild(solutionsElt);
            foreach (CasePalletSolution sol in analysis.Solutions)
            {
                SaveCasePalletSolution(
                    analysis
                    , sol
                    , analysis.GetSelSolutionBySolutionIndex(solIndex) // null if not selected
                    , false /*unique*/
                    , solutionsElt
                    , xmlDoc);
                ++solIndex;
            }
        }
示例#14
0
 /// <summary>
 /// Creates a new analysis in this document + compute solutions
 /// </summary>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="box"></param>
 /// <param name="pallet"></param>
 /// <param name="interlayer"></param>
 /// <param name="constraintSet"></param>
 /// <param name="solver">Node : analysis creation requires a solver</param>
 /// <returns>An analysis</returns>
 public CasePalletAnalysis CreateNewCasePalletAnalysis(
     string name, string description
     , BProperties box, PalletProperties pallet
     , InterlayerProperties interlayer, InterlayerProperties interlayerAntiSlip
     , PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm
     , PalletConstraintSet constraintSet
     , ICasePalletAnalysisSolver solver)
 {
     CasePalletAnalysis analysis = new CasePalletAnalysis(
         box, pallet,
         interlayer, interlayerAntiSlip,
         palletCorners, palletCap, palletFilm,
         constraintSet);
     analysis.Name = name;
     analysis.Description = description;
     // insert in list
     _casePalletAnalyses.Add(analysis);
     // compute analysis
     solver.ProcessAnalysis(analysis);
     if (analysis.Solutions.Count < 1)
     {	// remove analysis from list if it has no valid solution
         _casePalletAnalyses.Remove(analysis);
         return null;
     }
     // notify listeners
     NotifyOnNewCasePalletAnalysisCreated(analysis);
     Modify();
     return analysis;
 }
 public CasePalletSolution(CasePalletAnalysis analysis, string title, bool homogenousLayer)
 {
     _parentAnalysis = analysis;
     _title = title;
     _homogeneousLayer = homogenousLayer;
 }
示例#16
0
        private CasePalletAnalysis LoadPalletAnalysis(Document doc, string sid)
        {
            CasePalletAnalysis analysis = null;

            palletAnalysis xmlAnalysis = _root.data.analyses.palletAnalysis.Find(delegate(palletAnalysis pa) { return pa.id == sid; });
            if (null == xmlAnalysis)
                throw new XmlFileProcessorException(string.Format("Failed to load analysis with Id = {0}", xmlAnalysis.id));

            BoxProperties caseProperties = LoadCaseById(doc, _root.data.items.library_cases, xmlAnalysis.caseId);
            BundleProperties bundleProperties = LoadBundleById(doc, _root.data.items.library_bundles, xmlAnalysis.bundleId);

            BProperties bProperties;
            PalletConstraintSet constraintSet;

            if (null != caseProperties)
            {
                CasePalletConstraintSet caseConstraintSet = new CasePalletConstraintSet();
                // interlayer
                caseConstraintSet.HasInterlayer = xmlAnalysis.interlayerPeriodSpecified;
                caseConstraintSet.HasInterlayerAntiSlip = false;

                // allowed ortho axes
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                caseConstraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                // interlayer period
                caseConstraintSet.InterlayerPeriod = xmlAnalysis.interlayerPeriodSpecified ? (int)xmlAnalysis.interlayerPeriod : 1;

                bProperties = caseProperties;
                constraintSet = caseConstraintSet;
            }
            else if (null != bundleProperties)
            {
                BundlePalletConstraintSet bundleConstraintSet = new BundlePalletConstraintSet();

                bProperties = bundleProperties;
                constraintSet = bundleConstraintSet;
            }
            else
                throw new XmlFileProcessorException(string.Format("Failed to load analysis with Id = {0}", xmlAnalysis.id));

               // generic constraintSet properties
               // allow aligned / alternate layers
            constraintSet.AllowAlignedLayers = false;
            constraintSet.AllowAlternateLayers = false;
            foreach (layerArrangement layerArr in xmlAnalysis.allowedLayerArrangements)
            {
                if (layerArr == layerArrangement.ALIGNED)
                    constraintSet.AllowAlignedLayers = true;
                if (layerArr == layerArrangement.ROTATED180 | layerArr == layerArrangement.ROTATED90)
                    constraintSet.AllowAlternateLayers = true;
            }
            // allowed patterns
            foreach (patternName pName in xmlAnalysis.allowedLayerPatterns)
            {
                switch (pName)
                {
                    case patternName.COLUMN: constraintSet.SetAllowedPattern("Column"); break;
                    case patternName.DIAGONAL: constraintSet.SetAllowedPattern("Diagonal"); break;
                    case patternName.INTERLOCK: constraintSet.SetAllowedPattern("Interlock"); break;
                    case patternName.TRILOCK: constraintSet.SetAllowedPattern("Trilock"); break;
                    case patternName.SPIRAL: constraintSet.SetAllowedPattern("Spiral"); break;
                    case patternName.ENLARGED_SPIRAL: constraintSet.SetAllowedPattern("Enlarged spiral"); break;
                    default: break;
                }
            }
            // overhang
            constraintSet.OverhangX = xmlAnalysis.overhang[0];
            constraintSet.OverhangY = xmlAnalysis.overhang[1];

            // stop criterions
            // max height
            if (xmlAnalysis.stackingStopCriterions.stopMaxHeight.maxHeightSpecified)
            {
                constraintSet.UseMaximumHeight = true;
                constraintSet.MaximumHeight = xmlAnalysis.stackingStopCriterions.stopMaxHeight.maxHeight;
            }
            else
                constraintSet.UseMaximumHeight = false;
            // max weight
            if (xmlAnalysis.stackingStopCriterions.stopMaxWeight.maxWeightSpecified)
            {
                constraintSet.UseMaximumPalletWeight = true;
                constraintSet.MaximumPalletWeight = xmlAnalysis.stackingStopCriterions.stopMaxWeight.maxWeight;
            }
            else
                constraintSet.UseMaximumPalletWeight = false;
            // max number of box/bundle
            if (xmlAnalysis.stackingStopCriterions.stopMaxNumber.maxNumberSpecified)
            {
                constraintSet.UseMaximumNumberOfCases = true;
                constraintSet.MaximumNumberOfItems = (int)xmlAnalysis.stackingStopCriterions.stopMaxNumber.maxNumber;
            }
            else
                constraintSet.UseMaximumNumberOfCases = false;
            // max weight on case
            if (xmlAnalysis.stackingStopCriterions.stopMaxWeightOnCase.maxWeightOnCaseSpecified)
            {
                constraintSet.UseMaximumWeightOnBox = true;
                constraintSet.MaximumWeightOnBox = xmlAnalysis.stackingStopCriterions.stopMaxWeightOnCase.maxWeightOnCase;
            }
            else
                constraintSet.UseMaximumWeightOnBox = false;

            if (null != doc)
            {
                analysis = doc.CreateNewCasePalletAnalysis(xmlAnalysis.name, xmlAnalysis.description
                    , bProperties
                    , LoadPalletById(doc, _root.data.items.library_pallets, xmlAnalysis.palletId)
                    , LoadInterlayerById(doc, _root.data.items.library_interlayers, xmlAnalysis.interlayerId)
                    , LoadInterlayerById(doc, _root.data.items.library_interlayers, xmlAnalysis.interlayerAntiSlipId)
                    , null
                    , null
                    , null
                    , constraintSet
                    , new TreeDim.StackBuilder.Engine.CasePalletSolver());
            }
            else
            {
                // instantiate pallet analysis
                analysis = new CasePalletAnalysis(
                    bProperties
                    , LoadPalletById(null, _root.data.items.library_pallets, xmlAnalysis.palletId)
                    , LoadInterlayerById(null, _root.data.items.library_interlayers, xmlAnalysis.interlayerId)
                    , null
                    , null
                    , null
                    , null
                    , constraintSet);
                // name
                analysis.Name = xmlAnalysis.name;
                // description
                analysis.Description = xmlAnalysis.description;
            }
            return analysis;
        }
 /// <summary>
 /// handles new truck analysis created
 /// </summary>
 public void OnNewTruckAnalysisCreated(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis)
 {
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSISSOLUTION, doc, analysis, selSolution));
     // insert truckAnalysis node
     TreeNode nodeTruckAnalysis = new TreeNode(truckAnalysis.Name, 16, 16);
     nodeTruckAnalysis.Tag = new NodeTag(NodeTag.NodeType.NT_TRUCKANALYSIS, doc, analysis, selSolution, truckAnalysis);
     parentNode.Nodes.Add(nodeTruckAnalysis);
     // expand parent tree node
     parentNode.Expand();
 }
 /// <summary>
 /// handles new analysis created
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="analysis"></param>
 public void OnNewCasePalletAnalysisCreated(Document doc, CasePalletAnalysis analysis)
 {
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_LISTANALYSIS, doc));
     // insert analysis node
     int indexIconAnalysis = analysis.IsBoxAnalysis ? 13 : 14;
     TreeNode nodeAnalysis = new TreeNode(analysis.Name, indexIconAnalysis, indexIconAnalysis);
     nodeAnalysis.Tag = new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSIS, doc, analysis);
     parentNode.Nodes.Add(nodeAnalysis);
     parentNode.Expand();
     CasePalletAnalysis_InsertSubNodes(doc, analysis, nodeAnalysis);
     // add event handlers for solution selection
     analysis.Modified += new CasePalletAnalysis.ModifyAnalysis(onCasePalletAnalysisModified);
     analysis.SolutionSelected += new CasePalletAnalysis.SelectSolution(onPalletAnalysisSolutionSelected);
     analysis.SolutionSelectionRemoved += new CasePalletAnalysis.SelectSolution(onPalletAnalysisSolutionSelectionRemoved);
 }
示例#19
0
 private void AppendPalletFilmElement(PalletFilmProperties palletFilmProp, CasePalletAnalysis analyis, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
 {
     // sanity check
     if (null == palletFilmProp) return;
     // namespace
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     // interlayer
     XmlElement elemPalletFilm = xmlDoc.CreateElement("palletFilm", ns);
     elemPalletAnalysis.AppendChild(elemPalletFilm);
     // name
     XmlElement elemName = xmlDoc.CreateElement("name", ns);
     elemName.InnerText = palletFilmProp.Name;
     elemPalletFilm.AppendChild(elemName);
     // description
     XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
     elemDescription.InnerText = palletFilmProp.Description;
     elemPalletFilm.AppendChild(elemDescription);
     // number of turns
     XmlElement elemNumberOfTurns = xmlDoc.CreateElement("numberOfTurns", ns);
     elemNumberOfTurns.InnerText = analyis.ConstraintSet.PalletFilmTurns.ToString();
     elemPalletFilm.AppendChild(elemNumberOfTurns);
 }
示例#20
0
 public ReportData(CasePalletAnalysis palletAnalysis, SelCasePalletSolution selSolution)
 {
     _palletAnalysis = palletAnalysis;
     _selSolution = selSolution;
 }
示例#21
0
 private void AppendConstraintSet(CasePalletAnalysis analysis, CasePalletSolution sol, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
 {
     string ns = xmlDoc.DocumentElement.NamespaceURI;
     PalletConstraintSet cs = analysis.ConstraintSet;
     // solution
     XmlElement elemConstraintSet = xmlDoc.CreateElement("constraintSet", ns);
     elemPalletAnalysis.AppendChild(elemConstraintSet);
     // overhangX, overhangY
     AppendElementValue(xmlDoc, elemConstraintSet, "overhangX", UnitsManager.UnitType.UT_LENGTH, cs.OverhangX);
     AppendElementValue(xmlDoc, elemConstraintSet, "overhangY", UnitsManager.UnitType.UT_LENGTH, cs.OverhangY);
     // allowedPatterns
     XmlElement elemAllowedPatterns = xmlDoc.CreateElement("allowedPatterns", ns);
     elemAllowedPatterns.InnerText = cs.AllowedPatternString;
     elemConstraintSet.AppendChild(elemAllowedPatterns);
     // allowedBoxAxis
     XmlElement elemAllowedBoxAxis = xmlDoc.CreateElement("allowedOrthoAxis", ns);
     elemAllowedBoxAxis.InnerText = cs.AllowOrthoAxisString;
     elemConstraintSet.AppendChild(elemAllowedBoxAxis);
     // allowAlternateLayers
     XmlElement elemAllowAlternateLayers = xmlDoc.CreateElement("allowAlternateLayers", ns);
     elemAllowAlternateLayers.InnerText = cs.AllowAlternateLayers.ToString();
     elemConstraintSet.AppendChild(elemAllowAlternateLayers);
     // allowAlignedLayers
     XmlElement elemAllowAlignedLayers = xmlDoc.CreateElement("allowAlignedLayers", ns);
     elemAllowAlignedLayers.InnerText = cs.AllowAlignedLayers.ToString();
     elemConstraintSet.AppendChild(elemAllowAlignedLayers);
     // interlayerPeriod
     if (cs.HasInterlayer)
     {
         XmlElement elemInterlayerPeriodGroup = xmlDoc.CreateElement("interlayerPeriodGroup", ns);
         elemConstraintSet.AppendChild(elemInterlayerPeriodGroup);
         XmlElement elemInterlayerPeriod = xmlDoc.CreateElement("interlayerPeriod", ns);
         elemInterlayerPeriod.InnerText = string.Format("{0}", cs.InterlayerPeriod);
         elemInterlayerPeriodGroup.AppendChild(elemInterlayerPeriod);
     }
     // stopCriterion
     if (cs.UseMaximumHeight)
     {
         XmlElement maximumPalletHeightGroup = xmlDoc.CreateElement("maximumPalletHeightGroup", ns);
         elemConstraintSet.AppendChild(maximumPalletHeightGroup);
         // maximum pallet height
         AppendElementValue(xmlDoc, maximumPalletHeightGroup, "maximumPalletHeight", UnitsManager.UnitType.UT_LENGTH, cs.MaximumHeight);
     }
     if (cs.UseMaximumNumberOfCases)
     {
         XmlElement maximumNumberOfItemsGroup = xmlDoc.CreateElement("maximumNumberOfItemsGroup", ns);
         elemConstraintSet.AppendChild(maximumNumberOfItemsGroup);
         XmlElement maximumNumberOfItems = xmlDoc.CreateElement("maximumNumberOfItems", ns);
         maximumNumberOfItems.InnerText = string.Format("{0}", cs.MaximumNumberOfItems);
         maximumNumberOfItemsGroup.AppendChild(maximumNumberOfItems);
     }
     if (cs.UseMaximumPalletWeight)
     {
         XmlElement maximumPalletWeightGroup = xmlDoc.CreateElement("maximumPalletWeightGroup", ns);
         elemConstraintSet.AppendChild(maximumPalletWeightGroup);
         // pallet weight
         AppendElementValue(xmlDoc, maximumPalletWeightGroup, "maximumPalletHeight", UnitsManager.UnitType.UT_MASS, cs.MaximumPalletWeight);
     }
     if (cs.UseMaximumWeightOnBox)
     {
         XmlElement maximumWeightOnBoxGroup = xmlDoc.CreateElement("maximumWeightOnBoxGroup", ns);
         elemConstraintSet.AppendChild(maximumWeightOnBoxGroup);
         // admissible load on top
         AppendElementValue(xmlDoc, maximumWeightOnBoxGroup, "admissibleLoadOnTop", UnitsManager.UnitType.UT_MASS, cs.MaximumWeightOnBox);
     }
 }
 void CasePalletAnalysis_InsertSubNodes(Document doc, CasePalletAnalysis analysis, TreeNode nodeAnalysis)
 {
     // sanity check
     if (null == nodeAnalysis) return;
     // remove any existing subnodes
     nodeAnalysis.Nodes.Clear();
     // insert sub box node
     int indexIconBoxAnalysis = 4;
     if (analysis.BProperties is CaseOfBoxesProperties)
         indexIconBoxAnalysis = 18;
     else if (analysis.BProperties is BoxProperties)
         indexIconBoxAnalysis = 4;
     else if (analysis.BProperties is BundleProperties)
         indexIconBoxAnalysis = 5;
     TreeNode subBoxNode = new TreeNode(analysis.BProperties.Name, indexIconBoxAnalysis, indexIconBoxAnalysis);
     subBoxNode.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISBOX, doc, analysis, analysis.BProperties);
     nodeAnalysis.Nodes.Add(subBoxNode);
     // insert sub pallet node
     TreeNode subPalletNode = new TreeNode(analysis.PalletProperties.Name, 7, 7);
     subPalletNode.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISPALLET, doc, analysis, analysis.PalletProperties);
     nodeAnalysis.Nodes.Add(subPalletNode);
     // insert sub interlayer node if any
     if (analysis.HasInterlayer)
     {
         TreeNode subInterlayer = new TreeNode(analysis.InterlayerProperties.Name, 8, 8);
         subInterlayer.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISINTERLAYER, doc, analysis, analysis.InterlayerProperties);
         nodeAnalysis.Nodes.Add(subInterlayer);
     }
     if (analysis.HasInterlayerAntiSlip && (analysis.InterlayerProperties != analysis.InterlayerPropertiesAntiSlip))
     {
         TreeNode subInterlayer = new TreeNode(analysis.InterlayerPropertiesAntiSlip.Name, 8, 8);
         subInterlayer.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISINTERLAYER, doc, analysis, analysis.InterlayerPropertiesAntiSlip);
         nodeAnalysis.Nodes.Add(subInterlayer);
     }
     if (analysis.HasPalletCorners)
     {
         TreeNode subPalletCorners = new TreeNode(analysis.PalletCornerProperties.Name, 10, 10);
         subPalletCorners.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISPALLETCORNERS, doc, analysis, analysis.PalletCornerProperties);
         nodeAnalysis.Nodes.Add(subPalletCorners);
     }
     if (analysis.HasPalletCap)
     {
         TreeNode subPalletCap = new TreeNode(analysis.PalletCapProperties.Name, 11, 11);
         subPalletCap.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISPALLETCAP, doc, analysis, analysis.PalletCapProperties);
         nodeAnalysis.Nodes.Add(subPalletCap);
     }
     if (analysis.HasPalletFilm)
     {
         TreeNode subPalletFilm = new TreeNode(analysis.PalletFilmProperties.Name, 12, 12);
         subPalletFilm.Tag = new NodeTag(NodeTag.NodeType.NT_ANALYSISPALLETFILM, doc, analysis, analysis.PalletFilmProperties);
         nodeAnalysis.Nodes.Add(subPalletFilm);
     }
     nodeAnalysis.Expand();
 }
示例#23
0
        private void AppendCaseOfBoxesElement(CasePalletAnalysis analysis, CasePalletSolution sol, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // get CaseOfBoxProperties
            CaseOfBoxesProperties caseOfBoxes = analysis.BProperties as CaseOfBoxesProperties;
            if (null == caseOfBoxes) return;
            // elemCaseOfBoxes
            XmlElement elemCaseOfBoxes = xmlDoc.CreateElement("caseOfBoxes", ns);
            elemPalletAnalysis.AppendChild(elemCaseOfBoxes);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = caseOfBoxes.Name;
            elemCaseOfBoxes.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = caseOfBoxes.Description;
            elemCaseOfBoxes.AppendChild(elemDescription);
            // length
            XmlElement elemNoX = xmlDoc.CreateElement("noX", ns);
            elemNoX.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iLength);
            elemCaseOfBoxes.AppendChild(elemNoX);
            // width
            XmlElement elemNoY = xmlDoc.CreateElement("noY", ns);
            elemNoY.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iWidth);
            elemCaseOfBoxes.AppendChild(elemNoY);
            // height
            XmlElement elemNoZ = xmlDoc.CreateElement("noZ", ns);
            elemNoZ.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Arrangement._iHeight);
            elemCaseOfBoxes.AppendChild(elemNoZ);
            // number of boxes
            XmlElement elemNoBoxes = xmlDoc.CreateElement("numberOfBoxes", ns);
            elemNoBoxes.InnerText = string.Format("{0}", caseOfBoxes.NumberOfBoxes);
            elemCaseOfBoxes.AppendChild(elemNoBoxes);
            // dim0
            XmlElement eltDim0 = xmlDoc.CreateElement("dim0", ns);
            eltDim0.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Dim0);
            elemCaseOfBoxes.AppendChild(eltDim0);
            // dim1
            XmlElement eltDim1 = xmlDoc.CreateElement("dim1", ns);
            eltDim1.InnerText = string.Format("{0}", caseOfBoxes.CaseDefinition.Dim1);
            elemCaseOfBoxes.AppendChild(eltDim1);

            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerLength", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideLength);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerWidth", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideWidth);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerHeight", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.InsideHeight);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "innerVolume", UnitsManager.UnitType.UT_VOLUME, caseOfBoxes.InsideVolume * UnitsManager.FactorCubeLengthToVolume);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerLength", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Length);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerWidth", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Width);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerHeight", UnitsManager.UnitType.UT_LENGTH, caseOfBoxes.Height);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "outerVolume", UnitsManager.UnitType.UT_VOLUME, caseOfBoxes.Volume * UnitsManager.FactorCubeLengthToVolume);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "emptyWeight", UnitsManager.UnitType.UT_MASS, caseOfBoxes.WeightEmpty);
            AppendElementValue(xmlDoc, elemCaseOfBoxes, "weight", UnitsManager.UnitType.UT_MASS, caseOfBoxes.Weight);

            // type converter
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            // view case of boxes iso1
            Graphics3DImage graphics1 = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics1.CameraPosition = Graphics3D.Corner_0;
            CaseDefinitionViewer viewer = new CaseDefinitionViewer(caseOfBoxes.CaseDefinition, caseOfBoxes.InsideBoxProperties, caseOfBoxes.CaseOptimConstraintSet);
            viewer.CaseProperties = caseOfBoxes;
            viewer.Orientation = sol.FirstCaseOrientation;
            viewer.Draw(graphics1);
            graphics1.Flush();
            // view case of boxes iso2
            Graphics3DImage graphics2 = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics2.CameraPosition = Graphics3D.Corner_0;
            Box box = new Box(0, caseOfBoxes);
            graphics2.AddBox(box);
            graphics2.AddDimensions(new DimensionCube(caseOfBoxes.Length, caseOfBoxes.Width, caseOfBoxes.Height));
            graphics2.Flush();
            // view_caseOfBoxes_iso1
            XmlElement elemImage1 = xmlDoc.CreateElement("view_caseOfBoxes_iso1", ns);
            elemImage1.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics1.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute1 = xmlDoc.CreateAttribute("style");
            styleAttribute1.Value = string.Format("width:{0}pt;height:{1}pt", graphics1.Bitmap.Width / 3, graphics1.Bitmap.Height / 3);
            elemImage1.Attributes.Append(styleAttribute1);
            elemCaseOfBoxes.AppendChild(elemImage1);
            // save image
            SaveImageAs(graphics1.Bitmap, "view_caseOfBoxes_iso1.png");
            // view_caseOfBoxes_iso2
            XmlElement elemImage2 = xmlDoc.CreateElement("view_caseOfBoxes_iso2", ns);
            elemImage2.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics2.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute2 = xmlDoc.CreateAttribute("style");
            styleAttribute2.Value = string.Format("width:{0}pt;height:{1}pt", graphics2.Bitmap.Width / 3, graphics2.Bitmap.Height / 3);
            elemImage2.Attributes.Append(styleAttribute2);
            elemCaseOfBoxes.AppendChild(elemImage2);
            // save image
            SaveImageAs(graphics2.Bitmap, "view_caseOfBoxes_iso2.png");
        }
示例#24
0
        static int Main(string[] args)
        {
            ILog log = LogManager.GetLogger(typeof(Program));
            XmlConfigurator.Configure();

            try
            {
                bool useSingleColor = false;
                // instantiate document
                Document doc = new Document("Test", "Test", "fga", DateTime.Now, null);

                // define pallet properties
                PalletProperties palletProperties = new PalletProperties(doc, "EUR2", 1200, 1000, 150);
                Console.WriteLine("=== Pallet properties ===");
                Console.WriteLine(palletProperties.ToString());

                bool testCylinder = false;
                if (!testCylinder)
                {
                    // define box properties
                    BoxProperties boxProperties = new BoxProperties(doc, 162, 210, 250);
                    boxProperties.Name = "Box1";
                    boxProperties.Weight = 3.0;
                    if (!useSingleColor)
                    {
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_N, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_X_P, Color.Red);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_N, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Y_P, Color.Green);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_N, Color.Blue);
                        boxProperties.SetColor(HalfAxis.HAxis.AXIS_Z_P, Color.Blue);
                    }
                    else
                        boxProperties.SetColor(Color.Chocolate);

                    Console.WriteLine(boxProperties.ToString());

                    InterlayerProperties interlayerProperties = null;

                    // define constraints
                    CasePalletConstraintSet constraintSet = new CasePalletConstraintSet();
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, true);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, true);

                    constraintSet.SetAllowedPattern("Trilock");

                    constraintSet.AllowAlignedLayers = true;
                    constraintSet.AllowAlternateLayers = false;

                    constraintSet.MaximumPalletWeight = 2000;
                    constraintSet.MaximumNumberOfItems = 2000;
                    constraintSet.MaximumHeight = 2000.0;
                    constraintSet.UseMaximumHeight = true;
                    constraintSet.UseMaximumPalletWeight = true;
                    constraintSet.UseMaximumWeightOnBox = false;
                    constraintSet.AllowLastLayerOrientationChange = true;
                    Console.WriteLine("=== Constraint set ===");
                    Console.WriteLine(constraintSet.ToString());

                    // initialize analysis
                    CasePalletAnalysis analysis = new CasePalletAnalysis(
                        boxProperties, palletProperties, interlayerProperties,
                        null, null, null, null,
                        constraintSet);

                    // initialize solver
                    CasePalletSolver solver = new CasePalletSolver();
                    solver.ProcessAnalysis(analysis);

                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CasePalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(1000, 1000));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CasePalletSolutionViewer sv = new CasePalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        // save
                        string fileName = string.Format("Pallet_{0}.bmp", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
                else
                {
                    // cylinder
                    Console.WriteLine("=== Cylinder properties ===");
                    CylinderProperties cylProperties = new CylinderProperties(doc, "Cylinder", "Default cylinder",
                        90, 45.0, 100, 1.5, Color.Gray, Color.SkyBlue, Color.SkyBlue);
                    Console.WriteLine(cylProperties.ToString());
                    // constraint set
                    Console.WriteLine("=== Constraint set ===");
                    CylinderPalletConstraintSet constraintSet = new CylinderPalletConstraintSet();
                    constraintSet.UseMaximumPalletHeight = true;
                    constraintSet.MaximumPalletHeight = 1200.0;
                    constraintSet.UseMaximumPalletWeight = true;
                    constraintSet.MaximumPalletWeight = 2000;
                    constraintSet.UseMaximumNumberOfItems = true;
                    constraintSet.MaximumNumberOfItems = 2000;
                    Console.WriteLine(constraintSet.ToString());
                    // cylinder analysis
                    CylinderPalletAnalysis analysis = new CylinderPalletAnalysis(cylProperties, palletProperties, null, null, constraintSet);
                    // initialize solver
                    CylinderSolver solver = new CylinderSolver();
                    solver.ProcessAnalysis(analysis);
                    Console.WriteLine("=== Solutions ===");
                    int solIndex = 0;
                    foreach (CylinderPalletSolution sol in analysis.Solutions)
                    {
                        // instantiate graphics
                        Graphics3DImage graphics = new Graphics3DImage(new Size(512, 512));
                        graphics.CameraPosition = new Vector3D(10000.0, 10000.0, 10000.0);
                        graphics.Target = Vector3D.Zero;
                        graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
                        // instantiate solution viewer
                        CylinderPalletSolutionViewer sv = new CylinderPalletSolutionViewer(sol);
                        sv.Draw(graphics);
                        string fileName = string.Format("Pallet_{0}.jpg", solIndex++);
                        string filePath = Path.Combine(Path.GetTempPath(), fileName);
                        Console.WriteLine("Saving file " + filePath + "...");
                        graphics.SaveAs(filePath);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            return 0;
        }
 public FormSelectSolution(Document doc, CasePalletAnalysis analysis)
 {
     _document = doc;
     _analysis = analysis;
     InitializeComponent();
 }
        private void Compute()
        {
            try
            {
                _document = new Document(_name, _name, "", DateTime.Now, null);
                _analysis = null;
                // bundle
                BundleProperties bundleProperties = _document.CreateNewBundle(_name, _name, FlatLength, FlatWidth, FlatThickness, FlatWeight, Color.Beige, NoFlats);
                // pallet
                PalletProperties palletProp = _document.CreateNewPallet(CurrentPallet);
                // constraint set
                BundlePalletConstraintSet constraintSet = new BundlePalletConstraintSet();
                constraintSet.OverhangX = 0.0;
                constraintSet.OverhangY = 0.0;
                constraintSet.UseMaximumNumberOfCases = false;
                constraintSet.UseMaximumPalletWeight = false;
                constraintSet.UseMaximumWeightOnBox = false;
                constraintSet.UseMaximumHeight = true;
                constraintSet.MaximumHeight = MaximumPalletHeight;
                constraintSet.AllowAlignedLayers = true;
                constraintSet.AllowAlternateLayers = true;
                constraintSet.AllowedPatternString = "Column,Diagonale,Interlocked,Trilock,Spirale";

                _analysis = _document.CreateNewCasePalletAnalysis(
                    _name, _name
                    ,bundleProperties , palletProp
                    , null /*interlayer */, null /* interlayerAntiSlip */
                    , null /* palletCorners */, null  /*palletCap */, null /* palletFilm */
                    , constraintSet
                    , new CasePalletSolver()
                    );
                // fill grid
                FillGrid();
            }
            catch (Exception ex)
            {
                _log.Error( ex.ToString());
            }
        }
 /// <summary>
 /// handles truck analysis removal : removed truck analysis node from 
 /// </summary>
 public void OnTruckAnalysisRemoved(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis)
 {
     // get node
     TreeNode truckAnalysisNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_TRUCKANALYSIS, doc, analysis, selSolution, truckAnalysis));
     // test
     if (null == truckAnalysisNode)
     {
         _log.Warn(string.Format("Failed to find a valid tree node for truck analysis {0}", truckAnalysis.Name));
         return;
     }
     // remove node
     Nodes.Remove(truckAnalysisNode);
 }
示例#28
0
        public List<CaseOptimSolution> CaseOptimSolutions(int iNumber)
        {
            List<CaseOptimSolution> caseOptimSolutions = new List<CaseOptimSolution>();

            foreach (CaseDefinition caseDefinition in CaseDefinitions(iNumber))
            {
                Vector3D outerDimensions = caseDefinition.OuterDimensions(_boxProperties, _caseOptimConstraintSet);
                BoxProperties bProperties = new BoxProperties(_palletProperties.ParentDocument, outerDimensions.X, outerDimensions.Y, outerDimensions.Z);
                // build analysis
                CasePalletAnalysis casePalletAnalysis = new CasePalletAnalysis(
                    bProperties, _palletProperties,
                    null, null,
                    null, null, null,
                    _palletConstraintSet);
                // instantiate solver
                CasePalletSolver solver = new CasePalletSolver();
                // solve
                solver.ProcessAnalysis(casePalletAnalysis);
                // get list of pallet solutions
                List<CasePalletSolution> palletSolutions = casePalletAnalysis.Solutions;
                if (palletSolutions.Count > 0)
                {
                    int maxCaseCount = palletSolutions[0].CaseCount;
                    int i = 0;
                    while (maxCaseCount == palletSolutions[i].CaseCount)
                    {
                        caseOptimSolutions.Add(new CaseOptimSolution(caseDefinition, palletSolutions[i]));
                        ++i;
                    }
                }
            }
            // sort caseOptimSolution
            caseOptimSolutions.Sort();
            return caseOptimSolutions;
        }
示例#29
0
        public void SaveCasePalletSolution(CasePalletAnalysis analysis, CasePalletSolution sol, SelCasePalletSolution selSolution, bool unique, 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);
            // homogeneousLayers ?
            XmlAttribute homogeneousLayersAttribute = xmlDoc.CreateAttribute("HomogeneousLayers");
            homogeneousLayersAttribute.Value = sol.HasHomogeneousLayers ? "true" : "false";
            solutionElt.Attributes.Append(homogeneousLayersAttribute);
            // 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)
            {
                BoxLayer boxLayer = layer as BoxLayer;
                if (null != boxLayer)
                    Save(boxLayer, 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);
                }
            }

            // Is selected ?
            if (null != selSolution)
            {
                // selected attribute
                XmlAttribute selAttribute = xmlDoc.CreateAttribute("Selected");
                selAttribute.Value = "true";
                solutionElt.Attributes.Append(selAttribute);

                // truck analyses
                XmlElement truckAnalysesElt = xmlDoc.CreateElement("TruckAnalyses");
                solutionElt.AppendChild(truckAnalysesElt);

                foreach (TruckAnalysis truckAnalysis in selSolution.TruckAnalyses)
                    Save(truckAnalysis, unique, truckAnalysesElt, xmlDoc);

                // ect analyses
                XmlElement ectAnalysesElt = xmlDoc.CreateElement("EctAnalyses");
                solutionElt.AppendChild(ectAnalysesElt);

                foreach (ECTAnalysis ectAnalysis in selSolution.EctAnalyses)
                    Save(ectAnalysis, unique, ectAnalysesElt, xmlDoc);
            }
        }
        private bool GenerateProject(out Document doc, out CasePalletAnalysis analysis, out CasePalletSolution casePalletSolution)
        {
            doc = null;
            analysis = null;
            casePalletSolution = null;

            try
            {
                // build solution
                doc = new Document(
                    _boxName,
                    string.Format(Properties.Resources.ID_OPTDOCUMENTDESCRIPTION, _boxName),
                    string.Empty,
                    DateTime.Now,
                    null);
                // box
                BoxProperties boxProperties = doc.CreateNewBox(SelectedBox);
                // pallet
                PalletProperties palletProperties = doc.CreateNewPallet(SelectedPallet);
                // get selected caseOptimSolution
                CaseOptimSolution sol = SelectedSolution;
                PackArrangement arrangement = sol.CaseDefinition.Arrangement;
                // build new case name
                string arrangName = string.Format("{0}_{1}x{2}x{3}_{4}{5}"
                    , boxProperties.Name
                    , arrangement._iLength
                    , arrangement._iWidth
                    , arrangement._iHeight
                    , sol.CaseDefinition.Dim0
                    , sol.CaseDefinition.Dim1);
                // build new case description
                string description = string.Format(
                    Properties.Resources.ID_OPTCASEDESCRIPTION
                    , boxProperties.Name
                    , palletProperties.Name);
                // add new case
                CaseOfBoxesProperties caseProperties = doc.CreateNewCaseOfBoxes(
                    arrangName, description
                    , boxProperties
                    , sol.CaseDefinition
                    , BuildCaseOptimConstraintSet());
                // set color
                caseProperties.SetColor(Color.Chocolate);
                // add new pallet analysis
                string analysisName = string.Format(
                    Properties.Resources.ID_OPTANALYSISNAME
                    , boxProperties.Name
                    , boxProperties.Name
                    , arrangement._iLength
                    , arrangement._iWidth
                    , arrangement._iHeight
                    , sol.CaseDefinition.Dim0
                    , sol.CaseDefinition.Dim1);
                string analysisDescription = string.Format(
                    Properties.Resources.ID_OPTANALYSISDESCRIPTION
                    , boxProperties.Name
                    , palletProperties.Name);
                List<CasePalletSolution> palletSolutionList = new List<CasePalletSolution>();
                palletSolutionList.Add(sol.PalletSolution);
                analysis = doc.CreateNewCasePalletAnalysis(
                    analysisName
                    , analysisDescription
                    , caseProperties
                    , palletProperties
                    , null
                    , null
                    , null
                    , null
                    , null
                    , BuildPalletConstraintSet()
                    , palletSolutionList);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
                return false;
            }
            return true;
        }
示例#31
0
 internal void NotifyOnNewTruckAnalysisCreated(CasePalletAnalysis analysis, SelCasePalletSolution selSolution, TruckAnalysis truckAnalysis)
 {
     foreach (IDocumentListener listener in _listeners)
         listener.OnNewTruckAnalysisCreated(this, analysis, selSolution, truckAnalysis);
 }
 public NodeTag(NodeType type, Document document, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, ECTAnalysis ectAnalysis)
 {
     _type = type;
     _document = document;
     _itemProperties = null;
     _casePalletAnalysis = analysis;
     _selSolution = selSolution;
     _ectAnalysis = ectAnalysis;
 }
示例#33
0
 private void NotifyOnNewCasePalletAnalysisCreated(CasePalletAnalysis analysis)
 {
     foreach (IDocumentListener listener in _listeners)
         listener.OnNewCasePalletAnalysisCreated(this, analysis);
 }
示例#34
0
        private void AppendInsideBoxElement(CasePalletAnalysis analysis, CasePalletSolution sol, XmlElement elemPalletAnalysis, XmlDocument xmlDoc)
        {
            string ns = xmlDoc.DocumentElement.NamespaceURI;
            // get caseOfBoxProperties
            CaseOfBoxesProperties caseOfBoxes = analysis.BProperties as CaseOfBoxesProperties;
            // get box properties
            BoxProperties boxProperties = caseOfBoxes.InsideBoxProperties;
            // elemBoxes
            XmlElement elemBox = xmlDoc.CreateElement("box", ns);
            elemPalletAnalysis.AppendChild(elemBox);
            // name
            XmlElement elemName = xmlDoc.CreateElement("name", ns);
            elemName.InnerText = boxProperties.Name;
            elemBox.AppendChild(elemName);
            // description
            XmlElement elemDescription = xmlDoc.CreateElement("description", ns);
            elemDescription.InnerText = boxProperties.Description;
            elemBox.AppendChild(elemDescription);

            AppendElementValue(xmlDoc, elemBox, "length", UnitsManager.UnitType.UT_LENGTH, boxProperties.Length);
            AppendElementValue(xmlDoc, elemBox, "width", UnitsManager.UnitType.UT_LENGTH, boxProperties.Width);
            AppendElementValue(xmlDoc, elemBox, "height", UnitsManager.UnitType.UT_LENGTH, boxProperties.Height);
            AppendElementValue(xmlDoc, elemBox, "weight", UnitsManager.UnitType.UT_MASS, boxProperties.Weight);

            // --- build image
            Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail));
            graphics.CameraPosition = Graphics3D.Corner_0;
            graphics.Target = Vector3D.Zero;
            Box box = new Box(0, boxProperties);
            graphics.AddBox(box);
            DimensionCube dc = new DimensionCube(box.Length, box.Width, box.Height);    dc.FontSize = 6.0f;
            graphics.AddDimensions(dc);
            graphics.Flush();
            // ---
            // view_box_iso
            XmlElement elemImage = xmlDoc.CreateElement("view_box_iso", ns);
            TypeConverter converter = TypeDescriptor.GetConverter(typeof(Bitmap));
            elemImage.InnerText = Convert.ToBase64String((byte[])converter.ConvertTo(graphics.Bitmap, typeof(byte[])));
            XmlAttribute styleAttribute = xmlDoc.CreateAttribute("style");
            styleAttribute.Value = string.Format("width:{0}pt;height:{1}pt", graphics.Bitmap.Width / 4, graphics.Bitmap.Height / 4);
            elemImage.Attributes.Append(styleAttribute);
            elemBox.AppendChild(elemImage);
            // save image ?
            SaveImageAs(graphics.Bitmap, "view_box_iso.png");
        }
 private void onCasePalletAnalysisModified(CasePalletAnalysis analysis)
 {
     // retrieve parent document
     Document doc = analysis.ParentDocument;
     // get parent node
     TreeNode parentNode = FindNode(null, new NodeTag(NodeTag.NodeType.NT_CASEPALLETANALYSIS, doc, analysis));
     if (null == parentNode) throw new Exception("Failed to locate Analysis (NT_CASEPALLETANALYSIS) node...");
     // insert case/pallet/interlayer node
     CasePalletAnalysis_InsertSubNodes(doc, analysis, parentNode);
     // expand tree node
     parentNode.Expand();
 }