Exemple #1
0
 /// <summary>
 /// Loads pallet solution from database file
 /// </summary>
 public CasePalletSolution LoadPalletSolution()
 {
     if (null == _palletSolution)
     {
         if (!File.Exists(FullFilePath))
         {
             return(null);    // database file not available -> existing
         }
         else
         {
             Document doc = new Document(FullFilePath, null);
             if (!doc.AnalysesCasePallet.Any())
             {
                 return(null);    // no analysis -> exiting
             }
             CasePalletAnalysis analysis = doc.AnalysesCasePallet.First() as CasePalletAnalysis;
             if (analysis.Solutions.Count < 1)
             {
                 return(null);       // no solution -> exiting
             }
             _palletSolution = null; // doc.CasePalletAnalyses[0].Solutions[0];
         }
     }
     return(_palletSolution);
 }
        public DockContentAnalysisCaseOfBoxes(IDocument document, CasePalletAnalysis analysis)
        {
            _document = document;
            _analysis = analysis;
            _analysis.AddListener(this);

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

            _solution = sol;
            Name = sol.Title; 
        }
Exemple #4
0
        public SelCasePalletSolution(Document document, CasePalletAnalysis analysis, CasePalletSolution sol)
            : base(document)
        {
            _analysis = analysis;
            _analysis.AddDependancy(this);

            _solution = sol;
            ID.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);
 }
 /// <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)
 {
     ID.Name              = truckProperties.ID.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>
 /// Process case/pallet analysis
 /// </summary>
 /// <param name="analysis">Pallet analysis to process</param>
 public void ProcessAnalysis(CasePalletAnalysis analysis)
 {
     _bProperties = analysis.BProperties;
     _palletProperties = analysis.PalletProperties;
     _interlayerProperties = analysis.InterlayerProperties;
     _interlayerPropertiesAntiSlip = analysis.InterlayerPropertiesAntiSlip;
     _cornerProperties = analysis.PalletCornerProperties;
     _capProperties = analysis.PalletCapProperties;
     _constraintSet = analysis.ConstraintSet;
     // check contraint set validity
     if (!_constraintSet.IsValid)
         throw new EngineException("Constraint set is invalid!");
     // generate solutions
     analysis.Solutions = GenerateSolutions();
 }
 /// <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);
 }
 /// <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;
     }
 }
Exemple #12
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();
        }
Exemple #14
0
 private void NotifyOnNewCasePalletAnalysisCreated(CasePalletAnalysis analysis)
 {
     foreach (IDocumentListener listener in _listeners)
         listener.OnNewCasePalletAnalysisCreated(this, analysis);
 }
Exemple #15
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);
            }
        }
Exemple #16
0
 /// <summary>
 /// Creates new DockContentAnalysis view
 /// </summary>
 /// <param name="analysis">Case pallet analysis to view</param>
 /// <returns></returns>
 public DockContentCasePalletAnalysis CreateAnalysisViewCasePallet(CasePalletAnalysis analysis)
 {
     DockContentCasePalletAnalysis form = new DockContentCasePalletAnalysis(this, analysis);
     AddView(form);
     return form;
 }
Exemple #17
0
 public void OnNewCasePalletAnalysisCreated(Document doc, CasePalletAnalysis analysis)
 {
     _log.Info(string.Format("Loaded case/pallet analysis {0}", analysis.Name));
 }
Exemple #18
0
 public void OnTruckAnalysisRemoved(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selectedSolution, TruckAnalysis truckAnalysis)
 { 
 }
 void onSolutionSelectionChanged(CasePalletAnalysis analysis, SelCasePalletSolution selSolution)
 {
     UpdateSelectButtonText();
     UpdateGridCheckBoxes();
 }
Exemple #20
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;
 }
 /// <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 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);
 }
 public CasePalletSolutionViewer(CasePalletSolution solution)
 {
     _analysis = null != solution ? solution.Analysis : null;
     _solution = solution;
 }
 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();
 }
