public FormNewPalletCorners(Document doc, PalletCornerProperties palletCorners) : base(doc, palletCorners) { InitializeComponent(); if (null != palletCorners) { CornerLength = palletCorners.Length; CornerWidth = palletCorners.Width; CornerThickness = palletCorners.Thickness; CornerWeight = palletCorners.Weight; CornerColor = palletCorners.Color; } else { CornerLength = UnitsManager.ConvertLengthFrom(1200.0, UnitsManager.UnitSystem.UNIT_METRIC1);; CornerWidth = UnitsManager.ConvertLengthFrom(40.0, UnitsManager.UnitSystem.UNIT_METRIC1);; CornerThickness = UnitsManager.ConvertLengthFrom(5.0, UnitsManager.UnitSystem.UNIT_METRIC1); CornerWeight = UnitsManager.ConvertMassFrom(0.050, UnitsManager.UnitSystem.UNIT_METRIC1); CornerColor = Color.Khaki; } UpdateStatus(string.Empty); // units UnitsManager.AdaptUnitLabels(this); }
public CasePalletAnalysis( BProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm, PalletConstraintSet constraintSet) : base(boxProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) throw new Exception("box, pallet, interlayer do not belong to the same document"); if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet)) throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox"); // has interlayer ? constraintSet.HasInterlayer = null != interlayerProperties; // setting members this.BProperties = boxProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; this.PalletCornerProperties = palletCorners; this.PalletCapProperties = palletCap; this.PalletFilmProperties = palletFilm; this.ConstraintSet = constraintSet; }
public CasePalletAnalysis( BProperties boxProperties, PalletProperties palletProperties, InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip, PalletCornerProperties palletCorners, PalletCapProperties palletCap, PalletFilmProperties palletFilm, PalletConstraintSet constraintSet) : base(boxProperties.ParentDocument) { // sanity checks if (palletProperties.ParentDocument != ParentDocument || (interlayerProperties != null && interlayerProperties.ParentDocument != ParentDocument)) { throw new Exception("box, pallet, interlayer do not belong to the same document"); } if ((boxProperties is BoxProperties && constraintSet is BundlePalletConstraintSet) || (boxProperties is BundleProperties && constraintSet is CasePalletConstraintSet)) { throw new Exception("Invalid analysis: either BoxProperties with ConstraintSetBundle or BundleProperties with ConstraintSetBox"); } // has interlayer ? constraintSet.HasInterlayer = null != interlayerProperties; // setting members this.BProperties = boxProperties; this.PalletProperties = palletProperties; this.InterlayerProperties = interlayerProperties; this.InterlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip; this.PalletCornerProperties = palletCorners; this.PalletCapProperties = palletCap; this.PalletFilmProperties = palletFilm; this.ConstraintSet = constraintSet; }
public Corner(uint pickId, PalletCornerProperties cornerProperties) { _pickId = pickId; _w = cornerProperties.Width; _th = cornerProperties.Thickness; _height = cornerProperties.Length; _color = cornerProperties._color; }
/// <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> /// 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 void Save(PalletCornerProperties cornerProperties, XmlElement parentElement, XmlDocument xmlDoc) { // create PalletCornerProperties element XmlElement xmlCornerProperties = xmlDoc.CreateElement("PalletCornerProperties"); parentElement.AppendChild(xmlCornerProperties); // Id XmlAttribute guidAttribute = xmlDoc.CreateAttribute("Id"); guidAttribute.Value = cornerProperties.Guid.ToString(); xmlCornerProperties.Attributes.Append(guidAttribute); // name XmlAttribute nameAttribute = xmlDoc.CreateAttribute("Name"); nameAttribute.Value = cornerProperties.Name; xmlCornerProperties.Attributes.Append(nameAttribute); // description XmlAttribute descAttribute = xmlDoc.CreateAttribute("Description"); descAttribute.Value = cornerProperties.Description; xmlCornerProperties.Attributes.Append(descAttribute); // length XmlAttribute lengthAttribute = xmlDoc.CreateAttribute("Length"); lengthAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cornerProperties.Length); xmlCornerProperties.Attributes.Append(lengthAttribute); // width XmlAttribute widthAttribute = xmlDoc.CreateAttribute("Width"); widthAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cornerProperties.Width); xmlCornerProperties.Attributes.Append(widthAttribute); // height XmlAttribute heightAttribute = xmlDoc.CreateAttribute("Thickness"); heightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cornerProperties.Thickness); xmlCornerProperties.Attributes.Append(heightAttribute); // weight XmlAttribute weightAttribute = xmlDoc.CreateAttribute("Weight"); weightAttribute.Value = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}", cornerProperties.Weight); xmlCornerProperties.Attributes.Append(weightAttribute); // color XmlAttribute colorAttribute = xmlDoc.CreateAttribute("Color"); colorAttribute.Value = string.Format("{0}", cornerProperties.Color.ToArgb()); xmlCornerProperties.Attributes.Append(colorAttribute); }
public PalletCornerProperties CreateNewPalletCorners(string name, string description, double length, double width, double thickness, double weight, Color color) { // instantiate and initialize PalletCornerProperties palletCorners = new PalletCornerProperties( this, name, description, length, width, thickness, weight, color); // insert in list _typeList.Add(palletCorners); // notify listeners NotifyOnNewTypeCreated(palletCorners); Modify(); return palletCorners; }
private void AppendPalletCornerElement(PalletCornerProperties palletCornerProp, XmlElement elemPalletAnalysis, XmlDocument xmlDoc) { // sanity check if (null == palletCornerProp) return; // namespace string ns = xmlDoc.DocumentElement.NamespaceURI; // interlayer XmlElement elemPalletCorner = xmlDoc.CreateElement("palletCorner", ns); elemPalletAnalysis.AppendChild(elemPalletCorner); // name XmlElement elemName = xmlDoc.CreateElement("name", ns); elemName.InnerText = palletCornerProp.Name; elemPalletCorner.AppendChild(elemName); // description XmlElement elemDescription = xmlDoc.CreateElement("description", ns); elemDescription.InnerText = palletCornerProp.Description; elemPalletCorner.AppendChild(elemDescription); AppendElementValue(xmlDoc, elemPalletCorner, "length", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Length); AppendElementValue(xmlDoc, elemPalletCorner, "width", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Width); AppendElementValue(xmlDoc, elemPalletCorner, "thickness", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Thickness); AppendElementValue(xmlDoc, elemPalletCorner, "weight", UnitsManager.UnitType.UT_LENGTH, palletCornerProp.Weight); // --- // view_palletCorner_iso // build image Graphics3DImage graphics = new Graphics3DImage(new Size(ImageSizeDetail, ImageSizeDetail)); graphics.CameraPosition = Graphics3D.Corner_0; Corner corner = new Corner(0, palletCornerProp); corner.Draw(graphics); graphics.Flush(); // save image ? SaveImageAs(graphics.Bitmap, "view_palletCorner_iso.png"); // --- // view_palletCorner_iso XmlElement elemImage = xmlDoc.CreateElement("view_palletCorner_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); elemPalletCorner.AppendChild(elemImage); }
public void Draw(Graphics3DControl ctrl, Graphics3D graphics) { if (CornerLength > 0 && CornerWidth > 0 && CornerThickness > 0 && CornerThickness < CornerWidth) { // draw PalletCornerProperties palletCornerProperties = new PalletCornerProperties( null, ItemName, ItemDescription, CornerLength, CornerWidth, CornerThickness, CornerWeight, CornerColor); Corner palletCap = new Corner(0, palletCornerProperties); palletCap.Draw(graphics); graphics.AddDimensions(new DimensionCube(CornerWidth, CornerWidth, CornerLength)); } }
private Layer GenerateBestLayer( BProperties bProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties, PalletConstraintSet constraintSet, HalfAxis.HAxis hAxis) { Layer bestLayer = null; // loop through all patterns foreach (LayerPattern pattern in _patterns) { // is pattern allowed if (!_constraintSet.AllowPattern(pattern.Name)) continue; // direction 1 Layer layer1 = new Layer(bProperties, palletProperties, cornerProperties, constraintSet, hAxis); double actualLength = 0.0, actualWidth = 0.0; pattern.GetLayerDimensionsChecked(layer1, out actualLength, out actualWidth); pattern.GenerateLayer(layer1, actualLength, actualWidth); // save as best pattern if (null == bestLayer || bestLayer.Count < layer1.Count) bestLayer = layer1; // direction 2 (opposite) Layer layer2 = new Layer(bProperties, palletProperties, cornerProperties, constraintSet, HalfAxis.Opposite(hAxis)); actualLength = 0.0; actualWidth = 0.0; pattern.GetLayerDimensionsChecked(layer2, out actualLength, out actualWidth); pattern.GenerateLayer(layer2, actualLength, actualWidth); // save as best pattern if (null == bestLayer || bestLayer.Count < layer2.Count) bestLayer = layer2; } return bestLayer; }
/// <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(); }