Exemplo n.º 1
0
        private PeakHelper(PcanHelper pcan)
        {
            this.hasData  = false;
            this.AllValue = new double[51];

            this.pcanhelper = pcan;
            try
            { pcan.initialize();
              TPCANStatus result = pcan.setValue(); }
            catch (Exception ex)
            {
                MessageBox.Show("控制器初始化出错" + ex.Message);
            }
            //后台每隔一段时间读取一次数据
            this.readTimer = new System.Threading.Timer(_ =>
            {
                try
                {
                    ReadAllReadableValues();
                }
                catch (Exception ex)
                {
                    readTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    hasData = false;
                    System.Windows.Forms.MessageBox.Show("PEAKHelper读数据出错");
                }
            }, null, Timeout.Infinite, Timeout.Infinite);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 初始化peakhelper,使用 pcanhelper
 /// </summary>
 /// <param name="pcan"></param>
 /// <returns></returns>
 public static PeakHelper Initialize(PcanHelper pcan)
 {
     if (instance != null)
     {
         throw new Exception("peakHelper重复初始化报错");
     }
     instance = new PeakHelper(pcan);
     return(instance);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 公有方法获取单例
 /// </summary>
 /// <returns></returns>
 public static PcanHelper GetInstance()
 {
     if (instance == null)
     {
         lock (syncRoot)
         {
             if (syncRoot == null)
             {
                 instance = new PcanHelper();
             }
         }
     }
     return(instance);
 }