예제 #1
0
 /// <summary>
 /// 读取主变量传感器信息
 /// </summary>
 public SensorInfo ReadPVSensor(bool optical = false)
 {
     if (!optical || (_PVSensor == null && _ID != null))
     {
         _PVSensor = _HartComport.ReadPVSensor(_ID.LongAddress);
     }
     return(_PVSensor);
 }
예제 #2
0
        /// <summary>
        /// 写主变量传感器序列号
        /// </summary>
        public bool WritePVSensorSN(int sn)
        {
            if (_ID == null)
            {
                return(false);
            }
            bool ret = _HartComport.WritePVSensorSN(_ID.LongAddress, sn);

            if (ret)
            {
                _PVSensor = null;
            }
            return(ret);
        }
예제 #3
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);
        }
예제 #4
0
        /// <summary>
        /// 设置主传感器工作模式
        /// </summary>
        /// <param name="longAddress"></param>
        /// <param name="mode"></param>
        /// <param name="sensorCode"></param>
        /// <returns></returns>
        public bool WritePVSensorMode(SensorMode mode, SensorCode sensorCode)
        {
            if (_ID == null)
            {
                return(false);
            }
            bool ret = _HartComport.WritePVSensorMode(_ID.LongAddress, mode, sensorCode);

            if (ret)
            {
                _SensorMode = null;
                _SensorCode = null;
                _PVOutput   = null;
                _PVSensor   = null;
            }
            return(ret);
        }
예제 #5
0
        /// <summary>
        /// 读取主变量传感器信息
        /// </summary>
        public SensorInfo ReadPVSensor(long longAddress)
        {
            SensorInfo    ret     = null;
            RequestPacket request = new RequestPacket()
            {
                LongOrShort = 1, Address = longAddress, Command = 14
            };
            ResponsePacket response = Request(request);

            if (response != null && response.DataContent != null && response.DataContent.Length >= 16)
            {
                byte[] d = response.DataContent;
                ret             = new SensorInfo();
                ret.SensorSN    = SEBinaryConverter.BytesToInt(new byte[] { d[2], d[1], d[0] });
                ret.UnitCode    = (UnitCode)d[3];
                ret.UpperLimit  = BitConverter.ToSingle(new byte[] { d[7], d[6], d[5], d[4] }, 0);
                ret.LowerLimit  = BitConverter.ToSingle(new byte[] { d[11], d[10], d[9], d[8] }, 0);
                ret.MinimumSpan = BitConverter.ToSingle(new byte[] { d[15], d[14], d[13], d[12] }, 0);
            }
            return(ret);
        }