Esempio n. 1
0
 /// <summary>
 /// 读取设备的主变量
 /// </summary>
 public DeviceVariable ReadPV(bool optical = false)
 {
     if (!optical || (_PV == null && _ID != null))
     {
         _PV = _HartComport.ReadPV(_ID.LongAddress);
     }
     return(_PV);
 }
Esempio n. 2
0
        /// <summary>
        /// 设置主变量单位代码
        /// </summary>
        public bool WritePVUnit(UnitCode unitCode)
        {
            if (_ID == null)
            {
                return(false);
            }
            bool ret = _HartComport.WritePVUnit(_ID.LongAddress, unitCode);

            if (ret)
            {
                _PV       = null;
                _PVOutput = null;
                _PVSensor = null;
            }
            return(ret);
        }
Esempio n. 3
0
        /// <summary>
        /// 读取设备的主变量
        /// </summary>
        public DeviceVariable ReadPV(long longAddress)
        {
            DeviceVariable ret     = null;
            RequestPacket  request = new RequestPacket()
            {
                LongOrShort = 1, Address = longAddress, Command = 1
            };
            ResponsePacket response = Request(request);

            if (response != null && response.DataContent != null && response.DataContent.Length >= 5)
            {
                ret          = new DeviceVariable();
                ret.UnitCode = (UnitCode)response.DataContent[0];
                ret.Value    = BitConverter.ToSingle(new byte[] { response.DataContent[4], response.DataContent[3], response.DataContent[2], response.DataContent[1] }, 0);
            }
            return(ret);
        }