protected void Compute()
        {
            try
            {
                const double thickness = 4.0;
                _doc = new Document(_name, "", "", DateTime.Now, null);
                // colors
                Color[] colors = new Color[6];
                for (int i = 0; i < 6; ++i) colors[i] = Color.Chocolate;
                // bundle
                BundleProperties bundleProperties = _doc.CreateNewBundle(_name, _name, BundleLength, BundleWidth, FlatThickness, FlatWeight, Color.Beige, NoFlats);
                // case
                BoxProperties caseProperties = _doc.CreateNewCase(_name, _name
                    , CaseInsideLength + 2.0 * thickness, CaseInsideWidth + 2.0 * thickness, CaseInsideHeight + 2.0 * thickness
                    , CaseInsideLength, CaseInsideWidth, CaseInsideHeight
                    , CaseWeight, colors);
                // constraint set
                BundleCaseConstraintSet constraintSet = new BundleCaseConstraintSet();
                // maximum case weight
                constraintSet.UseMaximumCaseWeight = false;
                constraintSet.MaximumCaseWeight = 0.0;
                // maximum number of items
                constraintSet.UseMaximumNumberOfBoxes = false;
                constraintSet.MaximumNumberOfBoxes = 0;

                _analysis = _doc.CreateNewBoxCaseAnalysis(
                    _name, _name
                    , bundleProperties, caseProperties
                    , constraintSet
                    , new BoxCaseSolver());
                // fill grid
                FillGrid();
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
示例#2
0
        private BCaseConstraintSet LoadBoxCaseConstraintSet(XmlElement eltConstraintSet)
        {
            BCaseConstraintSet constraints = null;

            // allowed orthogonal axes
            if (eltConstraintSet.HasAttribute("AllowedBoxPositions"))
            {
                constraints = new BoxCaseConstraintSet();
                BoxCaseConstraintSet boxCaseContraintSet = constraints as BoxCaseConstraintSet;
                boxCaseContraintSet.AllowOrthoAxisString = eltConstraintSet.Attributes["AllowedBoxPositions"].Value;
            }
            else
                constraints = new BundleCaseConstraintSet();
            // maximum case weight
            if (constraints.UseMaximumCaseWeight = eltConstraintSet.HasAttribute("MaximumCaseWeight"))
                constraints.MaximumCaseWeight = UnitsManager.ConvertMassFrom(double.Parse(eltConstraintSet.Attributes["MaximumCaseWeight"].Value), _unitSystem);
            // allowed patterns
            if (constraints.UseMaximumNumberOfBoxes = eltConstraintSet.HasAttribute("ManimumNumberOfItems"))
                constraints.MaximumNumberOfBoxes = int.Parse(eltConstraintSet.Attributes["ManimumNumberOfItems"].Value);
            // sanity check
            if (!constraints.IsValid)
                throw new Exception("Invalid constraint set");
            return constraints;
        }
示例#3
0
        public BoxCaseAnalysis CreateNewBundleCaseAnalysisUI()
        {
            FormNewAnalysisBundleCase form = new FormNewAnalysisBundleCase(this, null);
            if (DialogResult.OK == form.ShowDialog())
            {
                // build constraint set
                BundleCaseConstraintSet constraintSet = new BundleCaseConstraintSet();
                // maximum case weight
                constraintSet.UseMaximumCaseWeight = form.UseMaximumCaseWeight;
                constraintSet.MaximumCaseWeight = form.MaximumCaseWeight;
                // maximum number of items
                constraintSet.UseMaximumNumberOfBoxes = form.UseMaximumNumberOfBoxes;
                constraintSet.MaximumNumberOfBoxes = form.MaximumNumberOfBoxes;

                return CreateNewBoxCaseAnalysis(
                    form.ItemName, form.ItemDescription
                    , form.SelectedBundle, form.SelectedCase
                    , constraintSet
                    , new BoxCaseSolver());
            }
            return null;
        }