Exemple #25
0
        /// <summary>
        /// Edit specified pallet analysis
        /// </summary>
        /// <param name="analysis"></param>
        public void EditCasePalletAnalysis(CasePalletAnalysis analysis)
        {
            // do we need to recompute analysis
            bool recomputeRequired = false;

            if (analysis.IsBoxAnalysis)
            {
                FormNewAnalysis form = new FormNewAnalysis(this, analysis);
                form.Cases = Cases.ToArray();
                form.Pallets = Pallets.ToArray();
                form.Interlayers = Interlayers.ToArray();
                form.PalletCorners = ListByType(typeof(PalletCornerProperties)).ToArray();
                form.PalletCaps = ListByType(typeof(PalletCapProperties)).ToArray();
                form.PalletFilms = ListByType(typeof(PalletFilmProperties)).ToArray();

                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    analysis.Name = form.AnalysisName;
                    analysis.Description = form.AnalysisDescription;
                    // box / palet / interlayer
                    analysis.BProperties = form.SelectedBox;
                    analysis.PalletProperties = form.SelectedPallet;
                    analysis.InterlayerProperties = form.SelectedInterlayer;
                    analysis.InterlayerPropertiesAntiSlip = form.SelectedInterlayerAntiSlip;
                    // build constraint set
                    CasePalletConstraintSet constraintSet = analysis.ConstraintSet as CasePalletConstraintSet;
                    // overhang / underhang
                    constraintSet.OverhangX = form.OverhangX;
                    constraintSet.OverhangY = form.OverhangY;
                    // allowed axes
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_N, form.AllowVerticalX);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_X_P, form.AllowVerticalX);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_N, form.AllowVerticalY);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Y_P, form.AllowVerticalY);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_N, form.AllowVerticalZ);
                    constraintSet.SetAllowedOrthoAxis(HalfAxis.HAxis.AXIS_Z_P, form.AllowVerticalZ);
                    // allowed dir change
                    constraintSet.AllowTwoLayerOrientations = form.AllowTwoLayerOrientations;
                    constraintSet.AllowLastLayerOrientationChange = form.AllowLastLayerOrientationChange;
                    // allowed patterns
                    constraintSet.ClearAllowedPatterns();
                    foreach (string s in form.AllowedPatterns)
                        constraintSet.SetAllowedPattern(s);
                    // allow alternate layer
                    constraintSet.AllowAlternateLayers = form.AllowAlternateLayers;
                    constraintSet.AllowAlignedLayers = form.AllowAlignedLayers;
                    // interlayers
                    constraintSet.HasInterlayer = form.HasInterlayers;
                    constraintSet.InterlayerPeriod = form.InterlayerPeriod;
                    constraintSet.HasInterlayerAntiSlip = form.HasInterlayerAntiSlip;
                    // pallet corner
                    analysis.PalletCornerProperties = form.SelectedPalletCorners;
                    // pallet cap
                    analysis.PalletCapProperties = form.SelectedPalletCap;
                    // pallet film
                    analysis.PalletFilmProperties = form.SelectedPalletFilm;
                    // stop criterion
                    constraintSet.UseMaximumHeight = form.UseMaximumPalletHeight;
                    constraintSet.UseMaximumNumberOfCases = form.UseMaximumNumberOfBoxes;
                    constraintSet.UseMaximumPalletWeight = form.UseMaximumPalletWeight;
                    constraintSet.UseMaximumWeightOnBox = form.UseMaximumLoadOnBox;
                    constraintSet.MaximumHeight = form.MaximumPalletHeight;
                    constraintSet.MaximumNumberOfItems = form.MaximumNumberOfBoxes;
                    constraintSet.MaximumPalletWeight = form.MaximumPalletWeight;
                    constraintSet.MaximumWeightOnBox = form.MaximumLoadOnBox;
                    // number of solution kept
                    constraintSet.UseNumberOfSolutionsKept = Properties.Settings.Default.KeepBestSolutions;
                    if (constraintSet.UseNumberOfSolutionsKept)
                        constraintSet.NumberOfSolutionsKept = Properties.Settings.Default.NoSolutionsToKeep;
                    // pallet film turns
                    constraintSet.PalletFilmTurns = form.PalletFilmTurns;
                }
            }
            else if (analysis.IsBundleAnalysis)
            {
                FormNewAnalysisBundle form = new FormNewAnalysisBundle(this, analysis);
                form.Boxes = Bundles.ToArray();
                form.Pallets = Pallets.ToArray();

                if (recomputeRequired = (DialogResult.OK == form.ShowDialog()))
                {
                    // analysis name / description
                    analysis.Name = form.ItemName;
                    analysis.Description = form.ItemDescription;
                    // analysis bundle / pallet
                    analysis.BProperties = form.SelectedBundle;
                    analysis.PalletProperties = form.SelectedPallet;
                    // build constraintSet
                    BundlePalletConstraintSet constraintSet = analysis.ConstraintSet as BundlePalletConstraintSet;
                    // overhang / underhang
                    constraintSet.OverhangX = form.OverhangX;
                    constraintSet.OverhangY = form.OverhangY;
                    // allowed patterns
                    constraintSet.ClearAllowedPatterns();
                    foreach (string s in form.AllowedPatterns)
                        constraintSet.SetAllowedPattern(s);
                    // allow aligned / alternate layer
                    constraintSet.AllowAlternateLayers = form.AllowAlternateLayers;
                    constraintSet.AllowAlignedLayers = form.AllowAlignedLayers;
                    // stop criterions
                    constraintSet.UseMaximumHeight = form.UseMaximumPalletHeight;
                    constraintSet.UseMaximumNumberOfCases = form.UseMaximumNumberOfBoxes;
                    constraintSet.UseMaximumPalletWeight = form.UseMaximumPalletWeight;
                    constraintSet.MaximumHeight = form.MaximumPalletHeight;
                    constraintSet.MaximumNumberOfItems = form.MaximumNumberOfBoxes;
                    constraintSet.MaximumPalletWeight = form.MaximumPalletWeight;
                }
            }
            if (recomputeRequired)
                analysis.OnEndUpdate(null);
        }
