/// <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; }
private TruckConstraintSet LoadTruckConstraintSet(XmlElement eltTruckConstraintSet) { TruckConstraintSet constraintSet = new TruckConstraintSet(); // multi layer allowed if (eltTruckConstraintSet.HasAttribute("MultilayerAllowed")) constraintSet.MultilayerAllowed = string.Equals(eltTruckConstraintSet.Attributes["MultilayerAllowed"].Value, "true", StringComparison.CurrentCultureIgnoreCase); if (eltTruckConstraintSet.HasAttribute("MinDistancePalletWall")) constraintSet.MinDistancePalletTruckWall = UnitsManager.ConvertLengthFrom(double.Parse(eltTruckConstraintSet.Attributes["MinDistancePalletWall"].Value), _unitSystem); if (eltTruckConstraintSet.HasAttribute("MinDistancePalletRoof")) constraintSet.MinDistancePalletTruckRoof = UnitsManager.ConvertLengthFrom(double.Parse(eltTruckConstraintSet.Attributes["MinDistancePalletRoof"].Value), _unitSystem); if (eltTruckConstraintSet.HasAttribute("AllowedPalletOrientations")) { string sAllowedPalletOrientations = eltTruckConstraintSet.Attributes["AllowedPalletOrientations"].Value; constraintSet.AllowPalletOrientationX = sAllowedPalletOrientations.Contains("X"); constraintSet.AllowPalletOrientationY = sAllowedPalletOrientations.Contains("Y"); } return constraintSet; }
private TruckAnalysis LoadTruckAnalysis(XmlElement eltTruckAnalysis, SelCasePalletSolution selSolution) { string sName = eltTruckAnalysis.Attributes["Name"].Value; string sDescription = eltTruckAnalysis.Attributes["Description"].Value; string sTruckId = eltTruckAnalysis.Attributes["TruckId"].Value; TruckConstraintSet constraintSet = new TruckConstraintSet(); List<TruckSolution> solutions = new List<TruckSolution>(); List<int> selectedIndices = new List<int>(); foreach (XmlNode node in eltTruckAnalysis.ChildNodes) { // load constraint set if (string.Equals(node.Name, "ConstraintSet", StringComparison.CurrentCultureIgnoreCase)) constraintSet = LoadTruckConstraintSet(node as XmlElement); // load solutions else if (string.Equals(node.Name, "Solutions", StringComparison.CurrentCultureIgnoreCase)) { int indexSol = 0; foreach (XmlNode solutionNode in node.ChildNodes) { XmlElement eltSolution = solutionNode as XmlElement; solutions.Add(LoadTruckSolution(eltSolution)); // is solution selected ? if (null != eltSolution.Attributes["Selected"] && string.Equals("true", eltSolution.Attributes["Selected"].Value, StringComparison.CurrentCultureIgnoreCase)) selectedIndices.Add(indexSol); ++indexSol; } } } TruckAnalysis truckAnalysis = selSolution.CreateNewTruckAnalysis( sName , sDescription , GetTypeByGuid(new Guid(sTruckId)) as TruckProperties , constraintSet , solutions); foreach (int index in selectedIndices) truckAnalysis.SelectedSolutionIndex = index; return truckAnalysis; }
private void onCreateNewTruckAnalysis(object sender, EventArgs e) { try { NodeTag tag = SelectedNode.Tag as NodeTag; if (tag.SelSolution.HasDependingAnalyses) return; FormNewTruckAnalysis form = new FormNewTruckAnalysis(tag.Document); form.Trucks = tag.Document.Trucks.ToArray(); if (DialogResult.OK == form.ShowDialog()) { TruckConstraintSet constraintSet = new TruckConstraintSet(); constraintSet.MultilayerAllowed = form.AllowSeveralPalletLayers; constraintSet.AllowPalletOrientationX = form.AllowPalletOrientationX; constraintSet.AllowPalletOrientationY = form.AllowPalletOrientationY; constraintSet.MinDistancePalletTruckWall = form.MinDistancePalletTruckWall; constraintSet.MinDistancePalletTruckRoof = form.MinDistancePalletTruckRoof; TruckAnalysis truckAnalysis = tag.SelSolution.CreateNewTruckAnalysis(form.SelectedTruck.Name, string.Empty, form.SelectedTruck, constraintSet, new TruckSolver()); if (null != truckAnalysis) FormMain.GetInstance().CreateOrActivateViewTruckAnalysis(truckAnalysis); } } catch (Exception ex) { _log.Error(ex.ToString()); } }
/// <summary> /// Creates new truck analysis based on solution /// This method used when loading truck analysis from file /// </summary> /// <param name="name"></param> /// <param name="description"></param> /// <param name="truckProperties"></param> /// <param name="constraintSet"></param> /// <param name="solutions"></param> /// <returns></returns> public TruckAnalysis CreateNewTruckAnalysis(string name, string description, TruckProperties truckProperties, TruckConstraintSet constraintSet, List<TruckSolution> solutions) { TruckAnalysis truckAnalysis = new TruckAnalysis(this.ParentDocument, _analysis, this, truckProperties, constraintSet); truckAnalysis.Name = name; truckAnalysis.Description = description; truckAnalysis.Solutions = solutions; _truckAnalyses.Add(truckAnalysis); AddDependancy(truckAnalysis); ParentDocument.NotifyOnNewTruckAnalysisCreated(_analysis, this, truckAnalysis); ParentDocument.Modify(); return truckAnalysis; }
/// <summary> /// Creates new truck analysis based on solution /// This method used when loading truck analysis from file /// </summary> /// <param name="name"></param> /// <param name="description"></param> /// <param name="truckProperties"></param> /// <param name="constraintSet"></param> /// <param name="solutions"></param> /// <returns></returns> public TruckAnalysis CreateNewTruckAnalysis(string name, string description, TruckProperties truckProperties, TruckConstraintSet constraintSet, List <TruckSolution> solutions) { TruckAnalysis truckAnalysis = new TruckAnalysis(this.ParentDocument, _analysis, this, truckProperties, constraintSet); truckAnalysis.Name = name; truckAnalysis.Description = description; truckAnalysis.Solutions = solutions; _truckAnalyses.Add(truckAnalysis); AddDependancy(truckAnalysis); ParentDocument.NotifyOnNewTruckAnalysisCreated(_analysis, this, truckAnalysis); ParentDocument.Modify(); return(truckAnalysis); }