Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// 读取模拟输出信息
        /// </summary>
        public OutputInfo ReadOutput(long longAddress)
        {
            OutputInfo    ret     = null;
            RequestPacket request = new RequestPacket()
            {
                LongOrShort = 1, Address = longAddress, Command = 15
            };
            ResponsePacket response = Request(request);

            if (response != null && response.DataContent != null && response.DataContent.Length >= 17)
            {
                byte[] d = response.DataContent;
                ret = new OutputInfo();
                ret.AlarmSelectCode             = d[0];
                ret.TransferFunctionCode        = d[1];
                ret.PVUnitCode                  = (UnitCode)d[2];
                ret.UpperRangeValue             = BitConverter.ToSingle(new byte[] { d[6], d[5], d[4], d[3] }, 0);
                ret.LowerRangeValue             = BitConverter.ToSingle(new byte[] { d[10], d[9], d[8], d[7] }, 0);
                ret.DampingValue                = BitConverter.ToSingle(new byte[] { d[14], d[13], d[12], d[11] }, 0);
                ret.WriteProtectCode            = d[15];
                ret.PrivateLabelDistributorCode = d[16];
            }
            return(ret);
        }