Example #1
0
        /// <summary>
        /// 读取输入电压及电流
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        private bool ReadModuleData(int addr, out string er)
        {
            er = string.Empty;

            try
            {
                CModule module = null;

                Thread.Sleep(_delayMs);

                if (!_devMon.ReadModuleData(addr, out module, out er))
                {
                    Thread.Sleep(_delayMs);

                    if (!_devMon.ReadModuleData(addr, out module, out er))
                    {
                        er = "地址【" + addr.ToString("D2") + "】;";
                        return(false);
                    }
                }

                _Mon[addr].Para.Module = module.Clone();

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 复制
        /// </summary>
        /// <returns></returns>
        public CModule Clone()
        {
            CModule module = new CModule();

            module.Volt = this.Volt;

            module.Current = this.Current;

            module.Temp = this.Temp;

            module.FanSpeed1 = this.FanSpeed1;

            module.FanSpeed2 = this.FanSpeed2;

            module.Status = this.Status;

            module.Alarm = this.Alarm;

            return(module);
        }
Example #3
0
        /// <summary>
        /// 读取模块信息
        /// </summary>
        /// <param name="addr"></param>
        /// <param name="module"></param>
        /// <param name="er"></param>
        /// <returns></returns>
        public bool ReadModuleData(int addr, out CModule module, out string er)
        {
            module = new CModule();

            er = string.Empty;

            try
            {
                string wCmd = string.Empty;

                string CID = "03";

                string INFO = string.Empty;

                wCmd = FormatRequestCmd(addr, CID, INFO);

                string rVal = string.Empty;

                string rData = string.Empty;

                int rLen = 6 + 12;

                if (!SendCmdToCOM(wCmd, rLen, out rData, out er, _TimeOut))
                {
                    return(false);
                }

                if (!CalReponseCmd(CID, rData, out rVal, out er))
                {
                    return(false);
                }

                //输出电压
                module.Volt = (double)System.Convert.ToInt32(rVal.Substring(0, 4)) / 100;
                //输出电流
                module.Current = (double)System.Convert.ToInt32(rVal.Substring(4, 4)) / 100;
                //内部温度
                module.Temp = (double)System.Convert.ToInt32(rVal.Substring(8, 2));
                //风扇1转速
                module.FanSpeed1 = System.Convert.ToInt32(rVal.Substring(10, 4));
                //风扇2转速
                module.FanSpeed2 = System.Convert.ToInt32(rVal.Substring(14, 4));
                //模块告警量
                int status = System.Convert.ToInt32(rVal.Substring(18, 2));
                //模块保护类型
                int protect = System.Convert.ToInt32(rVal.Substring(20, 2));

                module.Status = string.Empty;

                if ((status & (1 << 0)) != 0) //0:限流标志
                {
                    module.Status += "限流告警";
                }
                if ((status & (1 << 2)) != 0) //2:模块开关机
                {
                    module.Status += "模块关机";
                }
                if ((status & (1 << 4)) != 0) //模块风扇故障
                {
                    module.Status += "模块风扇故障";
                }
                if ((status & (1 << 5)) != 0) //交流故障
                {
                    module.Status += "交流故障";
                }
                if ((status & (1 << 6)) != 0) //模块保护
                {
                    module.Status += "模块保护";
                }

                module.Alarm = string.Empty;

                if (protect == 1)
                {
                    module.Alarm = "短路保护";
                }
                else if (protect == 2)
                {
                    module.Alarm = "过温保护";
                }
                else if (protect == 3)
                {
                    module.Alarm = "输出过压保护";
                }
                else if (protect == 4)
                {
                    module.Alarm = "输入过压保护";
                }
                else if (protect == 5)
                {
                    module.Alarm = "输入欠压保护";
                }
                else if (protect == 6)
                {
                    module.Alarm = "AC掉电";
                }

                if (module.Status == string.Empty)
                {
                    module.Status = "正常";
                }

                if (module.Alarm == string.Empty)
                {
                    module.Alarm = "正常";
                }

                return(true);
            }
            catch (Exception ex)
            {
                er = ex.ToString();
                return(false);
            }
        }