这个计时器发挥的作用是啥》》真不懂撒
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;
}