Esempio n. 1
0
        private List<TruckSolution> GenerateSolutions(TruckAnalysis truckAnalysis)
        {
            List<TruckSolution> solutions = new List<TruckSolution>();

            // build layer using truck length / width
            foreach (LayerPattern pattern in _patterns)
            {
                for (int swapPos = 0; swapPos < (pattern.CanBeSwapped ? 2 : 1); ++swapPos)
                {
                    pattern.Swapped = swapPos == 1;

                    for (int orientation = 0; orientation < 2; ++orientation)
                    {
                        try
                        {
                            Layer layer = new Layer(truckAnalysis.ParentSolution, truckAnalysis.TruckProperties, truckAnalysis.ConstraintSet, orientation);
                            double actualLength = 0.0, actualWidth = 0.0;
                            if (!pattern.GetLayerDimensionsChecked(layer, out actualLength, out actualWidth))
                                continue;
                            pattern.GenerateLayer(layer, actualLength, actualWidth);

                            TruckSolution sol = new TruckSolution("sol", truckAnalysis);

                            BoxLayer boxLayer = new BoxLayer(0.0, string.Empty);
                            foreach (LayerPosition layerPos in layer)
                                boxLayer.AddPosition(layerPos.Position, layerPos.LengthAxis, layerPos.WidthAxis);

                            sol.Layer = boxLayer;

                            // insert solution
                            if (sol.PalletCount > 0)
                                solutions.Add(sol);
                        }
                        catch (Exception ex)
                        {
                            _log.Error(string.Format("Exception caught: {0}", ex.ToString()));
                        }
                    }
                }
            }

            // sort solutions
            solutions.Sort();

            return solutions;
        }
Esempio n. 2
0
        public int CompareTo(object obj)
        {
            TruckSolution sol = (TruckSolution)obj;

            if (this.PalletCount > sol.PalletCount)
            {
                return(-1);
            }
            else if (this.PalletCount == sol.PalletCount)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }
