Exemplo n.º 1
0
        int MaxMissEventCnt        = 20;// 15;//错期发生后需要经历的最大平稳期数,从15改为20
        public ReceiveService()
        {
            InitializeComponent();
            RecTimers = new Dictionary <string, self_Timer>();
            try
            {
                this.ServiceName = "定时刷新接收数据服务";
                foreach (string key in GlobalClass.TypeDataPoints.Keys)
                {
                    //if(key.Equals("PK10"))//暂时跳过
                    //{
                    //    continue;
                    //}
                    self_Timer tm = new self_Timer();
                    tm.Name      = key;
                    tm.Enabled   = false;
                    tm.AutoReset = true;
                    tm.Interval  = GlobalClass.TypeDataPoints[key].ReceiveSeconds * 1000;
                    tm.Elapsed  += Tm_Elapsed;
                    RecTimers.Add(key, tm);
                }
                //if (GlobalClass.DataTypes.ContainsKey("PK10"))
                //{
                //    Tm_ForPK10.Enabled = false;
                //    Tm_ForPK10.AutoReset = true;

                //    Tm_ForPK10.Interval = GlobalClass.TypeDataPoints["PK10"].ReceiveSeconds * 1000;
                //    Tm_ForPK10.Elapsed += new ElapsedEventHandler(Tm_ForPK10_Elapsed);

                //}
                //////if (GlobalClass.DataTypes.ContainsKey("TXFFC"))
                //////{

                //////    Tm_ForTXFFC.Enabled = false;
                //////    Tm_ForTXFFC.AutoReset = true;
                //////    Tm_ForTXFFC.Interval = 10 * 1000 + GlobalClass.TypeDataPoints["TXFFC"].ReceiveSeconds * 1000;
                //////    Tm_ForTXFFC.Elapsed += new ElapsedEventHandler(Tm_ForTXFFC_Elapsed);
                //////}
                //////if (GlobalClass.DataTypes.ContainsKey("CAN28"))
                //////{

                //////    Tm_ForCAN28.Enabled = false;
                //////    Tm_ForCAN28.AutoReset = true;
                //////    Tm_ForCAN28.Interval = 10 * 1000 + GlobalClass.TypeDataPoints["CAN28"].ReceiveSeconds * 1000;
                //////    Tm_ForCAN28.Elapsed += new ElapsedEventHandler(Tm_ForCAN28_Elapsed);
                //////}
                //////////////tm.Interval = 5 * 1000;
                //////////////tm.Enabled = false;
                //////////////tm.AutoReset = true;
            }
            catch (Exception e)
            {
                Log("定时刷新接收数据服务错误!", string.Format("{0}:{1}", e.Message, e.StackTrace), true);
            }
            //tm.Elapsed += new ElapsedEventHandler(tm_Elapsed);
        }
Exemplo n.º 2
0
        private void Tm_Elapsed(object sender, ElapsedEventArgs e)
        {
            self_Timer tm  = sender as self_Timer;
            string     key = tm.Name;

            try
            {
                ReceiveData(key, tm, null, null, true);
            }
            catch (Exception ce)
            {
                Log(string.Format("接收{0}数据错误", key), string.Format("{0}:{1}", ce.Message, ce.StackTrace), true);
            }
        }