Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="task"></param>
        public void DoitReceive(Task task)
        {
            // get match cp with task
            //
            CommuniPort cp = this.GetCommPort(task.Device);

            byte[] bytes = null;
            if (cp != null)
            {
                //cp.Read();
                //bytes = cp.ReceivedBytes;
                bytes = cp.Read();
            }
            //else
            //{
            //    //bytes = null;
            //    bytes = new byte[0];
            //}

            LogReceived(task, bytes);

            ParseResult           pr = task.ParseReceiced(bytes);
            TaskExecutedEventArgs e  = new TaskExecutedEventArgs(task, pr);

            // 2010-09-15
            //
            //OnExecuted(task, pr);
            if (CommuniSoft.IsUseUISynchronizationContext)
            {
                CommuniSoft.UISynchronizationContext.Post(
                    this.ExecutedCallback, e);
            }
            else
            {
                OnExecuted(e);
            }

            // process df
            //
            if ((bytes != null && bytes.Length > 0))
            {
                if (!pr.Success)
                {
                    this.CommuniSoft.FDManager.Process(cp, bytes);
                }
                else if (pr.Remain != null)
                {
                    this.CommuniSoft.FDManager.Process(cp, pr.Remain);
                }
            }

            if (!task.CanRemove)
            {
                this.Tasks.Add(task);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// check communiport upload data
 /// </summary>
 public void AAA()
 {
     for (int i = this.CommuniPorts.Count - 1; i >= 0; i--)
     {
         CommuniPort cp = this.CommuniPorts[i];
         if (!cp.IsOccupy)
         {
             byte[] bs = cp.Read();
             if (bs.Length > 0)
             {
                 this._communiSoft.FDManager.Process(cp, bs);
             }
         }
     }
 }