public UInt16 chooseIndex(UInt16 max, PickMethod pickmet)
        {
            UInt16 index = 0;

            switch (pickmet)
            {
            case PickMethod.Cyclic:
                CyclePick = (UInt16)((CyclePick + 1) % max);
                index     = CyclePick;
                break;

            case PickMethod.Random:
                Random random = new Random((int)DateTime.Now.Ticks & (0x0000FFFF));
                index = (UInt16)(random.Next(max - 1));
                break;

            case PickMethod.Oldest:
                index = 0;
                break;

            case PickMethod.Newest:
            default:
                if (max >= 1)
                {
                    index = (UInt16)(max - 1);
                }
                else
                {
                    index = 0;
                }

                break;
            }
            return(index);
        }
示例#2
0
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();

            this.Window.AllowUserResizing = true;

            IsMouseVisible = true;

            methodArray = (PickMethod[])Enum.GetValues(typeof(PickMethod));

            picking        = PickMethod.Newest;
            mazeW          = 20;
            mazeH          = 18;
            backgroundsW   = 500;
            backgroundsH   = 400;
            holesCount     = 0;
            holesMaxRadius = 0;

            layoutIndex = 0;

            mlayout = new Layout(mazeW, mazeH);

            aMazIng = new Maze(mazeW, mazeH, mlayout, 0, 0, PickMethod.Cyclic);
            aMazIng.GenerateTWMaze_GrowingTree(picking);

            //aMazIng.dumpMaze();

            base.Initialize();
        }
示例#3
0
        //Obtiene el Stock de un producto, Ubicacion, cantodad segun un metodo (ZONE, LIFO, FIFO)
        public String GetStrProductStock(ProductStock productStock, PickMethod pickMethod)
        {
            //Query sobre label entity de tipo producto y activa, sacando la unidad base
            //Order tue query over  ZONE, FIFO, LIFO , FEFO segun el PickingMethod

            string result = "";

            //Label label = new Label
            //{
            //    Product = product,
            //    Bin = bin
            //};

            IList <ProductStock> list = Factory.DaoLabel().GetStock(productStock, pickMethod, 20);

            if (list == null || list.Count == 0)
            {
                return("");
            }

            foreach (ProductStock ps in list)
            {
                result += ps.Bin.BinCode + "(" + ps.Stock.ToString() + "), ";
            }

            return(result);
        }
示例#4
0
        public static IMain Map(PickMethod method)
        {
            switch (method)
            {
            case PickMethod.NlMeans:
                return(new NlMeans.Start());

            case PickMethod.NlMeansColored:
                return(new NlMeansColored.Start());

            case PickMethod.Dct:
                return(new Dct.Start());

            case PickMethod.TVL1:
                return(new Tvl1.Start());

            case PickMethod.DFTForward:
                return(null);

            case PickMethod.DFTInverse:
                return(null);

            case PickMethod.Prida:
                return(new Prida.Start());

            case PickMethod.Bm3d:
                //NOTE: This algorithm is patented and is excluded in this configuration;
                // Set OPENCV_ENABLE_NONFREE CMake option and rebuild the library
                return(null);                // new Bm3d.Start();
            }
            return(null);
        }
示例#5
0
        public override IQuery GetHsql(Object data)
        {
            StringBuilder sql        = new StringBuilder("select a from PickMethod a    where  ");
            PickMethod    PickMethod = (PickMethod)data;

            if (PickMethod != null)
            {
                Parms = new List <Object[]>();
                if (PickMethod.MethodID != 0)
                {
                    sql.Append(" a.MethodID = :id     and   ");
                    Parms.Add(new Object[] { "id", PickMethod.MethodID });
                }

                if (!String.IsNullOrEmpty(PickMethod.Name))
                {
                    sql.Append(" a.Name = :nom     and   ");
                    Parms.Add(new Object[] { "nom", PickMethod.Name });
                }

                if (PickMethod.Active != null)
                {
                    sql.Append(" a.Active = :act and ");
                    Parms.Add(new Object[] { "act", PickMethod.Active });
                }
            }

            sql = new StringBuilder(sql.ToString());
            sql.Append("1=1 order by a.MethodID asc ");
            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);
            return(query);
        }
示例#6
0
        public void Pick_Character_RunsWithoutError(PickMethod pickMethod)
        {
            // THIS TEST IS TO MAKE SURE THIS REUSABLE FUNCTION WORKS.
            SetUpForPickCharacter();

            Action pickCharacter = () => Pick.Character(new List <Character>(), fileData, pickMethod, null);

            Assert.DoesNotThrow(() => pickCharacter());
        }
示例#7
0
        //[TestCase(PickMethod.Reuse)] // IF THERE ARE NO CHARACTERS IN THE STORY, THIS TEST CASE WILL ALWAYS RETURN NULL.
        public void Pick_Character_ReturnsNotNull(PickMethod pickMethod)
        {
            // THIS TEST IS TO MAKE SURE THIS REUSABLE FUNCTION WORKS.
            SetUpForPickCharacter();

            var character = Pick.Character(new List <Character>(), fileData, pickMethod, null);

            Assert.IsNotNull(character);
        }
示例#8
0
        public IList <PickMethod> Select(PickMethod data)
        {
            IList <PickMethod> datos = new List <PickMethod>();

            datos = GetHsql(data).List <PickMethod>();
            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }
            return(datos);
        }
示例#9
0
        private bool KitCycle    = true; // true = increase, false = decrease

        // create a random maze, with a starting position eventually
        public Maze(UInt16 width, UInt16 length, Layout layout = null, UInt16 startx = 0, UInt16 starty = 0, PickMethod pimet = PickMethod.Newest, Byte holes = 0, byte maxradius = 0)
        {
            Debug.Print(string.Format("C: W={0} L={1}", width, length));

            this.width  = width;
            this.length = length;

            this.layout = layout;

            this.holes          = holes;
            this.holesMaxRadius = maxradius;

            pickMethod = pimet;

            maze = BuildBaseMaze(this.width, this.length, this.layout, this.holes, this.holesMaxRadius);
        }
示例#10
0
        public static void Usage(PickMethod method = PickMethod.None)
        {
            StringBuilder sb   = new StringBuilder();
            string        name = nameof(ImageOpenCV);

            sb
            .WL()
            .WL(0, $"Usage {name} (method) [options]")
            .WL(0, "Options:")
            .WL(1, "-h / --help", "Show full help")
            .WL(1, "(method) -h", "Method specific help")
            .WL(1, "--methods", "List possible methods")
            ;

            if (ShowFullHelp)
            {
                foreach (PickMethod a in Aids.EnumAll <PickMethod>())
                {
                    IMain func = Registry.Map(a);
                    func?.Usage(sb);
                }
            }
            else if (method != PickMethod.None)
            {
                IMain func = Registry.Map(method);
                func?.Usage(sb);
            }
            else
            {
                if (ShowHelpMethods)
                {
                    sb
                    .WL()
                    .WL(0, "Methods:")
                    .PrintEnum <PickMethod>(1)
                    ;
                }
            }

            Log.Message(sb.ToString());
        }
