Exemplo n.º 1
0
 private void ReadPV_Thread()
 {
     try
     {
         while (_Running)
         {
             Thread.Sleep(AppSettings.Current.RealInterval);
             if (HartDevice != null && HartDevice.IsConnected)
             {
                 DeviceVariable pv = HartDevice.ReadPV(false);
                 if (pv != null && _Running)
                 {
                     this.Invoke((Action)(() =>
                     {
                         _PV = pv;
                         txtReal.Text = pv.Value.ToString();
                     }
                                          ));
                 }
             }
         }
     }
     catch (ThreadAbortException)
     {
     }
     catch (Exception)
     {
     }
     finally
     {
         _ReadPV = null;
     }
 }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            DeviceVariable pv = HartDevice.ReadPV(false);

            if (pv != null)
            {
                txtUpper.Text = pv.Value.ToString();
            }
        }
Exemplo n.º 3
0
            public void Destroy()
            {
#if DEBUG
                if (Index == _badDispose)
                {
                    Debugger.Break();
                }
#endif
                if (!_disposed)
                {
                    DeviceVariable.Dispose();
                    _disposed = true;
                }
#if DEBUG
                GC.SuppressFinalize(this);
#endif
            }
Exemplo n.º 4
0
        private void ReadPV_Thread()
        {
            try
            {
                while (_Running)
                {
                    if (HartDevice == null || !HartDevice.IsConnected)
                    {
                        this.Invoke((Action)(() => { btnRealTime.Text = "实时采集"; }));
                        _ReadPV = null;
                        return;
                    }
                    DeviceVariable pv = HartDevice.ReadPV(false);
                    CurrentInfo    ci = HartDevice.ReadCurrent(false);
                    Action         a  = delegate()
                    {
                        if (pv != null)
                        {
                            lblPVUnit.Text = pv != null?UnitCodeDescr.GetDescr(pv.UnitCode) : null;

                            txtPV.Text = pv != null?pv.Value.ToString() : string.Empty;
                        }
                        if (ci != null)
                        {
                            txtCurrent.Text = ci != null?ci.Current.ToString() : string.Empty;

                            txtPercentOfRange.Text = ci != null?ci.PercentOfRange.ToString() : string.Empty;
                        }
                    };
                    this.Invoke(a);
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception)
            {
            }
            finally
            {
                _ReadPV = null;
            }
        }