Esempio n. 1
0
        /// <summary>
        /// 设置负载单个通道电流
        /// </summary>
        /// <param name="addr">1-40</param>
        /// <param name="chan">1-4</param>
        /// <param name="loadVal"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool SetCHLoad(int addr, int chan, CLOAD load, out string er, bool saveEPROM = true)
        {
            er = string.Empty;

            try
            {
                if (!_Mon.ContainsKey(addr))
                {
                    er = CLanguage.Lan("DA负载地址") + "[" + addr.ToString("D2") + CLanguage.Lan("不存在");
                    return(false);
                }

                _Mon[addr].Para.OP_SetLoadVal[chan - 1].LoadSeting.Mode = load.Mode;

                _Mon[addr].Para.OP_SetLoadVal[chan - 1].LoadSeting.Von = load.Von;

                _Mon[addr].Para.OP_SetLoadVal[chan - 1].LoadSeting.load = load.load;

                _Mon[addr].Para.OP_SetLoadVal[chan - 1].LoadSeting.mark = load.mark;

                _Mon[addr].Para.OP_SetLoadVal[chan - 1].op = EOP.写入;

                _Mon[addr].Para.OP_SetLoadVal[chan - 1].SaveEPROM = saveEPROM;

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
            finally
            {
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 设置8个电流通道负载
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="chanPara"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool SetLoadValue(int wAddr, int chanNo, CLOAD chanPara, bool saveEEPROM, out string er)
        {
            er = string.Empty;

            try
            {
                string CID = string.Empty;

                string INFO = string.Empty;

                if (saveEEPROM)
                {
                    CID = "11";
                }
                else
                {
                    CID = "12";
                }

                INFO += chanNo.ToString("X2");               //通道号-1Bytes

                INFO += ((int)chanPara.Mode).ToString("X2"); //负载模式-1Bytes

                if (chanPara.Von < 10)
                {
                    chanPara.Von = 10;
                }

                INFO += ((int)(chanPara.Von * 20)).ToString("X4"); //Von点-2Bytes

                switch (chanPara.Mode)
                {
                case EMODE.CC_Slow:
                    INFO += ((int)(chanPara.load * 1000)).ToString("X4");     //负载值:CCSlow或CCFast或者MTK模式时,设定值=电流(A)*1000,取值范围0.1A~5A
                    INFO += ((int)(chanPara.mark * 10)).ToString("X2");       //模式附加参数:负载启动延迟时间。设定值=延迟时间(秒)*10,取值范围0~20秒
                    break;

                case EMODE.CV:
                    INFO += ((int)(chanPara.load * 20)).ToString("X4");     //负载值:CV模式时,设定值=电压(V)*20,取值范围12V~400V
                    INFO += "00";                                           //模式附加参数:该参数无实际以及,需赋值为0
                    break;

                case EMODE.CP:
                    INFO += ((int)(chanPara.load * 10)).ToString("X4");     //负载值:CP模式时,设定值=功率(W)*10,取值范围2W~320W
                    INFO += "00";                                           //模式附加参数:该参数无实际以及,需赋值为0
                    break;

                case EMODE.CR:
                    INFO += ((int)(chanPara.load * 10)).ToString("X4");     //负载值:CR模式时,设定值=阻值(欧)*10,取值范围2.4欧~4000欧
                    INFO += "00";                                           //模式附加参数:该参数无实际以及,需赋值为0
                    break;

                case EMODE.CC_Fast:
                    INFO += ((int)(chanPara.load * 1000)).ToString("X4");     //负载值:CCSlow或CCFast或者MTK模式时,设定值=电流(A)*1000,取值范围0.1A~5A
                    INFO += ((int)(chanPara.mark * 10)).ToString("X2");       //模式附加参数:负载启动延迟时间。设定值=延迟时间(秒)*10,取值范围0~20秒
                    break;

                case EMODE.LED:
                    INFO += ((int)(chanPara.load * 20)).ToString("X4");     //负载值:LED模式时,设定值=电压(V)*20,取值范围12V~400V
                    INFO += ((int)(chanPara.mark * 10)).ToString("X2");     //模式附加参数:当负载模式为LED模式时,该参数为LED电流。设定值=电流(A)*10,取值范围:0.1A~5A
                    break;

                case EMODE.MTK:
                    INFO += ((int)(chanPara.load * 1000)).ToString("X4");     //负载值:CCSlow或CCFast或者MTK模式时,设定值=电流(A)*1000,取值范围0.1A~5A
                    INFO += ((int)(chanPara.mark)).ToString("X2");
                    break;

                /*模式附加参数:当负载模式为MTK快充模式时,
                 * 该参数为MKT快充电压类型。取值为1、2、3、4、5、6中的一个。
                 * 含义分别为:
                 *  1:MTK PE1.0   电压上升命令
                 *  2:MTK PE1.0   电压下降命令
                 *  3:MTK PE2.0   7V命令
                 *  4:MTK PE2.0   8V命令
                 *  5:MTK PE2.0   9V命令
                 *  6:MTK PE2.0   12V命令
                 */
                default:
                    break;
                }

                string wCmd  = CalDataFromERS272Cmd(wAddr, CID, INFO);
                string rData = string.Empty;
                int    rLen  = C_LEN;
                if (!SendCmdToERS272(wCmd, rLen, out rData, out er))
                {
                    return(false);
                }

                string temp = string.Empty;
                string rVal = string.Empty;
                if (!checkErrorCode(rData, out rVal, out temp))
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 读取负载设置
        /// </summary>
        /// <param name="wAddr"></param>
        /// <param name="chanList"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadLoadSetting(int wAddr, out List <CLOAD> chanList, out string er)
        {
            chanList = new List <CLOAD>();

            chanList.Clear();

            er = string.Empty;

            try
            {
                string CID   = "06";
                string INFO  = string.Empty;
                string wCmd  = CalDataFromERS272Cmd(wAddr, CID, INFO);
                string rData = string.Empty;
                int    rLen  = C_LEN + 48;
                if (!SendCmdToERS272(wCmd, rLen, out rData, out er))
                {
                    return(false);
                }
                string temp = string.Empty;
                string rVal = string.Empty;
                if (!checkErrorCode(rData, out rVal, out temp))
                {
                    return(false);
                }

                /*
                 * 每个通道含6个字节数据,数据从第1通道开始,共6字节*8通道=48字节数据。
                 * 每通道的第1字节为负载模式,第2/3字节为Von点,第4/5字节为负载值,第6字节为模式附加参数,
                 * 模式附加参数根据模式不同而有不同的含义
                 */

                for (int i = 0; i < _maxCH; i++)
                {
                    string rCmd = rVal.Substring(i * 12, 12);                      //单通道数据

                    int byte0 = System.Convert.ToInt16(rCmd.Substring(0, 2), 16);  //负载模式

                    int byte1 = System.Convert.ToInt16(rCmd.Substring(2, 4), 16);  //Von点

                    int byte2 = System.Convert.ToInt16(rCmd.Substring(6, 4), 16);  //负载值

                    int byte3 = System.Convert.ToInt16(rCmd.Substring(10, 2), 16); //模式附加参数

                    CLOAD para = new CLOAD();

                    para.Mode = (EMODE)byte0;

                    para.Von = (double)byte1 / 20;  //读值=Von*20(V) --->Von:0.5V-20V

                    switch (para.Mode)
                    {
                    case EMODE.CC_Slow:
                        para.load = (double)byte2 / 1000;    //CCSlow或CCFast或者MTK模式:读值=电流(A)*1000,取值范围0.1A~5A。
                        para.unit = "A";
                        para.mark = (double)byte3 / 10;      //当负载模式为CC Slow或者CC_Fast时,该参数的含义是负载启动延迟时间。
                        break;                               //读值=延迟时间(秒)*10,取值范围0~20秒

                    case EMODE.CV:
                        para.load = (double)byte2 / 20;     //CV模式:读值=电压(V)*20,取值范围12V~400V
                        para.unit = "V";
                        para.mark = 0;                      //当负载模式为CV/CP/CR时,该参数无实际以及,需赋值为0
                        break;

                    case EMODE.CP:
                        para.load = (double)byte2 / 10; //CP模式:读值=功率(W)*10,取值范围2W~320W
                        para.unit = "W";
                        para.mark = 0;                  //当负载模式为CV/CP/CR时,该参数无实际以及,需赋值为0
                        break;

                    case EMODE.CR:
                        para.load = (double)byte2 / 10; //CR模式:读值=阻值(欧)*10,取值范围2.4欧~4000欧
                        para.unit = "ohm";
                        para.mark = 0;                  //当负载模式为CV/CP/CR时,该参数无实际以及,需赋值为0
                        break;

                    case EMODE.CC_Fast:
                        para.load = (double)byte2 / 1000;
                        para.unit = "A";
                        para.mark = (double)byte3 / 10;      //当负载模式为CC Slow或者CC_Fast时,该参数的含义是负载启动延迟时间。
                        break;                               //读值=延迟时间(秒)*10,取值范围0~20秒

                    case EMODE.LED:
                        para.load = (double)byte2 / 20;    //LED模式:读值=电压(V)*20,取值范围12V~400V
                        para.unit = "V";
                        para.mark = (double)byte3 / 10;    //当负载模式为LED模式时,该参数为LED电流。读值=电流(A)*10,取值范围:0.1A~5A
                        break;

                    case EMODE.MTK:
                        para.load = (double)byte2 / 1000;
                        para.unit = "A";
                        para.mark = (double)byte3;     /*当负载模式为MTK快充模式时,该参数为MKT快充电压类型。取值为1、2、3、4、5、6中的一个。
                                                        * 含义分别为:
                                                        * 1:MTK PE1.0   电压上升命令
                                                        * 2:MTK PE1.0   电压下降命令
                                                        * 3:MTK PE2.0   7V命令
                                                        * 4:MTK PE2.0  8V命令
                                                        * 5:MTK PE2.0  9V命令
                                                        * 6:MTK PE2.0  12V命令
                                                        */
                        break;

                    default:
                        break;
                    }

                    chanList.Add(para);
                }

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 设置8个电流通道负载
 /// </summary>
 /// <param name="wAddr"></param>
 /// <param name="chanList"></param>
 /// <param name="saveEEPROM"></param>
 /// <param name="er"></param>
 /// <returns></returns>
 public bool SetLoadValue(int wAddr, int chanNo, CLOAD chanPara, bool saveEEPROM, out string er)
 {
     return(_devMon.SetLoadValue(wAddr, chanNo, chanPara, saveEEPROM, out er));
 }