示例#11
0
 public void DeletePickMethod(PickMethod data)
 {
     try
     {
         SetService(); SerClient.DeletePickMethod(data);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
示例#12
0
 public PickMethod SavePickMethod(PickMethod data)
 {
     try
     {
         SetService(); return SerClient.SavePickMethod(data);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
示例#13
0
        public IList <ProductStock> GetDocumentSuggestedBins(Document document, Location location, PickMethod pickMethod)
        {
            string initQuery = "SELECT l.ProductID, l.UnitID, l.BinID, l.SingleQuantity AS Stock,  l.PackQuantity as PackStock, l.MaxDate, l.MinDate "
                               + "FROM vwStockSummary AS l INNER JOIN Trace.DocumentLine dl ON dl.ProductID = l.ProductID " +
                               " Where (l.SingleQuantity > 0 Or l.PackQuantity > 0) And l.NodeID = :nid And l.StatusID = :sid ";


            StringBuilder sql = new StringBuilder(initQuery);

            Parms = new List <Object[]>();


            Parms.Add(new Object[] { "nid", NodeType.Stored });
            Parms.Add(new Object[] { "sid", EntityStatus.Active });

            if (document != null && document.DocID != 0)
            {
                sql.Append(" and dl.DocID = :id1 ");
                Parms.Add(new Object[] { "id1", document.DocID });
            }

            if (location != null && location.LocationID != 0)
            {
                sql.Append(" and l.LocationID = :id2 ");
                Parms.Add(new Object[] { "id2", location.LocationID });
            }



            if (pickMethod == null || pickMethod.MethodID == PickingMethod.FIFO)
            {
                sql.Append(" order by  l.MinDate");
            }

            else if (pickMethod.MethodID == PickingMethod.LIFO)
            {
                sql.Append(" order by  l.MaxDate DESC");
            }

            else if (pickMethod.MethodID == PickingMethod.ZONE)
            {
                sql.Append(" order by  l.BinID");
            }

            //else if (pickMethod == PickingMethod.FEFO)
            //sql.Append(" order by  ExpirationDate DESC");


            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());

            SetParameters(query);

            query.SetMaxResults(WmsSetupValues.DefaultBinsToShow);

            IList <ProductStock> ret = GetProductStockObject(query.List <Object[]>(), Factory);

            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }

            return(ret);
        }
示例#14
0
        /// <summary>
        /// Retorna una lista de objetos que contienen las ubicaciones de producto en bodega,
        /// producto,cantidad en unidad base
        /// </summary>
        /// <param name="data"></param>
        /// <param name="records">Numero de registros a devolver</param>
        /// <returns></returns>
        public IList <ProductStock> GetStock(ProductStock data, PickMethod pickMethod, int records)
        {
            //Sale solo product, y del nodo stored
            string initQuery = "select p.ProductID, p.BaseUnitID, b.BinID, SUM(CASE WHEN l.Printed = 0 THEN l.CurrQty*u.BaseAmount ELSE 0 END) AS Stock,"
                               + " SUM(CASE WHEN l.Printed = 1 THEN l.CurrQty*u.BaseAmount ELSE 0 END) as PackStock, Max(l.CreationDate) as MaxDate, Min(l.CreationDate) as MinDate " +
                               " from Trace.Label l inner join Master.Product p on l.ProductID = p.ProductID " +
                               " Inner Join Master.Unit u On l.UnitID = u.UnitID Inner Join Master.Bin b On l.BinID = b.BinID " +
                               " where l.CurrQty > 0 AND (l.LabelTypeID = :lt1 OR l.LabelTypeID = :lsn1)  AND l.NodeID = :nd1 AND l.StatusID = :st1 ";

            StringBuilder sql = new StringBuilder(initQuery);

            Parms = new List <Object[]>();

            Parms.Add(new Object[] { "lt1", LabelType.ProductLabel });
            Parms.Add(new Object[] { "lsn1", LabelType.UniqueTrackLabel });
            Parms.Add(new Object[] { "nd1", NodeType.Stored });
            Parms.Add(new Object[] { "st1", EntityStatus.Active });


            if (data.Product != null && data.Product.ProductID != 0)
            {
                sql.Append(" and p.ProductID = :id1 ");
                Parms.Add(new Object[] { "id1", data.Product.ProductID });
            }


            if (data.Bin != null)
            {
                if (data.Bin.BinID != 0)
                {
                    sql.Append(" and b.BinID = :id8 ");
                    Parms.Add(new Object[] { "id8", data.Bin.BinID });
                }

                if (!string.IsNullOrEmpty(data.Bin.BinCode))
                {
                    sql.Append(" and b.BinCode = :idz2 ");
                    Parms.Add(new Object[] { "idz2", data.Bin.BinCode });
                }

                if (data.Bin.Location != null && data.Bin.Location.LocationID != 0)
                {
                    sql.Append(" and b.LocationID = :id10 ");
                    Parms.Add(new Object[] { "id10", data.Bin.Location.LocationID });
                }
            }


            sql = new StringBuilder(sql.ToString());
            sql.Append(" group by  p.ProductID, p.BaseUnitID, b.BinID ");


            //Order By Picking Method

            if (pickMethod == null || pickMethod.MethodID == PickingMethod.FIFO)
            {
                sql.Append(" order by  MinDate");
            }

            else if (pickMethod.MethodID == PickingMethod.LIFO)
            {
                sql.Append(" order by  MaxDate DESC");
            }

            //else if (pickMethod.MethodID == PickingMethod.ZONE)
            //sql.Append(" order by  b.ZoneID, b.Rank");

            //else if (pickMethod == PickingMethod.FEFO)
            //    sql.Append(" order by  ExpirationDate DESC");



            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());

            SetParameters(query);

            query.SetMaxResults(records);

            IList <ProductStock> ret = GetProductStockObject(query.List <Object[]>(), Factory);

            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }

            return(ret);
        }
