Esempio n. 1
0
        /// <summary>
        /// 读取负载数据
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataVal"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadELData(int wAddr, CEL_ReadData rDataVal, out string er)
        {
            er = string.Empty;

            try
            {
                string cmd0  = "02";
                string cmd1  = "01";
                string wCmd  = cmd0 + cmd1;
                string wData = string.Empty;
                string rData = string.Empty;
                int    rLen  = 61;
                wData = CalDataFromELCmd(wAddr, wCmd, wData);
                if (!SendCmdToELoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }
                rDataVal.NTC_0 = System.Convert.ToInt16(rData.Substring(0, 2), 16);
                rDataVal.NTC_1 = System.Convert.ToInt16(rData.Substring(2, 2), 16);
                rDataVal.ONOFF = System.Convert.ToInt16(rData.Substring(4, 2), 16);
                for (int i = 0; i < ELCH; i++)
                {
                    rDataVal.Vs[i]   = ((double)System.Convert.ToInt16(rData.Substring(6 + i * 12, 4), 16)) / 100;
                    rDataVal.Volt[i] = ((double)System.Convert.ToInt16(rData.Substring(10 + i * 12, 4), 16)) / 100;
                    rDataVal.Load[i] = ((double)System.Convert.ToInt16(rData.Substring(14 + i * 12, 4), 16)) / 1000;
                }
                rDataVal.OCP = System.Convert.ToInt16(rData.Substring(102, 2), 16) / 100;
                rDataVal.OVP = System.Convert.ToInt16(rData.Substring(104, 2), 16) / 100;
                rDataVal.OPP = System.Convert.ToInt16(rData.Substring(106, 2), 16) / 100;
                rDataVal.OTP = System.Convert.ToInt16(rData.Substring(108, 2), 16) / 100;
                if (rDataVal.OCP == 1 || rDataVal.OVP == 1 || rDataVal.OPP == 1 || rDataVal.OTP == 1)
                {
                    rDataVal.Status = "Alarm:";
                    if (rDataVal.OCP == 1)
                    {
                        rDataVal.Status += "OCP;";
                    }
                    if (rDataVal.OVP == 1)
                    {
                        rDataVal.Status += "OVP;";
                    }
                    if (rDataVal.OPP == 1)
                    {
                        rDataVal.Status += "OPP;";
                    }
                    if (rDataVal.OTP == 1)
                    {
                        rDataVal.Status += "OTP;";
                    }
                }
                else
                {
                    rDataVal.Status = "OK";
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 读取负载数据
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataVal"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadELData(int wAddr, CEL_ReadData rDataVal, out string er)
        {
            er = string.Empty;

            try
            {
                int[] rOnOff = new int[1];

                if (!Read(wAddr, 0x0B14, ref rOnOff, out er))
                {
                    return(false);
                }

                rDataVal.ONOFF = rOnOff[0];

                int[] Val = new int[ELCH * 2 + 1];

                if (!Read(wAddr, 0x0B16, ref Val, out er))
                {
                    return(false);
                }

                for (int i = 0; i < ELCH; i++)
                {
                    rDataVal.Volt[i] = (double)Val[i * 2 + 0] / 100;

                    rDataVal.Load[i] = (double)Val[i * 2 + 1] / 1000;
                }

                int Status = Val[ELCH * 2];

                if ((Status & (1 << 0)) != 0 || (Status & (1 << 4)) != 0 || (Status & (1 << 8)) != 0 || (Status & (1 << 12)) != 0)
                {
                    rDataVal.OTP = 1;
                }
                if ((Status & (1 << 1)) != 0 || (Status & (1 << 5)) != 0 || (Status & (1 << 9)) != 0 || (Status & (1 << 13)) != 0)
                {
                    rDataVal.OPP = 1;
                }
                if ((Status & (1 << 2)) != 0 || (Status & (1 << 6)) != 0 || (Status & (1 << 10)) != 0 || (Status & (1 << 14)) != 0)
                {
                    rDataVal.OCP = 1;
                }
                if ((Status & (1 << 3)) != 0 || (Status & (1 << 7)) != 0 || (Status & (1 << 11)) != 0 || (Status & (1 << 15)) != 0)
                {
                    rDataVal.OVP = 1;
                }

                if (rDataVal.OCP == 1 || rDataVal.OVP == 1 || rDataVal.OPP == 1 || rDataVal.OTP == 1)
                {
                    rDataVal.Status = "Alarm:";
                    if (rDataVal.OCP == 1)
                    {
                        rDataVal.Status += "OCP;";
                    }
                    if (rDataVal.OVP == 1)
                    {
                        rDataVal.Status += "OVP;";
                    }
                    if (rDataVal.OPP == 1)
                    {
                        rDataVal.Status += "OPP;";
                    }
                    if (rDataVal.OTP == 1)
                    {
                        rDataVal.Status += "OTP;";
                    }
                }
                else
                {
                    rDataVal.Status = "OK";
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 读取负载数值
 /// </summary>
 /// <param name="wAddr"></param>
 /// <param name="rDataVal"></param>
 /// <param name="er"></param>
 /// <returns></returns>
 public bool ReadELData(int wAddr, CEL_ReadData rDataVal, out string er)
 {
     return(_devMon.ReadELData(wAddr, rDataVal, out er));
 }
Esempio n. 4
0
        /// <summary>
        /// 读取负载数据
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataVal"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadELData(int wAddr, CEL_ReadData rDataVal, out string er)
        {
            er = string.Empty;

            try
            {
                string cmd0 = "02";

                string cmd1 = "01";

                string wCmd = cmd0 + cmd1;

                string wData = string.Empty;

                string rData = string.Empty;

                int rLen = 41;

                wData = CalDataFromELCmd(wAddr, wCmd, wData);

                if (!SendCmdToELoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }

                /*
                 * D0.     ――>读取工状态(Start、Stop)0,1
                 * D1.     ――>读取工作功率(40W、80W) 2,3
                 * D2. D3  ――>Vsen电压                 4,5,6,7
                 * D4. D5  ――>电压                     8,9,10,11
                 * D6. D7  ――>电流                     12,13,14,15
                 * (D0-D7) X4
                 * D32.     ――>OCP
                 * D33.     ――>OVP
                 * D34.     ――>OPP
                 * D35.     ――>OTP
                 */

                int highByte = 0;

                int lowByte = 0;

                for (int i = 0; i < ELCH; i++)
                {
                    string strCH = rData.Substring(i * 16, 16);

                    highByte       = System.Convert.ToInt16(strCH.Substring(4, 2), 16);
                    lowByte        = System.Convert.ToInt16(strCH.Substring(6, 2), 16);
                    rDataVal.Vs[i] = ((double)(highByte * 240 + lowByte)) / 10;

                    highByte         = System.Convert.ToInt16(strCH.Substring(8, 2), 16);
                    lowByte          = System.Convert.ToInt16(strCH.Substring(10, 2), 16);
                    rDataVal.Volt[i] = ((double)(highByte * 240 + lowByte)) / 10;

                    highByte         = System.Convert.ToInt16(strCH.Substring(12, 2), 16);
                    lowByte          = System.Convert.ToInt16(strCH.Substring(14, 2), 16);
                    rDataVal.Load[i] = ((double)(highByte * 240 + lowByte)) / 1000;
                }

                string strDD = rData.Substring(rData.Length - 8, 8);

                rDataVal.OCP = System.Convert.ToInt16(strDD.Substring(0, 2), 16);
                rDataVal.OVP = System.Convert.ToInt16(strDD.Substring(2, 2), 16);
                rDataVal.OPP = System.Convert.ToInt16(strDD.Substring(4, 2), 16);
                rDataVal.OTP = System.Convert.ToInt16(strDD.Substring(6, 2), 16);
                if (rDataVal.OCP == 1 || rDataVal.OVP == 1 || rDataVal.OPP == 1 || rDataVal.OTP == 1)
                {
                    rDataVal.Status = "Alarm:";
                    if (rDataVal.OCP == 1)
                    {
                        rDataVal.Status += "OCP;";
                    }
                    if (rDataVal.OVP == 1)
                    {
                        rDataVal.Status += "OVP;";
                    }
                    if (rDataVal.OPP == 1)
                    {
                        rDataVal.Status += "OPP;";
                    }
                    if (rDataVal.OTP == 1)
                    {
                        rDataVal.Status += "OTP;";
                    }
                }
                else
                {
                    rDataVal.Status = "OK";
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }