Example #1
0
        public BQueryExecutor(ILogger log, BProperties properties, string sql)
        {
            //get function data
            LogUtilities.LogFunctionEntrance(log, log, sql);
            Log = log;
            m_Properties = properties;
            Sql = sql;

            // Create the prepared results.
            Results = new List<IResult>();
            
            // Create the parameters.
            ParameterMetadata = new List<ParameterMetadata>();

            //create our data
            IResult result = BResultTableFactory.CreateResultTable(log, sql, properties);
            if (result != null)
            {
                Results.Add(result);
            }
            else
            {
                throw new Exception("Failed to create the result table.");
            }
        }
Example #2
0
 /// <summary>
 /// Layer case analysis constructor
 /// </summary>
 public Layer(BProperties bProperties, BoxProperties caseProperties, HalfAxis.HAxis axisOrtho)
 {
     _axisOrtho    = axisOrtho;
     _palletLength = caseProperties.InsideLength;
     _palletWidth  = caseProperties.InsideWidth;
     Initialize(bProperties);
 }
Example #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for this metadata source.</param>
        public BColumnsMetadataSource(ILogger log, BProperties properties)
        {
            LogUtilities.LogFunctionEntrance(log, log);
            Log          = log;
            m_Properties = properties;

            //InitializeData();
            //List<ColumnInfo> column_infos = new List<ColumnInfo>();
            //column_infos.AddRange(m_Columns);
            //m_Columns.Clear();

            try
            {
                //get the client connection
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    //get the columns
                    ColumnMetadataResult[] columns = client.GetMetadataColumns();

                    //copy results
                    columns.ToList().Where(c => c.Visible).ToList().ForEach(c =>
                    {
                        //if(c.Table == "Mentions" &&
                        //    (
                        //        c.Column == "Id" ||
                        //        c.Column == "Name" ||
                        //        c.Column == "Description" ||
                        //        c.Column == "Type" ||
                        //        c.Column == "Sentiment" ||
                        //        c.Column == "Influence" ||
                        //        c.Column == "IsDisabled" ||
                        //        c.Column == "OccurredOn" ||
                        //        c.Column == "CreatedOn" ||
                        //        c.Column == "UpdatedOn" ||
                        //        c.Column == "Guid" ||
                        //        c.Column == "Author" ||
                        //        c.Column == "Followers" ||
                        //        c.Column == "Klout" ||
                        //        c.Column == "Comments"
                        //    ))
                        {
                            m_Columns.Add(
                                GetColumnInfo(
                                    c.Catalog,
                                    c.Table,
                                    c.Column,
                                    c.DataType,
                                    c.ColumnLength,
                                    c.Nullable,
                                    c.OrdinalPosition,
                                    c.ColumnPrecision));
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for this metadata source.</param>
        public BCatalogOnlyMetadataSource(ILogger log, BProperties properties)
        {
            LogUtilities.LogFunctionEntrance(log, log);
            Log = log;
            m_Properties = properties;

            try
            {
                //get the client connection
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    //get the catalogs
                    string[] catalogs = client.GetMetadataCatalogs();

                    //copy results
                    m_Catalogs.AddRange(catalogs);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }

            //m_Catalogs.Add(Driver.B_CATALOG);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for this metadata source.</param>
        public BCatalogOnlyMetadataSource(ILogger log, BProperties properties)
        {
            LogUtilities.LogFunctionEntrance(log, log);
            Log          = log;
            m_Properties = properties;

            try
            {
                //get the client connection
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    //get the catalogs
                    string[] catalogs = client.GetMetadataCatalogs();

                    //copy results
                    m_Catalogs.AddRange(catalogs);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }

            //m_Catalogs.Add(Driver.B_CATALOG);
        }
Example #6
0
        protected BoxPosition GetInitialBoxPosition(uint caseIndex)
        {
            uint iLayer = 0, iCounted = 0;

            foreach (ILayer layer in _palletSolution)
            {
                BoxLayer bLayer = layer as BoxLayer;
                if (null != bLayer)
                {
                    if (iCounted + bLayer.BoxCount > caseIndex)
                    {
                        break;
                    }
                    else
                    {
                        iCounted += (uint)bLayer.Count;
                    }
                }
                ++iLayer;
            }

            BProperties bProperties = _palletSolution.Analysis.BProperties;

            double   yOffset   = 0.5 * (_palletSolution.Analysis.PalletProperties.Width - bProperties.Length);
            Vector3D vPosition = new Vector3D(_xOffset + (caseIndex - iCounted) * bProperties.Width, yOffset, (_palletSolution.Count - 1 - iLayer) * bProperties.Height);

            return(new BoxPosition(vPosition, HalfAxis.HAxis.AXIS_Y_P, HalfAxis.HAxis.AXIS_X_N));
        }
Example #7
0
        public Box(uint pickId, BProperties bProperties)
        {
            _pickId = pickId;
            _dim[0] = bProperties.Length;
            _dim[1] = bProperties.Width;
            _dim[2] = bProperties.Height;

            _colors = bProperties.Colors;

            // IsBundle ?
            _isBundle = bProperties.IsBundle;

            // textures
            BoxProperties boxProperties = bProperties as BoxProperties;

            if (null != boxProperties)
            {
                List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                {
                    int iIndex = (int)tex.first;
                    if (null == _textureLists[iIndex])
                    {
                        _textureLists[iIndex] = new List <Texture>();
                    }
                    _textureLists[iIndex].Add(tex.second);
                }
                // tape
                _showTape  = boxProperties.ShowTape;
                _tapeWidth = boxProperties.TapeWidth;
                _tapeColor = boxProperties.TapeColor;
            }
        }
Example #8
0
        public Box(uint pickId, Packable packable, LayerPosition bPosition)
        {
            if (!bPosition.IsValid)
            {
                throw new GraphicsException("Invalid BoxPosition: can not create box");
            }
            _pickId = pickId;
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;

            // set position
            Position = bPosition.Position;
            // set direction length
            LengthAxis = HalfAxis.ToVector3D(bPosition.LengthAxis);
            // set direction width
            WidthAxis = HalfAxis.ToVector3D(bPosition.WidthAxis);

            _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray();

            BProperties bProperties = packable as BProperties;

            if (null != bProperties)
            {
                _colors = bProperties.Colors;

                BoxProperties boxProperties = packable as BoxProperties;
                if (null != boxProperties)
                {
                    List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                    foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                    {
                        int iIndex = (int)tex.first;
                        if (null == _textureLists[iIndex])
                        {
                            _textureLists[iIndex] = new List <Texture>();
                        }
                        _textureLists[iIndex].Add(tex.second);
                    }
                    _showTape  = boxProperties.ShowTape;
                    _tapeWidth = boxProperties.TapeWidth;
                    _tapeColor = boxProperties.TapeColor;
                }
                // IsBundle ?
                _isBundle = bProperties.IsBundle;
                if (bProperties.IsBundle)
                {
                    BundleProperties bundleProp = packable as BundleProperties;
                    if (null != bundleProp)
                    {
                        _noFlats = bundleProp.NoFlats;
                    }
                }
            }
            PackProperties packProperties = packable as PackProperties;

            if (null != packProperties)
            {
            }
        }
Example #9
0
        public BQueryExecutor(ILogger log, BProperties properties, string sql)
        {
            //get function data
            LogUtilities.LogFunctionEntrance(log, log, sql);
            Log          = log;
            m_Properties = properties;
            Sql          = sql;

            // Create the prepared results.
            Results = new List <IResult>();

            // Create the parameters.
            ParameterMetadata = new List <ParameterMetadata>();

            //create our data
            IResult result = BResultTableFactory.CreateResultTable(log, sql, properties);

            if (result != null)
            {
                Results.Add(result);
            }
            else
            {
                throw new Exception("Failed to create the result table.");
            }
        }
Example #10
0
        private void onInputChanged(object sender, EventArgs e)
        {
            try
            {
                // get case /pallet
                ItemBaseCB itemBaseCase = cbCases.SelectedItem as ItemBaseCB;
                if (null == itemBaseCase)
                {
                    return;
                }
                BProperties bProperties = itemBaseCase.Item as BProperties;

                ItemBaseCB itemBasePallet = cbPallets.SelectedItem as ItemBaseCB;
                if (null == itemBasePallet)
                {
                    return;
                }
                PalletProperties palletProperties = itemBasePallet.Item as PalletProperties;
                // compute
                LayerSolver    solver = new LayerSolver();
                List <Layer2D> layers = solver.BuildLayers(
                    bProperties.OuterDimensions
                    , new Vector2D(palletProperties.Length + 2.0 * uCtrlOverhang.ValueX, palletProperties.Width + 2.0 * uCtrlOverhang.ValueY)
                    , BuildConstraintSet()
                    , checkBoxBestLayersOnly.Checked);
                // update control
                uCtrlLayerList.BProperties     = bProperties;
                uCtrlLayerList.ContainerHeight = uCtrlOptMaximumHeight.Value.Value;
                uCtrlLayerList.LayerList       = layers;
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }
        }
Example #11
0
        public static Bitmap Draw(Layer2D layer, BProperties bProperties, double height, Size size, bool selected)
        {
            Graphics2DImage graphics = new Graphics2DImage(size);

            using (SolutionViewerLayer solViewer = new SolutionViewerLayer(layer))
            { solViewer.Draw(graphics, bProperties, height, selected); }
            return(graphics.Bitmap);
        }
Example #12
0
        private void DrawBoxPositions()
        {
            // get current boxProperties
            BProperties selectedBox = SelectedBox;

            BoxToPictureBox.Draw(selectedBox, HalfAxis.HAxis.AXIS_X_P, pictureBoxPositionX);
            BoxToPictureBox.Draw(selectedBox, HalfAxis.HAxis.AXIS_Y_P, pictureBoxPositionY);
            BoxToPictureBox.Draw(selectedBox, HalfAxis.HAxis.AXIS_Z_P, pictureBoxPositionZ);
        }
Example #13
0
        public Box(uint pickId, PackableBrick packable, BoxPosition bPosition)
        {
            // sanity checks
            CheckPosition(bPosition);
            // dimensions
            PickId  = pickId;
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;
            // set position
            BoxPosition = bPosition;
            // colors
            Colors = Enumerable.Repeat(Color.Chocolate, 6).ToArray();
            if (packable is PackProperties)
            {
            }
            else
            {
                BProperties bProperties = PackableToBProperties(packable);
                if (null == bProperties)
                {
                    throw new Exception(string.Format("Type {0} cannot be handled by Box constructor", packable.GetType().ToString()));
                }

                Colors   = bProperties.Colors;
                IsBundle = bProperties.IsBundle;
                // is box ?
                if (bProperties is BoxProperties boxProperties)
                {
                    List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                    foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                    {
                        int iIndex = (int)tex.first;
                        if (null == TextureLists[iIndex])
                        {
                            TextureLists[iIndex] = new List <Texture>();
                        }
                        TextureLists[iIndex].Add(tex.second);
                    }
                    TapeWidth = boxProperties.TapeWidth;
                    TapeColor = boxProperties.TapeColor;
                }
                // is bundle ?
                else if (bProperties.IsBundle)
                {
                    if (bProperties is BundleProperties bundleProp)
                    {
                        BundleFlats = bundleProp.NoFlats;
                    }
                }
            }
            if (packable is PackableBrickNamed packableBrickNamed)
            {
                StrapperList = new List <Strapper>(packableBrickNamed.StrapperSet.Strappers);
            }
        }
Example #14
0
 public Layer2D BuildLayer(BProperties bProperties, BoxProperties caseProperties
                           , HalfAxis.HAxis axisOrtho, bool swapped)
 {
     return(new Layer2D(
                new Vector3D(bProperties.Length, bProperties.Width, bProperties.Height)
                , new Vector2D(caseProperties.InsideLength, caseProperties.InsideWidth)
                , axisOrtho
                , swapped
                ));
 }
Example #15
0
        protected Layer2D BuildLayer(BProperties boxProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties
                                     , PalletConstraintSet constraintSet, HalfAxis.HAxis axisOrtho, bool swapped, bool inversed)
        {
            double cornerThickness = null != cornerProperties ? cornerProperties.Thickness : 0.0;

            return(new Layer2D(
                       boxProperties.OuterDimensions
                       , new Vector2D(palletProperties.Length + constraintSet.OverhangX - 2.0 * cornerThickness, palletProperties.Width + constraintSet.OverhangY - 2.0 * cornerThickness)
                       , axisOrtho
                       , swapped));
        }
Example #16
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for logging.</param>
        public BResultTable(ILogger log, string sql, BProperties properties)
            : base(log)
        {
            //get the parameters
            LogUtilities.LogFunctionEntrance(Log, log);
            m_Properties = properties;
            Sql          = sql;

            //execute the first fetch
            ExecuteFetch(m_CurrentPage);
        }
Example #17
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for logging.</param>
        public BResultTable(ILogger log, string sql, BProperties properties)
            : base(log)
        {
            //get the parameters
            LogUtilities.LogFunctionEntrance(Log, log);
            m_Properties = properties;
            Sql = sql;

            //execute the first fetch
            ExecuteFetch(m_CurrentPage);
        }
Example #18
0
        public Box(uint pickId, PackableBrick packable, LayerPosition bPosition)
        {
            // sanity checks
            CheckPosition(bPosition);
            // dimensions
            PickId  = pickId;
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;
            // weight
            _weight = packable.Weight;
            // set position
            BoxPosition = new BoxPosition(bPosition.Position, bPosition.LengthAxis, bPosition.WidthAxis);
            // colors
            Colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray();

            BProperties bProperties = PackableToBProperties(packable);

            if (null != bProperties)
            {
                Colors = bProperties.Colors;

                if (bProperties is BoxProperties boxProperties)
                {
                    List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                    foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                    {
                        int iIndex = (int)tex.first;
                        if (null == TextureLists[iIndex])
                        {
                            TextureLists[iIndex] = new List <Texture>();
                        }
                        TextureLists[iIndex].Add(tex.second);
                    }
                    TapeWidth = boxProperties.TapeWidth;
                    TapeColor = boxProperties.TapeColor;

                    _showTopLabel = boxProperties.ShowTopLabel;
                }
                // IsBundle ?
                IsBundle = bProperties.IsBundle;
                if (bProperties.IsBundle)
                {
                    BundleProperties bundleProp = packable as BundleProperties;
                    if (null != bundleProp)
                    {
                        BundleFlats = bundleProp.NoFlats;
                    }
                }
            }
            if (packable is PackProperties packProperties)
            {
            }
        }
Example #19
0
        /// <summary>
        /// Layer pallet analysis constructor (inversed = false)
        /// </summary>
        public Layer(BProperties boxProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties,
                     PalletConstraintSet constraintSet, HalfAxis.HAxis axisOrtho, bool inversed)
        {
            double cornerThickness = null != cornerProperties ? cornerProperties.Thickness : 0.0;

            _axisOrtho    = axisOrtho;
            _inversed     = inversed;
            _palletLength = palletProperties.Length + constraintSet.OverhangX - 2.0 * cornerThickness;
            _palletWidth  = palletProperties.Width + constraintSet.OverhangY - 2.0 * cornerThickness;
            Initialize(boxProperties);
        }
Example #20
0
 public static IResult CreateResultTable(ILogger log, string sql, BProperties properties)
 {
     switch (properties.ResultType)
     {
         case BProperties.ResultTypes.Normal:
             return new BResultTable(log, sql, properties);
         case BProperties.ResultTypes.FakeData:
             return new BFakeResultTable(log, sql, properties);
         default:
             return null;
     }
 }
Example #21
0
        private void OnSelectedBoxChanged(object sender, EventArgs e)
        {
            BoxItem     boxItem     = cbBoxes.SelectedItem as BoxItem;
            BProperties bProperties = boxItem?.Item;

            lbBoxDimensions.Text = null != bProperties?
                                   string.Format("({0}*{1}*{2})", bProperties.Length, bProperties.Width, bProperties.Height)
                                       : string.Empty;

            OptimizationParameterChanged(sender, e);
            SetMinCaseDimensions();
        }
Example #22
0
        public Box(uint pickId, PackableBrick packable, BoxPosition bPosition)
        {
            // sanity checks
            CheckPosition(bPosition);
            // dimensions
            _pickId = pickId;
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;
            // set position
            _boxPosition = bPosition;
            // colors
            _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray();

            BProperties bProperties = PackableToBProperties(packable);

            if (null == bProperties)
            {
                throw new Exception(string.Format("Type {0} cannot be handled by Box constructor", packable.GetType().ToString()));
            }

            _colors   = bProperties.Colors;
            _isBundle = bProperties.IsBundle;
            // is box ?
            BoxProperties boxProperties = bProperties as BoxProperties;

            if (null != boxProperties)
            {
                List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                {
                    int iIndex = (int)tex.first;
                    if (null == _textureLists[iIndex])
                    {
                        _textureLists[iIndex] = new List <Texture>();
                    }
                    _textureLists[iIndex].Add(tex.second);
                }
                _showTape  = boxProperties.ShowTape;
                _tapeWidth = boxProperties.TapeWidth;
                _tapeColor = boxProperties.TapeColor;
            }
            // is bundle ?
            else if (bProperties.IsBundle)
            {
                BundleProperties bundleProp = bProperties as BundleProperties;
                if (null != bundleProp)
                {
                    _noFlats = bundleProp.NoFlats;
                }
            }
        }
        public void ProcessAnalysis(BoxCaseAnalysis analysis)
        {
            _bProperties    = analysis.BProperties;
            _caseProperties = analysis.CaseProperties;
            _constraintSet  = analysis.ConstraintSet;

            if (!_constraintSet.IsValid)
            {
                throw new EngineException("Constraint set is invalid!");
            }

            analysis.Solutions = GenerateSolutions();
        }
Example #24
0
        public Box(uint pickId, PackableBrick packable)
        {
            _pickId = pickId;
            // dimensions
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;
            // box position
            _boxPosition = new BoxPosition(Vector3D.Zero, HalfAxis.HAxis.AXIS_X_P, HalfAxis.HAxis.AXIS_Y_P);
            // colors & textures
            _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray();

            if (packable is LoadedPallet)
            {
                _packable = packable;
            }
            else
            {
                BProperties bProperties = PackableToBProperties(packable);
                if (null != bProperties)
                {
                    _colors = bProperties.Colors;
                    // IsBundle ?
                    _isBundle = bProperties.IsBundle;
                    if (_isBundle)
                    {
                        _noFlats = (bProperties as BundleProperties).NoFlats;
                    }
                    // textures
                    BoxProperties boxProperties = bProperties as BoxProperties;
                    if (null != boxProperties)
                    {
                        List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                        foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                        {
                            int iIndex = (int)tex.first;
                            if (null == _textureLists[iIndex])
                            {
                                _textureLists[iIndex] = new List <Texture>();
                            }
                            _textureLists[iIndex].Add(tex.second);
                        }
                        // tape
                        _showTape  = boxProperties.ShowTape;
                        _tapeWidth = boxProperties.TapeWidth;
                        _tapeColor = boxProperties.TapeColor;
                    }
                }
            }
        }
Example #25
0
        public static IResult CreateResultTable(ILogger log, string sql, BProperties properties)
        {
            switch (properties.ResultType)
            {
            case BProperties.ResultTypes.Normal:
                return(new BResultTable(log, sql, properties));

            case BProperties.ResultTypes.FakeData:
                return(new BFakeResultTable(log, sql, properties));

            default:
                return(null);
            }
        }
Example #26
0
        public Box(uint pickId, BProperties bProperties, BoxPosition bPosition)
        {
            if (!bPosition.IsValid)
            {
                throw new GraphicsException("Invalid BoxPosition: can not create box");
            }
            _pickId = pickId;
            _dim[0] = bProperties.Length;
            _dim[1] = bProperties.Width;
            _dim[2] = bProperties.Height;

            _colors = bProperties.Colors;

            BoxProperties boxProperties = bProperties as BoxProperties;

            if (null != boxProperties)
            {
                List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                {
                    int iIndex = (int)tex.first;
                    if (null == _textureLists[iIndex])
                    {
                        _textureLists[iIndex] = new List <Texture>();
                    }
                    _textureLists[iIndex].Add(tex.second);
                }
                _showTape  = boxProperties.ShowTape;
                _tapeWidth = boxProperties.TapeWidth;
                _tapeColor = boxProperties.TapeColor;
            }

            // set position
            Position = bPosition.Position;
            // set direction length
            LengthAxis = HalfAxis.ToVector3D(bPosition.DirectionLength);
            // set direction width
            WidthAxis = HalfAxis.ToVector3D(bPosition.DirectionWidth);
            // IsBundle ?
            _isBundle = bProperties.IsBundle;
            if (bProperties.IsBundle)
            {
                BundleProperties bundleProp = bProperties as BundleProperties;
                if (null != bundleProp)
                {
                    _noFlats = bundleProp.NoFlats;
                }
            }
        }
Example #27
0
        public void Draw(Graphics2D graphics, BProperties bProperties, double height, bool selected)
        {
            graphics.NumberOfViews = 1;
            graphics.Graphics.Clear(selected ? Color.LightBlue : Color.White);
            graphics.SetViewport(0.0f, 0.0f, (float)_layer.PalletLength, (float)_layer.PalletWidth);

            if (_layer != null)
            {
                graphics.SetCurrentView(0);
                graphics.DrawRectangle(Vector2D.Zero, new Vector2D(_layer.PalletLength, _layer.PalletWidth), Color.Black);
                uint pickId = 0;
                foreach (LayerPosition bPosition in _layer)
                {
                    graphics.DrawBox(new Box(pickId++, bProperties, bPosition));
                }

                // draw axes
                bool showAxis = false;
                if (showAxis)
                {
                    // draw axis X
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(_layer.PalletLength, 0.0), Color.Red);
                    // draw axis Y
                    graphics.DrawLine(Vector2D.Zero, new Vector2D(0.0, _layer.PalletWidth), Color.Green);
                }
            }

            Size s = graphics.Size;

            // *** Annotate : begin ***
            string annotation = string.Format(
                "{0}*{1}={2}"
                , _layer.Count
                , _layer.NoLayers(height)
                , _layer.CountInHeight(height));
            Font         tfont           = new Font("Arial", _fontSize);
            Color        brushColor      = Color.White;
            Color        backgroundColor = Color.Black;
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Far;
            sf.LineAlignment = StringAlignment.Far;
            System.Drawing.Graphics g = graphics.Graphics;
            Size txtSize = g.MeasureString(annotation, tfont).ToSize();

            g.FillRectangle(new SolidBrush(backgroundColor), new Rectangle(s.Width - txtSize.Width - 2, s.Height - txtSize.Height - 2, txtSize.Width + 2, txtSize.Height + 2));
            g.DrawString(annotation, tfont, new SolidBrush(brushColor), new Point(s.Width - 3, s.Height - 3), sf);
            // *** Annotate : end ***
        }
        /// <summary>
        ///  Use this method when solution does not refer an analysis (e.g. when displaying CaseOptimizer result)
        /// </summary>
        public void Draw(Graphics3D graphics)
        {
            if (null == _boxCaseSolution)
            {
                throw new Exception("No box/case solution defined!");
            }

            BoxCaseAnalysis boxCaseAnalysis = _boxCaseSolution.Analysis;
            // retrieve case properties
            BProperties boxProperties = boxCaseAnalysis.BProperties;

            if (null == boxProperties)
            {
                return;
            }
            BoxProperties caseProperties = boxCaseAnalysis.CaseProperties;
            // draw case (inside)
            Case case_ = new Case(caseProperties);

            case_.DrawInside(graphics);
            // draw solution
            uint pickId = 0;

            foreach (ILayer layer in _boxCaseSolution)
            {
                BoxLayer blayer = layer as BoxLayer;
                if (null != blayer)
                {
                    foreach (BoxPosition bPosition in blayer)
                    {
                        graphics.AddBox(new Box(pickId++, boxProperties, bPosition));
                    }
                }
            }
            // get case analysis
            if (_showDimensions)
            {
                graphics.AddDimensions(new DimensionCube(
                                           Vector3D.Zero
                                           , caseProperties.Length, caseProperties.Width, caseProperties.Height
                                           , System.Drawing.Color.Black
                                           , true));
                graphics.AddDimensions(new DimensionCube(
                                           _boxCaseSolution.LoadBoundingBox
                                           , System.Drawing.Color.Red
                                           , false));
            }
        }
Example #29
0
 /// <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();
 }
Example #30
0
 public List <CasePalletSolution> Process(
     BoxProperties boxProperties, PalletProperties palletProperties,
     InterlayerProperties interlayerProperties, InterlayerProperties interlayerPropertiesAntiSlip,
     PalletConstraintSet constraintSet)
 {
     _bProperties                  = boxProperties;
     _palletProperties             = palletProperties;
     _interlayerProperties         = interlayerProperties;
     _interlayerPropertiesAntiSlip = interlayerPropertiesAntiSlip;
     _constraintSet                = constraintSet;
     // check constraint set validity
     if (!_constraintSet.IsValid)
     {
         throw new EngineException("Constraint set is invalid!");
     }
     // generate solutions
     return(GenerateSolutions());
 }
Example #31
0
        public Box(uint pickId, Packable packable)
        {
            _pickId = pickId;
            _dim[0] = packable.Length;
            _dim[1] = packable.Width;
            _dim[2] = packable.Height;

            _colors = Enumerable.Repeat <Color>(Color.Chocolate, 6).ToArray();

            BProperties bProperties = packable as BProperties;

            if (null != bProperties)
            {
                _colors = bProperties.Colors;

                // IsBundle ?
                _isBundle = bProperties.IsBundle;
                if (_isBundle)
                {
                    _noFlats = (bProperties as BundleProperties).NoFlats;
                }
                // textures
                BoxProperties boxProperties = bProperties as BoxProperties;
                if (null != boxProperties)
                {
                    List <Pair <HalfAxis.HAxis, Texture> > textures = boxProperties.TextureList;
                    foreach (Pair <HalfAxis.HAxis, Texture> tex in textures)
                    {
                        int iIndex = (int)tex.first;
                        if (null == _textureLists[iIndex])
                        {
                            _textureLists[iIndex] = new List <Texture>();
                        }
                        _textureLists[iIndex].Add(tex.second);
                    }
                    // tape
                    _showTape  = boxProperties.ShowTape;
                    _tapeWidth = boxProperties.TapeWidth;
                    _tapeColor = boxProperties.TapeColor;
                }
            }
        }
Example #32
0
        private void DrawBoxPosition(BProperties boxProperties, HalfAxis.HAxis axis, PictureBox pictureBox)
        {
            // get horizontal angle
            double angle = 45;
            // instantiate graphics
            Graphics3DImage graphics = new Graphics3DImage(pictureBox.Size)
            {
                CameraPosition = new Vector3D(
                    Math.Cos(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 100000.0
                    , Math.Sin(angle * Math.PI / 180.0) * Math.Sqrt(2.0) * 100000.0
                    , 10000.0),
                Target = Vector3D.Zero
            };

            graphics.SetViewport(-500.0f, -500.0f, 500.0f, 500.0f);
            // draw
            Box box = new Box(0, boxProperties);

            // set axes
            HalfAxis.HAxis lengthAxis = HalfAxis.HAxis.AXIS_X_P;
            HalfAxis.HAxis widthAxis  = HalfAxis.HAxis.AXIS_Y_P;
            switch (axis)
            {
            case HalfAxis.HAxis.AXIS_X_P: lengthAxis = HalfAxis.HAxis.AXIS_Z_P; widthAxis = HalfAxis.HAxis.AXIS_X_P; break;

            case HalfAxis.HAxis.AXIS_Y_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Z_N; break;

            case HalfAxis.HAxis.AXIS_Z_P: lengthAxis = HalfAxis.HAxis.AXIS_X_P; widthAxis = HalfAxis.HAxis.AXIS_Y_P; break;

            default: break;
            }
            box.HLengthAxis = lengthAxis;
            box.HWidthAxis  = widthAxis;

            // draw box
            graphics.AddBox(box);
            graphics.Flush();
            // set to picture box
            pictureBox.Image = graphics.Bitmap;
        }
Example #33
0
        private Layer2D GenerateBestLayer(
            BProperties bProperties, PalletProperties palletProperties, PalletCornerProperties cornerProperties,
            PalletConstraintSet constraintSet, HalfAxis.HAxis hAxis)
        {
            Layer2D bestLayer = null;

            // loop through all patterns
            foreach (LayerPatternBox pattern in LayerPatternBox.All)
            {
                // is pattern allowed
                if (!_constraintSet.AllowPattern(pattern.Name))
                {
                    continue;
                }

                // direction 1
                Layer2D layer1 = BuildLayer(bProperties, palletProperties, cornerProperties,
                                            constraintSet, hAxis, false, false);
                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)
                Layer2D layer2 = BuildLayer(bProperties, palletProperties, cornerProperties,
                                            constraintSet, HalfAxis.Opposite(hAxis), false, false);
                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);
        }
Example #34
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for logging.</param>
        public BFakeResultTable(ILogger log, string sql, BProperties properties)
            : base(log, sql, properties)
        {
            //set parameters
            LogUtilities.LogFunctionEntrance(Log, log);
            m_Properties = properties;
            Sql = sql;

            //init the columns
            try
            {
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    m_TableColumns = client.GetMetadataColumns();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
            //make the fake data
            InitializeFakeData(Sql);
        }
Example #35
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for logging.</param>
        public BFakeResultTable(ILogger log, string sql, BProperties properties)
            : base(log, sql, properties)
        {
            //set parameters
            LogUtilities.LogFunctionEntrance(Log, log);
            m_Properties = properties;
            Sql          = sql;

            //init the columns
            try
            {
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    m_TableColumns = client.GetMetadataColumns();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
            //make the fake data
            InitializeFakeData(Sql);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for this metadata source.</param>
        public BTablesMetadataSource(ILogger log, BProperties properties)
        {
            LogUtilities.LogFunctionEntrance(log, log);
            Log = log;
            m_Properties = properties;

            try
            {
                //get the client connection
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    //get the tables
                    TableMetadataResult[] tables = client.GetMetadataTables();

                    //copy results
                    tables.ToList().ForEach(t =>
                        {
                            m_Tables.Add(new TableMetadata()
                            {
                                Catalog = t.Catalog,
                                Table = t.Table,
                                Remarks = t.Table
                            });
                        });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }


            ////Mentions
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "Mentions",
            //    Remarks = "Mentions"
            //});
            ////Tags
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "Tags",
            //    Remarks = "Tags"
            //});
            ////Datasources
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "Datasources",
            //    Remarks = "Datasources"
            //});
            ////Themes
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "Themes",
            //    Remarks = "Themes"
            //});
            ////TagMentions
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "TagMentions",
            //    Remarks = "TagMentions"
            //});
            ////DatasourceMentions
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "DatasourceMentions",
            //    Remarks = "DatasourceMentions"
            //});
            ////ThemeMentions
            //m_Tables.Add(new TableMetadata()
            //{
            //    Catalog = Driver.B_CATALOG,
            //    Table = "ThemeMentions",
            //    Remarks = "ThemeMentions"
            //});
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="log">The logger to use for this metadata source.</param>
        public BColumnsMetadataSource(ILogger log, BProperties properties)
        {
            LogUtilities.LogFunctionEntrance(log, log);
            Log = log;
            m_Properties = properties;

            //InitializeData();
            //List<ColumnInfo> column_infos = new List<ColumnInfo>();
            //column_infos.AddRange(m_Columns);
            //m_Columns.Clear();
            
            try
            {
                //get the client connection
                using (var client = ExternalServiceClient.GetClient(m_Properties.Server))
                {
                    //get the columns
                    ColumnMetadataResult[] columns = client.GetMetadataColumns();

                    //copy results
                    columns.ToList().Where(c => c.Visible).ToList().ForEach(c =>
                    {
                        //if(c.Table == "Mentions" &&
                        //    (
                        //        c.Column == "Id" ||
                        //        c.Column == "Name" || 
                        //        c.Column == "Description" ||
                        //        c.Column == "Type" ||
                        //        c.Column == "Sentiment" ||
                        //        c.Column == "Influence" ||
                        //        c.Column == "IsDisabled" ||
                        //        c.Column == "OccurredOn" ||
                        //        c.Column == "CreatedOn" ||
                        //        c.Column == "UpdatedOn" ||
                        //        c.Column == "Guid" ||
                        //        c.Column == "Author" ||
                        //        c.Column == "Followers" ||
                        //        c.Column == "Klout" ||
                        //        c.Column == "Comments" 
                        //    ))
                        {
                            m_Columns.Add(
                                GetColumnInfo(
                                    c.Catalog, 
                                    c.Table, 
                                    c.Column, 
                                    c.DataType, 
                                    c.ColumnLength,
                                    c.Nullable, 
                                    c.OrdinalPosition, 
                                    c.ColumnPrecision));
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
            
            
        }
Example #38
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="statement">The parent statement of the data engine.</param>
 public BDataEngine(IStatement statement, BProperties properties) : base(statement)
 {
     LogUtilities.LogFunctionEntrance(Statement.Connection.Log, statement);
     m_Properties = properties;
 }