示例#15
0
 public static string MethodName(PickMethod m)
 {
     return($"{(int)m}. {m}");
 }
示例#16
0
 public static string GetOutputName(PickMethod m)
 {
     return($"{m}-{DateTime.Now.ToString("yyyyMMdd-hhmmss")}.png");
 }
示例#17
0
 public Boolean Update(PickMethod data)
 {
     return(base.Update(data));
 }
示例#18
0
        public UInt16 chooseIndex(UInt16 max, PickMethod pickmet)
        {
            UInt16 index = 0;

            //bool skip = false;

            switch (pickmet)
            {
            case PickMethod.Cyclic:
                CyclePick = (UInt16)((CyclePick + 1) % max);
                index     = CyclePick;
                break;

            case PickMethod.Random:
                // use class random object ! ~rand1/rand2 (1=use class object, 2=create a new one every time !)
                //Random random = new Random((int)DateTime.Now.Ticks & (0x0000FFFF));
                index = (UInt16)(random.Next(max - 1));
                break;

            case PickMethod.Oldest:
                index = 0;
                break;

            case PickMethod.Kit:
                // Kit from KinghtRaider show, cycle from 0 to max then max to 0 and so on back and forth
                // instead of the other cyclic method above which do a 0 to max, 0 to max, 0 to max, ...
                if (CyclePick < max - 1 && KitCycle == true)
                {
                    CyclePick++;
                }

                if (CyclePick > 0 && KitCycle == false)
                {
                    CyclePick--;
                }

                if (CyclePick >= max - 1)
                {
                    KitCycle = false;
                }
                if (CyclePick <= 0)
                {
                    KitCycle = true;
                }

                index = CyclePick;
                //Debug.Print(string.Format("idx={0} (max={1})", index, max));
                break;

            case PickMethod.Collapse:
            //todo
            case PickMethod.Newest:
            default:
                if (max >= 1)
                {
                    index = (UInt16)(max - 1);
                }
                else
                {
                    index = 0;
                }

                break;
            }
            return(index);
        }
示例#19
0
        public void GenerateTWMaze_GrowingTree(PickMethod pmethod = PickMethod.Newest)
        {
            List <UInt16[]> cells = new List <UInt16[]>();

            Array DirectionArray = Enum.GetValues(typeof(Direction));

            // Pick starting cell
            //Random random = new Random((int)DateTime.Now.Ticks & (0x0000FFFF));

            UInt16 x = (Byte)(random.Next(maze.GetLength(0) - 1) + 1);
            UInt16 y = (Byte)(random.Next(maze.GetLength(1) - 1) + 1);
            Int16  nx;
            Int16  ny;

            cells.Add(new UInt16[2] {
                x, y
            });

            while (cells.Count > 0)
            {
                //Debug.Print("=== CELL LOOP BEGIN ===");

                //choose index: 0 = older, cells.count = newest
                Int16    index       = (Int16)chooseIndex((UInt16)cells.Count, pmethod);
                UInt16[] cell_picked = cells[index];

                //use x,y as coord of current cell !
                x = cell_picked[0];
                y = cell_picked[1];
                //Debug.Print(string.Format("picked cell=[{0},{1}] Cells[{2}]", x, y, cells.Count));

                Direction[] tmpdir = RandomizeDirection();

                foreach (Direction way in tmpdir)  //shuffled dir
                //foreach (Direction way in DirectionArray) //    Enum.GetValues(typeof(Direction)))    //sequential dir, for test
                {
                    //Debug.Print(string.Format("DIRLOOP= Explore way {0}", way.ToString()));

                    //take a random dir
                    //Direction way = chooseARandomDirection();

                    //get an unvisited neighbor
                    // "go" to the random dir, if cell == 0 proceed
                    SByte[] move = DoAStep(way);

                    nx = (Int16)(x + move[0]);
                    ny = (Int16)(y + move[1]);

                    //Debug.Print(string.Format("chosen cell [{0}][{1}]", nx, ny));
                    //Debug.Print(string.Format("nx={0} ny={1}", nx, ny));

                    //if (nx >= 0 && ny >= 0 && nx < maze.GetLength(0) && ny < maze.GetLength(1))
                    //{
                    //    Debug.Print(string.Format("maze[nx,ny]={0}", maze[nx, ny]));
                    //}

                    // code need to be slowed down to generate good mazes !
                    // random method is bad, time dependant !!!
                    //for (int dumy = 0; dumy < 500000; dumy++)
                    //{ }

                    if (nx >= 0 && ny >= 0 && nx < maze.GetLength(0) && ny < maze.GetLength(1) && maze[nx, ny] == 0)
                    {
                        //Debug.Print(string.Format("xy=[{0},{1}] Unvisited cell [nx,ny]={2},{3}", x, y, nx, ny));

                        //Debug.Print(string.Format("B maze[x,y]={0} maze[nx,ny]={1}", maze[x, y], maze[nx, ny]));
                        maze[x, y]   |= (byte)way;
                        maze[nx, ny] |= (byte)OppositeDirection(way);
                        //Debug.Print(string.Format("A maze[x,y]={0} maze[nx,ny]={1}", maze[x, y], maze[nx, ny]));

                        //Debug.Print(string.Format("add cell [{0}][{1}]", nx, ny));
                        cells.Add(new UInt16[2] {
                            (UInt16)nx, (UInt16)ny
                        });
                        //Debug.Print(string.Format("Cells #={0}", cells.Count));

                        index = -1;
                        // need to break the foreach loop here !!
                        break;
                    }
                    else
                    {
                        //Debug.Print("out of maze cells or already processed");
                    }
                }
                //**end dir loop
                //Debug.Print("==END DIR LOOP==");

                //delete this cell from list if none found
                if (index != -1)
                {
                    UInt16[] cell_removed = cells[index];

                    cells.RemoveAt(index);
                    //Debug.Print(string.Format("Cells {0} [{1},{2}] removed, #={3}", index, cell_removed[0], cell_removed[1], cells.Count));
                }

                //Debug.Print("=== CELL LOOP END ===");
            }
        }
