Ejemplo n.º 1
0
        /// <summary>
        /// 复制
        /// </summary>
        /// <returns></returns>
        public CrData Clone()
        {
            CrData para = new CrData();

            for (int i = 0; i < 12; i++)
            {
                para.Volt[i] = this.Volt[i];
            }
            for (int i = 0; i < 8; i++)
            {
                para.Cur[i] = this.Cur[i];
            }
            para.S1     = this.S1;
            para.OnOff  = this.OnOff;
            para.PS_On  = this.PS_On;
            para.OTP    = this.OTP;
            para.OVP    = this.OVP;
            para.OPP    = this.OPP;
            para.FanErr = this.FanErr;
            para.Status = this.Status;
            return(para);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="er"></param>
        /// <returns></returns>
        private bool readModuleData(int addr, out string er)
        {
            er = string.Empty;

            try
            {
                _syncLock.AcquireWriterLock(-1);

                Thread.Sleep(_delayMs);

                CrData para = new CrData();

                if (!_devMon.ReadData(addr, ref para, out er))
                {
                    Thread.Sleep(_delayMs);

                    if (!_devMon.ReadData(addr, ref para, out er))
                    {
                        er = _Mon[addr].ToString() + "读数据;";
                        return(false);
                    }
                }

                _Mon[addr].Para.Data = para.Clone();

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
            finally
            {
                _syncLock.ReleaseWriterLock();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 读取数据
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataVal"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadData(int wAddr, ref CrData rDataVal, out string er)
        {
            er = string.Empty;

            try
            {
                //读取12/26个电压通道的数据及一个含模块工作壮况的Byte
                string cmd0  = "02";
                string cmd1  = "02";
                string wCmd  = cmd0 + cmd1;
                string wData = string.Empty;
                wData = CalDataFromDDCmd(wAddr, wCmd, wData);
                string rData = string.Empty;
                int    rLen  = 33;
                if (!SendCmdToDDLoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }
                for (int i = 0; i < (rData.Length - 2) / 4; i++)
                {
                    rDataVal.Volt[i] = ((double)(System.Convert.ToInt32(rData.Substring(i * 4, 4), 16))) / 1000;
                }
                int statusVal = System.Convert.ToInt16(rData.Substring(rData.Length - 2, 2), 16);
                rDataVal.Status = "";
                if ((statusVal & 1 << 0) == (1 << 0))
                {
                    rDataVal.S1      = 1;
                    rDataVal.Status += "S1_ON;";
                }
                else if ((statusVal & 1 << 1) == (1 << 1))
                {
                    rDataVal.OnOff = 1;
                }
                else if ((statusVal & 1 << 2) == (1 << 2))
                {
                    rDataVal.OTP     = 1;
                    rDataVal.Status += "OTP;";
                }
                else if ((statusVal & 1 << 3) == (1 << 3))
                {
                    rDataVal.FanErr  = 1;
                    rDataVal.Status += "FANErr;";
                }
                else if ((statusVal & 1 << 4) == (1 << 4))
                {
                    rDataVal.PS_On = 1;
                }
                else if ((statusVal & 1 << 6) == (1 << 6))
                {
                    rDataVal.OVP     = 1;
                    rDataVal.Status += "OVP;";
                }
                else if ((statusVal & 1 << 7) == (1 << 7))
                {
                    rDataVal.OPP     = 1;
                    rDataVal.Status += "OPP;";
                }
                if (rDataVal.Status == "")
                {
                    rDataVal.Status = "OK";
                }
                System.Threading.Thread.Sleep(20);
                //读取8/16个电流通道的数据.(电流显示精度:0.001A)
                rData = string.Empty;
                rLen  = 24;
                cmd0  = "02";
                cmd1  = "03";
                wCmd  = cmd0 + cmd1;
                wData = string.Empty;
                wData = CalDataFromDDCmd(wAddr, wCmd, wData);
                if (!SendCmdToDDLoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }
                for (int i = 0; i < rData.Length / 4; i++)
                {
                    rDataVal.Cur[i] = ((double)(System.Convert.ToInt32(rData.Substring(i * 4, 4), 16))) / 1000;
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 读取数据
 /// </summary>
 /// <param name="wAddr"></param>
 /// <param name="rData"></param>
 /// <param name="er"></param>
 /// <returns></returns>
 public bool ReadData(int wAddr, ref CrData rData, out string er)
 {
     return(_devMon.ReadData(wAddr, ref rData, out er));
 }