Exemple #1
0
        /// <summary>
        /// 读取负载设定值
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataSet"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadELLoadSet(int wAddr, CEL_ReadSetPara rDataSet, out string er)
        {
            er = string.Empty;

            try
            {
                string cmd0  = "02";
                string cmd1  = "02";
                string wCmd  = cmd0 + cmd1;
                string wData = string.Empty;
                string rData = string.Empty;
                int    rLen  = 55;
                wData = CalDataFromELCmd(wAddr, wCmd, wData);
                if (!SendCmdToELoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }
                for (int i = 0; i < ELCH; i++)
                {
                    if (rData.Substring(i * 10 + 18, 2) == "FF")
                    {
                        rDataSet.status[i] = "TimeOut";
                        continue;
                    }
                    rDataSet.status[i]   = "OK";
                    rDataSet.LoadMode[i] = (EMode)System.Convert.ToInt16(rData.Substring(i * 10 + 18, 2), 16);
                    if (rDataSet.LoadMode[i] == EMode.CC)
                    {
                        rDataSet.LoadVal[i] = ((double)System.Convert.ToInt16(rData.Substring(i * 10 + 18 + 2, 4), 16)) / 1000;
                    }
                    else
                    {
                        rDataSet.LoadVal[i] = ((double)System.Convert.ToInt16(rData.Substring(i * 10 + 18 + 2, 4), 16)) / 100;
                    }
                    rDataSet.Von[i] = ((double)System.Convert.ToInt16(rData.Substring(i * 10 + 18 + 6, 4), 16)) / 100;
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 读取负载设定值
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataSet"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadELLoadSet(int wAddr, CEL_ReadSetPara rDataSet, out string er)
        {
            er = string.Empty;

            try
            {
                int[] Val = new int[ELCH * 4];

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

                for (int i = 0; i < ELCH; i++)
                {
                    rDataSet.status[i] = "OK";

                    rDataSet.LoadMode[i] = (EMode)Val[i * ELCH + 0];

                    if (rDataSet.LoadMode[i] == EMode.CC)
                    {
                        rDataSet.LoadVal[i] = (double)Val[i * ELCH + 1] / 1000;
                    }
                    else
                    {
                        rDataSet.LoadVal[i] = (double)Val[i * ELCH + 1] / 100;
                    }

                    rDataSet.Von[i] = (double)Val[i * ELCH + 2] / 100;
                }

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Exemple #3
0
 /// <summary>
 /// 读取负载设置
 /// </summary>
 /// <param name="wAddr"></param>
 /// <param name="rLoadVal"></param>
 /// <param name="er"></param>
 /// <returns></returns>
 public bool ReadELLoadSet(int wAddr, CEL_ReadSetPara rDataSet, out string er)
 {
     return(_devMon.ReadELLoadSet(wAddr, rDataSet, out er));
 }
Exemple #4
0
        /// <summary>
        /// 读取负载设定值
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="rDataSet"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadELLoadSet(int wAddr, CEL_ReadSetPara rDataSet, out string er)
        {
            er = string.Empty;

            try
            {
                string cmd0 = "02";

                string cmd1 = "02";

                string wCmd = cmd0 + cmd1;

                string wData = string.Empty;

                string rData = string.Empty;

                int rLen = 47;

                int highByte = 0;

                int lowByte = 0;

                wData = CalDataFromELCmd(wAddr, wCmd, wData);

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

                //D0――>读取PWM状态 00:PWM_stop 01:PWM_start

                //D1.D2=Data  ――>读取PWM频率

                //D3.D4=Data  ――>读取PWM占空比

                string rValData = rData.Substring(10, rData.Length - 10);

                //单通道(D5-D13) X4

                //D5.――>读取工作状态 00:停止  01:运行
                //D6.――>读取工作功率 00:40W  01:80W
                //D7.――>读取工作模式  00:CC模式 01:CV模式02:LED模式
                //D8.D9=Data.  ――>读取工作状态 工作数据
                //D10.D11=Data ――>读取工作状态 V_ON数据
                //D12.       ――>读取工作状态 CC模式下过功率保护时间
                //D13.       ――>读取工作状态 CV、LED模式下过功率保护时间


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

                    if (strCH.Substring(0, 2) == "FF") //D5-读取工作状态 00:停止  01:运行
                    {
                        rDataSet.status[i] = "TimeOut";
                        continue;
                    }

                    rDataSet.status[i] = "OK";                                                       //D6--读取工作功率 00:40W  01:80W

                    rDataSet.LoadMode[i] = (EMode)System.Convert.ToInt16(strCH.Substring(4, 2), 16); //D7:读取工作模式  00:CC模式 01:CV模式02:LED模式

                    highByte = System.Convert.ToInt16(strCH.Substring(6, 2), 16);

                    lowByte = System.Convert.ToInt16(strCH.Substring(8, 2), 16);

                    if (rDataSet.LoadMode[i] == EMode.CC) //D8,D9-->读取工作状态 工作数据
                    {
                        rDataSet.LoadVal[i] = ((double)(highByte * 240 + lowByte)) / 1000;
                    }
                    else
                    {
                        rDataSet.LoadVal[i] = ((double)(highByte * 240 + lowByte)) / 10;
                    }

                    highByte = System.Convert.ToInt16(strCH.Substring(10, 2), 16);

                    lowByte = System.Convert.ToInt16(strCH.Substring(12, 2), 16);

                    //D10.D11=Data ――>读取工作状态 V_ON数据
                    rDataSet.Von[i] = ((double)(highByte * 240 + lowByte)) / 10;
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }