Exemplo n.º 1
0
 //执行任务
 void bgMeet_TestDoWork(object sender, DoWorkEventArgs e)
 {
     for (int i = 0; i < showDateList.Count; i++)
     {
         if (bgMeet.CancellationPending)
         {
             e.Cancel = true;
             return;
         }
         else
         {
             //int now = 0;
             //if (i == -1 || i == 0) now = 0;
             //else now = i;
             ShowDate showDate = showDateList[i];
             if (showDate.Protocal != null && showDate.Protocal != string.Empty)
             {
                 byte[] byteToSend = StrToByte(showDate.Protocal.Split(','));
                 GlobalData.Instance.da.SendBytes(byteToSend);
             }
             System.Threading.Thread.Sleep(200);
             bgMeet.ReportProgress(i + 1, showDate);
         }
     }
 }
Exemplo n.º 2
0
 //执行任务
 void bgMeet_DoWork(object sender, DoWorkEventArgs e)
 {
     ////开始播放等待动画
     //this.Dispatcher.Invoke(new Action(() =>
     //{
     //    this.tbprocess.Text = "0/" + calList.Count;
     //}));
     for (int i = 0; i < showDateList.Count; i++)
     {
         if (bgMeet.CancellationPending)
         {
             e.Cancel = true;
             return;
         }
         else
         {
             //int now = 0;
             //if (i == -1 || i == 0) now = 0;
             //else now = i;
             ShowDate showDate = showDateList[i];
             if (showDate.Protocal != null && showDate.Protocal != string.Empty)
             {
                 byte[] byteToSend = StrToByte(showDate.Protocal.Split(','));
                 GlobalData.Instance.da.SendBytes(byteToSend);
             }
             System.Threading.Thread.Sleep(200);
             bgMeet.ReportProgress(i + 1, showDate);
         }
     }
 }
Exemplo n.º 3
0
        //报告任务进度
        void bgMeet_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                if (e.ProgressPercentage > 0)
                {
                    this.tbTotalNum.Text = e.ProgressPercentage + "/" + showDateList.Count();
                    if (e.UserState is ShowDate)
                    {
                        ShowDate data = e.UserState as ShowDate;
                        if (data.Field != null && data.Field != string.Empty) // 需要从通信数据中读取
                        {
                            data.Value = GlobalData.Instance.da[data.Field].Value.Int16;
                            if (data.MinValue > 0 && data.MaxValue > 0) // 有范围值
                            {
                                if (data.Value >= data.MinValue && data.Value <= data.MaxValue)
                                {
                                    data.Result = "读取值正常";
                                }
                                else
                                {
                                    data.Result = "读取值异常";
                                }
                            }
                            else
                            {
                                data.Result = "读取值正常";
                            }
                        }
                        else
                        {
                            data.Value = showDateList[data.MaxValue].Value - showDateList[data.MinValue].Value;
                            if (Math.Abs(data.Value) <= 35)
                            {
                                data.Result = "读取值正常";
                            }
                            else
                            {
                                data.Result = "读取值异常";
                            }
                        }

                        this.lvList.Items.Add(data);
                        //string sql = string.Format("Update ShowDate Set Value='{0}' Where ID='{1}'", data.Value, data.ID);
                        //DataHelper.Instance.ExecuteNonQuery(sql);
                    }
                }
            }));
        }