Esempio n. 1
0
        /// <summary>
        /// 设置负载值
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="wDataSet"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool SetELData(int wAddr, CEL_SetPara wDataSet, out string er)
        {
            er = string.Empty;

            try
            {
                string cmd0  = "01";
                string cmd1  = "01";
                string wCmd  = cmd0 + cmd1;
                string wData = string.Empty;
                string rData = string.Empty;
                int    rLen  = 9;
                wData += wDataSet.SaveEEPROM.ToString("X2");    // D0 ――>设定写EEPROM状态00:不擦除旧数据及写新数据    01:擦除旧数据   02:写新数据
                wData += wDataSet.PWM_Status.ToString("X2");    //D1――>设定PWM状态 00:PWM_stop  01:PWM_start
                wData += wDataSet.PWM_Freq.ToString("X4");      //D2.D3=Data  ――>设定PWM频率
                wData += wDataSet.PWM_DutyCycle.ToString("X4"); //D4.D5=Data  ――>设定PWM占空比
                wData += wDataSet.Run_Status.ToString("X2");    //D6. ――>设定工作状态 00:停止  01:运行
                wData += "00";                                  //D7. ――>设定工作功率 00:40W  01:80W
                for (int i = 0; i < ELCH; i++)                  //(D8-D12) X4
                {
                    //D8 ――>设定工作模式  00:CC模式 01:CV模式02:LED模式(1通道工作方式)
                    wData += ((int)wDataSet.Run_Mode[i]).ToString("X2");

                    //D9.D10=Data  ――>设定工作状态 工作数据
                    if (wDataSet.Run_Mode[i] == EMode.CC)
                    {
                        wData += ((int)(wDataSet.Run_Val[i] * 1000)).ToString("X4");
                    }
                    else
                    {
                        wData += ((int)(wDataSet.Run_Val[i] * 10)).ToString("X4");
                    }

                    //D11.D12=Data ――>设定工作状态 V_ON数据
                    wData += ((int)(wDataSet.Run_Von[i] * 10)).ToString("X4");
                }
                wData = CalDataFromELCmd(wAddr, wCmd, wData);
                if (!SendCmdToELoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 设置负载值
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="wDataSet"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool SetELData(int wAddr, CEL_SetPara wDataSet, out string er)
        {
            er = string.Empty;

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

                for (int i = 0; i < ELCH; i++)
                {
                    //设定工作模式--0x0A08

                    Val[i * ELCH + 0] = (int)wDataSet.Run_Mode[i];

                    //设定通道工作数据1--0x0A09

                    if (wDataSet.Run_Mode[i] == EMode.CC)
                    {
                        Val[i * ELCH + 1] = (int)(wDataSet.Run_Val[i] * 1000);
                    }
                    else
                    {
                        Val[i * ELCH + 1] = (int)(wDataSet.Run_Val[i] * 100);
                    }

                    //设定通道工作数据2--0x0A0A

                    Val[i * ELCH + 2] = (int)(wDataSet.Run_Von[i] * 100);

                    //设定通道工作数据3--0x0A0B

                    Val[i * ELCH + 3] = 0;
                }

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

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 设置负载值
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="wDataSet"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool SetELData(int wAddr, CEL_SetPara wDataSet, out string er)
        {
            er = string.Empty;

            try
            {
                string cmd0  = "01";
                string cmd1  = "01";
                string wCmd  = cmd0 + cmd1;
                string wData = string.Empty;
                string rData = string.Empty;
                int    rLen  = 0;
                wData += wDataSet.SaveEEPROM.ToString("X2");    //D0
                wData += wDataSet.OTP_Start.ToString("X2");     //D1
                wData += wDataSet.OTP_Stop.ToString("X2");      //D2
                wData += wDataSet.PWM_Status.ToString("X2");    //D3
                wData += wDataSet.PWM_Freq.ToString("X4");      //D4,D5
                wData += wDataSet.PWM_DutyCycle.ToString("X4"); //D6,D7
                wData += wDataSet.Run_Status.ToString("X2");    //D8
                wData += wDataSet.Run_Power[0].ToString("X2");  //D9
                for (int i = 0; i < ELCH; i++)
                {
                    wData += ((int)wDataSet.Run_Mode[i]).ToString("X2");                   //D10
                    if (wDataSet.Run_Mode[i] == EMode.CC)
                    {
                        wData += ((int)(wDataSet.Run_Val[i] * 1000)).ToString("X4"); //D11,D12
                    }
                    else
                    {
                        wData += ((int)(wDataSet.Run_Val[i] * 100)).ToString("X4");
                    }
                    wData += ((int)(wDataSet.Run_Von[i] * 100)).ToString("X4"); //D13,D14
                }
                wData = CalDataFromELCmd(wAddr, wCmd, wData);
                if (!SendCmdToELoad(wData, rLen, out rData, out er))
                {
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 设置负载
 /// </summary>
 /// <param name="wAddr"></param>
 /// <param name="wDataSet"></param>
 /// <param name="er"></param>
 /// <returns></returns>
 public bool SetELData(int wAddr, CEL_SetPara wDataSet, out string er)
 {
     return(_devMon.SetELData(wAddr, wDataSet, out er));
 }