Esempio n. 1
0
        private void OnBinIndexChanged(object sender, EventArgs e)
        {
            int binIndex = cbPalletIndex.SelectedIndex;

            if (-1 == binIndex)
            {
                pbPalletIndex.Image = null;
                return;
            }
            try
            {
                DateTime dt0 = DateTime.Now;
                _log.Info($"Calling web service method {binIndex}");

                using (var client = new StackBuilderClient())
                {
                    var hSolItem = client.SB_GetHSolutionPart(
                        Items.ToArray(),
                        new DCSBPallet()
                    {
                        Name        = "EUR2",
                        Description = "EUR2",
                        PalletType  = "EUR2",
                        Color       = Color.Yellow.ToArgb(),
                        Dimensions  = PalletDimensions,
                        Weight      = PalletWeight
                    },
                        new DCSBHConstraintSet()
                    {
                        MaxHeight = new DCSBConstraintDouble()
                        {
                            Active = true, Value_d = MaxPalletHeight
                        },
                        MaxWeight = new DCSBConstraintDouble()
                        {
                            Active = false, Value_d = 1000.0
                        },
                        Overhang = PalletOverhang
                    },
                        0, // solution index
                        binIndex,
                        new DCCompFormat()
                    {
                        Size = new DCCompSize()
                        {
                            CX = pbPalletIndex.Size.Width,
                            CY = pbPalletIndex.Size.Height
                        },
                        Format = OutFormat.IMAGE
                    },
                        true
                        );
                    var               bboxLoad    = hSolItem.BBoxLoad;
                    var               bboxTotal   = hSolItem.BBoxTotal;
                    double            weightLoad  = hSolItem.WeightLoad;
                    double            weightTotal = hSolItem.WeightTotal;
                    DCSBContentItem[] content     = hSolItem.Content;

                    if (null != hSolItem.OutFile)
                    {
                        using (var ms = new System.IO.MemoryStream(hSolItem.OutFile.Bytes))
                        {
                            Image img = Image.FromStream(ms);
                            pbPalletIndex.Image = img;
                        }
                    }
                    var sb = new StringBuilder();
                    // pallet load dims
                    sb.AppendLine($"Load dim.   : {hSolItem.BBoxLoad.M0} x {hSolItem.BBoxLoad.M1} x {hSolItem.BBoxLoad.M2}");
                    // pallet outer dims
                    sb.AppendLine($"Outer dim.  : {hSolItem.BBoxTotal.M0} x {hSolItem.BBoxTotal.M1} x {hSolItem.BBoxTotal.M2}");
                    // pallet load weight
                    sb.AppendLine($"Load weight : {hSolItem.WeightLoad}");
                    // pallet total weight
                    sb.AppendLine($"Load height : {hSolItem.WeightTotal}");

                    rtbPalletData.Text = sb.ToString();
                }

                DateTime dt1 = DateTime.Now;
                _log.Info($"Web service answered in {(dt1 - dt0).TotalMilliseconds} ms");
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }
Esempio n. 2
0
        private void OnCompute(object sender, EventArgs e)
        {
            try
            {
                using (StackBuilderClient client = new StackBuilderClient())
                {
                    DCSBSolution sol = null;

                    if (tabCtrlContent.SelectedIndex == 0 && tabCtrlContainer.SelectedIndex == 0)
                    {
                        sol = client.SB_GetCasePalletBestSolution(
                            new DCSBCase()
                        {
                            Name            = "Case",
                            Description     = "Default case",
                            DimensionsOuter = OuterDimensions,
                            HasInnerDims    = false,
                            DimensionsInner = null,
                            Weight          = CaseWeight,
                            MaxWeight       = 100.0,
                            NetWeight       = 0.9 * CaseWeight,
                            ShowTape        = true,
                            TapeWidth       = 50.0,
                            TapeColor       = Color.Beige.ToArgb(),
                            Colors          = new int[6]
                            {
                                Color.Chocolate.ToArgb(), Color.Chocolate.ToArgb(),
                                Color.Chocolate.ToArgb(), Color.Chocolate.ToArgb(),
                                Color.Chocolate.ToArgb(), Color.Chocolate.ToArgb()
                            }
                        }
                            , new DCSBPallet()
                        {
                            Name        = "EUR2",
                            Description = "EUR2",
                            PalletType  = "EUR2",
                            Color       = Color.Yellow.ToArgb(),
                            Dimensions  = PalletDimensions,
                            Weight      = PalletWeight
                        }
                            , null
                            , new DCSBConstraintSet()
                        {
                            Overhang    = PalletOverhang,
                            Orientation = new DCSBBool3()
                            {
                                X = AllowOrientX, Y = AllowOrientY, Z = AllowOrientZ
                            },
                            MaxHeight = new DCSBConstraintDouble()
                            {
                                Active = true, Value_d = MaxPalletHeight
                            },
                            MaxWeight = new DCSBConstraintDouble()
                            {
                                Active = false, Value_d = 1000.0
                            },
                            MaxNumber = new DCSBConstraintInt()
                            {
                                Active = false, Value_i = 100
                            },
                            AllowMultipleLayerOrientations = this.AllowMultipleLayerOrientations
                        }
                            , new DCCompFormat()
                        {
                            Size = new DCCompSize()
                            {
                                CX = pbStackbuilder.Size.Width,
                                CY = pbStackbuilder.Size.Height
                            },
                            Format = OutFormat.IMAGE
                        }
                            , true
                            );
                    }
                    else if (tabCtrlContent.SelectedIndex == 1 && tabCtrlContainer.SelectedIndex == 0)
                    {
                        sol = client.SB_GetBundlePalletBestSolution(
                            new DCSBBundle()
                        {
                            Name           = "Bundle",
                            Description    = "Bundle",
                            DimensionsUnit = FlatDimensions,
                            UnitWeight     = FlatWeight,
                            Number         = NumberOfFlats,
                            Color          = Color.Beige.ToArgb()
                        }
                            , new DCSBPallet()
                        {
                            Name        = "EUR2",
                            Description = "EUR2",
                            PalletType  = "EUR2",
                            Color       = Color.Yellow.ToArgb(),
                            Dimensions  = PalletDimensions,
                            Weight      = PalletWeight,
                        }
                            , null
                            , new DCSBConstraintSet()
                        {
                            Overhang    = PalletOverhang,
                            Orientation = new DCSBBool3()
                            {
                                X = false, Y = false, Z = true
                            },
                            MaxHeight = new DCSBConstraintDouble()
                            {
                                Active = true, Value_d = MaxPalletHeight
                            },
                            MaxWeight = new DCSBConstraintDouble()
                            {
                                Active = false, Value_d = 1000.0
                            },
                            MaxNumber = new DCSBConstraintInt()
                            {
                                Active = false, Value_i = 100
                            }
                        }
                            , new DCCompFormat()
                        {
                            Size = new DCCompSize()
                            {
                                CX = pbStackbuilder.Size.Width,
                                CY = pbStackbuilder.Size.Height
                            },
                            Format = OutFormat.IMAGE
                        }
                            , true
                            );
                    }
                    else if (tabCtrlContent.SelectedIndex == 0 && tabCtrlContainer.SelectedIndex == 1)
                    {
                        sol = client.SB_GetBoxCaseBestSolution(
                            new DCSBCase()
                        {
                            Name            = "Box",
                            Description     = "Box",
                            DimensionsOuter = OuterDimensions,
                            HasInnerDims    = false,
                            DimensionsInner = null,
                            Weight          = CaseWeight,
                            MaxWeight       = 1.0,
                            NetWeight       = 0.9 * CaseWeight,
                            ShowTape        = false,
                            Colors          = Enumerable.Repeat <int>(Color.Turquoise.ToArgb(), 6).ToArray()
                        }
                            , new DCSBCase()
                        {
                            Name            = "Case",
                            Description     = "Case",
                            HasInnerDims    = true,
                            DimensionsOuter = null,
                            DimensionsInner = InnerDimensions,
                            Colors          = Enumerable.Repeat <int>(Color.Chocolate.ToArgb(), 6).ToArray()
                        }
                            , null
                            , new DCSBConstraintSet()
                        {
                            Orientation = new DCSBBool3()
                            {
                                X = AllowOrientX, Y = AllowOrientY, Z = AllowOrientZ
                            },
                            MaxWeight = new DCSBConstraintDouble()
                            {
                                Active = false, Value_d = 1000.0
                            },
                            MaxNumber = new DCSBConstraintInt()
                            {
                                Active = false, Value_i = 100
                            },
                            AllowMultipleLayerOrientations = AllowMultipleLayerOrientations
                        }
                            , new DCCompFormat()
                        {
                            Size = new DCCompSize()
                            {
                                CX = pbStackbuilder.Size.Width,
                                CY = pbStackbuilder.Size.Height
                            },
                            Format = OutFormat.IMAGE
                        }
                            , true
                            );
                    }
                    else if (tabCtrlContent.SelectedIndex == 1 && tabCtrlContainer.SelectedIndex == 1)
                    {
                        sol = client.SB_GetBundleCaseBestSolution(
                            new DCSBBundle()
                        {
                            Name           = "Bundle",
                            Description    = "Bundle",
                            DimensionsUnit = FlatDimensions,
                            UnitWeight     = FlatWeight,
                            Number         = NumberOfFlats,
                            Color          = Color.Beige.ToArgb()
                        }
                            , new DCSBCase()
                        {
                            Name            = "Case",
                            Description     = "Case",
                            HasInnerDims    = true,
                            DimensionsOuter = null,
                            DimensionsInner = InnerDimensions,
                            Colors          = Enumerable.Repeat <int>(Color.Chocolate.ToArgb(), 6).ToArray()
                        }
                            , new DCSBConstraintSet()
                        {
                            Orientation = new DCSBBool3()
                            {
                                X = false, Y = false, Z = true
                            },
                            MaxWeight = new DCSBConstraintDouble()
                            {
                                Active = false, Value_d = 1000.0
                            },
                            MaxNumber = new DCSBConstraintInt()
                            {
                                Active = false, Value_i = 100
                            }
                        }
                            , new DCCompFormat()
                        {
                            Size = new DCCompSize()
                            {
                                CX = pbStackbuilder.Size.Width,
                                CY = pbStackbuilder.Size.Height
                            },
                            Format = OutFormat.IMAGE
                        }
                            , true
                            );
                    }
                    if (null != sol)
                    {
                        foreach (string err in sol.Errors)
                        {
                            ToRtb(err);
                        }
                        if (sol.Errors.Length > 0)
                        {
                            return;
                        }
                    }
                    else
                    {
                        ToRtb("Call to SB_GetBestSolution failed... : sol == null");
                        return;
                    }
                    // output
                    // image
                    pbStackbuilder.Image = null;
                    if (null != sol.OutFile)
                    {
                        using (var ms = new System.IO.MemoryStream(sol.OutFile.Bytes))
                        {
                            Image img = Image.FromStream(ms);
                            pbStackbuilder.Image = img;
                        }
                    }
                    // case count
                    CaseCount         = sol.CaseCount;
                    TotalPalletWeight = sol.WeightTotal;
                    PalletEfficiency  = sol.Efficiency;
                    if (null != sol.BBoxLoad)
                    {
                        BBoxTotal = sol.BBoxTotal;
                    }
                    if (null != sol.PalletMapPhrase)
                    {
                        PalletMapPhrase = sol.PalletMapPhrase;
                    }
                }
            }
            catch (Exception ex)
            {
                ToRtb(ex.ToString());
            }
        }
Esempio n. 3
0
        private void OnCompute(object sender, EventArgs e)
        {
            try
            {
                DateTime dt0 = DateTime.Now;
                using (StackBuilderClient client = new StackBuilderClient())
                {
                    _log.Info($"Calling web service method");

                    var hSolution = client.SB_GetHSolutionBestCasePallet(
                        Items.ToArray(),
                        new DCSBPallet()
                    {
                        Name        = "EUR2",
                        Description = "EUR2",
                        PalletType  = "EUR2",
                        Color       = Color.Yellow.ToArgb(),
                        Dimensions  = PalletDimensions,
                        Weight      = PalletWeight
                    },
                        new DCSBHConstraintSet()
                    {
                        MaxHeight = new DCSBConstraintDouble()
                        {
                            Active = true, Value_d = MaxPalletHeight
                        },
                        MaxWeight = new DCSBConstraintDouble()
                        {
                            Active = false, Value_d = 1000.0
                        },
                        Overhang = PalletOverhang
                    },
                        new DCCompFormat()
                    {
                        Size = new DCCompSize()
                        {
                            CX = pbStackbuilder.Size.Width,
                            CY = pbStackbuilder.Size.Height
                        },
                        Format = OutFormat.IMAGE
                    },
                        false
                        );

                    // image
                    pbStackbuilder.Image = null;
                    if (null != hSolution.OutFile)
                    {
                        using (var ms = new System.IO.MemoryStream(hSolution.OutFile.Bytes))
                        {
                            Image img = Image.FromStream(ms);
                            pbStackbuilder.Image = img;
                        }
                    }

                    lbPalletCount.Text = $"out of {hSolution.PalletCount}";
                    cbPalletIndex.Items.Clear();
                    for (int i = 0; i < hSolution.PalletCount; ++i)
                    {
                        cbPalletIndex.Items.Add($"{i+1}");
                    }
                    cbPalletIndex.SelectedIndex = 0;

                    DateTime dt1 = DateTime.Now;
                    _log.Info($"Web service answered in {(dt1 - dt0).TotalMilliseconds} ms");
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
        }