Esempio n. 3
0
 private TruckSolution LoadTruckSolution(XmlElement eltTruckSolution)
 {
     // title -> instantiation
     string stitle = string.Empty;
     if (eltTruckSolution.HasAttribute("Title"))
         stitle = eltTruckSolution.Attributes["Title"].Value;
     TruckSolution sol = new TruckSolution(stitle, null);
     // load only one BoxLayer (actually Pallet layer)
     XmlElement eltLayers = eltTruckSolution.ChildNodes[0] as XmlElement;
     XmlElement eltLayer = eltLayers.ChildNodes[0] as XmlElement;
     sol.Layer = LoadLayer(eltLayer) as BoxLayer;
     return sol;
 }
 public void Update(ItemBase item)
 {
     // update grid
     FillGrid();
     // select first solution
     if (gridSolutions.RowsCount > 0)
         gridSolutions.Selection.SelectRow(1, true);
     if (_truckAnalysis.Solutions.Count > 0)
         _sol = _truckAnalysis.Solutions[0];
     // draw
     graphCtrlSolution.Invalidate();
 }
 // selection changed
 private void onGridSolutionSelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
 {
     SourceGrid.RangeRegion region = gridSolutions.Selection.GetSelectionRegion();
     int[] indexes = region.GetRowsIndex();
     // no selection -> exit
     if (indexes.Length == 0) return;
     // get selected solution
     _sol = _truckAnalysis.Solutions[indexes[0] - 1];
     // update select/unselect button text
     UpdateSelectButtonText();
     // redraw
     graphCtrlSolution.Invalidate();
 }
        private void FillGrid()
        {
            // fill grid solutions
            gridSolutions.Rows.Clear();

            // border
            DevAge.Drawing.BorderLine border = new DevAge.Drawing.BorderLine(Color.DarkBlue, 1);
            DevAge.Drawing.RectangleBorder cellBorder = new DevAge.Drawing.RectangleBorder(border, border);

            // views
            CellBackColorAlternate viewNormal = new CellBackColorAlternate(Color.LightBlue, Color.White);
            viewNormal.Border = cellBorder;
            CheckboxBackColorAlternate viewNormalCheck = new CheckboxBackColorAlternate(Color.LightBlue, Color.White);
            viewNormalCheck.Border = cellBorder;

            // column header view
            SourceGrid.Cells.Views.ColumnHeader viewColumnHeader = new SourceGrid.Cells.Views.ColumnHeader();
            DevAge.Drawing.VisualElements.ColumnHeader backHeader = new DevAge.Drawing.VisualElements.ColumnHeader();
            backHeader.BackColor = Color.LightGray;
            backHeader.Border = DevAge.Drawing.RectangleBorder.NoBorder;
            viewColumnHeader.Background = backHeader;
            viewColumnHeader.ForeColor = Color.White;
            viewColumnHeader.Font = new Font("Arial", 10, FontStyle.Bold);
            viewColumnHeader.ElementSort.SortStyle = DevAge.Drawing.HeaderSortStyle.None;

            // create the grid
            gridSolutions.BorderStyle = BorderStyle.FixedSingle;

            gridSolutions.ColumnsCount = 8;
            gridSolutions.FixedRows = 1;
            gridSolutions.Rows.Insert(0);

            // header
            SourceGrid.Cells.ColumnHeader columnHeader;
            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_INDEX);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 0] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LAYOUT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 1] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_PALLETCOUNT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 2] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_CASECOUNT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 3] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_VOLUMEEFFICIENCY);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 4] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LOADWEIGHT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 5] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_LOADHEIGHT);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 6] = columnHeader;

            columnHeader = new SourceGrid.Cells.ColumnHeader(Resources.ID_SELECTED);
            columnHeader.AutomaticSortEnabled = false;
            columnHeader.View = viewColumnHeader;
            gridSolutions[0, 7] = columnHeader;

            // handling check box click
            SourceGrid.Cells.Controllers.CustomEvents solCheckboxClickEvent = new SourceGrid.Cells.Controllers.CustomEvents();
            solCheckboxClickEvent.Click += new EventHandler(clickEvent_Click);

            // data rows
            int iIndex = 0;
            foreach (TruckSolution sol in _truckAnalysis.Solutions)
            {
                ++iIndex;
                gridSolutions.Rows.Insert(iIndex);
                // index
                gridSolutions[iIndex, 0] = new SourceGrid.Cells.Cell(string.Format("{0}", iIndex));
                // Layout
                {
                    Graphics2DImage graphics = new Graphics2DImage(new Size(300, 30));
                    TruckSolutionViewer sv = new TruckSolutionViewer(sol);
                    sv.Draw(graphics);
                    gridSolutions[iIndex, 1] = new SourceGrid.Cells.Image(graphics.Bitmap);
                }
                // Pallet count
                gridSolutions[iIndex, 2] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.PalletCount));
                // Case count
                gridSolutions[iIndex, 3] = new SourceGrid.Cells.Cell(string.Format("{0}", sol.BoxCount));
                // Efficiency
                gridSolutions[iIndex, 4] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.Efficiency));
                // Load
                gridSolutions[iIndex, 5] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.LoadWeight));
                // Load height
                gridSolutions[iIndex, 6] = new SourceGrid.Cells.Cell(string.Format("{0:F}", sol.LoadHeight));
                // Selected
                gridSolutions[iIndex, 7] = new SourceGrid.Cells.CheckBox(null, _truckAnalysis.HasSolutionSelected(iIndex-1));

                gridSolutions[iIndex, 0].View = viewNormal;
                gridSolutions[iIndex, 1].View = viewNormal;
                gridSolutions[iIndex, 2].View = viewNormal;
                gridSolutions[iIndex, 3].View = viewNormal;
                gridSolutions[iIndex, 4].View = viewNormal;
                gridSolutions[iIndex, 5].View = viewNormal;
                gridSolutions[iIndex, 6].View = viewNormal;
                gridSolutions[iIndex, 7].View = viewNormalCheck;

                gridSolutions[iIndex, 7].AddController(solCheckboxClickEvent);
            }

            gridSolutions.AutoStretchColumnsToFitWidth = true;
            gridSolutions.AutoSizeCells();
            gridSolutions.Columns.StretchToFit();

            // select first solution
            gridSolutions.Selection.SelectRow(1, true);
            if (_truckAnalysis.Solutions.Count > 0)
                _sol = _truckAnalysis.Solutions[0];
            graphCtrlSolution.Invalidate();
        }
 public TruckSolutionViewer(TruckSolution truckSolution)
 {
     _truckSolution = truckSolution;
 }