Exemple #26
0
 internal void NotifyOnNewECTAnalysisCreated(CasePalletAnalysis analysis, SelCasePalletSolution selSolution, ECTAnalysis ectAnalysis)
 { 
     foreach (IDocumentListener listener in _listeners)
         listener.OnNewECTAnalysisCreated(this, analysis, selSolution, ectAnalysis);
 }
Exemple #27
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;
 }
        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());
            }
        }
 public NodeTag(NodeType type, Document document, CasePalletAnalysis analysis, SelCasePalletSolution selSolution, ECTAnalysis ectAnalysis)
 {
     _type = type;
     _document = document;
     _itemProperties = null;
     _casePalletAnalysis = analysis;
     _selSolution = selSolution;
     _ectAnalysis = ectAnalysis;
 }
 /// <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);
 }
Exemple #31
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;
        }
 public CasePalletSolution(CasePalletAnalysis analysis, string title, bool homogenousLayer)
 {
     _parentAnalysis   = analysis;
     _title            = title;
     _homogeneousLayer = homogenousLayer;
 }
Exemple #33
0
 public void OnECTAnalysisRemoved(Document doc, CasePalletAnalysis analysis, SelCasePalletSolution selectedSolution, ECTAnalysis ectAnalysis)
 { 
 }
Exemple #34
0
        public void SaveCasePalletAnalysis(CasePalletAnalysis analysis, CasePalletSolution sol, SelCasePalletSolution selSolution, 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);
            }
            if (null != analysis.InterlayerPropertiesAntiSlip)
            {
                XmlAttribute interlayerIdAttribute = xmlDoc.CreateAttribute("InterlayerAntiSlipId");
                interlayerIdAttribute.Value = string.Format("{1}", analysis.InterlayerPropertiesAntiSlip.Guid);
                xmlAnalysisElt.Attributes.Append(interlayerIdAttribute);
            }
            // ###
            // 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("{0}", analysis.ConstraintSet.OverhangX);
            constraintSetElement.Attributes.Append(overhangX);
            XmlAttribute overhangY = xmlDoc.CreateAttribute("OverhangY");
            overhangY.Value = string.Format("{0}", analysis.ConstraintSet.OverhangY);
            constraintSetElement.Attributes.Append(overhangY);
            // number of solutions to keep
            if (analysis.ConstraintSet.UseNumberOfSolutionsKept)
            {
                XmlAttribute numberOfSolutionsKept = xmlDoc.CreateAttribute("NumberOfSolutions");
                numberOfSolutionsKept.Value = "1";
                constraintSetElement.Attributes.Append(numberOfSolutionsKept);
            }

            xmlAnalysisElt.AppendChild(constraintSetElement);
            // ###
            // Solutions
            XmlElement solutionsElt = xmlDoc.CreateElement("Solutions");
            xmlAnalysisElt.AppendChild(solutionsElt);
            SaveCasePalletSolution(analysis, sol, selSolution, true /* unique */, solutionsElt, 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;
        }
 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();
 }