标题:这个计时器发挥的作用是啥》》真不懂撒
取消只看楼主
绝伦
Rank: 1
等 级:新手上路
帖 子:67
专家分:3
注 册:2011-10-10
结帖率:63.64%
已结贴  问题点数:20 回复次数:0 
这个计时器发挥的作用是啥》》真不懂撒
private int RealDataCount = 0;
        private int ReadDataCount = 1;
        private int numXX = 0;
        private int operMode = 0;
        Boolean busy = false;

        /// <summary>
        /// 时间计时器定时查询信息
        /// </summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (busy)
                return;
            busy = true;
            myAPI.HiPerfTimer ht = new myAPI.HiPerfTimer();
            ht.Start();                          //调用开始计时方法
            if (GlobalVars.StartOver)                    
            {
                if (operMode == 0)
                {
                    ReadPLC(Globalvar.Info[0]);
                    ReadPLC(Globalvar.Info[1]);  //PLC读取1#和2#车对应基本信息数据
                    Display(EAFInst);            //显示画面信息
                }
                else
                {
                   if (RealDataCount == 0)
                    {
                        WriteRTData();         //向LF_RT表中更新数据
                    }

                    if (ReadDataCount == 0)
                    {

                        DealEvent(Globalvar.Info[numXX]);//相应冶炼事件
                        ReadSample(Globalvar.Info[numXX]);//取样信息
                        if (ReadDB.ReadVechInfo(Globalvar.Info[numXX]))
                        {
                            DealEvent(Globalvar.Info[numXX]);
                        }

                        numXX = (numXX + 1) % 2;
                    }
                }
                ReadDataCount = (ReadDataCount + 1) % GlobalVars.AllCS.RealTime; //realtime为实时数据发送间隔
                RealDataCount = (RealDataCount + 1) % GlobalVars.AllCS.RealTime;
                operMode = (operMode + 1) % 2;
            }
            ht.Stop();  //停止计时
            System.Diagnostics.Debug.WriteLine("Main Loop expired " + ht.DurationInMs.ToString("0") + "mS");
            busy = false;
        }
搜索更多相关主题的帖子: 计时器 void private return false 
2012-02-23 19:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-361470-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.575723 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved