Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="device"></param>
        /// <param name="bs"></param>
        /// <returns></returns>
        public PickResult Pick(IDevice device, byte[] bs)
        {
            int length = 0;

            if (bs != null)
            {
                length = bs.Length;
            }

            if (length < _receivePard.DataFieldManager.Length)
            {
                return(PickResult.CreateFailPickResult(bs));
            }

            for (int i = 0; i <= bs.Length - _receivePard.DataFieldManager.Length; i++)
            {
                byte[] bsForParse = new byte[_receivePard.DataFieldManager.Length];
                Array.Copy(bs, i, bsForParse, 0, _receivePard.DataFieldManager.Length);

                IParseResult pr = _receivePard.ToValues(bsForParse);
                if (pr.IsSuccess)
                {
                    byte[]     remain  = Remove(bs, i, _receivePard.DataFieldManager.Length);
                    PickResult success = PickResult.CreateSuccessPickResult(
                        this.Name, pr, remain);
                    return(success);
                }
            }

            return(PickResult.CreateFailPickResult(bs));
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="remain"></param>
        /// <returns></returns>
        static public PickResult CreateFailPickResult(byte[] remain)
        {
            PickResult r = new PickResult();

            r.IsSuccess = false;
            r.Remain    = remain;
            return(r);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="parseResult"></param>
        /// <param name="remain"></param>
        /// <returns></returns>
        static public PickResult CreateSuccessPickResult(string name, IParseResult pr, byte[] remain)
        {
            PickResult r = new PickResult();

            r.IsSuccess = true;
            //r.Name = name;
            r.Remain = remain;
            //r.Results = keyValues;
            r.ParseResult = pr;
            return(r);
        }
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="bs"></param>
 /// <returns></returns>
 public byte[] ProcessUpload(byte[] bs)
 {
     byte[] bsWork = bs;
     foreach (IPicker item in this.Pickers)
     {
         PickResult result = item.Pick(this, bsWork);
         if (result.IsSuccess)
         {
             this.Dpu.Processor.ProcessUpload(this, result.ParseResult);
         }
         bsWork = result.Remain;
     }
     return(bsWork);
 }