示例#20
0
        public IList <ProductStock> GetSuggestedBins(Product product, Location location, PickMethod pickMethod)
        {
            string initQuery = "SELECT l.ProductID, p.BaseUnitID, l.BinID, SUM(l.SingleQuantity * u.BaseAmount) AS Stock,  SUM(l.PackQuantity*u.BaseAmount) as PackStock, l.MaxDate, l.MinDate, b.Rank "
                               + " FROM vwStockSummary AS l INNER JOIN Master.Unit u ON u.UnitID = l.UnitID INNER JOIN Master.Product p ON p.ProductID = l.ProductID INNER JOIN Master.Bin b ON b.BinID = l.BinID "
                               + " Where l.NodeID = :nid And l.StatusID = :sid AND ISNULL(b.LevelCode,'') != 'NOUSE' ";


            StringBuilder sql = new StringBuilder(initQuery);

            Parms = new List <Object[]>();


            Parms.Add(new Object[] { "nid", NodeType.Stored });
            Parms.Add(new Object[] { "sid", EntityStatus.Active });

            if (product != null && product.ProductID != 0)
            {
                sql.Append(" and l.ProductID = :id1 ");
                Parms.Add(new Object[] { "id1", product.ProductID });
            }

            if (location != null && location.LocationID != 0)
            {
                sql.Append(" and l.LocationID = :id2 ");
                Parms.Add(new Object[] { "id2", location.LocationID });
            }

            sql.Append(" GROUP by   l.ProductID, p.BaseUnitID, l.BinID, l.MaxDate, l.MinDate, b.Rank");
            sql.Append(" HAVING SUM(l.SingleQuantity * u.BaseAmount) > 0 OR SUM(l.PackQuantity * u.BaseAmount) > 0 ");


            if (pickMethod == null || pickMethod.MethodID == PickingMethod.FIFO)
            {
                sql.Append(" order by  l.MinDate");
            }

            else if (pickMethod.MethodID == PickingMethod.LIFO)
            {
                sql.Append(" order by  l.MaxDate DESC");
            }

            else if (pickMethod.MethodID == PickingMethod.ZONE)
            {
                sql.Append(" order by b.Rank"); //l.BinID
            }
            //else if (pickMethod == PickingMethod.FEFO)
            //sql.Append(" order by  ExpirationDate DESC");


            IQuery query = Factory.Session.CreateSQLQuery(sql.ToString());

            SetParameters(query);

            query.SetMaxResults(WmsSetupValues.DefaultBinsToShow);

            IList <ProductStock> ret = GetProductStockObject(query.List <Object[]>(), Factory);

            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }

            return(ret);
        }
示例#21
0
 public PickMethod SelectById(PickMethod data)
 {
     return((PickMethod)base.SelectById(data));
 }
示例#22
0
 public Boolean Delete(PickMethod data)
 {
     return(base.Delete(data));
 }
示例#23
0
 public IList<ProductStock> GetProductStock(ProductStock productStock, PickMethod pickMethod)
 {
     try
     {
         SetService();
         return SerClient.GetProductStock(productStock, pickMethod);
     }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
             SerClient.Abort();
     }
 }
示例#24
0
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;
            graphics.ApplyChanges();

            this.Window.AllowUserResizing = true;

            IsMouseVisible = true;

            methodArray = (PickMethod[])Enum.GetValues(typeof(PickMethod));

            picking = PickMethod.Newest;
            mazeW = 20;
            mazeH = 18;
            backgroundsW = 500;
            backgroundsH = 400;
            holesCount = 0;
            holesMaxRadius = 0;

            layoutIndex = 0;

            mlayout = new Layout(mazeW, mazeH);

            aMazIng = new Maze(mazeW, mazeH, mlayout, 0, 0, PickMethod.Cyclic);
            aMazIng.GenerateTWMaze_GrowingTree(picking);

            //aMazIng.dumpMaze();

            base.Initialize();
        }
示例#25
0
 public PickMethod Save(PickMethod data)
 {
     return((PickMethod)base.Save(data));
 }