Exemplo n.º 1
0
 /// <summary>
 /// 读取电流和量程百分比
 /// </summary>
 public CurrentInfo ReadCurrent(bool optical = false)
 {
     if (!optical || (_PVCurrent == null && _ID != null))
     {
         _PVCurrent = _HartComport.ReadCurrent(_ID.LongAddress);
     }
     return(_PVCurrent);
 }
Exemplo n.º 2
0
        /// <summary>
        /// 设置固定电流输出,当传入的参数为0时表示取消固定电流输出模式
        /// </summary>
        public bool SetFixedCurrent(float current)
        {
            if (_ID == null)
            {
                return(false);
            }
            bool ret = _HartComport.SetFixedCurrent(_ID.LongAddress, current);

            if (ret)
            {
                _PVCurrent = null;
            }
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 读取电流和量程百分比
        /// </summary>
        public CurrentInfo ReadCurrent(long longAddress)
        {
            CurrentInfo   ret     = null;
            RequestPacket request = new RequestPacket()
            {
                LongOrShort = 1, Address = longAddress, Command = 2
            };
            ResponsePacket response = Request(request);

            if (response != null && response.DataContent != null && response.DataContent.Length >= 8)
            {
                byte[] d = response.DataContent;
                ret                = new CurrentInfo();
                ret.Current        = BitConverter.ToSingle(new byte[] { d[3], d[2], d[1], d[0] }, 0);
                ret.PercentOfRange = BitConverter.ToSingle(new byte[] { d[7], d[6], d[5], d[4] }, 0);
            }
            return(ret);
        }